mirror of https://gitee.com/openkylin/libvirt.git
qemuMonitorGetCommandLineOptionParameters: remove the unused function and helpers
Remove the function along with helpers for caching the reply and tests. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
bf8bd93df0
commit
3c40710f9c
|
@ -101,9 +101,6 @@ struct _qemuMonitor {
|
||||||
|
|
||||||
bool waitGreeting;
|
bool waitGreeting;
|
||||||
|
|
||||||
/* cache of query-command-line-options results */
|
|
||||||
virJSONValuePtr options;
|
|
||||||
|
|
||||||
/* If found, path to the virtio memballoon driver */
|
/* If found, path to the virtio memballoon driver */
|
||||||
char *balloonpath;
|
char *balloonpath;
|
||||||
bool ballooninit;
|
bool ballooninit;
|
||||||
|
@ -240,7 +237,6 @@ qemuMonitorDispose(void *obj)
|
||||||
virResetError(&mon->lastError);
|
virResetError(&mon->lastError);
|
||||||
virCondDestroy(&mon->notify);
|
virCondDestroy(&mon->notify);
|
||||||
VIR_FREE(mon->buffer);
|
VIR_FREE(mon->buffer);
|
||||||
virJSONValueFree(mon->options);
|
|
||||||
VIR_FREE(mon->balloonpath);
|
VIR_FREE(mon->balloonpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -992,20 +988,6 @@ qemuMonitorLastError(qemuMonitorPtr mon)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virJSONValuePtr
|
|
||||||
qemuMonitorGetOptions(qemuMonitorPtr mon)
|
|
||||||
{
|
|
||||||
return mon->options;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
qemuMonitorSetOptions(qemuMonitorPtr mon, virJSONValuePtr options)
|
|
||||||
{
|
|
||||||
mon->options = options;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search the qom objects for the balloon driver object by its known names
|
* Search the qom objects for the balloon driver object by its known names
|
||||||
* of "virtio-balloon-pci" or "virtio-balloon-ccw". The entry for the driver
|
* of "virtio-balloon-pci" or "virtio-balloon-ccw". The entry for the driver
|
||||||
|
@ -3856,23 +3838,6 @@ qemuMonitorGetEvents(qemuMonitorPtr mon,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Collect the parameters associated with a given command line option.
|
|
||||||
* Return count of known parameters or -1 on error. */
|
|
||||||
int
|
|
||||||
qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
|
||||||
const char *option,
|
|
||||||
char ***params,
|
|
||||||
bool *found)
|
|
||||||
{
|
|
||||||
VIR_DEBUG("option=%s params=%p", option, params);
|
|
||||||
|
|
||||||
QEMU_CHECK_MONITOR(mon);
|
|
||||||
|
|
||||||
return qemuMonitorJSONGetCommandLineOptionParameters(mon, option,
|
|
||||||
params, found);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GHashTable *
|
GHashTable *
|
||||||
qemuMonitorGetCommandLineOptions(qemuMonitorPtr mon)
|
qemuMonitorGetCommandLineOptions(qemuMonitorPtr mon)
|
||||||
{
|
{
|
||||||
|
|
|
@ -444,10 +444,6 @@ int qemuMonitorSetLink(qemuMonitorPtr mon,
|
||||||
char *qemuMonitorNextCommandID(qemuMonitorPtr mon);
|
char *qemuMonitorNextCommandID(qemuMonitorPtr mon);
|
||||||
int qemuMonitorSend(qemuMonitorPtr mon,
|
int qemuMonitorSend(qemuMonitorPtr mon,
|
||||||
qemuMonitorMessagePtr msg) G_GNUC_NO_INLINE;
|
qemuMonitorMessagePtr msg) G_GNUC_NO_INLINE;
|
||||||
virJSONValuePtr qemuMonitorGetOptions(qemuMonitorPtr mon)
|
|
||||||
ATTRIBUTE_NONNULL(1);
|
|
||||||
void qemuMonitorSetOptions(qemuMonitorPtr mon, virJSONValuePtr options)
|
|
||||||
ATTRIBUTE_NONNULL(1);
|
|
||||||
int qemuMonitorUpdateVideoMemorySize(qemuMonitorPtr mon,
|
int qemuMonitorUpdateVideoMemorySize(qemuMonitorPtr mon,
|
||||||
virDomainVideoDefPtr video,
|
virDomainVideoDefPtr video,
|
||||||
const char *videoName)
|
const char *videoName)
|
||||||
|
@ -1284,10 +1280,6 @@ int qemuMonitorGetCommands(qemuMonitorPtr mon,
|
||||||
char ***commands);
|
char ***commands);
|
||||||
int qemuMonitorGetEvents(qemuMonitorPtr mon,
|
int qemuMonitorGetEvents(qemuMonitorPtr mon,
|
||||||
char ***events);
|
char ***events);
|
||||||
int qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
|
||||||
const char *option,
|
|
||||||
char ***params,
|
|
||||||
bool *found);
|
|
||||||
GHashTable *qemuMonitorGetCommandLineOptions(qemuMonitorPtr mon);
|
GHashTable *qemuMonitorGetCommandLineOptions(qemuMonitorPtr mon);
|
||||||
|
|
||||||
int qemuMonitorGetKVMState(qemuMonitorPtr mon,
|
int qemuMonitorGetKVMState(qemuMonitorPtr mon,
|
||||||
|
|
|
@ -6426,126 +6426,6 @@ qemuMonitorJSONGetCommandLineOptions(qemuMonitorPtr mon)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
|
||||||
const char *option,
|
|
||||||
char ***params,
|
|
||||||
bool *found)
|
|
||||||
{
|
|
||||||
int ret = -1;
|
|
||||||
virJSONValuePtr cmd = NULL;
|
|
||||||
virJSONValuePtr reply = NULL;
|
|
||||||
virJSONValuePtr data = NULL;
|
|
||||||
virJSONValuePtr array = NULL;
|
|
||||||
char **paramlist = NULL;
|
|
||||||
size_t n = 0;
|
|
||||||
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
|
|
||||||
* option at a time, we cache the option list from qemu. */
|
|
||||||
if (!(array = qemuMonitorGetOptions(mon))) {
|
|
||||||
if (!(cmd = qemuMonitorJSONMakeCommand("query-command-line-options",
|
|
||||||
NULL)))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
|
|
||||||
ret = 0;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (virJSONValueObjectRemoveKey(reply, "return", &array) <= 0) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("query-command-line-options reply was missing "
|
|
||||||
"return data"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!virJSONValueIsArray(array)) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("Malformed query-command-line-options array"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
qemuMonitorSetOptions(mon, array);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < virJSONValueArraySize(array); i++) {
|
|
||||||
virJSONValuePtr child = virJSONValueArrayGet(array, i);
|
|
||||||
const char *tmp;
|
|
||||||
|
|
||||||
if (!(tmp = virJSONValueObjectGetString(child, "option"))) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("query-command-line-options reply data was "
|
|
||||||
"missing 'option'"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
if (STREQ(tmp, option)) {
|
|
||||||
data = virJSONValueObjectGet(child, "parameters");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!data) {
|
|
||||||
/* Option not found; return 0 parameters rather than an error. */
|
|
||||||
ret = 0;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (found)
|
|
||||||
*found = true;
|
|
||||||
|
|
||||||
if (!virJSONValueIsArray(data)) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("Malformed query-command-line-options parameters array"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
n = virJSONValueArraySize(data);
|
|
||||||
|
|
||||||
/* null-terminated list */
|
|
||||||
paramlist = g_new0(char *, n + 1);
|
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
virJSONValuePtr child = virJSONValueArrayGet(data, i);
|
|
||||||
const char *tmp;
|
|
||||||
|
|
||||||
if (!(tmp = virJSONValueObjectGetString(child, "name"))) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("query-command-line-options parameter data was "
|
|
||||||
"missing 'name'"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
paramlist[i] = g_strdup(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = n;
|
|
||||||
*params = paramlist;
|
|
||||||
paramlist = NULL;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
/* If we failed before getting the JSON array of options, we (try)
|
|
||||||
* to cache an empty array to speed up the next failure. */
|
|
||||||
if (!qemuMonitorGetOptions(mon))
|
|
||||||
qemuMonitorSetOptions(mon, virJSONValueNewArray());
|
|
||||||
|
|
||||||
g_strfreev(paramlist);
|
|
||||||
virJSONValueFree(cmd);
|
|
||||||
virJSONValueFree(reply);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int qemuMonitorJSONGetKVMState(qemuMonitorPtr mon,
|
int qemuMonitorJSONGetKVMState(qemuMonitorPtr mon,
|
||||||
bool *enabled,
|
bool *enabled,
|
||||||
bool *present)
|
bool *present)
|
||||||
|
|
|
@ -425,11 +425,6 @@ int qemuMonitorJSONGetCommands(qemuMonitorPtr mon,
|
||||||
int qemuMonitorJSONGetEvents(qemuMonitorPtr mon,
|
int qemuMonitorJSONGetEvents(qemuMonitorPtr mon,
|
||||||
char ***events)
|
char ***events)
|
||||||
ATTRIBUTE_NONNULL(2);
|
ATTRIBUTE_NONNULL(2);
|
||||||
int qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
|
||||||
const char *option,
|
|
||||||
char ***params,
|
|
||||||
bool *found)
|
|
||||||
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
|
||||||
GHashTable *qemuMonitorJSONGetCommandLineOptions(qemuMonitorPtr mon);
|
GHashTable *qemuMonitorJSONGetCommandLineOptions(qemuMonitorPtr mon);
|
||||||
|
|
||||||
int qemuMonitorJSONGetKVMState(qemuMonitorPtr mon,
|
int qemuMonitorJSONGetKVMState(qemuMonitorPtr mon,
|
||||||
|
|
|
@ -616,122 +616,6 @@ testQemuMonitorJSONGetTPMModels(const void *opaque)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
testQemuMonitorJSONGetCommandLineOptionParameters(const void *opaque)
|
|
||||||
{
|
|
||||||
const testGenericData *data = opaque;
|
|
||||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
|
||||||
int ret = -1;
|
|
||||||
char **params = NULL;
|
|
||||||
int nparams = 0;
|
|
||||||
bool found = false;
|
|
||||||
g_autoptr(qemuMonitorTest) test = NULL;
|
|
||||||
|
|
||||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (qemuMonitorTestAddItem(test, "query-command-line-options",
|
|
||||||
"{ "
|
|
||||||
" \"return\": [ "
|
|
||||||
" {\"parameters\": [], \"option\": \"acpi\" },"
|
|
||||||
" {\"parameters\": ["
|
|
||||||
" {\"name\": \"romfile\", "
|
|
||||||
" \"type\": \"string\"}, "
|
|
||||||
" {\"name\": \"bootindex\", "
|
|
||||||
" \"type\": \"number\"}], "
|
|
||||||
" \"option\": \"option-rom\"}"
|
|
||||||
" ]"
|
|
||||||
"}") < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
/* present with params */
|
|
||||||
if ((nparams = qemuMonitorGetCommandLineOptionParameters(qemuMonitorTestGetMonitor(test),
|
|
||||||
"option-rom",
|
|
||||||
¶ms,
|
|
||||||
NULL)) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (nparams != 2) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
"nparams was %d, expected 2", nparams);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define CHECK(i, wantname) \
|
|
||||||
do { \
|
|
||||||
if (STRNEQ(params[i], (wantname))) { \
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
|
||||||
"name was %s, expected %s", \
|
|
||||||
params[i], (wantname)); \
|
|
||||||
goto cleanup; \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
CHECK(0, "romfile");
|
|
||||||
CHECK(1, "bootindex");
|
|
||||||
|
|
||||||
#undef CHECK
|
|
||||||
|
|
||||||
g_strfreev(params);
|
|
||||||
params = NULL;
|
|
||||||
|
|
||||||
/* present but empty */
|
|
||||||
if ((nparams = qemuMonitorGetCommandLineOptionParameters(qemuMonitorTestGetMonitor(test),
|
|
||||||
"acpi",
|
|
||||||
¶ms,
|
|
||||||
&found)) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (nparams != 0) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
"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");
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_strfreev(params);
|
|
||||||
params = NULL;
|
|
||||||
|
|
||||||
/* no such option */
|
|
||||||
if ((nparams = qemuMonitorGetCommandLineOptionParameters(qemuMonitorTestGetMonitor(test),
|
|
||||||
"foobar",
|
|
||||||
¶ms,
|
|
||||||
&found)) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (nparams != 0) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
"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");
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
g_strfreev(params);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct qemuMonitorJSONTestAttachChardevData {
|
struct qemuMonitorJSONTestAttachChardevData {
|
||||||
qemuMonitorTestPtr test;
|
qemuMonitorTestPtr test;
|
||||||
virDomainChrSourceDefPtr chr;
|
virDomainChrSourceDefPtr chr;
|
||||||
|
@ -3256,7 +3140,6 @@ mymain(void)
|
||||||
DO_TEST(GetCPUDefinitions);
|
DO_TEST(GetCPUDefinitions);
|
||||||
DO_TEST(GetCommands);
|
DO_TEST(GetCommands);
|
||||||
DO_TEST(GetTPMModels);
|
DO_TEST(GetTPMModels);
|
||||||
DO_TEST(GetCommandLineOptionParameters);
|
|
||||||
if (qemuMonitorJSONTestAttachChardev(driver.xmlopt, qapiData.schema) < 0)
|
if (qemuMonitorJSONTestAttachChardev(driver.xmlopt, qapiData.schema) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
DO_TEST(DetachChardev);
|
DO_TEST(DetachChardev);
|
||||||
|
|
Loading…
Reference in New Issue