[PATCH 28/38] qemu: monitor: Remove qemuMonitorGetEvents

Peter Krempa pkrempa at redhat.com
Mon Apr 19 12:35:32 UTC 2021


Modern code uses QMP schema to query for supported event types.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
Reviewed-by: Pavel Hrdina <phrdina at redhat.com>
Reviewed-by: Neal Gompa <ngompa13 at gmail.com>
---
 src/qemu/qemu_monitor.c      | 12 --------
 src/qemu/qemu_monitor.h      |  2 --
 src/qemu/qemu_monitor_json.c | 57 ------------------------------------
 src/qemu/qemu_monitor_json.h |  3 --
 4 files changed, 74 deletions(-)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index f3f14c46b6..f28023e957 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3830,18 +3830,6 @@ qemuMonitorGetCommands(qemuMonitor *mon,
 }


-int
-qemuMonitorGetEvents(qemuMonitor *mon,
-                     char ***events)
-{
-    VIR_DEBUG("events=%p", events);
-
-    QEMU_CHECK_MONITOR(mon);
-
-    return qemuMonitorJSONGetEvents(mon, events);
-}
-
-
 GHashTable *
 qemuMonitorGetCommandLineOptions(qemuMonitor *mon)
 {
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 230d00a894..a39e8e6e82 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1244,8 +1244,6 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig);

 int qemuMonitorGetCommands(qemuMonitor *mon,
                            char ***commands);
-int qemuMonitorGetEvents(qemuMonitor *mon,
-                         char ***events);
 GHashTable *qemuMonitorGetCommandLineOptions(qemuMonitor *mon);

 int qemuMonitorGetKVMState(qemuMonitor *mon,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 652034472a..534ab75c2c 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6274,63 +6274,6 @@ int qemuMonitorJSONGetCommands(qemuMonitor *mon,
 }


-int qemuMonitorJSONGetEvents(qemuMonitor *mon,
-                             char ***events)
-{
-    int ret = -1;
-    virJSONValue *cmd;
-    virJSONValue *reply = NULL;
-    virJSONValue *data;
-    char **eventlist = NULL;
-    size_t n = 0;
-    size_t i;
-
-    *events = NULL;
-
-    if (!(cmd = qemuMonitorJSONMakeCommand("query-events", NULL)))
-        return -1;
-
-    if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
-
-    if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
-        ret = 0;
-        goto cleanup;
-    }
-
-    if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
-        goto cleanup;
-
-    data = virJSONValueObjectGetArray(reply, "return");
-    n = virJSONValueArraySize(data);
-
-    /* null-terminated list */
-    eventlist = g_new0(char *, n + 1);
-
-    for (i = 0; i < n; i++) {
-        virJSONValue *child = virJSONValueArrayGet(data, i);
-        const char *tmp;
-
-        if (!(tmp = virJSONValueObjectGetString(child, "name"))) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("query-events reply data was missing 'name'"));
-            goto cleanup;
-        }
-
-        eventlist[i] = g_strdup(tmp);
-    }
-
-    ret = n;
-    *events = g_steal_pointer(&eventlist);
-
- cleanup:
-    g_strfreev(eventlist);
-    virJSONValueFree(cmd);
-    virJSONValueFree(reply);
-    return ret;
-}
-
-
 static int
 qemuMonitorJSONGetCommandLineOptionsWorker(size_t pos G_GNUC_UNUSED,
                                            virJSONValue *item,
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 0846325a81..97b8d2a991 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -420,9 +420,6 @@ int qemuMonitorJSONGetCPUModelComparison(qemuMonitor *mon,
 int qemuMonitorJSONGetCommands(qemuMonitor *mon,
                                char ***commands)
     ATTRIBUTE_NONNULL(2);
-int qemuMonitorJSONGetEvents(qemuMonitor *mon,
-                             char ***events)
-    ATTRIBUTE_NONNULL(2);
 GHashTable *qemuMonitorJSONGetCommandLineOptions(qemuMonitor *mon);

 int qemuMonitorJSONGetKVMState(qemuMonitor *mon,
-- 
2.30.2




More information about the libvir-list mailing list