]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuFirmwareEnsureNVRAM: Don't try to setup non-local nvram
authorPeter Krempa <pkrempa@redhat.com>
Mon, 19 Aug 2024 13:45:31 +0000 (15:45 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 15 Nov 2024 08:42:03 +0000 (09:42 +0100)
'qemuFirmwareEnsureNVRAM' which fills the NVRAM configuration bits which
may be missing was basing its decision to do something based on whether
the 'path' field was set. This is insufficient if remote storage is to
be considered.

Use 'virStorageSourceIsEmpty()' instead as that properly considers
remote filesystems and explain why the source is unref'd when the
function decides to rewrite the config.

The 'firmware-auto-efi-format-nvram-qcow2-network-nbd' is modified to
omit filling the 'path' field, which without this fix would result in
the nvram to be reset to a local file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_firmware.c
tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nbd.x86_64-latest.args
tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nbd.x86_64-latest.xml
tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nbd.xml

index 914f8596bd28154dcf6fdbe773e9825768c83ddd..5c247b1cf299c144d74da321b8d772612dacf244 100644 (file)
@@ -1054,13 +1054,14 @@ qemuFirmwareEnsureNVRAM(virDomainDef *def,
     if (loader->nvram && !loader->nvram->format)
         loader->nvram->format = loader->format;
 
-    /* If the source already exists and is fully specified, including
-     * the path, leave it alone */
-    if (loader->nvram && loader->nvram->path)
-        return;
+    if (loader->nvram) {
+        /* Nothing to do if a proper NVRAM backend is already configured */
+        if (!virStorageSourceIsEmpty(loader->nvram))
+            return;
 
-    if (loader->nvram)
+        /* otherwise we want to reset and re-populate the definition */
         virObjectUnref(loader->nvram);
+    }
 
     loader->nvram = virStorageSourceNew();
     loader->nvram->type = VIR_STORAGE_TYPE_FILE;
index 77babdc1479bd9389324538e8f445a0aab167b29..f78b4e7abfdd3746cf7b7a938f617e5e91921c28 100644 (file)
@@ -12,7 +12,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-guest/.config \
 -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-guest/master-key.aes"}' \
 -blockdev '{"driver":"file","filename":"/usr/share/edk2/ovmf/OVMF_CODE_4M.qcow2","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}' \
 -blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,"driver":"qcow2","file":"libvirt-pflash0-storage"}' \
--blockdev '{"driver":"nbd","server":{"type":"inet","host":"example.org","port":"6000"},"export":"bar","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}' \
+-blockdev '{"driver":"nbd","server":{"type":"inet","host":"example.org","port":"6000"},"node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}' \
 -blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver":"qcow2","file":"libvirt-pflash1-storage"}' \
 -machine pc-i440fx-4.0,usb=off,dump-guest-core=off,memory-backend=pc.ram,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format,acpi=on \
 -accel tcg \
index 35865b23c5e770ee4f3fb7477bd22f6f25ba0f31..cc87905306f43db049de12eb23e2e95452b136f1 100644 (file)
@@ -11,7 +11,7 @@
     </firmware>
     <loader readonly='yes' type='pflash' format='qcow2'>/usr/share/edk2/ovmf/OVMF_CODE_4M.qcow2</loader>
     <nvram type='network' format='qcow2'>
-      <source protocol='nbd' name='bar'>
+      <source protocol='nbd'>
         <host name='example.org' port='6000'/>
       </source>
     </nvram>
index 0028bde4d700b8466664b2c12ef92a365a59ec84..d604840edd87b2fdbef1e68433982bc0b3eac986 100644 (file)
@@ -6,7 +6,7 @@
   <os firmware='efi'>
     <type arch='x86_64' machine='pc-i440fx-4.0'>hvm</type>
     <nvram type='network' format='qcow2'>
-      <source protocol='nbd' name='bar'>
+      <source protocol='nbd'>
         <host name='example.org' port='6000'/>
       </source>
     </nvram>