mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
qemu: allow qmp probing for cmdline options without params
That can be lately achieved with by having .param == NULL in the virQEMUCapsCommandLineProps struct. Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
1a7be8c600
commit
7bc1db5a1d
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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 "
|
||||
|
@ -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,
|
||||
|
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user