]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: allow qmp probing for cmdline options without params
authorMartin Kletzander <mkletzan@redhat.com>
Tue, 17 Jun 2014 11:41:16 +0000 (13:41 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Wed, 16 Jul 2014 18:15:46 +0000 (20:15 +0200)
That can be lately achieved with by having .param == NULL in the
virQEMUCapsCommandLineProps struct.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_capabilities.c
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.h
tests/qemumonitorjsontest.c

index c5fef5324929c01a4432ae8098ca7a559cf40994..a8d464837998fd35398374f574ec84e8e85c7a49 100644 (file)
@@ -2429,6 +2429,7 @@ static int
 virQEMUCapsProbeQMPCommandLine(virQEMUCapsPtr qemuCaps,
                                qemuMonitorPtr mon)
 {
+    bool found = false;
     int nvalues;
     char **values;
     size_t i, j;
@@ -2436,10 +2437,15 @@ virQEMUCapsProbeQMPCommandLine(virQEMUCapsPtr qemuCaps,
     for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsCommandLine); i++) {
         if ((nvalues = qemuMonitorGetCommandLineOptionParameters(mon,
                                                                  virQEMUCapsCommandLine[i].option,
-                                                                 &values)) < 0)
+                                                                 &values,
+                                                                 &found)) < 0)
             return -1;
+
+        if (found && !virQEMUCapsCommandLine[i].param)
+            virQEMUCapsSet(qemuCaps, virQEMUCapsCommandLine[i].flag);
+
         for (j = 0; j < nvalues; j++) {
-            if (STREQ(virQEMUCapsCommandLine[i].param, values[j])) {
+            if (STREQ_NULLABLE(virQEMUCapsCommandLine[i].param, values[j])) {
                 virQEMUCapsSet(qemuCaps, virQEMUCapsCommandLine[i].flag);
                 break;
             }
index db3dd730bc0771c9692b43770782bdebb815ce58..3d9f87b63f0ebe34ee072a4e9c289d293a725bc1 100644 (file)
@@ -3659,7 +3659,8 @@ int qemuMonitorGetEvents(qemuMonitorPtr mon,
 int
 qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon,
                                           const char *option,
-                                          char ***params)
+                                          char ***params,
+                                          bool *found)
 {
     VIR_DEBUG("mon=%p option=%s params=%p", mon, option, params);
 
@@ -3675,7 +3676,8 @@ qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon,
         return -1;
     }
 
-    return qemuMonitorJSONGetCommandLineOptionParameters(mon, option, params);
+    return qemuMonitorJSONGetCommandLineOptionParameters(mon, option,
+                                                         params, found);
 }
 
 
index 8a23267c1c5527d7b2a06ec489e2e1cd8668c1e2..c3695f248742b49ba486fd48cc976704c9155881 100644 (file)
@@ -748,7 +748,8 @@ int qemuMonitorGetEvents(qemuMonitorPtr mon,
                          char ***events);
 int qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon,
                                               const char *option,
-                                              char ***params);
+                                              char ***params,
+                                              bool *found);
 
 int qemuMonitorGetKVMState(qemuMonitorPtr mon,
                            bool *enabled,
index bef6a14144f7ecb876bcfb6a60960003cb26f967..a62c02f14cc7bed1f8c21ff79df3207492a555de 100644 (file)
@@ -4504,7 +4504,8 @@ int qemuMonitorJSONGetEvents(qemuMonitorPtr mon,
 int
 qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
                                               const char *option,
-                                              char ***params)
+                                              char ***params,
+                                              bool *found)
 {
     int ret;
     virJSONValuePtr cmd = NULL;
@@ -4516,6 +4517,8 @@ qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
     size_t i;
 
     *params = NULL;
+    if (found)
+        *found = false;
 
     /* query-command-line-options has fixed output for a given qemu
      * binary; but since callers want to query parameters for one
@@ -4576,6 +4579,9 @@ qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
         goto cleanup;
     }
 
+    if (found)
+        *found = true;
+
     if ((n = virJSONValueArraySize(data)) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("query-command-line-options parameter data was not "
index 385211c421cebb6ba7d5593413f645226dbdf53a..5f6c846e7c2d3b7c87a9c7893a225de04f434526 100644 (file)
@@ -332,7 +332,8 @@ int qemuMonitorJSONGetEvents(qemuMonitorPtr mon,
     ATTRIBUTE_NONNULL(2);
 int qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
                                                   const char *option,
-                                                  char ***params)
+                                                  char ***params,
+                                                  bool *found)
     ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
 
 int qemuMonitorJSONGetKVMState(qemuMonitorPtr mon,
index 6debe13d50e7bfa9845ba03c4b7cd956bf180c53..baee80a7ac0d4f01f31faf79a4d7324e830258b5 100644 (file)
@@ -583,6 +583,7 @@ testQemuMonitorJSONGetCommandLineOptionParameters(const void *data)
     int ret = -1;
     char **params = NULL;
     int nparams = 0;
+    bool found = false;
 
     if (!test)
         return -1;
@@ -604,7 +605,8 @@ testQemuMonitorJSONGetCommandLineOptionParameters(const void *data)
     /* present with params */
     if ((nparams = qemuMonitorGetCommandLineOptionParameters(qemuMonitorTestGetMonitor(test),
                                                              "option-rom",
-                                                             &params)) < 0)
+                                                             &params,
+                                                             NULL)) < 0)
         goto cleanup;
 
     if (nparams != 2) {
@@ -634,7 +636,8 @@ testQemuMonitorJSONGetCommandLineOptionParameters(const void *data)
     /* present but empty */
     if ((nparams = qemuMonitorGetCommandLineOptionParameters(qemuMonitorTestGetMonitor(test),
                                                              "acpi",
-                                                             &params)) < 0)
+                                                             &params,
+                                                             &found)) < 0)
         goto cleanup;
 
     if (nparams != 0) {
@@ -642,6 +645,11 @@ testQemuMonitorJSONGetCommandLineOptionParameters(const void *data)
                        "nparams was %d, expected 0", nparams);
         goto cleanup;
     }
+    if (!found) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       "found was false, expected true");
+        goto cleanup;
+    }
     if (params && params[0]) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        "unexpected array contents");
@@ -654,7 +662,8 @@ testQemuMonitorJSONGetCommandLineOptionParameters(const void *data)
     /* no such option */
     if ((nparams = qemuMonitorGetCommandLineOptionParameters(qemuMonitorTestGetMonitor(test),
                                                              "foobar",
-                                                             &params)) < 0)
+                                                             &params,
+                                                             &found)) < 0)
         goto cleanup;
 
     if (nparams != 0) {
@@ -662,6 +671,11 @@ testQemuMonitorJSONGetCommandLineOptionParameters(const void *data)
                        "nparams was %d, expected 0", nparams);
         goto cleanup;
     }
+    if (found) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       "found was true, expected false");
+        goto cleanup;
+    }
     if (params && params[0]) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        "unexpected array contents");