[RFC PATCH 5/4] qemu: detect -machine mem-merge capability

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

 



* src/qemu/qemu_capabilities.h: New capability bit.
* src/qemu/qemu_capabilities.c (virQEMUCapsProbeQMPCommandLine): New
function; use it to set new capability bit.
(virQEMUCapsInitQMP): Use new function.
---

As promised, here is how I would set the new capability for use
in Osier's series here:
https://www.redhat.com/archives/libvir-list/2013-April/msg01833.html

 src/qemu/qemu_capabilities.c | 46 ++++++++++++++++++++++++++++++++++++++++----
 src/qemu/qemu_capabilities.h |  1 +
 2 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 2acf535..40b824c 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -222,9 +222,10 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
               "tpm-tis",

               "nvram",  /* 140 */
-              "pci-bridge", /* 141 */
-              "vfio-pci", /* 142 */
-              "vfio-pci.bootindex", /* 143 */
+              "pci-bridge",
+              "vfio-pci",
+              "vfio-pci.bootindex",
+              "mem-merge",
     );

 struct _virQEMUCaps {
@@ -1441,7 +1442,6 @@ static struct virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] = {
       ARRAY_CARDINALITY(virQEMUCapsObjectPropsUsbHost) },
 };

-
 static void
 virQEMUCapsProcessStringFlags(virQEMUCapsPtr qemuCaps,
                               size_t nflags,
@@ -2225,6 +2225,42 @@ virQEMUCapsProbeQMPKVMState(virQEMUCapsPtr qemuCaps,
 }


+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)
 {
@@ -2552,6 +2588,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 213f63c..c9c7fc9 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -182,6 +182,7 @@ enum virQEMUCapsFlags {
     QEMU_CAPS_DEVICE_PCI_BRIDGE  = 141, /* -device pci-bridge */
     QEMU_CAPS_DEVICE_VFIO_PCI    = 142, /* -device vfio-pci */
     QEMU_CAPS_VFIO_PCI_BOOTINDEX = 143, /* bootindex param for vfio-pci device */
+    QEMU_CAPS_MEM_MERGE          = 144, /* -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]