On Thu, Jul 14, 2016 at 16:35:42 +0200, Viktor Mihajlovski wrote:
Refresh the VCPU halted states in API functions returning domain
VCPU state information to make sure it's current. This affects
qemuDomainGetVcpus and qemuDomainGetStatsVcpu
Signed-off-by: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy(a)linux.vnet.ibm.com>
---
src/qemu/qemu_driver.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
[..]
@@ -5283,6 +5288,13 @@ qemuDomainGetVcpus(virDomainPtr dom,
goto cleanup;
}
+ if (qemuDomainRefreshVcpuHalted(driver, vm, QEMU_ASYNC_JOB_NONE) < 0) {
APIs calling the monitor need to enter a job since monitor calls unlock
the domain. There wouldn't be anything guarding the API.
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s",
+ _("could not refresh CPU states"));
+ return -1;
This skips cleanup section where the VM object needs to be unlocked.
+ }
+
ret = qemuDomainHelperGetVcpus(vm, info, NULL, maxinfo, cpumaps, maplen);
cleanup:
@@ -18565,6 +18577,13 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr
driver ATTRIBUTE_UNUSED,
VIR_ALLOC_N(cpuwait, virDomainDefGetVcpus(dom->def)) < 0)
goto cleanup;
[1]
>
> + if (qemuDomainRefreshVcpuHalted(driver, dom, QEMU_ASYNC_JOB_NONE) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s",
+ _("could not refresh CPU states"));
+ return -1;
This would leak memory allocated just above this hunk.
+ }
+
I've fixed the problems mentioned above and tweaked the code to comply
with changes done to previous patches. I've also dropped the reviewed-by
tag since I'll be sending this for review again due to the changes
needed.
Peter