From nobody Mon May 6 18:44:50 2024 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=1565021695; cv=none; d=zoho.com; s=zohoarc; b=Rowd0P6OToNyGrwaqwU6Mnp7/yjMyZtB/Lp38QEWb6A9JPXWb8Q+V4jlpHr9WrHEJ+J1whDwabVQYfFvFhl5C4hY954U8jwhdtS6HE7G7M0DlC+6issJxKB5ZY2AKNmTwZGl8jy6Ob3yRJIvVIM/c90Xtdy6+xN24BD+dA1BadU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565021695; h=Content-Type:Content-Transfer-Encoding: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=2lAOfVXosSg+qeIvHB4FuI64J+KW1PdsaZYDIQcOzVI=; b=XWpdjTr8AI3/F0bwS/uTKzFXADOKNVHfR2Zu96NYACwD0oO0vfcT8Cy8x2n3aRkIjB8cKpfxufPBpCM+7e+Fxji3295mrW/L6+60dVO1fO9H3/E0TaGqt0cIQ5GImsagRO40lsG54k4venKrk/oInfArJiZQcUxcJnWv1olBn7Q= 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 1565021695527657.7521657714428; Mon, 5 Aug 2019 09:14:55 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5121EEB9CB; Mon, 5 Aug 2019 16:14:54 +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 200E9166A0; Mon, 5 Aug 2019 16:14:54 +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 D660318005A0; Mon, 5 Aug 2019 16:14:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x75GEdDM026328 for ; Mon, 5 Aug 2019 12:14:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0F53960A97; Mon, 5 Aug 2019 16:14:39 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-137.brq.redhat.com [10.40.204.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 82034608C1 for ; Mon, 5 Aug 2019 16:14:38 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 5 Aug 2019 18:14:21 +0200 Message-Id: <26f71a831ad81bbc5fe52d22bb1bc97eb0c6f04d.1565021239.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/5] virfirmware: Expose and define autoptr for virFirmwareFree 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 05 Aug 2019 16:14:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This function frees a _virFirmware struct. So far, it doesn't need to be called from outside of the module, but this will change shortly. In the light of recent VIR_DEFINE_AUTOPTR_FUNC() additions, do the same to virFirmwareFree(). Signed-off-by: Michal Privoznik Reviewed-by: Cole Robinson Tested-by: Kashyap Chamarthy --- src/libvirt_private.syms | 1 + src/util/virfirmware.c | 2 +- src/util/virfirmware.h | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c323f679b3..c66161496e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2036,6 +2036,7 @@ virFirewallDZoneExists; =20 =20 # util/virfirmware.h +virFirmwareFree; virFirmwareFreeList; virFirmwareParse; virFirmwareParseList; diff --git a/src/util/virfirmware.c b/src/util/virfirmware.c index f41e000447..b4747bd346 100644 --- a/src/util/virfirmware.c +++ b/src/util/virfirmware.c @@ -31,7 +31,7 @@ VIR_LOG_INIT("util.firmware"); =20 =20 -static void +void virFirmwareFree(virFirmwarePtr firmware) { if (!firmware) diff --git a/src/util/virfirmware.h b/src/util/virfirmware.h index ed59f34102..30bcd21fa4 100644 --- a/src/util/virfirmware.h +++ b/src/util/virfirmware.h @@ -31,6 +31,11 @@ struct _virFirmware { }; =20 =20 +void +virFirmwareFree(virFirmwarePtr firmware); + +VIR_DEFINE_AUTOPTR_FUNC(virFirmware, virFirmwareFree); + void virFirmwareFreeList(virFirmwarePtr *firmwares, size_t nfirmwares); =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 18:44:50 2024 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=1565021690; cv=none; d=zoho.com; s=zohoarc; b=Hy0EIvaWbWgnrY2/P3+gcA2PFXgtjZVLsnQUVk7q7PUu/5gQFJxveeGUV1yIj3mJquLVwq1G5UG7VxfrAZxcUQBIxdNph2NajqA6EDlcNSQRGRHDaU5D5pWsh8aNjn5qA6cU/HnbqPT3nVw453xdwgX5fybqNohA4fzbAfvAWXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565021690; h=Content-Type:Content-Transfer-Encoding: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=7L8BGIl4q8QNohtG5H5IRTnAXsZHnCgs9/Xaz///tno=; b=DJdWPQMIa3YQj35IEeoKA1BLm5/O0c9tXdhVlUjFu4Weo8f5wzuWLqkQPwHToxTUQ3anQ8yz6ua9O2ONZSxe6efuC5In6tCDCQqcGdT8X4u6zSSVpkphAq0X60laYJGv1X26soBmiygagR9nqnSzCeHMxgx2HVUhqNPC2G1qxQw= 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 156502169048821.554293251895615; Mon, 5 Aug 2019 09:14:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0DF02C057FA6; Mon, 5 Aug 2019 16:14:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CC9535DA21; Mon, 5 Aug 2019 16:14:48 +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 9447A2551E; Mon, 5 Aug 2019 16:14:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x75GEdju026338 for ; Mon, 5 Aug 2019 12:14:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id E4E11608C1; Mon, 5 Aug 2019 16:14:39 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-137.brq.redhat.com [10.40.204.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6388F60A97 for ; Mon, 5 Aug 2019 16:14:39 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 5 Aug 2019 18:14:22 +0200 Message-Id: <3e1c2fa5f0ba5623ab340c299b2dd40c99d8ad0b.1565021239.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/5] qemu_firmware: Document qemuFirmwareGetSupported 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 05 Aug 2019 16:14:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This function is going to get some new arguments. Document the current ones for clarity. Signed-off-by: Michal Privoznik Reviewed-by: Cole Robinson Tested-by: Kashyap Chamarthy --- src/qemu/qemu_firmware.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index bf29b10b9a..8fbe8952ba 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -1413,6 +1413,25 @@ qemuFirmwareFillDomain(virQEMUDriverPtr driver, } =20 =20 +/** + * qemuFirmwareGetSupported: + * @machine: machine type + * @arch: architecture + * @privileged: whether running as privileged user + * @supported: returned bitmap of supported interfaces + * @secure: true if at least one secure boot enabled FW was found + * + * Parse all FW descriptors (depending whether running as @privileged this= may + * or may not include user's $HOME) and for given combination of @machine = and + * @arch extract information to be later reported in domain capabilities. + * The @supported contains a bitmap of found interfaces (and ORed values o= f 1 + * << VIR_DOMAIN_OS_DEF_FIRMWARE_*). Then, @supported is true if at least = one + * FW descriptor signalizes secure boot (although, this is checked against= SMM + * rather than SECURE_BOOT because reasons). + * + * Returns: 0 on success, + * -1 otherwise. + */ int qemuFirmwareGetSupported(const char *machine, virArch arch, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 18:44:50 2024 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=1565021699; cv=none; d=zoho.com; s=zohoarc; b=fGCzpXauNm/5Tj/JG/007gHrVKZXd3hy5P1fDREcKyBctk58s/8eFuxhc/yPnCSJFAC4yuiiVsqEBuO3eXPcncTXItuWjAWXbUcuPoaqvJ3gi6LEMIgmI1jTFOsrCnSj2edlIVsq++N12BLXT7JCfKvNm6wK3hozA9Pe4OwmnNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565021699; h=Content-Type:Content-Transfer-Encoding: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=Utnh43utJllwdV/C0/yH6SuB51p9FXVR5IGTL8Ypbyk=; b=DV37O/TRvPfRmRHkdaftQOKfY1rlDpaPHSQn9PDFgeZd/EMNO2LjnuLdFh9UO4ArSyn+BEE/+bXUHuaLRQEecYtpcw0bFMrz9AKZPOEavhpRuAyzzKInCQD37qmziZ5pomFR1Von7pIm5mdVn+lSkYX59n8eXCBVRSwnA7syu3w= 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 1565021699166591.3626054010884; Mon, 5 Aug 2019 09:14:59 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ADCF530EA18D; Mon, 5 Aug 2019 16:14:57 +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 71A9360605; Mon, 5 Aug 2019 16:14:57 +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 3120618005C7; Mon, 5 Aug 2019 16:14:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x75GEeqs026343 for ; Mon, 5 Aug 2019 12:14:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id C4EEA60A97; Mon, 5 Aug 2019 16:14:40 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-137.brq.redhat.com [10.40.204.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43E23608C1 for ; Mon, 5 Aug 2019 16:14:40 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 5 Aug 2019 18:14:23 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/5] qemu_firmware: Extend qemuFirmwareGetSupported to return FW paths 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 05 Aug 2019 16:14:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The qemuFirmwareGetSupported() function is called from qemu driver to generate domain capabilities XML based on FW descriptor files. However, the function currently reports only some features from domcapabilities XML and not actual FW image paths. The paths reported in the domcapabilities XML still from from pre-FW descriptor era and therefore the XML might be a bit confusing. For instance, it may say that secure boot is supported but secboot enabled FW is not in the listed FW image paths. To resolve this problem, change qemuFirmwareGetSupported() so that it also returns a list of FW images (we have the list anyway). Luckily, we already have a structure to represent a FW image - virFirmware. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1733940 Signed-off-by: Michal Privoznik Reviewed-by: Cole Robinson Tested-by: Kashyap Chamarthy --- src/qemu/qemu_capabilities.c | 3 +- src/qemu/qemu_firmware.c | 62 +++++++++++++++++++++++++++++++++++- src/qemu/qemu_firmware.h | 5 ++- tests/qemufirmwaretest.c | 2 +- 4 files changed, 68 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2388f145af..db1fc31cd9 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5165,7 +5165,8 @@ virQEMUCapsFillDomainOSCaps(virDomainCapsOSPtr os, os->supported =3D VIR_TRISTATE_BOOL_YES; os->firmware.report =3D true; =20 - if (qemuFirmwareGetSupported(machine, arch, privileged, &autoFirmwares= , &secure) < 0) + if (qemuFirmwareGetSupported(machine, arch, privileged, + &autoFirmwares, &secure, NULL, NULL) < 0) return -1; =20 if (autoFirmwares & (1ULL << VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS)) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index 8fbe8952ba..9ba38477cc 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -1420,6 +1420,8 @@ qemuFirmwareFillDomain(virQEMUDriverPtr driver, * @privileged: whether running as privileged user * @supported: returned bitmap of supported interfaces * @secure: true if at least one secure boot enabled FW was found + * @fws: (optional) list of found firmwares + * @nfws: (optional) number of members in @fws * * Parse all FW descriptors (depending whether running as @privileged this= may * or may not include user's $HOME) and for given combination of @machine = and @@ -1429,6 +1431,15 @@ qemuFirmwareFillDomain(virQEMUDriverPtr driver, * FW descriptor signalizes secure boot (although, this is checked against= SMM * rather than SECURE_BOOT because reasons). * + * If @fws and @nfws are not NULL, then @fws is allocated (must be freed by + * caller when no longer needed) and contains list of firmwares found in f= orm + * of virFirmware. This can be useful if caller wants to know the paths to + * firmware images (e.g. to present them in domain capabilities XML). + * Moreover, to allow the caller distinguish between no FW descriptors fou= nd + * and no matching FW descriptors found (nfws =3D=3D 0 in both cases), the= @fws is + * going to be allocated in case of the latter anyway (with no real content + * though). + * * Returns: 0 on success, * -1 otherwise. */ @@ -1437,7 +1448,9 @@ qemuFirmwareGetSupported(const char *machine, virArch arch, bool privileged, uint64_t *supported, - bool *secure) + bool *secure, + virFirmwarePtr **fws, + size_t *nfws) { qemuFirmwarePtr *firmwares =3D NULL; ssize_t nfirmwares =3D 0; @@ -1446,12 +1459,21 @@ qemuFirmwareGetSupported(const char *machine, *supported =3D VIR_DOMAIN_OS_DEF_FIRMWARE_NONE; *secure =3D false; =20 + if (fws) { + *fws =3D NULL; + *nfws =3D 0; + } + if ((nfirmwares =3D qemuFirmwareFetchParsedConfigs(privileged, &firmwares, NULL)) < = 0) return -1; =20 for (i =3D 0; i < nfirmwares; i++) { qemuFirmwarePtr fw =3D firmwares[i]; + const qemuFirmwareMappingFlash *flash =3D &fw->mapping.data.flash; + const qemuFirmwareMappingMemory *memory =3D &fw->mapping.data.memo= ry; + const char *fwpath =3D NULL; + const char *nvrampath =3D NULL; size_t j; =20 if (!qemuFirmwareMatchesMachineArch(fw, machine, arch)) @@ -1491,8 +1513,46 @@ qemuFirmwareGetSupported(const char *machine, break; } } + + switch (fw->mapping.device) { + case QEMU_FIRMWARE_DEVICE_FLASH: + fwpath =3D flash->executable.filename; + nvrampath =3D flash->nvram_template.filename; + break; + + case QEMU_FIRMWARE_DEVICE_MEMORY: + fwpath =3D memory->filename; + break; + + case QEMU_FIRMWARE_DEVICE_KERNEL: + case QEMU_FIRMWARE_DEVICE_NONE: + case QEMU_FIRMWARE_DEVICE_LAST: + break; + } + + if (fws && fwpath) { + VIR_AUTOPTR(virFirmware) tmp =3D NULL; + + /* Append only unique pairs. */ + for (j =3D 0; j < *nfws; j++) { + if (STREQ((*fws)[j]->name, fwpath) && + STREQ_NULLABLE((*fws)[j]->nvram, nvrampath)) + break; + } + + if (j =3D=3D *nfws && + (VIR_ALLOC(tmp) < 0 || + VIR_STRDUP(tmp->name, fwpath) < 0 || + VIR_STRDUP(tmp->nvram, nvrampath) < 0 || + VIR_APPEND_ELEMENT(*fws, *nfws, tmp) < 0)) + return -1; + } } =20 + if (fws && !*fws && nfirmwares && + VIR_REALLOC_N(*fws, 0) < 0) + return -1; + for (i =3D 0; i < nfirmwares; i++) qemuFirmwareFree(firmwares[i]); VIR_FREE(firmwares); diff --git a/src/qemu/qemu_firmware.h b/src/qemu/qemu_firmware.h index 6a3b6061f4..28e8322ec9 100644 --- a/src/qemu/qemu_firmware.h +++ b/src/qemu/qemu_firmware.h @@ -24,6 +24,7 @@ #include "qemu_conf.h" #include "virautoclean.h" #include "virarch.h" +#include "virfirmware.h" =20 typedef struct _qemuFirmware qemuFirmware; typedef qemuFirmware *qemuFirmwarePtr; @@ -53,6 +54,8 @@ qemuFirmwareGetSupported(const char *machine, virArch arch, bool privileged, uint64_t *supported, - bool *secure); + bool *secure, + virFirmwarePtr **fws, + size_t *nfws); =20 verify(VIR_DOMAIN_OS_DEF_FIRMWARE_LAST <=3D 64); diff --git a/tests/qemufirmwaretest.c b/tests/qemufirmwaretest.c index 2228359a7b..bab23f696e 100644 --- a/tests/qemufirmwaretest.c +++ b/tests/qemufirmwaretest.c @@ -123,7 +123,7 @@ testSupportedFW(const void *opaque) expectedInterfaces |=3D 1ULL << data->interfaces[i]; =20 if (qemuFirmwareGetSupported(data->machine, data->arch, false, - &actualInterfaces, &actualSecure) < 0) { + &actualInterfaces, &actualSecure, NULL, N= ULL) < 0) { fprintf(stderr, "Unable to get list of supported interfaces\n"); return -1; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 18:44:50 2024 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=1565021685; cv=none; d=zoho.com; s=zohoarc; b=lwOjcuovlmZt0K1hWtAkT/TBx7C8FFvKc9pBqp0/VwjgxXK7CJRaO7uXHsahOyGZt3vDKOurqt5ZCIHN57kGFnMj0RI//igV+vOmkCq3kee4hnovP4Jthyl0STiCs2iwAxQbaR0Fb1eA2iGaGT5i+/0cMBmiK0Hug/ygOCJIGVk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565021685; h=Content-Type:Content-Transfer-Encoding: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=YrWl7HgnEaNmixH7yiCs9mr3QGYAzNGSPNuPnLRSOHk=; b=GbfreIbXepGAaIyglbGzpoAHaBGGAgWO+/nQkk2mJW4yU9mFfTgGg0YVwc+GQrA05skIO524lnB/wjTizlKfSXIf2xYsB7AquTzqgwttAzTBXaERedlI7FtrgbwmuCxV4uHK9L+EBVqKlSWJLw+gCiLN+sAfHO04YbAZnYRfxfw= 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 1565021685336141.17185877457234; Mon, 5 Aug 2019 09:14:45 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 214C481DE3; Mon, 5 Aug 2019 16:14:44 +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 C146260A97; Mon, 5 Aug 2019 16:14:43 +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 4F95D180B536; Mon, 5 Aug 2019 16:14:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x75GEfcN026351 for ; Mon, 5 Aug 2019 12:14:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id A37C1608C1; Mon, 5 Aug 2019 16:14:41 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-137.brq.redhat.com [10.40.204.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23ECB60A97 for ; Mon, 5 Aug 2019 16:14:40 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 5 Aug 2019 18:14:24 +0200 Message-Id: <4b00d2c78f15802c722fedee84956555cf82fab2.1565021239.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/5] qemufirmwaretest: Test FW path getting through qemuFirmwareGetSupported() 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 05 Aug 2019 16:14:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" There is one hack hidden here, but since this is in a test, it's okay. In order to get a list of expected firmwares in virFirmwarePtr form I'm using virFirmwareParseList(). But usually, in real life scenario, this function is used only to parse a list of UEFI images which have NVRAM split out. In other words, this function expects ${FW}:${NVRAM} pairs. But in this test, we also want to allow just a single path: ${FW} because some reported firmwares are just a BIOS image really. To avoid writing some parser function, let's just pass "NULL" as ${NVRAM} and fix the result later. Signed-off-by: Michal Privoznik Reviewed-by: Cole Robinson Tested-by: Kashyap Chamarthy --- tests/qemufirmwaretest.c | 78 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 71 insertions(+), 7 deletions(-) diff --git a/tests/qemufirmwaretest.c b/tests/qemufirmwaretest.c index bab23f696e..653476fdc1 100644 --- a/tests/qemufirmwaretest.c +++ b/tests/qemufirmwaretest.c @@ -105,6 +105,7 @@ struct supportedData { const char *machine; virArch arch; bool secure; + const char *fwlist; unsigned int *interfaces; size_t ninterfaces; }; @@ -117,15 +118,35 @@ testSupportedFW(const void *opaque) uint64_t actualInterfaces; uint64_t expectedInterfaces =3D 0; bool actualSecure; + virFirmwarePtr *expFWs =3D NULL; + size_t nexpFWs =3D 0; + virFirmwarePtr *actFWs =3D NULL; + size_t nactFWs =3D 0; size_t i; + int ret =3D -1; =20 for (i =3D 0; i < data->ninterfaces; i++) expectedInterfaces |=3D 1ULL << data->interfaces[i]; =20 + if (virFirmwareParseList(data->fwlist, &expFWs, &nexpFWs) < 0) { + fprintf(stderr, "Unable to parse list of expected FW paths\n"); + return -1; + } + + /* virFirmwareParseList() expects to see pairs of paths: ${FW}:${NVRAM= }. + * Well, some images don't have a NVRAM store. In that case NULL was p= assed: + * ${FW}:NULL. Now iterate over expected firmwares and fix this. */ + for (i =3D 0; i < nexpFWs; i++) { + virFirmwarePtr tmp =3D expFWs[i]; + + if (STREQ(tmp->nvram, "NULL")) + VIR_FREE(tmp->nvram); + } + if (qemuFirmwareGetSupported(data->machine, data->arch, false, - &actualInterfaces, &actualSecure, NULL, N= ULL) < 0) { + &actualInterfaces, &actualSecure, &actFWs= , &nactFWs) < 0) { fprintf(stderr, "Unable to get list of supported interfaces\n"); - return -1; + goto cleanup; } =20 if (actualInterfaces !=3D expectedInterfaces) { @@ -133,7 +154,7 @@ testSupportedFW(const void *opaque) "Mismatch in supported interfaces. " "Expected 0x%" PRIx64 " got 0x%" PRIx64 "\n", expectedInterfaces, actualInterfaces); - return -1; + goto cleanup; } =20 if (actualSecure !=3D data->secure) { @@ -141,10 +162,42 @@ testSupportedFW(const void *opaque) "Mismatch in SMM requirement/support. " "Expected %d got %d\n", data->secure, actualSecure); - return -1; + goto cleanup; } =20 - return 0; + for (i =3D 0; i < nactFWs; i++) { + virFirmwarePtr actFW =3D actFWs[i]; + virFirmwarePtr expFW =3D NULL; + + if (i >=3D nexpFWs) { + fprintf(stderr, "Unexpected FW image: %s NVRAM: %s\n", + actFW->name, NULLSTR(actFW->nvram)); + goto cleanup; + } + + expFW =3D expFWs[i]; + + if (STRNEQ(actFW->name, expFW->name) || + STRNEQ_NULLABLE(actFW->nvram, expFW->nvram)) { + fprintf(stderr, "Unexpected FW image: %s NVRAM: %s\n" + "Expected: %s NVRAM: %s\n", + actFW->name, NULLSTR(actFW->nvram), + expFW->name, NULLSTR(expFW->nvram)); + goto cleanup; + } + } + + if (i < nexpFWs) { + fprintf(stderr, "Expected FW image: %s NVRAM: %s got nothing\n", + expFWs[i]->name, NULLSTR(expFWs[i]->nvram)); + goto cleanup; + } + + ret =3D 0; + cleanup: + virFirmwareFreeList(actFWs, nactFWs); + virFirmwareFreeList(expFWs, nexpFWs); + return ret; } =20 =20 @@ -176,10 +229,13 @@ mymain(void) if (virTestRun("QEMU FW precedence test", testFWPrecedence, NULL) < 0) ret =3D -1; =20 -#define DO_SUPPORTED_TEST(machine, arch, secure, ...) \ + /* The @fwlist contains pairs of ${FW}:${NVRAM}. If there's + * no NVRAM expected pass literal "NULL" and test fixes that + * later. */ +#define DO_SUPPORTED_TEST(machine, arch, secure, fwlist, ...) \ do { \ unsigned int interfaces[] =3D {__VA_ARGS__}; \ - struct supportedData data =3D {machine, arch, secure, \ + struct supportedData data =3D {machine, arch, secure, fwlist, \ interfaces, ARRAY_CARDINALITY(interfa= ces)}; \ if (virTestRun("QEMU FW SUPPORTED " machine " " #arch, \ testSupportedFW, &data) < 0) \ @@ -187,16 +243,24 @@ mymain(void) } while (0) =20 DO_SUPPORTED_TEST("pc-i440fx-3.1", VIR_ARCH_X86_64, false, + "/usr/share/seabios/bios-256k.bin:NULL:" + "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_V= ARS.fd", VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS, VIR_DOMAIN_OS_DEF_FIRMWARE_EFI); DO_SUPPORTED_TEST("pc-i440fx-3.1", VIR_ARCH_I686, false, + "/usr/share/seabios/bios-256k.bin:NULL", VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS); DO_SUPPORTED_TEST("pc-q35-3.1", VIR_ARCH_X86_64, true, + "/usr/share/seabios/bios-256k.bin:NULL:" + "/usr/share/OVMF/OVMF_CODE.secboot.fd:/usr/share/OVM= F/OVMF_VARS.secboot.fd:" + "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_V= ARS.fd", VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS, VIR_DOMAIN_OS_DEF_FIRMWARE_EFI); DO_SUPPORTED_TEST("pc-q35-3.1", VIR_ARCH_I686, false, + "/usr/share/seabios/bios-256k.bin:NULL", VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS); DO_SUPPORTED_TEST("virt-3.1", VIR_ARCH_AARCH64, false, + "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAV= MF_VARS.fd", VIR_DOMAIN_OS_DEF_FIRMWARE_EFI); =20 virFileWrapperClearPrefixes(); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 18:44:50 2024 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=1565021691; cv=none; d=zoho.com; s=zohoarc; b=mpZXNn8xorYTgECRqv9TfMl7TsAvt2Bz3BZtfvDq8IsYnocdQ9RL7mFgAZ/wdAGw6+X5iGK7EVPfTFg/oHh+dgZFfXhgxNGt6QbIft4lhReQ7MROthHzwfOHv6wRM1Mv0uhj08SB7LuT1Mavj/Vv+wgl4wWQ3QKeRyPqZR/vVBM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565021691; h=Content-Type:Content-Transfer-Encoding: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=5MPqhN4meMD9iaaB82gSuMuOIKmab6Ljz4XYQSPaTCg=; b=SAJeXz9w121YbbIm6/p2+mPBmMx7dR7yzMz3WFOaTVxbBLuYhlnUuJc430o6y1IXmp7KFuNUBrp8v14SK8I8MClnIf8Le+sVvy1NQINZrIPRv/XZBJekM4EcxbSeQ4UJSH9OWmzPY0oKfvhQ6qFcPb8Bh0zhd3p6lMAz+Z/feFM= 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 1565021691226492.1347152475904; Mon, 5 Aug 2019 09:14:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8AF9B20260; Mon, 5 Aug 2019 16:14:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 622C860605; Mon, 5 Aug 2019 16:14:49 +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 2396D24FDE; Mon, 5 Aug 2019 16:14:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x75GEgOs026363 for ; Mon, 5 Aug 2019 12:14:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8330960A97; Mon, 5 Aug 2019 16:14:42 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-137.brq.redhat.com [10.40.204.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 021C9608C1 for ; Mon, 5 Aug 2019 16:14:41 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 5 Aug 2019 18:14:25 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/5] qemu: Use FW descriptors to report FW image paths 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 05 Aug 2019 16:14:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Now that we have qemuFirmwareGetSupported() so that it also returns a list of FW image paths, we can use it to report them in domain capabilities instead of the old time default list. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1733940 Signed-off-by: Michal Privoznik Reviewed-by: Cole Robinson Tested-by: Kashyap Chamarthy --- src/qemu/qemu_capabilities.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index db1fc31cd9..318cfcebf3 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5161,12 +5161,16 @@ virQEMUCapsFillDomainOSCaps(virDomainCapsOSPtr os, virDomainCapsLoaderPtr capsLoader =3D &os->loader; uint64_t autoFirmwares =3D 0; bool secure =3D false; + virFirmwarePtr *firmwaresAlt =3D NULL; + size_t nfirmwaresAlt =3D 0; + int ret =3D -1; =20 os->supported =3D VIR_TRISTATE_BOOL_YES; os->firmware.report =3D true; =20 if (qemuFirmwareGetSupported(machine, arch, privileged, - &autoFirmwares, &secure, NULL, NULL) < 0) + &autoFirmwares, &secure, + &firmwaresAlt, &nfirmwaresAlt) < 0) return -1; =20 if (autoFirmwares & (1ULL << VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS)) @@ -5174,9 +5178,15 @@ virQEMUCapsFillDomainOSCaps(virDomainCapsOSPtr os, if (autoFirmwares & (1ULL << VIR_DOMAIN_OS_DEF_FIRMWARE_EFI)) VIR_DOMAIN_CAPS_ENUM_SET(os->firmware, VIR_DOMAIN_OS_DEF_FIRMWARE_= EFI); =20 - if (virQEMUCapsFillDomainLoaderCaps(capsLoader, secure, firmwares, nfi= rmwares) < 0) - return -1; - return 0; + if (virQEMUCapsFillDomainLoaderCaps(capsLoader, secure, + firmwaresAlt ? firmwaresAlt : firm= wares, + firmwaresAlt ? nfirmwaresAlt : nfi= rmwares) < 0) + goto cleanup; + + ret =3D 0; + cleanup: + virFirmwareFreeList(firmwaresAlt, nfirmwaresAlt); + return ret; } =20 =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list