mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-26 07:36:19 +00:00
qemu: Add support for resctrl
We've been building up to this. This adds support for cputune/cachetune settings for domains in the QEMU driver. The addition into qemuProcessSetupVcpu() automatically adds support for hotplug. For hot-unplug we need to remove the allocation only if all the vCPUs were unplugged. But since the threads are left running, we can't really do much about it now. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1289368 Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
ae885bb520
commit
9a2fc2db8f
@ -2507,6 +2507,32 @@ qemuProcessSetupEmulator(virDomainObjPtr vm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuProcessResctrlCreate(virQEMUDriverPtr driver,
|
||||||
|
virDomainObjPtr vm)
|
||||||
|
{
|
||||||
|
int ret = -1;
|
||||||
|
size_t i = 0;
|
||||||
|
virCapsPtr caps = virQEMUDriverGetCapabilities(driver, false);
|
||||||
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
|
|
||||||
|
if (!caps)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for (i = 0; i < vm->def->ncachetunes; i++) {
|
||||||
|
if (virResctrlAllocCreate(caps->host.resctrl,
|
||||||
|
vm->def->cachetunes[i]->alloc,
|
||||||
|
priv->machineName) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
cleanup:
|
||||||
|
virObjectUnref(caps);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuProcessInitPasswords(virConnectPtr conn,
|
qemuProcessInitPasswords(virConnectPtr conn,
|
||||||
virQEMUDriverPtr driver,
|
virQEMUDriverPtr driver,
|
||||||
@ -5018,12 +5044,26 @@ qemuProcessSetupVcpu(virDomainObjPtr vm,
|
|||||||
{
|
{
|
||||||
pid_t vcpupid = qemuDomainGetVcpuPid(vm, vcpuid);
|
pid_t vcpupid = qemuDomainGetVcpuPid(vm, vcpuid);
|
||||||
virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(vm->def, vcpuid);
|
virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(vm->def, vcpuid);
|
||||||
|
size_t i = 0;
|
||||||
|
|
||||||
return qemuProcessSetupPid(vm, vcpupid, VIR_CGROUP_THREAD_VCPU,
|
if (qemuProcessSetupPid(vm, vcpupid, VIR_CGROUP_THREAD_VCPU,
|
||||||
vcpuid, vcpu->cpumask,
|
vcpuid, vcpu->cpumask,
|
||||||
vm->def->cputune.period,
|
vm->def->cputune.period,
|
||||||
vm->def->cputune.quota,
|
vm->def->cputune.quota,
|
||||||
&vcpu->sched);
|
&vcpu->sched) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for (i = 0; i < vm->def->ncachetunes; i++) {
|
||||||
|
virDomainCachetuneDefPtr ct = vm->def->cachetunes[i];
|
||||||
|
|
||||||
|
if (virBitmapIsBitSet(ct->vcpus, vcpuid)) {
|
||||||
|
if (virResctrlAllocAddPID(ct->alloc, vcpupid) < 0)
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -5896,6 +5936,10 @@ qemuProcessLaunch(virConnectPtr conn,
|
|||||||
if (qemuProcessSetupEmulator(vm) < 0)
|
if (qemuProcessSetupEmulator(vm) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
VIR_DEBUG("Setting up resctrlfs");
|
||||||
|
if (qemuProcessResctrlCreate(driver, vm) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
VIR_DEBUG("Setting domain security labels");
|
VIR_DEBUG("Setting domain security labels");
|
||||||
if (qemuSecuritySetAllLabel(driver,
|
if (qemuSecuritySetAllLabel(driver,
|
||||||
vm,
|
vm,
|
||||||
@ -6544,6 +6588,12 @@ void qemuProcessStop(virQEMUDriverPtr driver,
|
|||||||
vm->def->name);
|
vm->def->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove resctrl allocation after cgroups are cleaned up which makes it
|
||||||
|
* kind of safer (although removing the allocation should work even with
|
||||||
|
* pids in tasks file */
|
||||||
|
for (i = 0; i < vm->def->ncachetunes; i++)
|
||||||
|
virResctrlAllocRemove(vm->def->cachetunes[i]->alloc);
|
||||||
|
|
||||||
qemuProcessRemoveDomainStatus(driver, vm);
|
qemuProcessRemoveDomainStatus(driver, vm);
|
||||||
|
|
||||||
/* Remove VNC and Spice ports from port reservation bitmap, but only if
|
/* Remove VNC and Spice ports from port reservation bitmap, but only if
|
||||||
|
Loading…
Reference in New Issue
Block a user