On Thu, Jul 14, 2016 at 16:35:41 +0200, Viktor Mihajlovski wrote: > Adding a field to the domain's private vcpu object to hold the halted > state information. > Adding two functions in support of the halted state: > - qemuDomainGetVcpuHalted: retrieve the halted state from a > private vcpu object > - qemuDomainRefreshVcpuHalted: obtain the per-vcpu halted states > via qemu monitor and store the results in the private vcpu objects > > Signed-off-by: Viktor Mihajlovski <mihajlov@xxxxxxxxxxxxxxxxxx> > Reviewed-by: Bjoern Walk <bwalk@xxxxxxxxxxxxxxxxxx> > Signed-off-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxxxxxxx> > --- > src/qemu/qemu_domain.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++ > src/qemu/qemu_domain.h | 4 +++ > 2 files changed, 86 insertions(+) > > diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c > index 286f096..945a75d 100644 > --- a/src/qemu/qemu_domain.c > +++ b/src/qemu/qemu_domain.c > @@ -5650,6 +5650,88 @@ qemuDomainDetectVcpuPids(virQEMUDriverPtr driver, > return ret; > } > > +/** > + * qemuDomainGetVcpuHalted: > + * @vm: domain object > + * @vcpu: cpu id > + * > + * Returns the vCPU halted state. > + */ > +bool > +qemuDomainGetVcpuHalted(virDomainObjPtr vm, > + unsigned int vcpuid) > +{ > + virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(vm->def, vcpuid); > + return QEMU_DOMAIN_VCPU_PRIVATE(vcpu)->halted; > +} > + > +/** > + * qemuDomainRefreshVcpuHalted: > + * @driver: qemu driver data > + * @vm: domain object > + * @asyncJob: current asynchronous job type > + * > + * Updates vCPU halted state in the private data of @vm. > + * > + * Returns number of detected vCPUs on success, -1 on error and reports > + * an appropriate error, -2 if the domain doesn't exist any more. > + */ > +int > +qemuDomainRefreshVcpuHalted(virQEMUDriverPtr driver, > + virDomainObjPtr vm, > + int asyncJob) > +{ > + virDomainVcpuDefPtr vcpu; > + size_t maxvcpus = virDomainDefGetVcpusMax(vm->def); > + bool *cpuhalted = NULL; > + int ncpuhalted; > + size_t i; > + int ret = -1; > + > + /* Not supported currently for TCG, see above > + */ > + if (vm->def->virtType == VIR_DOMAIN_VIRT_QEMU) > + return 0; > + > + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) > + return -1; > + ncpuhalted = qemuMonitorGetCPUState(qemuDomainGetMonitor(vm), &cpuhalted); > + if (qemuDomainObjExitMonitor(driver, vm) < 0) { > + ret = -2; > + goto cleanup; > + } > + > + /* Don't fail for older QEMUs > + */ > + if (ncpuhalted <= 0) { > + virResetLastError(); > + ret = 0; > + goto cleanup; > + } > + > + for (i = 0; i < maxvcpus; i++) { > + vcpu = virDomainDefGetVcpu(vm->def, i); > + > + if (i < ncpuhalted) > + QEMU_DOMAIN_VCPU_PRIVATE(vcpu)->halted = cpuhalted[i]; > + else > + QEMU_DOMAIN_VCPU_PRIVATE(vcpu)->halted = false; I've merged the 4 lines above to the function refreshing other VCPU (since I'll be adding a patch that will make it not refresh the pids all the time) and thus dropped the rest of this function. I've tweaked the commit message an I'll resend it with the rest of the patches soon. Peter -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list