1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-21 10:50:24 +03:00

qemu: add support for offline vcpupin

Allow pinning for inactive vcpus. The pinning mask will be automatically
applied as we would apply the default mask in case of a cpu hotplug.

Setting the scheduler settings for a vcpu has the same semantics.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1306556
This commit is contained in:
Peter Krempa 2016-02-12 14:57:45 +01:00
parent acf521e121
commit 02ae21deb3
2 changed files with 24 additions and 41 deletions

View File

@ -1620,7 +1620,8 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainDefParserConfig virQEMUDriverDomainDefParserConfig = { virDomainDefParserConfig virQEMUDriverDomainDefParserConfig = {
.devicesPostParseCallback = qemuDomainDeviceDefPostParse, .devicesPostParseCallback = qemuDomainDeviceDefPostParse,
.domainPostParseCallback = qemuDomainDefPostParse, .domainPostParseCallback = qemuDomainDefPostParse,
.features = VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG, .features = VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG |
VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN
}; };

View File

@ -4760,9 +4760,6 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
VIR_CGROUP_THREAD_VCPU, vcpu) < 0) VIR_CGROUP_THREAD_VCPU, vcpu) < 0)
goto cleanup; goto cleanup;
virBitmapFree(vcpuinfo->cpumask);
vcpuinfo->cpumask = NULL;
ret = 0; ret = 0;
cleanup: cleanup:
@ -5022,38 +5019,21 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
priv = vm->privateData; priv = vm->privateData;
if (def) { if (def && !(vcpuinfolive = virDomainDefGetVcpu(def, vcpu))) {
if (!(vcpuinfolive = virDomainDefGetVcpu(def, vcpu))) {
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
_("vcpu %d is out of range of live cpu count %d"), _("vcpu %d is out of range of live cpu count %d"),
vcpu, virDomainDefGetVcpus(def)); vcpu, virDomainDefGetVcpus(def));
goto endjob; goto endjob;
} }
if (!vcpuinfolive->online) { if (persistentDef &&
virReportError(VIR_ERR_OPERATION_INVALID, !(vcpuinfopersist = virDomainDefGetVcpu(persistentDef, vcpu))) {
_("setting cpu pinning for inactive vcpu '%d' is not "
"supported"), vcpu);
goto endjob;
}
}
if (persistentDef) {
if (!(vcpuinfopersist = virDomainDefGetVcpu(persistentDef, vcpu))) {
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
_("vcpu %d is out of range of persistent cpu count %d"), _("vcpu %d is out of range of persistent cpu count %d"),
vcpu, virDomainDefGetVcpus(persistentDef)); vcpu, virDomainDefGetVcpus(persistentDef));
goto endjob; goto endjob;
} }
if (!vcpuinfopersist->online) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("setting cpu pinning for inactive vcpu '%d' is not "
"supported"), vcpu);
goto endjob;
}
}
if (!(pcpumap = virBitmapNewData(cpumap, maplen))) if (!(pcpumap = virBitmapNewData(cpumap, maplen)))
goto endjob; goto endjob;
@ -5074,6 +5054,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
goto endjob; goto endjob;
} }
if (vcpuinfolive->online) {
/* Configure the corresponding cpuset cgroup before set affinity. */ /* Configure the corresponding cpuset cgroup before set affinity. */
if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) { if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_VCPU, vcpu, if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_VCPU, vcpu,
@ -5085,6 +5066,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
if (virProcessSetAffinity(qemuDomainGetVcpuPid(vm, vcpu), pcpumap) < 0) if (virProcessSetAffinity(qemuDomainGetVcpuPid(vm, vcpu), pcpumap) < 0)
goto endjob; goto endjob;
}
virBitmapFree(vcpuinfolive->cpumask); virBitmapFree(vcpuinfolive->cpumask);
vcpuinfolive->cpumask = pcpumaplive; vcpuinfolive->cpumask = pcpumaplive;