Currently, the lack of a <loader> element results in the <nvram>
element being completely ignored, but this is unnecessarily
limiting: even when firmware autoselection is in use, it should
be possible for the user to specify a custom path for the NVRAM
file.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/conf/domain_conf.c | 17 ++++++++++-------
.../firmware-auto-efi-nvram.x86_64-latest.args | 2 +-
.../firmware-auto-efi-nvram.x86_64-latest.xml | 1 +
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 858242b3ae..9b82f391c4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18053,6 +18053,15 @@ virDomainLoaderDefParseXML(virDomainLoaderDef *loader,
unsigned int flags,
bool fwAutoSelect)
{
+ if (virDomainLoaderDefParseXMLNvram(loader,
+ nvramNode, nvramSourceNode,
+ ctxt, xmlopt, flags,
+ fwAutoSelect) < 0)
+ return -1;
+
+ if (!loaderNode)
+ return 0;
+
if (!fwAutoSelect) {
if (virXMLPropTristateBool(loaderNode, "readonly", VIR_XML_PROP_NONE,
&loader->readonly) < 0)
@@ -18073,12 +18082,6 @@ virDomainLoaderDefParseXML(virDomainLoaderDef *loader,
&loader->secure) < 0)
return -1;
- if (virDomainLoaderDefParseXMLNvram(loader,
- nvramNode, nvramSourceNode,
- ctxt, xmlopt, flags,
- fwAutoSelect) < 0)
- return -1;
-
return 0;
}
@@ -18477,7 +18480,7 @@ virDomainDefParseBootLoaderOptions(virDomainDef *def,
xmlNodePtr nvramSourceNode = virXPathNode("./os/nvram/source[1]", ctxt);
const bool fwAutoSelect = def->os.firmware != VIR_DOMAIN_OS_DEF_FIRMWARE_NONE;
- if (!loaderNode)
+ if (!loaderNode && !nvramNode)
return 0;
def->os.loader = g_new0(virDomainLoaderDef, 1);
diff --git a/tests/qemuxml2argvdata/firmware-auto-efi-nvram.x86_64-latest.args
b/tests/qemuxml2argvdata/firmware-auto-efi-nvram.x86_64-latest.args
index 885c83445d..e37521b0a3 100644
--- a/tests/qemuxml2argvdata/firmware-auto-efi-nvram.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/firmware-auto-efi-nvram.x86_64-latest.args
@@ -12,7 +12,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-fedora/.config \
-object
'{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-fedora/master-key.aes"}'
\
-blockdev
'{"driver":"file","filename":"/usr/share/OVMF/OVMF_CODE.secboot.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}'
\
-blockdev
'{"node-name":"libvirt-pflash0-format","read-only":true,"driver":"raw","file":"libvirt-pflash0-storage"}'
\
--blockdev
'{"driver":"file","filename":"/var/lib/libvirt/qemu/nvram/fedora_VARS.fd","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}'
\
+-blockdev
'{"driver":"file","filename":"/path/to/fedora_VARS.fd","node-name":"libvirt-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-q35-4.0,usb=off,smm=on,dump-guest-core=off,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format,memory-backend=pc.ram
\
-accel kvm \
diff --git a/tests/qemuxml2xmloutdata/firmware-auto-efi-nvram.x86_64-latest.xml
b/tests/qemuxml2xmloutdata/firmware-auto-efi-nvram.x86_64-latest.xml
index 7e2e40036e..abd6ec079d 100644
--- a/tests/qemuxml2xmloutdata/firmware-auto-efi-nvram.x86_64-latest.xml
+++ b/tests/qemuxml2xmloutdata/firmware-auto-efi-nvram.x86_64-latest.xml
@@ -6,6 +6,7 @@
<vcpu placement='static'>1</vcpu>
<os firmware='efi'>
<type arch='x86_64' machine='pc-q35-4.0'>hvm</type>
+ <nvram>/path/to/fedora_VARS.fd</nvram>
<boot dev='hd'/>
</os>
<features>
--
2.35.3