mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-30 21:47:18 +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,
|
virQEMUCapsProbeQMPCommandLine(virQEMUCapsPtr qemuCaps,
|
||||||
qemuMonitorPtr mon)
|
qemuMonitorPtr mon)
|
||||||
{
|
{
|
||||||
|
bool found = false;
|
||||||
int nvalues;
|
int nvalues;
|
||||||
char **values;
|
char **values;
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
@ -2436,10 +2437,15 @@ virQEMUCapsProbeQMPCommandLine(virQEMUCapsPtr qemuCaps,
|
|||||||
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsCommandLine); i++) {
|
for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsCommandLine); i++) {
|
||||||
if ((nvalues = qemuMonitorGetCommandLineOptionParameters(mon,
|
if ((nvalues = qemuMonitorGetCommandLineOptionParameters(mon,
|
||||||
virQEMUCapsCommandLine[i].option,
|
virQEMUCapsCommandLine[i].option,
|
||||||
&values)) < 0)
|
&values,
|
||||||
|
&found)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (found && !virQEMUCapsCommandLine[i].param)
|
||||||
|
virQEMUCapsSet(qemuCaps, virQEMUCapsCommandLine[i].flag);
|
||||||
|
|
||||||
for (j = 0; j < nvalues; j++) {
|
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);
|
virQEMUCapsSet(qemuCaps, virQEMUCapsCommandLine[i].flag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3659,7 +3659,8 @@ int qemuMonitorGetEvents(qemuMonitorPtr mon,
|
|||||||
int
|
int
|
||||||
qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
||||||
const char *option,
|
const char *option,
|
||||||
char ***params)
|
char ***params,
|
||||||
|
bool *found)
|
||||||
{
|
{
|
||||||
VIR_DEBUG("mon=%p option=%s params=%p", mon, option, params);
|
VIR_DEBUG("mon=%p option=%s params=%p", mon, option, params);
|
||||||
|
|
||||||
@ -3675,7 +3676,8 @@ qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return qemuMonitorJSONGetCommandLineOptionParameters(mon, option, params);
|
return qemuMonitorJSONGetCommandLineOptionParameters(mon, option,
|
||||||
|
params, found);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -748,7 +748,8 @@ int qemuMonitorGetEvents(qemuMonitorPtr mon,
|
|||||||
char ***events);
|
char ***events);
|
||||||
int qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
int qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
||||||
const char *option,
|
const char *option,
|
||||||
char ***params);
|
char ***params,
|
||||||
|
bool *found);
|
||||||
|
|
||||||
int qemuMonitorGetKVMState(qemuMonitorPtr mon,
|
int qemuMonitorGetKVMState(qemuMonitorPtr mon,
|
||||||
bool *enabled,
|
bool *enabled,
|
||||||
|
@ -4504,7 +4504,8 @@ int qemuMonitorJSONGetEvents(qemuMonitorPtr mon,
|
|||||||
int
|
int
|
||||||
qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
||||||
const char *option,
|
const char *option,
|
||||||
char ***params)
|
char ***params,
|
||||||
|
bool *found)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
virJSONValuePtr cmd = NULL;
|
virJSONValuePtr cmd = NULL;
|
||||||
@ -4516,6 +4517,8 @@ qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*params = NULL;
|
*params = NULL;
|
||||||
|
if (found)
|
||||||
|
*found = false;
|
||||||
|
|
||||||
/* query-command-line-options has fixed output for a given qemu
|
/* query-command-line-options has fixed output for a given qemu
|
||||||
* binary; but since callers want to query parameters for one
|
* binary; but since callers want to query parameters for one
|
||||||
@ -4576,6 +4579,9 @@ qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (found)
|
||||||
|
*found = true;
|
||||||
|
|
||||||
if ((n = virJSONValueArraySize(data)) < 0) {
|
if ((n = virJSONValueArraySize(data)) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("query-command-line-options parameter data was not "
|
_("query-command-line-options parameter data was not "
|
||||||
|
@ -332,7 +332,8 @@ int qemuMonitorJSONGetEvents(qemuMonitorPtr mon,
|
|||||||
ATTRIBUTE_NONNULL(2);
|
ATTRIBUTE_NONNULL(2);
|
||||||
int qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
int qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
||||||
const char *option,
|
const char *option,
|
||||||
char ***params)
|
char ***params,
|
||||||
|
bool *found)
|
||||||
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
||||||
|
|
||||||
int qemuMonitorJSONGetKVMState(qemuMonitorPtr mon,
|
int qemuMonitorJSONGetKVMState(qemuMonitorPtr mon,
|
||||||
|
@ -583,6 +583,7 @@ testQemuMonitorJSONGetCommandLineOptionParameters(const void *data)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
char **params = NULL;
|
char **params = NULL;
|
||||||
int nparams = 0;
|
int nparams = 0;
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
if (!test)
|
if (!test)
|
||||||
return -1;
|
return -1;
|
||||||
@ -604,7 +605,8 @@ testQemuMonitorJSONGetCommandLineOptionParameters(const void *data)
|
|||||||
/* present with params */
|
/* present with params */
|
||||||
if ((nparams = qemuMonitorGetCommandLineOptionParameters(qemuMonitorTestGetMonitor(test),
|
if ((nparams = qemuMonitorGetCommandLineOptionParameters(qemuMonitorTestGetMonitor(test),
|
||||||
"option-rom",
|
"option-rom",
|
||||||
¶ms)) < 0)
|
¶ms,
|
||||||
|
NULL)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (nparams != 2) {
|
if (nparams != 2) {
|
||||||
@ -634,7 +636,8 @@ testQemuMonitorJSONGetCommandLineOptionParameters(const void *data)
|
|||||||
/* present but empty */
|
/* present but empty */
|
||||||
if ((nparams = qemuMonitorGetCommandLineOptionParameters(qemuMonitorTestGetMonitor(test),
|
if ((nparams = qemuMonitorGetCommandLineOptionParameters(qemuMonitorTestGetMonitor(test),
|
||||||
"acpi",
|
"acpi",
|
||||||
¶ms)) < 0)
|
¶ms,
|
||||||
|
&found)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (nparams != 0) {
|
if (nparams != 0) {
|
||||||
@ -642,6 +645,11 @@ testQemuMonitorJSONGetCommandLineOptionParameters(const void *data)
|
|||||||
"nparams was %d, expected 0", nparams);
|
"nparams was %d, expected 0", nparams);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
if (!found) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
"found was false, expected true");
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
if (params && params[0]) {
|
if (params && params[0]) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"unexpected array contents");
|
"unexpected array contents");
|
||||||
@ -654,7 +662,8 @@ testQemuMonitorJSONGetCommandLineOptionParameters(const void *data)
|
|||||||
/* no such option */
|
/* no such option */
|
||||||
if ((nparams = qemuMonitorGetCommandLineOptionParameters(qemuMonitorTestGetMonitor(test),
|
if ((nparams = qemuMonitorGetCommandLineOptionParameters(qemuMonitorTestGetMonitor(test),
|
||||||
"foobar",
|
"foobar",
|
||||||
¶ms)) < 0)
|
¶ms,
|
||||||
|
&found)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (nparams != 0) {
|
if (nparams != 0) {
|
||||||
@ -662,6 +671,11 @@ testQemuMonitorJSONGetCommandLineOptionParameters(const void *data)
|
|||||||
"nparams was %d, expected 0", nparams);
|
"nparams was %d, expected 0", nparams);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
if (found) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
"found was true, expected false");
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
if (params && params[0]) {
|
if (params && params[0]) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"unexpected array contents");
|
"unexpected array contents");
|
||||||
|
Loading…
Reference in New Issue
Block a user