[PATCH 1/2] qemu: detect -machine mem-merge capability

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

 



From: Eric Blake <eblake@xxxxxxxxxx>

* src/qemu/qemu_capabilities.h: New capability bit.
* src/qemu/qemu_capabilities.c (virQEMUCapsProbeQMPCommandLine): New
function, based on qemuMonitorGetCommandLineOptionParameters, which was
introduced by commit bd56d0d813; use it to set new capability bit.
(virQEMUCapsInitQMP): Use new function.
---
 src/qemu/qemu_capabilities.c | 37 +++++++++++++++++++++++++++++++++++++
 src/qemu/qemu_capabilities.h |  1 +
 2 files changed, 38 insertions(+)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 74ac43c..c711e92 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -227,6 +227,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
               "scsi-generic",
 
               "scsi-generic.bootindex", /* 145 */
+              "mem-merge",
     );
 
 struct _virQEMUCaps {
@@ -2234,6 +2235,40 @@ virQEMUCapsProbeQMPKVMState(virQEMUCapsPtr qemuCaps,
     return 0;
 }
 
+struct virQEMUCapsCommandLineProps {
+    const char *option;
+    const char *param;
+    int flag;
+};
+
+static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = {
+    { "machine", "mem-merge", QEMU_CAPS_MEM_MERGE },
+};
+
+static int
+virQEMUCapsProbeQMPCommandLine(virQEMUCapsPtr qemuCaps,
+                               qemuMonitorPtr mon)
+{
+    int nvalues;
+    char **values;
+    size_t i, j;
+
+    for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsCommandLine); i++) {
+        if ((nvalues = qemuMonitorGetCommandLineOptionParameters(mon,
+                                                                 virQEMUCapsCommandLine[i].option,
+                                                                 &values)) < 0)
+            return -1;
+        for (j = 0; j < nvalues; j++) {
+            if (STREQ(virQEMUCapsCommandLine[i].param, values[j])) {
+                virQEMUCapsSet(qemuCaps, virQEMUCapsCommandLine[i].flag);
+                break;
+            }
+        }
+        virStringFreeList(values);
+    }
+
+    return 0;
+}
 
 int virQEMUCapsProbeQMP(virQEMUCapsPtr qemuCaps,
                         qemuMonitorPtr mon)
@@ -2581,6 +2616,8 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
         goto cleanup;
     if (virQEMUCapsProbeQMPTPM(qemuCaps, mon) < 0)
         goto cleanup;
+    if (virQEMUCapsProbeQMPCommandLine(qemuCaps, mon) < 0)
+        goto cleanup;
 
     ret = 0;
 
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index a9eea4e..477e526 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -184,6 +184,7 @@ enum virQEMUCapsFlags {
     QEMU_CAPS_VFIO_PCI_BOOTINDEX = 143, /* bootindex param for vfio-pci device */
     QEMU_CAPS_DEVICE_SCSI_GENERIC = 144,  /* -device scsi-generic */
     QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX = 145,  /* -device scsi-generic.bootindex */
+    QEMU_CAPS_MEM_MERGE          = 146, /* -machine mem-merge */
 
     QEMU_CAPS_LAST,                   /* this must always be the last item */
 };
-- 
1.8.1.4

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