From: Peter Krempa Date: Thu, 18 May 2017 11:27:24 +0000 (+0200) Subject: qemu: monitor: Don't bother extracting vCPU halted state in text monitor X-Git-Tag: v3.4.0-rc1~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ff99e95771bb33531ea6733a823bc6a30158256;p=thirdparty%2Flibvirt.git qemu: monitor: Don't bother extracting vCPU halted state in text monitor The code causes the 'offset' variable to be overwritten (possibly with NULL if neither of the vCPUs is halted) which causes a crash since the variable is still used after that part. Additionally there's a bug, since strstr() would look up the '(halted)' string in the whole string rather than just the currently processed line the returned data is completely bogus. Rather than switching to single line parsing let's remove the code altogether since it has a commonly used JSON monitor alternative and the data itself is not very useful to report. The code was introduced in commit cc5e695bde Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1452106 --- diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 9c9eeea01d..66c94fbcd2 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -552,12 +552,6 @@ qemuMonitorTextQueryCPUs(qemuMonitorPtr mon, cpu.qemu_id = cpuid; cpu.tid = tid; - /* Extract halted indicator */ - if ((offset = strstr(line, "(halted)")) != NULL) - cpu.halted = true; - else - cpu.halted = false; - if (VIR_APPEND_ELEMENT_COPY(cpus, ncpus, cpu) < 0) { ret = -1; goto cleanup;