[PATCH v4 04/13] qemu: Use 'def->os.loader->nvram' directly instead of 'priv->pflash1'

Peter Krempa pkrempa at redhat.com
Fri Jun 3 11:48:36 UTC 2022


Since we now have a full virStorageSource for storing the nvram path we
don't need the extra dance of transfering the data into the 'pflash1'
variable which was an intermediary solution to use -blockdev.

For now we keep it functionally identical to the previous impl.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_command.c | 14 +++++++++-----
 src/qemu/qemu_domain.c  | 12 ++----------
 src/qemu/qemu_domain.h  |  1 -
 3 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 952336bafc..c57ff6d281 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7138,11 +7138,12 @@ qemuBuildMachineCommandLine(virCommand *cmd,
         }
     }

-    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) {
+    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV) &&
+        virDomainDefHasOldStyleUEFI(def)) {
         if (priv->pflash0)
             virBufferAsprintf(&buf, ",pflash0=%s", priv->pflash0->nodeformat);
-        if (priv->pflash1)
-            virBufferAsprintf(&buf, ",pflash1=%s", priv->pflash1->nodeformat);
+        if (def->os.loader->nvram)
+            virBufferAsprintf(&buf, ",pflash1=%s", def->os.loader->nvram->nodeformat);
     }

     if (virDomainNumaHasHMAT(def->numa))
@@ -10126,6 +10127,9 @@ qemuBuildPflashBlockdevCommandLine(virCommand *cmd,
 {
     qemuDomainObjPrivate *priv = vm->privateData;

+    if (!virDomainDefHasOldStyleUEFI(vm->def))
+        return 0;
+
     if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV))
         return 0;

@@ -10133,8 +10137,8 @@ qemuBuildPflashBlockdevCommandLine(virCommand *cmd,
         qemuBuildPflashBlockdevOne(cmd, priv->pflash0, priv->qemuCaps) < 0)
         return -1;

-    if (priv->pflash1 &&
-        qemuBuildPflashBlockdevOne(cmd, priv->pflash1, priv->qemuCaps) < 0)
+    if (vm->def->os.loader->nvram &&
+        qemuBuildPflashBlockdevOne(cmd, vm->def->os.loader->nvram, priv->qemuCaps) < 0)
         return -1;

     return 0;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 1ee3cc3922..9ed2d1fd86 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1698,7 +1698,6 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivate *priv)
     virHashRemoveAll(priv->blockjobs);

     g_clear_pointer(&priv->pflash0, virObjectUnref);
-    g_clear_pointer(&priv->pflash1, virObjectUnref);
     g_clear_pointer(&priv->backup, virDomainBackupDefFree);

     /* reset node name allocator */
@@ -11314,7 +11313,6 @@ qemuDomainInitializePflashStorageSource(virDomainObj *vm)
     qemuDomainObjPrivate *priv = vm->privateData;
     virDomainDef *def = vm->def;
     g_autoptr(virStorageSource) pflash0 = NULL;
-    g_autoptr(virStorageSource) pflash1 = NULL;

     if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV))
         return 0;
@@ -11333,17 +11331,11 @@ qemuDomainInitializePflashStorageSource(virDomainObj *vm)


     if (def->os.loader->nvram) {
-        pflash1 = virStorageSourceNew();
-        pflash1->type = VIR_STORAGE_TYPE_FILE;
-        pflash1->format = VIR_STORAGE_FILE_RAW;
-        pflash1->path = g_strdup(def->os.loader->nvram->path);
-        pflash1->readonly = false;
-        pflash1->nodeformat = g_strdup("libvirt-pflash1-format");
-        pflash1->nodestorage = g_strdup("libvirt-pflash1-storage");
+        def->os.loader->nvram->nodeformat = g_strdup("libvirt-pflash1-format");
+        def->os.loader->nvram->nodestorage = g_strdup("libvirt-pflash1-storage");
     }

     priv->pflash0 = g_steal_pointer(&pflash0);
-    priv->pflash1 = g_steal_pointer(&pflash1);

     return 0;
 }
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 558037204c..0c6b3eeffa 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -231,7 +231,6 @@ struct _qemuDomainObjPrivate {
      * pointers hold the temporary virStorageSources for creating the -blockdev
      * commandline for pflash drives. */
     virStorageSource *pflash0;
-    virStorageSource *pflash1;

     /* running backup job */
     virDomainBackupDef *backup;
-- 
2.35.3



More information about the libvir-list mailing list