[PATCH v1 2/3] qemu : Add loadparm to qemu command line string

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

 



Introduce a new QEMU capability for loadparm and if the capability is
supported by QEMU then append the loadparm value to "-machine" string
of qemu command line.

Signed-off-by: Farhan Ali <alifm@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Bjoern Walk <bwalk@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxxxxxxx>
---
 src/qemu/qemu_capabilities.c |  3 +++
 src/qemu/qemu_capabilities.h |  3 +++
 src/qemu/qemu_command.c      | 37 +++++++++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 71951e6..4034638 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -366,6 +366,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
               "query-named-block-nodes",
               "cpu-cache",
               "qemu-xhci",
+
+              "loadparm", /* 255 */
     );
 
 
@@ -3130,6 +3132,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = {
     { "drive", "throttling.bps-total-max-length", QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH },
     { "drive", "throttling.group", QEMU_CAPS_DRIVE_IOTUNE_GROUP },
     { "spice", "rendernode", QEMU_CAPS_SPICE_RENDERNODE },
+    { "machine", "loadparm", QEMU_CAPS_LOADPARM },
 };
 
 static int
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 06a43ab..5464006 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -404,6 +404,9 @@ typedef enum {
     QEMU_CAPS_CPU_CACHE, /* -cpu supports host-cache-info and l3-cache properties */
     QEMU_CAPS_DEVICE_QEMU_XHCI, /* -device qemu-xhci */
 
+    /* 255 */
+    QEMU_CAPS_LOADPARM, /* -machine loadparm */
+
     QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
 
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 813a851..6608cf2 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7208,6 +7208,41 @@ qemuAppendKeyWrapMachineParms(virBuffer *buf, virQEMUCapsPtr qemuCaps,
     return true;
 }
 
+static void
+qemuAppendLoadparmMachineParm(virBuffer *buf,
+                              const virDomainDef *def,
+                              virQEMUCapsPtr qemuCaps)
+{
+    size_t i = 0;
+
+    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) ||
+        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_LOADPARM))
+        return;
+
+    for (i = 0; i < def->ndisks; i++) {
+        virDomainDiskDefPtr disk = def->disks[i];
+
+        if (disk->info.bootIndex == 1) {
+            if (disk->info.loadparm)
+                virBufferAsprintf(buf, ",loadparm=%s", disk->info.loadparm);
+
+            return;
+        }
+    }
+
+    /* Network boot device*/
+    for (i = 0; i < def->nnets; i++) {
+        virDomainNetDefPtr net = def->nets[i];
+
+        if (net->info.bootIndex == 1) {
+            if (net->info.loadparm)
+                virBufferAsprintf(buf, ",loadparm=%s", net->info.loadparm);
+
+            return;
+        }
+    }
+}
+
 static int
 qemuBuildNameCommandLine(virCommandPtr cmd,
                          virQEMUDriverConfigPtr cfg,
@@ -7297,6 +7332,8 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
         virCommandAddArg(cmd, "-machine");
         virBufferAdd(&buf, def->os.machine, -1);
 
+        qemuAppendLoadparmMachineParm(&buf, def, qemuCaps);
+
         if (def->virtType == VIR_DOMAIN_VIRT_QEMU)
             virBufferAddLit(&buf, ",accel=tcg");
         else if (def->virtType == VIR_DOMAIN_VIRT_KVM)
-- 
1.9.1

--
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