mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-26 22:45:17 +00:00
qemu: Add domain support for VCPU halted state
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@linux.vnet.ibm.com> Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> Reviewed-by: Hao QingFeng <haoqf@linux.vnet.ibm.com> Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
This commit is contained in:
parent
cc5e695bde
commit
08f22976b1
@ -6086,6 +6086,72 @@ qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
|
|||||||
return ret;
|
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 0 on success and -1 on error
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
qemuDomainRefreshVcpuHalted(virQEMUDriverPtr driver,
|
||||||
|
virDomainObjPtr vm,
|
||||||
|
int asyncJob)
|
||||||
|
{
|
||||||
|
virDomainVcpuDefPtr vcpu;
|
||||||
|
qemuMonitorCPUInfoPtr info = NULL;
|
||||||
|
size_t maxvcpus = virDomainDefGetVcpusMax(vm->def);
|
||||||
|
size_t i;
|
||||||
|
bool hotplug;
|
||||||
|
int rc;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
/* Not supported currently for TCG, see qemuDomainRefreshVcpuInfo */
|
||||||
|
if (vm->def->virtType == VIR_DOMAIN_VIRT_QEMU)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
hotplug = qemuDomainSupportsNewVcpuHotplug(vm);
|
||||||
|
|
||||||
|
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
rc = qemuMonitorGetCPUInfo(qemuDomainGetMonitor(vm), &info, maxvcpus, hotplug);
|
||||||
|
|
||||||
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (rc < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
for (i = 0; i < maxvcpus; i++) {
|
||||||
|
vcpu = virDomainDefGetVcpu(vm->def, i);
|
||||||
|
QEMU_DOMAIN_VCPU_PRIVATE(vcpu)->halted = info[i].halted;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
qemuMonitorCPUInfoFree(info, maxvcpus);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
qemuDomainSupportsNicdev(virDomainDefPtr def,
|
qemuDomainSupportsNicdev(virDomainDefPtr def,
|
||||||
|
@ -320,6 +320,7 @@ struct _qemuDomainVcpuPrivate {
|
|||||||
pid_t tid; /* vcpu thread id */
|
pid_t tid; /* vcpu thread id */
|
||||||
int enable_id; /* order in which the vcpus were enabled in qemu */
|
int enable_id; /* order in which the vcpus were enabled in qemu */
|
||||||
char *alias;
|
char *alias;
|
||||||
|
bool halted;
|
||||||
|
|
||||||
/* information for hotpluggable cpus */
|
/* information for hotpluggable cpus */
|
||||||
char *type;
|
char *type;
|
||||||
@ -679,6 +680,10 @@ int qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
|
|||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
int asyncJob,
|
int asyncJob,
|
||||||
bool state);
|
bool state);
|
||||||
|
bool qemuDomainGetVcpuHalted(virDomainObjPtr vm, unsigned int vcpu);
|
||||||
|
int qemuDomainRefreshVcpuHalted(virQEMUDriverPtr driver,
|
||||||
|
virDomainObjPtr vm,
|
||||||
|
int asyncJob);
|
||||||
|
|
||||||
bool qemuDomainSupportsNicdev(virDomainDefPtr def,
|
bool qemuDomainSupportsNicdev(virDomainDefPtr def,
|
||||||
virDomainNetDefPtr net);
|
virDomainNetDefPtr net);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user