[PATCH 02/13] qemuFirmwareEnsureNVRAM: Don't try to setup non-local nvram

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



'qemuFirmwareEnsureNVRAM' which fills the NVRAM configuration bits which
may be missing was basing it's 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@xxxxxxxxxx>
---
 src/qemu/qemu_firmware.c                              | 11 ++++++-----
 ...-format-nvram-qcow2-network-nbd.x86_64-latest.args |  2 +-
 ...i-format-nvram-qcow2-network-nbd.x86_64-latest.xml |  2 +-
 ...rmware-auto-efi-format-nvram-qcow2-network-nbd.xml |  2 +-
 4 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c
index 914f8596bd..5c247b1cf2 100644
--- a/src/qemu/qemu_firmware.c
+++ b/src/qemu/qemu_firmware.c
@@ -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;
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nbd.x86_64-latest.args b/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nbd.x86_64-latest.args
index 77babdc147..f78b4e7abf 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nbd.x86_64-latest.args
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nbd.x86_64-latest.args
@@ -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 \
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nbd.x86_64-latest.xml b/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nbd.x86_64-latest.xml
index 35865b23c5..cc87905306 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nbd.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nbd.x86_64-latest.xml
@@ -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>
diff --git a/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nbd.xml b/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nbd.xml
index 0028bde4d7..d604840edd 100644
--- a/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nbd.xml
+++ b/tests/qemuxmlconfdata/firmware-auto-efi-format-nvram-qcow2-network-nbd.xml
@@ -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>
-- 
2.47.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux