mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
qemu: domain: Extract cpu-hotplug related data
Now that the monitor code gathers all the data we can extract it to relevant places either in the definition or the private data of a vcpu. As only thread id is broken for TCG guests we may extract the rest of the data and just skip assigning of the thread id. In case where qemu would allow cpu hotplug in TCG mode this will make it work eventually.
This commit is contained in:
parent
04fce1d496
commit
6b4a23ff6c
@ -854,8 +854,12 @@ qemuDomainVcpuPrivateNew(void)
|
||||
|
||||
|
||||
static void
|
||||
qemuDomainVcpuPrivateDispose(void *obj ATTRIBUTE_UNUSED)
|
||||
qemuDomainVcpuPrivateDispose(void *obj)
|
||||
{
|
||||
qemuDomainVcpuPrivatePtr priv = obj;
|
||||
|
||||
VIR_FREE(priv->type);
|
||||
VIR_FREE(priv->alias);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -5746,6 +5750,15 @@ qemuDomainValidateVcpuInfo(virDomainObjPtr vm)
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
qemuDomainSupportsNewVcpuHotplug(virDomainObjPtr vm)
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||
|
||||
return virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* qemuDomainRefreshVcpuInfo:
|
||||
* @driver: qemu driver data
|
||||
@ -5767,9 +5780,27 @@ qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
|
||||
qemuMonitorCPUInfoPtr info = NULL;
|
||||
size_t maxvcpus = virDomainDefGetVcpusMax(vm->def);
|
||||
size_t i;
|
||||
bool hotplug;
|
||||
int rc;
|
||||
int ret = -1;
|
||||
|
||||
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);
|
||||
vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu);
|
||||
|
||||
/*
|
||||
* Current QEMU *can* report info about host threads mapped
|
||||
* to vCPUs, but it is not in a manner we can correctly
|
||||
@ -5798,25 +5829,18 @@ qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
|
||||
* Just disable CPU pinning with TCG until someone wants
|
||||
* to try to do this hard work.
|
||||
*/
|
||||
if (vm->def->virtType == VIR_DOMAIN_VIRT_QEMU)
|
||||
return 0;
|
||||
|
||||
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
||||
return -1;
|
||||
|
||||
rc = qemuMonitorGetCPUInfo(qemuDomainGetMonitor(vm), &info, maxvcpus, false);
|
||||
|
||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (rc < 0)
|
||||
goto cleanup;
|
||||
|
||||
for (i = 0; i < maxvcpus; i++) {
|
||||
vcpu = virDomainDefGetVcpu(vm->def, i);
|
||||
vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu);
|
||||
|
||||
if (vm->def->virtType != VIR_DOMAIN_VIRT_QEMU)
|
||||
vcpupriv->tid = info[i].tid;
|
||||
|
||||
vcpupriv->socket_id = info[i].socket_id;
|
||||
vcpupriv->core_id = info[i].core_id;
|
||||
vcpupriv->thread_id = info[i].thread_id;
|
||||
vcpupriv->vcpus = info[i].vcpus;
|
||||
VIR_FREE(vcpupriv->type);
|
||||
VIR_STEAL_PTR(vcpupriv->type, info[i].type);
|
||||
VIR_FREE(vcpupriv->alias);
|
||||
VIR_STEAL_PTR(vcpupriv->alias, info[i].alias);
|
||||
vcpupriv->enable_id = info[i].id;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
@ -315,6 +315,15 @@ struct _qemuDomainVcpuPrivate {
|
||||
virObject parent;
|
||||
|
||||
pid_t tid; /* vcpu thread id */
|
||||
int enable_id; /* order in which the vcpus were enabled in qemu */
|
||||
char *alias;
|
||||
|
||||
/* information for hotpluggable cpus */
|
||||
char *type;
|
||||
int socket_id;
|
||||
int core_id;
|
||||
int thread_id;
|
||||
int vcpus;
|
||||
};
|
||||
|
||||
# define QEMU_DOMAIN_VCPU_PRIVATE(vcpu) \
|
||||
@ -645,6 +654,7 @@ int qemuDomainDefValidateMemoryHotplug(const virDomainDef *def,
|
||||
virQEMUCapsPtr qemuCaps,
|
||||
const virDomainMemoryDef *mem);
|
||||
|
||||
bool qemuDomainSupportsNewVcpuHotplug(virDomainObjPtr vm);
|
||||
bool qemuDomainHasVcpuPids(virDomainObjPtr vm);
|
||||
pid_t qemuDomainGetVcpuPid(virDomainObjPtr vm, unsigned int vcpuid);
|
||||
int qemuDomainValidateVcpuInfo(virDomainObjPtr vm);
|
||||
|
Loading…
x
Reference in New Issue
Block a user