From d8b6801095eaccee876995275a2533fa9522952e Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 14 Jul 2023 15:16:32 +0200 Subject: [PATCH] qemu: capabilities: Probe presence of commands from QMP schema instead of 'query-commands' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the probing code to extract the data from the QMP schema rather than invoking 'query-commands'. This patch doesn't yet remove the actual invocation of 'query-commands', just moves the actual probing. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_capabilities.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 5da49e48ac..c3ebece144 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2602,7 +2602,7 @@ virQEMUCapsGetSGXCapabilities(virQEMUCaps *qemuCaps) static int -virQEMUCapsProbeQMPCommands(virQEMUCaps *qemuCaps, +virQEMUCapsProbeQMPCommands(virQEMUCaps *qemuCaps G_GNUC_UNUSED, qemuMonitor *mon) { g_auto(GStrv) commands = NULL; @@ -2610,11 +2610,6 @@ virQEMUCapsProbeQMPCommands(virQEMUCaps *qemuCaps, if (qemuMonitorGetCommands(mon, &commands) < 0) return -1; - virQEMUCapsProcessStringFlags(qemuCaps, - G_N_ELEMENTS(virQEMUCapsCommands), - virQEMUCapsCommands, - commands); - return 0; } @@ -5520,7 +5515,6 @@ static int virQEMUCapsProbeQMPSchemaCapabilities(virQEMUCaps *qemuCaps, qemuMonitor *mon) { - struct virQEMUCapsStringFlags *entry; virJSONValue *schemareply; g_autoptr(GHashTable) schema = NULL; size_t i; @@ -5533,12 +5527,19 @@ virQEMUCapsProbeQMPSchemaCapabilities(virQEMUCaps *qemuCaps, schemareply = NULL; for (i = 0; i < G_N_ELEMENTS(virQEMUCapsQMPSchemaQueries); i++) { - entry = virQEMUCapsQMPSchemaQueries + i; + struct virQEMUCapsStringFlags *entry = virQEMUCapsQMPSchemaQueries + i; if (virQEMUQAPISchemaPathExists(entry->value, schema)) virQEMUCapsSet(qemuCaps, entry->flag); } + for (i = 0; i < G_N_ELEMENTS(virQEMUCapsCommands); i++) { + struct virQEMUCapsStringFlags *cmd = virQEMUCapsCommands + i; + + if (virQEMUQAPISchemaPathExists(cmd->value, schema)) + virQEMUCapsSet(qemuCaps, cmd->flag); + } + return 0; }