[PATCH 4/6] qemu: command: Build -blockdev-s for backing of pflash

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

 



As a first step we will build the blockdevs which will be supposed to
back the pflash drives when moving away from -drive.

This code is similar to the way we build the blockdevs for the disk, but
skips the copy-on-read layer and doesn't implement any legacy approach.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 46 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c82d13483e..c1de2a398f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9884,6 +9884,49 @@ qemuBuildManagedPRCommandLine(virCommandPtr cmd,
 }


+static int
+qemuBuildPflashBlockdevOne(virCommandPtr cmd,
+                           virStorageSourcePtr src,
+                           virQEMUCapsPtr qemuCaps)
+{
+    g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
+    size_t i;
+
+    if (!(data = qemuBuildStorageSourceChainAttachPrepareBlockdev(src,
+                                                                  qemuCaps)))
+        return -1;
+
+    for (i = data->nsrcdata; i > 0; i--) {
+        if (qemuBuildBlockStorageSourceAttachDataCommandline(cmd,
+                                                             data->srcdata[i - 1]) < 0)
+            return -1;
+    }
+
+    return 0;
+}
+
+
+static int
+qemuBuildPflashBlockdevCommandLine(virCommandPtr cmd,
+                                   qemuDomainObjPrivatePtr priv)
+{
+    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV))
+        return 0;
+
+    if (priv->pflash0) {
+        if (qemuBuildPflashBlockdevOne(cmd, priv->pflash0, priv->qemuCaps) < 0)
+            return -1;
+    }
+
+    if (priv->pflash1) {
+        if (qemuBuildPflashBlockdevOne(cmd, priv->pflash1, priv->qemuCaps) < 0)
+            return -1;
+    }
+
+    return 0;
+}
+
+
 static virJSONValuePtr
 qemuBuildDBusVMStateInfoPropsInternal(const char *alias,
                                       const char *addr)
@@ -10200,6 +10243,9 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
     if (qemuBuildManagedPRCommandLine(cmd, def, priv) < 0)
         return NULL;

+    if (qemuBuildPflashBlockdevCommandLine(cmd, priv) < 0)
+        return NULL;
+
     if (enableFips)
         virCommandAddArg(cmd, "-enable-fips");

-- 
2.23.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[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