mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: qemuDomainHotplugVcpus - separate out the add cgroup
Future IOThread setting patches would copy the code anyway, so create and generalize the add the vcpu to a cgroup into its own API. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
0456eda317
commit
0ed8e47a7e
@ -4635,9 +4635,44 @@ static void qemuProcessEventHandler(void *data, void *opaque)
|
|||||||
VIR_FREE(processEvent);
|
VIR_FREE(processEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
|
static virCgroupPtr
|
||||||
virDomainObjPtr vm,
|
qemuDomainAddCgroupForThread(virCgroupPtr cgroup,
|
||||||
unsigned int nvcpus)
|
virCgroupThreadName nameval,
|
||||||
|
int index,
|
||||||
|
char *mem_mask,
|
||||||
|
pid_t pid)
|
||||||
|
{
|
||||||
|
virCgroupPtr new_cgroup = NULL;
|
||||||
|
int rv = -1;
|
||||||
|
|
||||||
|
/* Create cgroup */
|
||||||
|
if (virCgroupNewThread(cgroup, nameval, index, true, &new_cgroup) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (mem_mask && virCgroupSetCpusetMems(new_cgroup, mem_mask) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
/* Add pid/thread to the cgroup */
|
||||||
|
rv = virCgroupAddTask(new_cgroup, pid);
|
||||||
|
if (rv < 0) {
|
||||||
|
virReportSystemError(-rv,
|
||||||
|
_("unable to add id %d task %d to cgroup"),
|
||||||
|
index, pid);
|
||||||
|
virCgroupRemove(new_cgroup);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new_cgroup;
|
||||||
|
|
||||||
|
error:
|
||||||
|
virCgroupFree(&new_cgroup);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
|
||||||
|
virDomainObjPtr vm,
|
||||||
|
unsigned int nvcpus)
|
||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -4726,26 +4761,13 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
|
|||||||
if (nvcpus > oldvcpus) {
|
if (nvcpus > oldvcpus) {
|
||||||
for (i = oldvcpus; i < nvcpus; i++) {
|
for (i = oldvcpus; i < nvcpus; i++) {
|
||||||
if (priv->cgroup) {
|
if (priv->cgroup) {
|
||||||
int rv = -1;
|
cgroup_vcpu =
|
||||||
/* Create cgroup for the onlined vcpu */
|
qemuDomainAddCgroupForThread(priv->cgroup,
|
||||||
if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_VCPU, i,
|
VIR_CGROUP_THREAD_VCPU,
|
||||||
true, &cgroup_vcpu) < 0)
|
i, mem_mask,
|
||||||
|
cpupids[i]);
|
||||||
|
if (!cgroup_vcpu)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (mem_mask &&
|
|
||||||
virCgroupSetCpusetMems(cgroup_vcpu, mem_mask) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
/* Add vcpu thread to the cgroup */
|
|
||||||
rv = virCgroupAddTask(cgroup_vcpu, cpupids[i]);
|
|
||||||
if (rv < 0) {
|
|
||||||
virReportSystemError(-rv,
|
|
||||||
_("unable to add vcpu %zu task %d to cgroup"),
|
|
||||||
i, cpupids[i]);
|
|
||||||
virCgroupRemove(cgroup_vcpu);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Inherit def->cpuset */
|
/* Inherit def->cpuset */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user