virQEMUCapsProbeQMPCommandLine(virQEMUCapsPtr qemuCaps,
qemuMonitorPtr mon)
{
+ bool found = false;
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)
+ &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;
}
int
qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon,
const char *option,
- char ***params)
+ char ***params,
+ bool *found)
{
VIR_DEBUG("mon=%p option=%s params=%p", mon, option, params);
return -1;
}
- return qemuMonitorJSONGetCommandLineOptionParameters(mon, option, params);
+ return qemuMonitorJSONGetCommandLineOptionParameters(mon, option,
+ params, found);
}
char ***events);
int qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon,
const char *option,
- char ***params);
+ char ***params,
+ bool *found);
int qemuMonitorGetKVMState(qemuMonitorPtr mon,
bool *enabled,
int
qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
const char *option,
- char ***params)
+ char ***params,
+ bool *found)
{
int ret;
virJSONValuePtr cmd = NULL;
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
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 "
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,
int ret = -1;
char **params = NULL;
int nparams = 0;
+ bool found = false;
if (!test)
return -1;
/* present with params */
if ((nparams = qemuMonitorGetCommandLineOptionParameters(qemuMonitorTestGetMonitor(test),
"option-rom",
- ¶ms)) < 0)
+ ¶ms,
+ NULL)) < 0)
goto cleanup;
if (nparams != 2) {
/* present but empty */
if ((nparams = qemuMonitorGetCommandLineOptionParameters(qemuMonitorTestGetMonitor(test),
"acpi",
- ¶ms)) < 0)
+ ¶ms,
+ &found)) < 0)
goto cleanup;
if (nparams != 0) {
"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");
/* no such option */
if ((nparams = qemuMonitorGetCommandLineOptionParameters(qemuMonitorTestGetMonitor(test),
"foobar",
- ¶ms)) < 0)
+ ¶ms,
+ &found)) < 0)
goto cleanup;
if (nparams != 0) {
"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");