]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Use 'def->os.loader->nvram' directly instead of 'priv->pflash1'
authorPeter Krempa <pkrempa@redhat.com>
Wed, 18 May 2022 13:08:36 +0000 (15:08 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 14 Jun 2022 12:39:55 +0000 (14:39 +0200)
Since we now have a full virStorageSource for storing the nvram path we
don't need the extra dance of transferring 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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Tested-by: Rohit Kumar <rohit.kumar3@nutanix.com>
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
src/qemu/qemu_domain.h

index 5e39bca0e3a8365feb3c7f0223914a364c2ec4fe..d5f0c25e8a0cba77e0553be27ec4aae07db13535 100644 (file)
@@ -7142,11 +7142,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))
@@ -10148,6 +10149,9 @@ qemuBuildPflashBlockdevCommandLine(virCommand *cmd,
 {
     qemuDomainObjPrivate *priv = vm->privateData;
 
+    if (!virDomainDefHasOldStyleUEFI(vm->def))
+        return 0;
+
     if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV))
         return 0;
 
@@ -10155,8 +10159,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;
index e5f819a4b4d4717b372dc55f9fd980cb00abc05c..2b9f06b1ec758c056f2f128aef6cca275736235d 100644 (file)
@@ -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 */
@@ -11317,7 +11316,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;
@@ -11336,17 +11334,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;
 }
index e6509b5af552aab457a5057d4df839c6d5bb2c38..c2a4dd01452d5b73362ce498820e2576f27ed824 100644 (file)
@@ -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;