1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-23 21:34:54 +03:00

conf: Always parse NVRAM path if present

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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Andrea Bolognani 2022-06-17 11:40:14 +02:00
parent bdd9ce0fda
commit 9c7499ce54
3 changed files with 12 additions and 8 deletions

View File

@ -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);

View File

@ -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 \

View File

@ -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>