Remove the function along with helpers for caching the reply and tests.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_monitor.c | 35 ----------
src/qemu/qemu_monitor.h | 8 ---
src/qemu/qemu_monitor_json.c | 120 -----------------------------------
src/qemu/qemu_monitor_json.h | 5 --
tests/qemumonitorjsontest.c | 117 ----------------------------------
5 files changed, 285 deletions(-)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index a60d04f78a..c333fc1364 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -101,9 +101,6 @@ struct _qemuMonitor {
bool waitGreeting;
- /* cache of query-command-line-options results */
- virJSONValuePtr options;
-
/* If found, path to the virtio memballoon driver */
char *balloonpath;
bool ballooninit;
@@ -240,7 +237,6 @@ qemuMonitorDispose(void *obj)
virResetError(&mon->lastError);
virCondDestroy(&mon->notify);
VIR_FREE(mon->buffer);
- virJSONValueFree(mon->options);
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
* 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 *
qemuMonitorGetCommandLineOptions(qemuMonitorPtr mon)
{
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 6b2e435f70..3dcceffef8 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -444,10 +444,6 @@ int qemuMonitorSetLink(qemuMonitorPtr mon,
char *qemuMonitorNextCommandID(qemuMonitorPtr mon);
int qemuMonitorSend(qemuMonitorPtr mon,
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,
virDomainVideoDefPtr video,
const char *videoName)
@@ -1284,10 +1280,6 @@ int qemuMonitorGetCommands(qemuMonitorPtr mon,
char ***commands);
int qemuMonitorGetEvents(qemuMonitorPtr mon,
char ***events);
-int qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon,
- const char *option,
- char ***params,
- bool *found);
GHashTable *qemuMonitorGetCommandLineOptions(qemuMonitorPtr mon);
int qemuMonitorGetKVMState(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 44d0152812..5990163519 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6450,126 +6450,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,
bool *enabled,
bool *present)
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 53445b97bb..da988f0d41 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -425,11 +425,6 @@ int qemuMonitorJSONGetCommands(qemuMonitorPtr mon,
int qemuMonitorJSONGetEvents(qemuMonitorPtr mon,
char ***events)
ATTRIBUTE_NONNULL(2);
-int qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
- const char *option,
- char ***params,
- bool *found)
- ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
GHashTable *qemuMonitorJSONGetCommandLineOptions(qemuMonitorPtr mon);
int qemuMonitorJSONGetKVMState(qemuMonitorPtr mon,
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 25ebf06eb0..d22a92d3e1 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -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 {
qemuMonitorTestPtr test;
virDomainChrSourceDefPtr chr;
@@ -3256,7 +3140,6 @@ mymain(void)
DO_TEST(GetCPUDefinitions);
DO_TEST(GetCommands);
DO_TEST(GetTPMModels);
- DO_TEST(GetCommandLineOptionParameters);
if (qemuMonitorJSONTestAttachChardev(driver.xmlopt, qapiData.schema) < 0)
ret = -1;
DO_TEST(DetachChardev);
--
2.28.0