That can be lately achieved with by having .param == NULL in the
virQEMUCapsCommandLineProps struct.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 10 ++++++++--
src/qemu/qemu_monitor.c | 6 ++++--
src/qemu/qemu_monitor.h | 3 ++-
src/qemu/qemu_monitor_json.c | 8 +++++++-
src/qemu/qemu_monitor_json.h | 3 ++-
tests/qemumonitorjsontest.c | 20 +++++++++++++++++---
6 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index cbfc728..9c4ea87 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2428,6 +2428,7 @@ static int
virQEMUCapsProbeQMPCommandLine(virQEMUCapsPtr qemuCaps,
qemuMonitorPtr mon)
{
+ bool found = false;
int nvalues;
char **values;
size_t i, j;
@@ -2435,10 +2436,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;
}
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index db3dd73..3d9f87b 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -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);
}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 8a23267..c3695f2 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -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,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index bef6a14..a62c02f 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -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 "
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 385211c..5f6c846 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -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,
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 6debe13..baee80a 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -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",
- ¶ms)) < 0)
+ ¶ms,
+ NULL)) < 0)
goto cleanup;
if (nparams != 2) {
@@ -634,7 +636,8 @@ testQemuMonitorJSONGetCommandLineOptionParameters(const void *data)
/* present but empty */
if ((nparams =
qemuMonitorGetCommandLineOptionParameters(qemuMonitorTestGetMonitor(test),
"acpi",
- ¶ms)) < 0)
+ ¶ms,
+ &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",
- ¶ms)) < 0)
+ ¶ms,
+ &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");
--
2.0.0