From nobody Thu Sep 19 00:55:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1720454025055631.760493555665; Mon, 8 Jul 2024 08:53:45 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id F23A2150D; Mon, 8 Jul 2024 11:53:43 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6FE3D14BF; Mon, 8 Jul 2024 11:52:01 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 5ECA4C90; Mon, 8 Jul 2024 11:51:53 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 945D311D2 for ; Mon, 8 Jul 2024 11:51:52 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-327-gHhjrz0KMTyRUKt_9mGJBQ-1; Mon, 08 Jul 2024 11:51:50 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0731D196CDF5 for ; Mon, 8 Jul 2024 15:51:50 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.45.226.122]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 328DC3000181 for ; Mon, 8 Jul 2024 15:51:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720453912; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nx0wR2mkb9HzxvRntTOsrMfe/dJFGS8N+cY2ZbLSHNA=; b=ApUKuV/EfCMgzbGz0rU/EggE6LbVZZdwQ+9myDb2aqjsabp2kMTPzk8xJxwOGWedlBTcw2 n6MUvMv2rn5WULjpTfYKLwpNRtY9DIrK4eAv/aQCLLEYLOsU1kMOOAzI0mjU2SlBp+URaT xNLj0zlNTPIwHhSlALqkpTm9PzyMe/o= X-MC-Unique: gHhjrz0KMTyRUKt_9mGJBQ-1 From: Andrea Bolognani To: devel@lists.libvirt.org Subject: [PATCH 3/6] qemu: Filter firmware images by type Date: Mon, 8 Jul 2024 17:51:39 +0200 Message-ID: <20240708155142.91500-4-abologna@redhat.com> In-Reply-To: <20240708155142.91500-1-abologna@redhat.com> References: <20240708155142.91500-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: CF2CWGWDTZ35RV3LUJQAWX2WFPGHU4KI X-Message-ID-Hash: CF2CWGWDTZ35RV3LUJQAWX2WFPGHU4KI X-MailFrom: abologna@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1720454026198100001 Content-Type: text/plain; charset="utf-8"; x-default="true" If the configuration explicitly requests a specific type of firmware image, be it pflash or ROM, we should ignore all images that are not of that type. If no specific type has been requested, of course, any type is considered a match and the selection will be based upon the other attributes. Signed-off-by: Andrea Bolognani --- src/qemu/qemu_firmware.c | 12 +++++++ ...ware-auto-efi-rw-pflash.x86_64-latest.args | 34 ------------------- ...mware-auto-efi-rw-pflash.x86_64-latest.err | 1 + ...mware-auto-efi-rw-pflash.x86_64-latest.xml | 6 +--- tests/qemuxmlconftest.c | 2 +- 5 files changed, 15 insertions(+), 40 deletions(-) delete mode 100644 tests/qemuxmlconfdata/firmware-auto-efi-rw-pflash.x86_6= 4-latest.args create mode 100644 tests/qemuxmlconfdata/firmware-auto-efi-rw-pflash.x86_6= 4-latest.err diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index 424b0b3217..a0b13f76b8 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -1280,6 +1280,12 @@ qemuFirmwareMatchDomain(const virDomainDef *def, if (fw->mapping.device =3D=3D QEMU_FIRMWARE_DEVICE_FLASH) { const qemuFirmwareMappingFlash *flash =3D &fw->mapping.data.flash; =20 + if (loader && loader->type && + loader->type !=3D VIR_DOMAIN_LOADER_TYPE_PFLASH) { + VIR_DEBUG("Discarding flash loader"); + return false; + } + if (loader && loader->stateless =3D=3D VIR_TRISTATE_BOOL_YES) { if (flash->mode !=3D QEMU_FIRMWARE_FLASH_MODE_STATELESS) { VIR_DEBUG("Discarding loader without stateless flash"); @@ -1327,6 +1333,12 @@ qemuFirmwareMatchDomain(const virDomainDef *def, return false; } } + } else if (fw->mapping.device =3D=3D QEMU_FIRMWARE_DEVICE_MEMORY) { + if (loader && loader->type && + loader->type !=3D VIR_DOMAIN_LOADER_TYPE_ROM) { + VIR_DEBUG("Discarding rom loader"); + return false; + } } =20 if (def->sec) { diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-rw-pflash.x86_64-lates= t.args b/tests/qemuxmlconfdata/firmware-auto-efi-rw-pflash.x86_64-latest.ar= gs deleted file mode 100644 index 753ad2d4b5..0000000000 --- a/tests/qemuxmlconfdata/firmware-auto-efi-rw-pflash.x86_64-latest.args +++ /dev/null @@ -1,34 +0,0 @@ -LC_ALL=3DC \ -PATH=3D/bin \ -HOME=3D/var/lib/libvirt/qemu/domain--1-guest \ -USER=3Dtest \ -LOGNAME=3Dtest \ -XDG_DATA_HOME=3D/var/lib/libvirt/qemu/domain--1-guest/.local/share \ -XDG_CACHE_HOME=3D/var/lib/libvirt/qemu/domain--1-guest/.cache \ -XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-guest/.config \ -/usr/bin/qemu-system-x86_64 \ --name guest=3Dguest,debug-threads=3Don \ --S \ --object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/va= r/lib/libvirt/qemu/domain--1-guest/master-key.aes"}' \ --machine pc-q35-4.0,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ra= m,acpi=3Don \ --accel kvm \ --cpu qemu64 \ --bios /usr/share/edk2/ovmf/OVMF.inteltdx.secboot.fd \ --m size=3D1048576k \ --object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":1073741824}= ' \ --overcommit mem-lock=3Doff \ --smp 1,sockets=3D1,cores=3D1,threads=3D1 \ --uuid 63840878-0deb-4095-97e6-fc444d9bc9fa \ --display none \ --no-user-config \ --nodefaults \ --chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ --mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ --rtc base=3Dutc \ --no-shutdown \ --boot strict=3Don \ --audiodev '{"id":"audio1","driver":"none"}' \ --global ICH9-LPC.noreboot=3Doff \ --watchdog-action reset \ --sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ --msg timestamp=3Don diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-rw-pflash.x86_64-lates= t.err b/tests/qemuxmlconfdata/firmware-auto-efi-rw-pflash.x86_64-latest.err new file mode 100644 index 0000000000..3edb2b3451 --- /dev/null +++ b/tests/qemuxmlconfdata/firmware-auto-efi-rw-pflash.x86_64-latest.err @@ -0,0 +1 @@ +operation failed: Unable to find 'efi' firmware that is compatible with th= e current configuration diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-rw-pflash.x86_64-lates= t.xml b/tests/qemuxmlconfdata/firmware-auto-efi-rw-pflash.x86_64-latest.xml index fe05e33b69..3ced80f78b 100644 --- a/tests/qemuxmlconfdata/firmware-auto-efi-rw-pflash.x86_64-latest.xml +++ b/tests/qemuxmlconfdata/firmware-auto-efi-rw-pflash.x86_64-latest.xml @@ -6,11 +6,7 @@ 1 hvm - - - - - /usr/share/edk2/ovmf/OVMF.inteltd= x.secboot.fd + diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c index 07454f19c2..2c1918cb46 100644 --- a/tests/qemuxmlconftest.c +++ b/tests/qemuxmlconftest.c @@ -1421,7 +1421,7 @@ mymain(void) DO_TEST_CAPS_LATEST_ABI_UPDATE("firmware-auto-efi"); DO_TEST_CAPS_LATEST("firmware-auto-efi-stateless"); DO_TEST_CAPS_LATEST("firmware-auto-efi-rw"); - DO_TEST_CAPS_LATEST("firmware-auto-efi-rw-pflash"); + DO_TEST_CAPS_LATEST_FAILURE("firmware-auto-efi-rw-pflash"); DO_TEST_CAPS_LATEST("firmware-auto-efi-loader-secure"); DO_TEST_CAPS_LATEST_ABI_UPDATE("firmware-auto-efi-loader-secure"); DO_TEST_CAPS_LATEST("firmware-auto-efi-loader-insecure"); --=20 2.45.2