
On Thu, Jul 14, 2016 at 16:35:39 +0200, Viktor Mihajlovski wrote:
New monitor function qemuMonitorGetCPUState added to retrieve the halted state of VCPUs via the query-cpus command.
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com> Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com> --- src/qemu/qemu_monitor.c | 22 ++++++++++++++++++ src/qemu/qemu_monitor.h | 2 ++ src/qemu/qemu_monitor_json.c | 52 ++++++++++++++++++++++++++++++++++++++---- src/qemu/qemu_monitor_json.h | 2 ++ src/qemu/qemu_monitor_text.c | 54 +++++++++++++++++++++++++++++++++++--------- src/qemu/qemu_monitor_text.h | 2 ++ 6 files changed, 119 insertions(+), 15 deletions(-)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 098e654..0fdee29 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1667,6 +1667,28 @@ qemuMonitorGetCPUInfo(qemuMonitorPtr mon, }
+/** + * qemuMonitorGetCPUState: + * @mon: monitor + * @halted: returned array of boolean containing the vCPUs halted state + * + * Detects whether vCPUs are halted. Returns count of detected vCPUs on success, + * 0 if qemu didn't report vcpus (does not report libvirt error), + * -1 on error (reports libvirt error). + */ +int +qemuMonitorGetCPUState(qemuMonitorPtr mon, + bool **halted)
Extraction of the data is cheap compared to calling the monitor. Also this adds a lot of duplicated code. I've merged this to the code returnign the thread ids and dropped the duplicate monitor helpers. I've kept the extraction code though. Peter