[libvirt] [PATCH v2 0/2] qemu: monitor: Use 'target' instead of 'arch' in reply of 'query-cpus-fast'

Peter Krempa (2): qemu: monitor: Remove qemuMonitorJSONExtractCPUArchInfo wrapper qemu: monitor: Use 'target' instead of 'arch' in reply of 'query-cpus-fast' src/qemu/qemu_monitor_json.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) -- 2.16.2

The wraper is quite pointless and also the 'arch' field may depend on whether query-cpus-fast is used. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_monitor_json.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 3e90279b71..fc5cec42dd 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1580,27 +1580,6 @@ qemuMonitorJSONExtractCPUS390Info(virJSONValuePtr jsoncpu, } -/** - * qemuMonitorJSONExtractCPUArchInfo: - * @jsoncpu: pointer to a single JSON cpu entry - * @cpu: pointer to a single cpu entry - * - * Extracts architecure specific virtual CPU data for a single - * CPU from the QAPI response using an architecture specific - * function. - * - */ -static void -qemuMonitorJSONExtractCPUArchInfo(virJSONValuePtr jsoncpu, - struct qemuMonitorQueryCpusEntry *cpu) -{ - const char *arch = virJSONValueObjectGetString(jsoncpu, "arch"); - - if (STREQ_NULLABLE(arch, "s390")) - qemuMonitorJSONExtractCPUS390Info(jsoncpu, cpu); -} - - /** * qemuMonitorJSONExtractCPUInfo: * @data: JSON response data @@ -1652,6 +1631,7 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr data, size_t *nentries, bool fast) { + const char *arch = NULL; struct qemuMonitorQueryCpusEntry *cpus = NULL; int ret = -1; size_t i; @@ -1679,10 +1659,12 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr data, * The return data of query-cpus-fast has different field names */ if (fast) { + arch = virJSONValueObjectGetString(entry, "arch"); ignore_value(virJSONValueObjectGetNumberInt(entry, "cpu-index", &cpuid)); ignore_value(virJSONValueObjectGetNumberInt(entry, "thread-id", &thread)); qom_path = virJSONValueObjectGetString(entry, "qom-path"); } else { + arch = virJSONValueObjectGetString(entry, "arch"); ignore_value(virJSONValueObjectGetNumberInt(entry, "CPU", &cpuid)); ignore_value(virJSONValueObjectGetNumberInt(entry, "thread_id", &thread)); ignore_value(virJSONValueObjectGetBoolean(entry, "halted", &halted)); @@ -1696,7 +1678,8 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr data, goto cleanup; /* process optional architecture-specific data */ - qemuMonitorJSONExtractCPUArchInfo(entry, cpus + i); + if (STREQ_NULLABLE(arch, "s390")) + qemuMonitorJSONExtractCPUS390Info(entry, cpus + i); } VIR_STEAL_PTR(*entries, cpus); -- 2.16.2

On Mon, Jul 09, 2018 at 02:17:07PM +0200, Peter Krempa wrote:
The wraper is quite pointless and also the 'arch' field may depend on whether query-cpus-fast is used.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_monitor_json.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

qemu changed the output field name for the architecture from 'arch' to 'target'. Note the change and fix the code so that the arch-specific extraction works. https://bugzilla.redhat.com/show_bug.cgi?id=1598829 Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_monitor_json.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index fc5cec42dd..f9fe9e35ba 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1624,6 +1624,9 @@ qemuMonitorJSONExtractCPUS390Info(virJSONValuePtr jsoncpu, * ...}, * {...} * ] + * + * Note that since QEMU 2.13.0 the "arch" output member of the + * "query-cpus-fast" command is replaced by "target". */ static int qemuMonitorJSONExtractCPUInfo(virJSONValuePtr data, @@ -1659,7 +1662,8 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr data, * The return data of query-cpus-fast has different field names */ if (fast) { - arch = virJSONValueObjectGetString(entry, "arch"); + if (!(arch = virJSONValueObjectGetString(entry, "target"))) + arch = virJSONValueObjectGetString(entry, "arch"); ignore_value(virJSONValueObjectGetNumberInt(entry, "cpu-index", &cpuid)); ignore_value(virJSONValueObjectGetNumberInt(entry, "thread-id", &thread)); qom_path = virJSONValueObjectGetString(entry, "qom-path"); -- 2.16.2

On Mon, Jul 09, 2018 at 02:17:08PM +0200, Peter Krempa wrote:
qemu changed the output field name for the architecture from 'arch' to 'target'. Note the change and fix the code so that the arch-specific extraction works.
https://bugzilla.redhat.com/show_bug.cgi?id=1598829
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_monitor_json.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
participants (2)
-
Daniel P. Berrangé
-
Peter Krempa