From nobody Mon Feb 9 20:35:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1554821589; cv=none; d=zoho.com; s=zohoarc; b=MKyK0nm7B2AtG4UMKPQ9zGdUUbqtYJJ2l8j9Ua8j5j0ECfkBc36IuWE7JeQAEKOzMNJFD6SPg3hqOgtmYFIocC+28I1NOD74+WncWfFWFEk90Yg3XinkeJ8Rk5ybYZEG0MfcNbsdP+RRGQImpxqt0GnQ0xhA+flrL5BNmoE48QA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1554821589; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=NiZ1EDgkeg82hGyuV4ZlDKJ5i2awS0CZxH6jfKPMzww=; b=jEW5S2BaFHajo/Ksuiu0YNwu5LtZ4Kpr/mjSE3VeMDHawHFoTWKGRIGbgajgMyTR2w0x6Y2o5nBQT07lU6zCpdywY4qzc4JAaPQEejTGBYT4wIjTPlVRJ4Y1iqqkCkzUtM9C/q/hnXDL2eiZ85oOPxDr97GT1NSBrmwy1pBXIuw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554821589775236.3505796559175; Tue, 9 Apr 2019 07:53:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B7074859FF; Tue, 9 Apr 2019 14:53:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 882945C666; Tue, 9 Apr 2019 14:53:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 40A4C181AC46; Tue, 9 Apr 2019 14:53:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x39Er4ko029711 for ; Tue, 9 Apr 2019 10:53:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 53E631001E92; Tue, 9 Apr 2019 14:53:04 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 82FC91001E6B; Tue, 9 Apr 2019 14:53:00 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 9 Apr 2019 16:52:55 +0200 Message-Id: <174644a729b3f7bbd9160f88fbe156059e747af9.1554821424.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: lersek@redhat.com, ptoscano@redhat.com Subject: [libvirt] [PATCH v2 1/4] qemu_firmware: Separate firmware loading into a function X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 09 Apr 2019 14:53:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This piece of code will be reused later. Signed-off-by: Michal Privoznik --- src/qemu/qemu_firmware.c | 53 ++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index 787b76b531..065e0d11aa 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -1314,15 +1314,49 @@ qemuFirmwareSanityCheck(const qemuFirmware *fw, } =20 =20 +static ssize_t +qemuFirmwareFetchParsedConfigs(bool privileged, + qemuFirmwarePtr **firmwaresRet, + char ***pathsRet) +{ + VIR_AUTOSTRINGLIST paths =3D NULL; + size_t npaths; + qemuFirmwarePtr *firmwares =3D NULL; + size_t i; + + if (qemuFirmwareFetchConfigs(&paths, privileged) < 0) + return -1; + + npaths =3D virStringListLength((const char **)paths); + + if (VIR_ALLOC_N(firmwares, npaths) < 0) + return -1; + + for (i =3D 0; i < npaths; i++) { + if (!(firmwares[i] =3D qemuFirmwareParse(paths[i]))) + goto error; + } + + VIR_STEAL_PTR(*firmwaresRet, firmwares); + VIR_STEAL_PTR(*pathsRet, paths); + return npaths; + + error: + while (i > 0) + qemuFirmwareFree(firmwares[--i]); + VIR_FREE(firmwares); + return -1; +} + + int qemuFirmwareFillDomain(virQEMUDriverPtr driver, virDomainObjPtr vm, unsigned int flags) { VIR_AUTOSTRINGLIST paths =3D NULL; - size_t npaths =3D 0; qemuFirmwarePtr *firmwares =3D NULL; - size_t nfirmwares =3D 0; + ssize_t nfirmwares =3D 0; const qemuFirmware *theone =3D NULL; size_t i; int ret =3D -1; @@ -1333,21 +1367,10 @@ qemuFirmwareFillDomain(virQEMUDriverPtr driver, if (vm->def->os.firmware =3D=3D VIR_DOMAIN_OS_DEF_FIRMWARE_NONE) return 0; =20 - if (qemuFirmwareFetchConfigs(&paths, driver->privileged) < 0) + if ((nfirmwares =3D qemuFirmwareFetchParsedConfigs(driver->privileged, + &firmwares, &paths)) = < 0) return -1; =20 - npaths =3D virStringListLength((const char **)paths); - - if (VIR_ALLOC_N(firmwares, npaths) < 0) - return -1; - - nfirmwares =3D npaths; - - for (i =3D 0; i < nfirmwares; i++) { - if (!(firmwares[i] =3D qemuFirmwareParse(paths[i]))) - goto cleanup; - } - for (i =3D 0; i < nfirmwares; i++) { if (qemuFirmwareMatchDomain(vm->def, firmwares[i], paths[i])) { theone =3D firmwares[i]; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list