qemu: capabilities: Probe presence of commands from QMP schema instead of 'query-commands'

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 <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2023-07-14 15:16:32 +02:00
parent 7ca777cc09
commit d8b6801095

View File

@ -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;
}