From nobody Mon May 13 21:36:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1645550659; cv=none; d=zohomail.com; s=zohoarc; b=F9tBLtUyRo0lKaSXYHl4G1gQ8sUkHoXFbvMmgUrqjnqKekjCcrNJ2Wi8zrFEd+J1NFUcsXNOoReEb4Oj4WBjcJC/HiNPOthdQyC+0cgEl7QGWhFSQkk5O7Ko938mczoZsi2xlApfkLvh9o/M/1rqAPI97VcBRBNkIsX4ZwxO0jc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645550659; 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; bh=N0uweY1tE36F/q34LV8vcw9L34zmGkKypLtpC6eEyC4=; b=WExCtDh2VgbYjy24DjpTHtRJQpj0sT23dZ/oeT01UcjvNSdnlCX3dCI7YVLwfcrc3zZ42uHfXbOLHmDyyX5I0kY+ZmDvTlPgPoO77sBqp2q62NMzkc3z39HECsjI080ORhsEutimdlXGwCRB2l6WMn8tyH/V+9KpksnYpd/FL2A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1645550659840846.9683326258572; Tue, 22 Feb 2022 09:24:19 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-639-aSH4CdmCNhmEu-smqQjSkw-1; Tue, 22 Feb 2022 12:24:16 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B98DE1091DA0; Tue, 22 Feb 2022 17:24:10 +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 E81D887527; Tue, 22 Feb 2022 17:24:09 +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 BCB744BB40; Tue, 22 Feb 2022 17:24:07 +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 21MHNuC0019473 for ; Tue, 22 Feb 2022 12:23:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 65CC31077D4B; Tue, 22 Feb 2022 17:23:56 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.195.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4221E108116A; Tue, 22 Feb 2022 17:23:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645550658; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=N0uweY1tE36F/q34LV8vcw9L34zmGkKypLtpC6eEyC4=; b=C3A2wOhGAUo71fiweAclKqiaenB/fvqm8gW/87yF9F6grv7QAeGD/tgudRpE2xWpkZ9xBu ACGhxlhwN90+/c4YRFWmKEPRP8a5WfCpJ8WmRkVISZhNzd+yO0z4J2GTGlaJs81iA6cVGY K35YavYVFnqyjveGNog/vW5oZ1d3IaI= X-MC-Unique: aSH4CdmCNhmEu-smqQjSkw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 1/5] qemu: fix populating NVRAM vars from template with R/W loader Date: Tue, 22 Feb 2022 17:23:46 +0000 Message-Id: <20220222172350.2053536-2-berrange@redhat.com> In-Reply-To: <20220222172350.2053536-1-berrange@redhat.com> References: <20220222172350.2053536-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1645550661295100001 The QEMU driver will populate the template to the nvram file any time it sees both the template and nvram paths present. It will auto-generate a nvram path per-VM if not provided by the user, but only if the loader is marked R/O. So with a R/O loader we have these possible scenarios - No NVRAM path or template -> try to infer a template based on the loader path, if not possible, fatal error. Auto-generate NVRAM per per VM - NVRAM path only -> try to infer a template based on the loader path, if not possible, app must have pre-created NVRAM - NVRAM path + template -> QEMU driver will copy template to NVRAM - NVRAM template only -> auto-generate NVRAM path per VM and then copy template While with a R/W loader we have these possible scenarios - No NVRAM path or template -> do nothing - NVRAM path only -> app must have pre-created NVRAM - NVRAM path + template -> QEMU driver will copy template to NVRAM - NVRAM template only -> silently ignored This change fixses the last scenario by making us auto-generate an NVRAM path per VM, and then copy the template. We can't infer a template based on the loaer path, but we align in other key areas. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_domain.c | 6 ++- ...-nvram-rw-template-vars.x86_64-latest.args | 41 +++++++++++++++++++ .../bios-nvram-rw-template-vars.xml | 36 ++++++++++++++++ .../bios-nvram-rw-template.x86_64-latest.args | 41 +++++++++++++++++++ .../bios-nvram-rw-template.xml | 36 ++++++++++++++++ .../bios-nvram-rw-vars.x86_64-latest.args | 41 +++++++++++++++++++ tests/qemuxml2argvdata/bios-nvram-rw-vars.xml | 36 ++++++++++++++++ tests/qemuxml2argvtest.c | 3 ++ 8 files changed, 238 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/bios-nvram-rw-template-vars.x86_= 64-latest.args create mode 100644 tests/qemuxml2argvdata/bios-nvram-rw-template-vars.xml create mode 100644 tests/qemuxml2argvdata/bios-nvram-rw-template.x86_64-la= test.args create mode 100644 tests/qemuxml2argvdata/bios-nvram-rw-template.xml create mode 100644 tests/qemuxml2argvdata/bios-nvram-rw-vars.x86_64-latest= .args create mode 100644 tests/qemuxml2argvdata/bios-nvram-rw-vars.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index acc76c1cd6..14a558a7ac 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4451,8 +4451,10 @@ qemuDomainDefPostParse(virDomainDef *def, def->os.machine =3D g_strdup(machine); } =20 - if (virDomainDefHasOldStyleROUEFI(def) && - !def->os.loader->nvram) + if (virDomainDefHasOldStyleUEFI(def) && + !def->os.loader->nvram && + (def->os.loader->readonly =3D=3D VIR_TRISTATE_BOOL_YES || + def->os.loader->nvramTemplate)) qemuDomainNVRAMPathFormat(cfg, def, &def->os.loader->nvram); =20 if (qemuDomainDefAddDefaultDevices(driver, def, qemuCaps) < 0) diff --git a/tests/qemuxml2argvdata/bios-nvram-rw-template-vars.x86_64-late= st.args b/tests/qemuxml2argvdata/bios-nvram-rw-template-vars.x86_64-latest.= args new file mode 100644 index 0000000000..8d971ec29b --- /dev/null +++ b/tests/qemuxml2argvdata/bios-nvram-rw-template-vars.x86_64-latest.args @@ -0,0 +1,41 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-test-bios \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-test-bios/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-test-bios/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-test-bios/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Dtest-bios,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tm= p/lib/domain--1-test-bios/master-key.aes"}' \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/qemu/nvram/test-b= ios.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discar= d":"unmap"}' \ +-blockdev '{"node-name":"libvirt-pflash0-format","read-only":false,"driver= ":"raw","file":"libvirt-pflash0-storage"}' \ +-blockdev '{"driver":"file","filename":"/some/vars/path.fd","node-name":"l= ibvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver= ":"raw","file":"libvirt-pflash1-storage"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,pflash0=3Dlibvirt-pflash0-form= at,pflash1=3Dlibvirt-pflash1-format,memory-backend=3Dpc.ram \ +-accel tcg \ +-cpu qemu64 \ +-m 1024 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":1073741824}= ' \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid 362d1fc1-df7d-193e-5c18-49a71bd1da66 \ +-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 menu=3Don,strict=3Don \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","no= de-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw= ","file":"libvirt-1-storage"}' \ +-device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-form= at","id":"ide0-0-0","bootindex":1}' \ +-device '{"driver":"usb-tablet","id":"input0","bus":"usb.0","port":"1"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x2"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/bios-nvram-rw-template-vars.xml b/tests= /qemuxml2argvdata/bios-nvram-rw-template-vars.xml new file mode 100644 index 0000000000..fe6a064c84 --- /dev/null +++ b/tests/qemuxml2argvdata/bios-nvram-rw-template-vars.xml @@ -0,0 +1,36 @@ + + test-bios + 362d1fc1-df7d-193e-5c18-49a71bd1da66 + 1048576 + 1048576 + 1 + + hvm + /var/lib/libvirt/qemu/nvram/te= st-bios.fd + /some/vars/path.fd + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + + +
+ + + + + + + + + + diff --git a/tests/qemuxml2argvdata/bios-nvram-rw-template.x86_64-latest.ar= gs b/tests/qemuxml2argvdata/bios-nvram-rw-template.x86_64-latest.args new file mode 100644 index 0000000000..2900571473 --- /dev/null +++ b/tests/qemuxml2argvdata/bios-nvram-rw-template.x86_64-latest.args @@ -0,0 +1,41 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-test-bios \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-test-bios/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-test-bios/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-test-bios/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Dtest-bios,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tm= p/lib/domain--1-test-bios/master-key.aes"}' \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/qemu/nvram/test-b= ios.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discar= d":"unmap"}' \ +-blockdev '{"node-name":"libvirt-pflash0-format","read-only":false,"driver= ":"raw","file":"libvirt-pflash0-storage"}' \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/qemu/nvram/test-b= ios_VARS.fd","node-name":"libvirt-pflash1-storage","auto-read-only":true,"d= iscard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver= ":"raw","file":"libvirt-pflash1-storage"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,pflash0=3Dlibvirt-pflash0-form= at,pflash1=3Dlibvirt-pflash1-format,memory-backend=3Dpc.ram \ +-accel tcg \ +-cpu qemu64 \ +-m 1024 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":1073741824}= ' \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid 362d1fc1-df7d-193e-5c18-49a71bd1da66 \ +-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 menu=3Don,strict=3Don \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","no= de-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw= ","file":"libvirt-1-storage"}' \ +-device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-form= at","id":"ide0-0-0","bootindex":1}' \ +-device '{"driver":"usb-tablet","id":"input0","bus":"usb.0","port":"1"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x2"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/bios-nvram-rw-template.xml b/tests/qemu= xml2argvdata/bios-nvram-rw-template.xml new file mode 100644 index 0000000000..334ed1425b --- /dev/null +++ b/tests/qemuxml2argvdata/bios-nvram-rw-template.xml @@ -0,0 +1,36 @@ + + test-bios + 362d1fc1-df7d-193e-5c18-49a71bd1da66 + 1048576 + 1048576 + 1 + + hvm + /var/lib/libvirt/qemu/nvram/te= st-bios.fd + + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + + +
+ + + + + + + + + + diff --git a/tests/qemuxml2argvdata/bios-nvram-rw-vars.x86_64-latest.args b= /tests/qemuxml2argvdata/bios-nvram-rw-vars.x86_64-latest.args new file mode 100644 index 0000000000..8d971ec29b --- /dev/null +++ b/tests/qemuxml2argvdata/bios-nvram-rw-vars.x86_64-latest.args @@ -0,0 +1,41 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-test-bios \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-test-bios/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-test-bios/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-test-bios/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Dtest-bios,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tm= p/lib/domain--1-test-bios/master-key.aes"}' \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/qemu/nvram/test-b= ios.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discar= d":"unmap"}' \ +-blockdev '{"node-name":"libvirt-pflash0-format","read-only":false,"driver= ":"raw","file":"libvirt-pflash0-storage"}' \ +-blockdev '{"driver":"file","filename":"/some/vars/path.fd","node-name":"l= ibvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver= ":"raw","file":"libvirt-pflash1-storage"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,pflash0=3Dlibvirt-pflash0-form= at,pflash1=3Dlibvirt-pflash1-format,memory-backend=3Dpc.ram \ +-accel tcg \ +-cpu qemu64 \ +-m 1024 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":1073741824}= ' \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid 362d1fc1-df7d-193e-5c18-49a71bd1da66 \ +-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 menu=3Don,strict=3Don \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","no= de-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw= ","file":"libvirt-1-storage"}' \ +-device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-form= at","id":"ide0-0-0","bootindex":1}' \ +-device '{"driver":"usb-tablet","id":"input0","bus":"usb.0","port":"1"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x2"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/bios-nvram-rw-vars.xml b/tests/qemuxml2= argvdata/bios-nvram-rw-vars.xml new file mode 100644 index 0000000000..12fdb251f3 --- /dev/null +++ b/tests/qemuxml2argvdata/bios-nvram-rw-vars.xml @@ -0,0 +1,36 @@ + + test-bios + 362d1fc1-df7d-193e-5c18-49a71bd1da66 + 1048576 + 1048576 + 1 + + hvm + /var/lib/libvirt/qemu/nvram/te= st-bios.fd + /some/vars/path.fd + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + + +
+ + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 9378125da1..d2a53d35a8 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1191,6 +1191,9 @@ mymain(void) DO_TEST_PARSE_ERROR_NOCAPS("bios-nvram-no-path"); DO_TEST_CAPS_LATEST("bios-nvram-rw"); DO_TEST_CAPS_LATEST("bios-nvram-rw-implicit"); + DO_TEST_CAPS_LATEST("bios-nvram-rw-template"); + DO_TEST_CAPS_LATEST("bios-nvram-rw-template-vars"); + DO_TEST_CAPS_LATEST("bios-nvram-rw-vars"); DO_TEST("bios-nvram-secure", QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_DEVICE_PCI_BRIDGE, --=20 2.34.1 From nobody Mon May 13 21:36:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1645550680; cv=none; d=zohomail.com; s=zohoarc; b=ikXdwe0qUXEN6sdGlTRsUWK5VZj50UN9KcBP4lUs2u2cv0fkIQPXnZ914+jrjYpYd7G7DzbPWJAaysq9FWw+/ucXAeCcwWxD5ojMshSc4UDBNn8XSRvL3EE8b7tbqoBiDPtvPRMJahODBELuqmzNSBO1R4z3rjnH3znNAd+XzXA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645550680; 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; bh=4cjdLJwTFacZZ7O8+pz+BgEWyT1gaxeJQXHn24su17o=; b=eIZ4SmfmRBjMhsWp9DubUig68JwRereJhR5x7tT+uy9g3PPfKBJlROZW9bmzunnlA+oo1FVuEQ0+WcoouOKLMYarWN9sJhiMIR9+61XnSQSMlWmYJsjrrNEF5AmZLqjgNLWBrHNcl0P6GWp7OyQLF7ZLR2hckDYTivB242Isl3s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1645550680464815.0448485479094; Tue, 22 Feb 2022 09:24:40 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-633-zt3mAyNKNfuRuY_Bmyaqvw-1; Tue, 22 Feb 2022 12:24:36 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C75396D4EC; Tue, 22 Feb 2022 17:24:30 +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 604E087531; Tue, 22 Feb 2022 17:24:30 +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 1838F1809CB2; Tue, 22 Feb 2022 17:24:30 +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 21MHNw3T019484 for ; Tue, 22 Feb 2022 12:23:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1F06F108116A; Tue, 22 Feb 2022 17:23:58 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.195.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id EED591077D4B; Tue, 22 Feb 2022 17:23:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645550679; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=4cjdLJwTFacZZ7O8+pz+BgEWyT1gaxeJQXHn24su17o=; b=ZdRVepYay4VE5hR363J+m+fvQ0pELAY3UGptx6wXatw30cemzenJTB5Qv12DElGsvJYx8D vdqe7vXyxCOMbQqzhbQeQFdVhofStOStTfMmi4ZbCtVsPwOzdK4Xy9s75mtzx9Mz6yS7Cp q9DkixWn8pnWr4/oxHG3bxBSWaLfJms= X-MC-Unique: zt3mAyNKNfuRuY_Bmyaqvw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 2/5] tests: don't permit NVRAM path when using firmware auto-select Date: Tue, 22 Feb 2022 17:23:47 +0000 Message-Id: <20220222172350.2053536-3-berrange@redhat.com> In-Reply-To: <20220222172350.2053536-1-berrange@redhat.com> References: <20220222172350.2053536-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1645550681443100003 When using we still parse the path, but completely ignore it, replacing any user provided content with a custom generated path. This makes sense since when undefining the guest, the code to cleanup NVRAM also uses the same generated path. Instead of silently ignoring user config, we should report an explicit error message. This shows that some of our tests had the bogus config scenario present. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_validate.c | 8 +++ tests/qemuxml2argvdata/os-firmware-bios.xml | 1 - ...mware-efi-bad-nvram-path.x86_64-latest.err | 1 + .../os-firmware-efi-bad-nvram-path.xml | 68 +++++++++++++++++++ .../os-firmware-efi-secboot.xml | 1 - tests/qemuxml2argvdata/os-firmware-efi.xml | 1 - tests/qemuxml2argvtest.c | 1 + .../os-firmware-bios.x86_64-latest.xml | 1 - .../os-firmware-efi-secboot.x86_64-latest.xml | 1 - .../os-firmware-efi.x86_64-latest.xml | 1 - 10 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 tests/qemuxml2argvdata/os-firmware-efi-bad-nvram-path.x= 86_64-latest.err create mode 100644 tests/qemuxml2argvdata/os-firmware-efi-bad-nvram-path.x= ml diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index f0b8aa2655..22bfb3b59d 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1504,6 +1504,14 @@ virDomainDefOSValidate(const virDomainDef *def, return -1; } =20 + if (def->os.firmware !=3D VIR_DOMAIN_OS_DEF_FIRMWARE_NONE) { + if (def->os.loader->nvram) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("NVRAM path is not permitted with firmware at= tribute")); + return -1; + } + } + return 0; } =20 diff --git a/tests/qemuxml2argvdata/os-firmware-bios.xml b/tests/qemuxml2ar= gvdata/os-firmware-bios.xml index 63886666dd..d89fcb6c58 100644 --- a/tests/qemuxml2argvdata/os-firmware-bios.xml +++ b/tests/qemuxml2argvdata/os-firmware-bios.xml @@ -7,7 +7,6 @@ hvm - /var/lib/libvirt/qemu/nvram/fedora_VARS.fd diff --git a/tests/qemuxml2argvdata/os-firmware-efi-bad-nvram-path.x86_64-l= atest.err b/tests/qemuxml2argvdata/os-firmware-efi-bad-nvram-path.x86_64-la= test.err new file mode 100644 index 0000000000..2ba8135ad4 --- /dev/null +++ b/tests/qemuxml2argvdata/os-firmware-efi-bad-nvram-path.x86_64-latest.e= rr @@ -0,0 +1 @@ +XML error: NVRAM path is not permitted with firmware attribute diff --git a/tests/qemuxml2argvdata/os-firmware-efi-bad-nvram-path.xml b/te= sts/qemuxml2argvdata/os-firmware-efi-bad-nvram-path.xml new file mode 100644 index 0000000000..a4afdb6d0b --- /dev/null +++ b/tests/qemuxml2argvdata/os-firmware-efi-bad-nvram-path.xml @@ -0,0 +1,68 @@ + + fedora + 63840878-0deb-4095-97e6-fc444d9bc9fa + 8192 + 8192 + 1 + + hvm + + /some/path + + + + + + + + + + destroy + restart + restart + + + + + + /usr/bin/qemu-system-x86_64 + +
+ + + +
+ + + +
+ + + +
+ + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + diff --git a/tests/qemuxml2argvdata/os-firmware-efi-secboot.xml b/tests/qem= uxml2argvdata/os-firmware-efi-secboot.xml index a285e06334..51faac54bf 100644 --- a/tests/qemuxml2argvdata/os-firmware-efi-secboot.xml +++ b/tests/qemuxml2argvdata/os-firmware-efi-secboot.xml @@ -7,7 +7,6 @@ hvm - /var/lib/libvirt/qemu/nvram/fedora_VARS.fd diff --git a/tests/qemuxml2argvdata/os-firmware-efi.xml b/tests/qemuxml2arg= vdata/os-firmware-efi.xml index 46a7b1b780..cb21437ed8 100644 --- a/tests/qemuxml2argvdata/os-firmware-efi.xml +++ b/tests/qemuxml2argvdata/os-firmware-efi.xml @@ -7,7 +7,6 @@ hvm - /var/lib/libvirt/qemu/nvram/fedora_VARS.fd diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d2a53d35a8..693566f2d4 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3406,6 +3406,7 @@ mymain(void) =20 DO_TEST_CAPS_LATEST("os-firmware-bios"); DO_TEST_CAPS_LATEST("os-firmware-efi"); + DO_TEST_CAPS_LATEST_PARSE_ERROR("os-firmware-efi-bad-nvram-path"); DO_TEST_CAPS_LATEST("os-firmware-efi-secboot"); DO_TEST_CAPS_LATEST("os-firmware-efi-no-enrolled-keys"); DO_TEST_CAPS_ARCH_LATEST("aarch64-os-firmware-efi", "aarch64"); diff --git a/tests/qemuxml2xmloutdata/os-firmware-bios.x86_64-latest.xml b/= tests/qemuxml2xmloutdata/os-firmware-bios.x86_64-latest.xml index df6f61421a..a278ff059c 100644 --- a/tests/qemuxml2xmloutdata/os-firmware-bios.x86_64-latest.xml +++ b/tests/qemuxml2xmloutdata/os-firmware-bios.x86_64-latest.xml @@ -7,7 +7,6 @@ hvm - /var/lib/libvirt/qemu/nvram/fedora_VARS.fd diff --git a/tests/qemuxml2xmloutdata/os-firmware-efi-secboot.x86_64-latest= .xml b/tests/qemuxml2xmloutdata/os-firmware-efi-secboot.x86_64-latest.xml index c383546cc6..e7224896aa 100644 --- a/tests/qemuxml2xmloutdata/os-firmware-efi-secboot.x86_64-latest.xml +++ b/tests/qemuxml2xmloutdata/os-firmware-efi-secboot.x86_64-latest.xml @@ -7,7 +7,6 @@ hvm - /var/lib/libvirt/qemu/nvram/fedora_VARS.fd diff --git a/tests/qemuxml2xmloutdata/os-firmware-efi.x86_64-latest.xml b/t= ests/qemuxml2xmloutdata/os-firmware-efi.x86_64-latest.xml index 04d57860e7..73f4b9a033 100644 --- a/tests/qemuxml2xmloutdata/os-firmware-efi.x86_64-latest.xml +++ b/tests/qemuxml2xmloutdata/os-firmware-efi.x86_64-latest.xml @@ -7,7 +7,6 @@ hvm - /var/lib/libvirt/qemu/nvram/fedora_VARS.fd --=20 2.34.1 From nobody Mon May 13 21:36:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1645550822; cv=none; d=zohomail.com; s=zohoarc; b=kBhwEKMdN5rQ7n/zJ9vFgHDdGWWc9PJuhOqgfekJORIISIbYlloSNheWUgwGihnqGql7T8IxSE9CwVfqHAH+bTDvyZO1FB1tYlTJwgfI5efZtmVPx7bFhnVhYOaY3vKCm8sPRcGoiiKIBJkV4j6LJGVavCSIazU/t1UApfLvOCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645550822; 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; bh=jSd1v7h2ejLOPqvhKc4/LdABpf47R4dSd7jd4L5b1bQ=; b=Lc4dH8p2S7dxIRrbHgOAQiZIi07DyYyiWrzaluecHB4v1w0CEOJL72MmMF6fcp3tgiJqtSicyZViXQDo0gK9tJm5TzokUmZxO4m8hwF8nKGIZcpcaLofdZYHd3na2eQkAK8SYg1LWdk4XiCIYpsaKOCvNWbhvRBk2Dv9Jn9TFuM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1645550822486131.10147098823643; Tue, 22 Feb 2022 09:27:02 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-480-Hnlf5D1DOsqCDGixnKwzDQ-1; Tue, 22 Feb 2022 12:25:09 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24D0619253C2; Tue, 22 Feb 2022 17:25:04 +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 0344F866D5; Tue, 22 Feb 2022 17:25:04 +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 C5C0746FAB; Tue, 22 Feb 2022 17:25:03 +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 21MHNxwF019493 for ; Tue, 22 Feb 2022 12:23:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9A3CF108117A; Tue, 22 Feb 2022 17:23:59 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.195.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id A4A081077D4B; Tue, 22 Feb 2022 17:23:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645550821; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=jSd1v7h2ejLOPqvhKc4/LdABpf47R4dSd7jd4L5b1bQ=; b=RijWXAuYyJ9U3m3BKTwPssVwrjpVe6Jld9lhjO9sPdsfcg9dcqGFq0lp7iMQ+BV+20rahj ZpJbN2GMYStu3fIj3WRYH8DhvjVm3OwVfpmCORgGPG72M0JCO8cFHg4hAwslZqLfAcr6AI 755FYLcfKBC4PNMxaZtZr6uoObMMCwk= X-MC-Unique: Hnlf5D1DOsqCDGixnKwzDQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 3/5] conf: switch nvram parsing to use XML node / property helpers Date: Tue, 22 Feb 2022 17:23:48 +0000 Message-Id: <20220222172350.2053536-4-berrange@redhat.com> In-Reply-To: <20220222172350.2053536-1-berrange@redhat.com> References: <20220222172350.2053536-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Michal Privoznik 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1645550824299100001 Instead of using XPath, parse the using the XML node and property helpers so the code is consistent with the parsing of . Reviewed-by: Michal Privoznik Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 34fec887a3..1b423298ce 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18211,21 +18211,30 @@ virDomainDefParseBootLoaderOptions(virDomainDef *= def, xmlXPathContextPtr ctxt) { xmlNodePtr loader_node =3D virXPathNode("./os/loader[1]", ctxt); + xmlNodePtr nvram_node =3D virXPathNode("./os/nvram[1]", ctxt); const bool fwAutoSelect =3D def->os.firmware !=3D VIR_DOMAIN_OS_DEF_FI= RMWARE_NONE; + virDomainLoaderDef *loader; =20 if (!loader_node) return 0; =20 - def->os.loader =3D g_new0(virDomainLoaderDef, 1); + def->os.loader =3D loader =3D g_new0(virDomainLoaderDef, 1); =20 if (virDomainLoaderDefParseXML(loader_node, def->os.loader, fwAutoSelect) < 0) return -1; =20 - def->os.loader->nvram =3D virXPathString("string(./os/nvram[1])", ctxt= ); - if (!fwAutoSelect) - def->os.loader->nvramTemplate =3D virXPathString("string(./os/nvra= m[1]/@template)", ctxt); + if (nvram_node) { + if (!(loader->nvram =3D virXMLNodeContentString(nvram_node))) + return -1; + + if (STREQ(loader->nvram, "")) + VIR_FREE(loader->nvram); + + if (!fwAutoSelect) + def->os.loader->nvramTemplate =3D virXMLPropString(nvram_node,= "template"); + } =20 return 0; } --=20 2.34.1 From nobody Mon May 13 21:36:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1645550703; cv=none; d=zohomail.com; s=zohoarc; b=VfquRfOuH6lnG5Z9eAGXilfb0iPC9z8G4sqNqmVDbrSdm0cUeSNnx0b1XX8W6EnTXfZZRTmIkNrnKyamm94yOcf01gAV5LVBra63BhenVkvgI9TN5CZe2Ycoa4cMEJikqyNSkV+mzejskOMIE9LtKKRKWqZyqoQjTUC2tmkmK8g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645550703; 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; bh=VnrtzmWuzZ67YtqPCXum/kCXtozID8sszZbqDNdYZ5I=; b=bq4P7r7tyXUa5mjLDiAfFHPfJacGNd66vqxwWCa8Lgk+XyNookxZpLazfztCj4gSNkoi2s877aOhjAS1wz28MNAdpqzRrUZ0QYXGQyaxMfU/FzC4wC2zzuV3LtKDm2BvF/0ecc3WwNLc6Sc4K8c5pSl8moDtBxoyioD1nacVKAw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1645550703032612.2416683172326; Tue, 22 Feb 2022 09:25:03 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-619-JeLsEsSgMOa5o9-AARN2Vw-1; Tue, 22 Feb 2022 12:24:58 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C56996D4EC; Tue, 22 Feb 2022 17:24:51 +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 A4BC1865BE; Tue, 22 Feb 2022 17:24:51 +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 79EAA46FA8; Tue, 22 Feb 2022 17:24:51 +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 21MHO1P4019506 for ; Tue, 22 Feb 2022 12:24:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 134081077D4B; Tue, 22 Feb 2022 17:24:01 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.195.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C1FD1077D49; Tue, 22 Feb 2022 17:23:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645550701; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=VnrtzmWuzZ67YtqPCXum/kCXtozID8sszZbqDNdYZ5I=; b=LE4PlP125A3WAVTjpn//MPlE5ymjzIjP15vLi5wcZ/IuW8rquQLuz1ePG3u/zsUGunx8eS oxbIXhwO0saF4JqqoX5W2+Sh4Y4qeliEc2RfBaAyRsJAdfFkzr1lQXg1rxMTkntch9fFya ML17vDko3a2fiddUm8h/1QSjR2Tqgls= X-MC-Unique: JeLsEsSgMOa5o9-AARN2Vw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 4/5] conf: move nvram parsing into virDomainLoaderDefParseXML Date: Tue, 22 Feb 2022 17:23:49 +0000 Message-Id: <20220222172350.2053536-5-berrange@redhat.com> In-Reply-To: <20220222172350.2053536-1-berrange@redhat.com> References: <20220222172350.2053536-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Michal Privoznik 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1645550705387100001 The virDomainLoaderDef struct contains fields for both and elements, so it makes sense to parse them in the same method, just like we'll format them in the same method. Reviewed-by: Michal Privoznik Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 92 ++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 52 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1b423298ce..d79af0b6c8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17795,29 +17795,51 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDoma= inDef *def) } =20 static int -virDomainLoaderDefParseXML(xmlNodePtr node, - virDomainLoaderDef *loader, - bool fwAutoSelect) +virDomainLoaderDefParseXML(virDomainDef *def, + xmlXPathContextPtr ctxt) { - if (!fwAutoSelect) { - if (virXMLPropTristateBool(node, "readonly", VIR_XML_PROP_NONE, - &loader->readonly) < 0) - return -1; + xmlNodePtr loader_node =3D virXPathNode("./os/loader[1]", ctxt); + xmlNodePtr nvram_node =3D virXPathNode("./os/nvram[1]", ctxt); + const bool fwAutoSelect =3D def->os.firmware !=3D VIR_DOMAIN_OS_DEF_FI= RMWARE_NONE; + virDomainLoaderDef *loader; + + if (!loader_node && !nvram_node) + return 0; + + def->os.loader =3D loader =3D g_new0(virDomainLoaderDef, 1); + + if (loader_node) { + if (!fwAutoSelect) { + if (virXMLPropTristateBool(loader_node, "readonly", VIR_XML_PR= OP_NONE, + &loader->readonly) < 0) + return -1; + + if (virXMLPropEnum(loader_node, "type", virDomainLoaderTypeFro= mString, + VIR_XML_PROP_NONZERO, &loader->type) < 0) + return -1; =20 - if (virXMLPropEnum(node, "type", virDomainLoaderTypeFromString, - VIR_XML_PROP_NONZERO, &loader->type) < 0) + if (!(loader->path =3D virXMLNodeContentString(loader_node))) + return -1; + + if (STREQ(loader->path, "")) + VIR_FREE(loader->path); + } + + if (virXMLPropTristateBool(loader_node, "secure", VIR_XML_PROP_NON= E, + &loader->secure) < 0) return -1; + } =20 - if (!(loader->path =3D virXMLNodeContentString(node))) + if (nvram_node) { + if (!(loader->nvram =3D virXMLNodeContentString(nvram_node))) return -1; =20 - if (STREQ(loader->path, "")) - VIR_FREE(loader->path); - } + if (STREQ(loader->nvram, "")) + VIR_FREE(loader->nvram); =20 - if (virXMLPropTristateBool(node, "secure", VIR_XML_PROP_NONE, - &loader->secure) < 0) - return -1; + if (!fwAutoSelect) + loader->nvramTemplate =3D virXMLPropString(nvram_node, "templa= te"); + } =20 return 0; } @@ -18206,40 +18228,6 @@ virDomainDefParseBootFirmwareOptions(virDomainDef = *def, } =20 =20 -static int -virDomainDefParseBootLoaderOptions(virDomainDef *def, - xmlXPathContextPtr ctxt) -{ - xmlNodePtr loader_node =3D virXPathNode("./os/loader[1]", ctxt); - xmlNodePtr nvram_node =3D virXPathNode("./os/nvram[1]", ctxt); - const bool fwAutoSelect =3D def->os.firmware !=3D VIR_DOMAIN_OS_DEF_FI= RMWARE_NONE; - virDomainLoaderDef *loader; - - if (!loader_node) - return 0; - - def->os.loader =3D loader =3D g_new0(virDomainLoaderDef, 1); - - if (virDomainLoaderDefParseXML(loader_node, - def->os.loader, - fwAutoSelect) < 0) - return -1; - - if (nvram_node) { - if (!(loader->nvram =3D virXMLNodeContentString(nvram_node))) - return -1; - - if (STREQ(loader->nvram, "")) - VIR_FREE(loader->nvram); - - if (!fwAutoSelect) - def->os.loader->nvramTemplate =3D virXMLPropString(nvram_node,= "template"); - } - - return 0; -} - - static int virDomainDefParseBootAcpiOptions(virDomainDef *def, xmlXPathContextPtr ctxt) @@ -18304,7 +18292,7 @@ virDomainDefParseBootOptions(virDomainDef *def, if (virDomainDefParseBootFirmwareOptions(def, ctxt) < 0) return -1; =20 - if (virDomainDefParseBootLoaderOptions(def, ctxt) < 0) + if (virDomainLoaderDefParseXML(def, ctxt) < 0) return -1; =20 if (virDomainDefParseBootAcpiOptions(def, ctxt) < 0) @@ -18320,7 +18308,7 @@ virDomainDefParseBootOptions(virDomainDef *def, case VIR_DOMAIN_OSTYPE_UML: virDomainDefParseBootKernelOptions(def, ctxt); =20 - if (virDomainDefParseBootLoaderOptions(def, ctxt) < 0) + if (virDomainLoaderDefParseXML(def, ctxt) < 0) return -1; =20 break; --=20 2.34.1 From nobody Mon May 13 21:36:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1645550686; cv=none; d=zohomail.com; s=zohoarc; b=WLRSaeI0SMfUnoKCiS5kWXaEJlrnbBAu/2tYs+z0yzRGTI0iBLAP/w/xX3nboHutCn5PeEptOk5TSWZebGWk3UC0UtznNb+/IrDCqpcIVe8dcQTnRRH9xLmUXtI1W/GyOiT9DjHirYAs6Z5Cf9HevYd2S/GqwrXrbX6mpEuKdoU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645550686; 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; bh=gWoS+vXW+dYk23w8S0U1n/og1Bpxa8Bxvf2oj7mPncA=; b=oGfZ2tizZgDrwkVqRzS8RgOhFV1ZjraNktgdNJ/mX3BiuYL0vpAOO9c3yWu1T+ovmraubIg8dGWnph29gSOfQ08wjwZd6YN/yNmDePsJl5mX19gN2JkJUQUIse9dj2/1yQv+YAYbp9flFJbf3cfmSJHSaH2HwkIF2Ow4I08yaK8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1645550686082543.4081259422845; Tue, 22 Feb 2022 09:24:46 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-212-7tz0DkTnO4admVKCGw3SzA-1; Tue, 22 Feb 2022 12:24:40 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C6534835DE5; Tue, 22 Feb 2022 17:24:35 +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 A965C1077D49; Tue, 22 Feb 2022 17:24:35 +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 5650D46F9A; Tue, 22 Feb 2022 17:24:35 +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 21MHO3mV019519 for ; Tue, 22 Feb 2022 12:24:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id 262BC1077D49; Tue, 22 Feb 2022 17:24:03 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.195.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A271108116A; Tue, 22 Feb 2022 17:24:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645550684; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=gWoS+vXW+dYk23w8S0U1n/og1Bpxa8Bxvf2oj7mPncA=; b=Bk4w+RHIvf9rcbnpWbHBB8eJCx1765kN/JfU85iWCpk09tzaAErSrqTzHrU0S2kkCGMeF2 hvS34vhu+P2KbNEDO9Q3pxPHLUVled6PZXmwMEF59f5ni4D7VdrFl/LcfS1nMRkCBtjtMD qO4RDyrGASdb8G8ddD6/DPUUh4KHtJo= X-MC-Unique: 7tz0DkTnO4admVKCGw3SzA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 5/5] conf: stop ignoring / with firmware auto-select Date: Tue, 22 Feb 2022 17:23:50 +0000 Message-Id: <20220222172350.2053536-6-berrange@redhat.com> In-Reply-To: <20220222172350.2053536-1-berrange@redhat.com> References: <20220222172350.2053536-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Michal Privoznik 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1645550687339100001 Currently if the firmware attribute is set then we silently ignore most of the and element configs. This changes the code so that we always fully parse the and but then use a post-parse method to explicitly reject invalid combinations. Reviewed-by: Michal Privoznik Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 26 +++---- src/conf/domain_validate.c | 24 +++++++ ...ware-efi-bad-loader-path.x86_64-latest.err | 1 + .../os-firmware-efi-bad-loader-path.xml | 67 ++++++++++++++++++ ...ware-efi-bad-loader-type.x86_64-latest.err | 1 + .../os-firmware-efi-bad-loader-type.xml | 67 ++++++++++++++++++ ...e-efi-bad-nvram-template.x86_64-latest.err | 1 + .../os-firmware-efi-bad-nvram-template.xml | 68 +++++++++++++++++++ tests/qemuxml2argvtest.c | 3 + 9 files changed, 243 insertions(+), 15 deletions(-) create mode 100644 tests/qemuxml2argvdata/os-firmware-efi-bad-loader-path.= x86_64-latest.err create mode 100644 tests/qemuxml2argvdata/os-firmware-efi-bad-loader-path.= xml create mode 100644 tests/qemuxml2argvdata/os-firmware-efi-bad-loader-type.= x86_64-latest.err create mode 100644 tests/qemuxml2argvdata/os-firmware-efi-bad-loader-type.= xml create mode 100644 tests/qemuxml2argvdata/os-firmware-efi-bad-nvram-templa= te.x86_64-latest.err create mode 100644 tests/qemuxml2argvdata/os-firmware-efi-bad-nvram-templa= te.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d79af0b6c8..e8ce0caa85 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17800,7 +17800,6 @@ virDomainLoaderDefParseXML(virDomainDef *def, { xmlNodePtr loader_node =3D virXPathNode("./os/loader[1]", ctxt); xmlNodePtr nvram_node =3D virXPathNode("./os/nvram[1]", ctxt); - const bool fwAutoSelect =3D def->os.firmware !=3D VIR_DOMAIN_OS_DEF_FI= RMWARE_NONE; virDomainLoaderDef *loader; =20 if (!loader_node && !nvram_node) @@ -17809,21 +17808,19 @@ virDomainLoaderDefParseXML(virDomainDef *def, def->os.loader =3D loader =3D g_new0(virDomainLoaderDef, 1); =20 if (loader_node) { - if (!fwAutoSelect) { - if (virXMLPropTristateBool(loader_node, "readonly", VIR_XML_PR= OP_NONE, - &loader->readonly) < 0) - return -1; + if (virXMLPropTristateBool(loader_node, "readonly", VIR_XML_PROP_N= ONE, + &loader->readonly) < 0) + return -1; =20 - if (virXMLPropEnum(loader_node, "type", virDomainLoaderTypeFro= mString, - VIR_XML_PROP_NONZERO, &loader->type) < 0) - return -1; + if (virXMLPropEnum(loader_node, "type", virDomainLoaderTypeFromStr= ing, + VIR_XML_PROP_NONZERO, &loader->type) < 0) + return -1; =20 - if (!(loader->path =3D virXMLNodeContentString(loader_node))) - return -1; + if (!(loader->path =3D virXMLNodeContentString(loader_node))) + return -1; =20 - if (STREQ(loader->path, "")) - VIR_FREE(loader->path); - } + if (STREQ(loader->path, "")) + VIR_FREE(loader->path); =20 if (virXMLPropTristateBool(loader_node, "secure", VIR_XML_PROP_NON= E, &loader->secure) < 0) @@ -17837,8 +17834,7 @@ virDomainLoaderDefParseXML(virDomainDef *def, if (STREQ(loader->nvram, "")) VIR_FREE(loader->nvram); =20 - if (!fwAutoSelect) - loader->nvramTemplate =3D virXMLPropString(nvram_node, "templa= te"); + loader->nvramTemplate =3D virXMLPropString(nvram_node, "template"); } =20 return 0; diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 22bfb3b59d..9ccb5d0dc2 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1505,6 +1505,30 @@ virDomainDefOSValidate(const virDomainDef *def, } =20 if (def->os.firmware !=3D VIR_DOMAIN_OS_DEF_FIRMWARE_NONE) { + if (def->os.loader->path) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Loader path is not permitted with firmware a= ttribute")); + return -1; + } + + if (def->os.loader->type) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Loader type is not permitted with firmware a= ttribute")); + return -1; + } + + if (def->os.loader->readonly) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Loader read-only attribute is not permitted = with firmware attribute")); + return -1; + } + + if (def->os.loader->nvramTemplate) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("NVRAM template path is not permitted with fi= rmware attribute")); + return -1; + } + if (def->os.loader->nvram) { virReportError(VIR_ERR_XML_ERROR, "%s", _("NVRAM path is not permitted with firmware at= tribute")); diff --git a/tests/qemuxml2argvdata/os-firmware-efi-bad-loader-path.x86_64-= latest.err b/tests/qemuxml2argvdata/os-firmware-efi-bad-loader-path.x86_64-= latest.err new file mode 100644 index 0000000000..a8dbd0d6d8 --- /dev/null +++ b/tests/qemuxml2argvdata/os-firmware-efi-bad-loader-path.x86_64-latest.= err @@ -0,0 +1 @@ +XML error: Loader path is not permitted with firmware attribute diff --git a/tests/qemuxml2argvdata/os-firmware-efi-bad-loader-path.xml b/t= ests/qemuxml2argvdata/os-firmware-efi-bad-loader-path.xml new file mode 100644 index 0000000000..02eec67c35 --- /dev/null +++ b/tests/qemuxml2argvdata/os-firmware-efi-bad-loader-path.xml @@ -0,0 +1,67 @@ + + fedora + 63840878-0deb-4095-97e6-fc444d9bc9fa + 8192 + 8192 + 1 + + hvm + /some/path + + + + + + + + + + destroy + restart + restart + + + + + + /usr/bin/qemu-system-x86_64 + +
+ + + +
+ + + +
+ + + +
+ + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + diff --git a/tests/qemuxml2argvdata/os-firmware-efi-bad-loader-type.x86_64-= latest.err b/tests/qemuxml2argvdata/os-firmware-efi-bad-loader-type.x86_64-= latest.err new file mode 100644 index 0000000000..2824399628 --- /dev/null +++ b/tests/qemuxml2argvdata/os-firmware-efi-bad-loader-type.x86_64-latest.= err @@ -0,0 +1 @@ +XML error: Loader type is not permitted with firmware attribute diff --git a/tests/qemuxml2argvdata/os-firmware-efi-bad-loader-type.xml b/t= ests/qemuxml2argvdata/os-firmware-efi-bad-loader-type.xml new file mode 100644 index 0000000000..9091a2a8ce --- /dev/null +++ b/tests/qemuxml2argvdata/os-firmware-efi-bad-loader-type.xml @@ -0,0 +1,67 @@ + + fedora + 63840878-0deb-4095-97e6-fc444d9bc9fa + 8192 + 8192 + 1 + + hvm + + + + + + + + + + + destroy + restart + restart + + + + + + /usr/bin/qemu-system-x86_64 + +
+ + + +
+ + + +
+ + + +
+ + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + diff --git a/tests/qemuxml2argvdata/os-firmware-efi-bad-nvram-template.x86_= 64-latest.err b/tests/qemuxml2argvdata/os-firmware-efi-bad-nvram-template.x= 86_64-latest.err new file mode 100644 index 0000000000..866ef34ec4 --- /dev/null +++ b/tests/qemuxml2argvdata/os-firmware-efi-bad-nvram-template.x86_64-late= st.err @@ -0,0 +1 @@ +XML error: NVRAM template path is not permitted with firmware attribute diff --git a/tests/qemuxml2argvdata/os-firmware-efi-bad-nvram-template.xml = b/tests/qemuxml2argvdata/os-firmware-efi-bad-nvram-template.xml new file mode 100644 index 0000000000..cf77ca5433 --- /dev/null +++ b/tests/qemuxml2argvdata/os-firmware-efi-bad-nvram-template.xml @@ -0,0 +1,68 @@ + + fedora + 63840878-0deb-4095-97e6-fc444d9bc9fa + 8192 + 8192 + 1 + + hvm + + /some/vars + + + + + + + + + + destroy + restart + restart + + + + + + /usr/bin/qemu-system-x86_64 + +
+ + + +
+ + + +
+ + + +
+ + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 693566f2d4..35a5c6d555 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3406,7 +3406,10 @@ mymain(void) =20 DO_TEST_CAPS_LATEST("os-firmware-bios"); DO_TEST_CAPS_LATEST("os-firmware-efi"); + DO_TEST_CAPS_LATEST_PARSE_ERROR("os-firmware-efi-bad-loader-path"); + DO_TEST_CAPS_LATEST_PARSE_ERROR("os-firmware-efi-bad-loader-type"); DO_TEST_CAPS_LATEST_PARSE_ERROR("os-firmware-efi-bad-nvram-path"); + DO_TEST_CAPS_LATEST_PARSE_ERROR("os-firmware-efi-bad-nvram-template"); DO_TEST_CAPS_LATEST("os-firmware-efi-secboot"); DO_TEST_CAPS_LATEST("os-firmware-efi-no-enrolled-keys"); DO_TEST_CAPS_ARCH_LATEST("aarch64-os-firmware-efi", "aarch64"); --=20 2.34.1