mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-31 22:17:17 +00:00
qemu: synchronize emulatorpin info to cgroup
Introduce qemuSetupCgroupEmulatorPin() function to add emulator threads pin info to cpuset cgroup, the same as vcpupin. Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
This commit is contained in:
parent
19630db3e3
commit
a1249489ce
@ -496,29 +496,40 @@ int qemuSetupCgroupVcpuPin(virCgroupPtr cgroup,
|
|||||||
int nvcpupin,
|
int nvcpupin,
|
||||||
int vcpuid)
|
int vcpuid)
|
||||||
{
|
{
|
||||||
int i, rc = 0;
|
int i;
|
||||||
char *new_cpus = NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < nvcpupin; i++) {
|
for (i = 0; i < nvcpupin; i++) {
|
||||||
if (vcpuid == vcpupin[i]->vcpuid) {
|
if (vcpuid == vcpupin[i]->vcpuid) {
|
||||||
new_cpus = virDomainCpuSetFormat(vcpupin[i]->cpumask,
|
return qemuSetupCgroupEmulatorPin(cgroup, vcpupin[i]);
|
||||||
VIR_DOMAIN_CPUMASK_LEN);
|
|
||||||
if (!new_cpus) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("failed to convert cpu mask"));
|
|
||||||
rc = -1;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
rc = virCgroupSetCpusetCpus(cgroup, new_cpus);
|
|
||||||
if (rc != 0) {
|
|
||||||
virReportSystemError(-rc,
|
|
||||||
"%s",
|
|
||||||
_("Unable to set cpuset.cpus"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int qemuSetupCgroupEmulatorPin(virCgroupPtr cgroup,
|
||||||
|
virDomainVcpuPinDefPtr vcpupin)
|
||||||
|
{
|
||||||
|
int rc = 0;
|
||||||
|
char *new_cpus = NULL;
|
||||||
|
|
||||||
|
new_cpus = virDomainCpuSetFormat(vcpupin->cpumask,
|
||||||
|
VIR_DOMAIN_CPUMASK_LEN);
|
||||||
|
if (!new_cpus) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("failed to convert cpu mask"));
|
||||||
|
rc = -1;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = virCgroupSetCpusetCpus(cgroup, new_cpus);
|
||||||
|
if (rc < 0) {
|
||||||
|
virReportSystemError(-rc,
|
||||||
|
"%s",
|
||||||
|
_("Unable to set cpuset.cpus"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(new_cpus);
|
VIR_FREE(new_cpus);
|
||||||
return rc;
|
return rc;
|
||||||
@ -636,6 +647,7 @@ int qemuSetupCgroupForEmulator(struct qemud_driver *driver,
|
|||||||
{
|
{
|
||||||
virCgroupPtr cgroup = NULL;
|
virCgroupPtr cgroup = NULL;
|
||||||
virCgroupPtr cgroup_emulator = NULL;
|
virCgroupPtr cgroup_emulator = NULL;
|
||||||
|
virDomainDefPtr def = vm->def;
|
||||||
int rc, i;
|
int rc, i;
|
||||||
|
|
||||||
if (driver->cgroup == NULL)
|
if (driver->cgroup == NULL)
|
||||||
@ -672,6 +684,11 @@ int qemuSetupCgroupForEmulator(struct qemud_driver *driver,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (def->cputune.emulatorpin &&
|
||||||
|
qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPUSET) &&
|
||||||
|
qemuSetupCgroupEmulatorPin(cgroup_emulator, def->cputune.emulatorpin) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
virCgroupFree(&cgroup_emulator);
|
virCgroupFree(&cgroup_emulator);
|
||||||
virCgroupFree(&cgroup);
|
virCgroupFree(&cgroup);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -57,6 +57,7 @@ int qemuSetupCgroupVcpuPin(virCgroupPtr cgroup,
|
|||||||
virDomainVcpuPinDefPtr *vcpupin,
|
virDomainVcpuPinDefPtr *vcpupin,
|
||||||
int nvcpupin,
|
int nvcpupin,
|
||||||
int vcpuid);
|
int vcpuid);
|
||||||
|
int qemuSetupCgroupEmulatorPin(virCgroupPtr cgroup, virDomainVcpuPinDefPtr vcpupin);
|
||||||
int qemuSetupCgroupForVcpu(struct qemud_driver *driver, virDomainObjPtr vm);
|
int qemuSetupCgroupForVcpu(struct qemud_driver *driver, virDomainObjPtr vm);
|
||||||
int qemuSetupCgroupForEmulator(struct qemud_driver *driver,
|
int qemuSetupCgroupForEmulator(struct qemud_driver *driver,
|
||||||
virDomainObjPtr vm);
|
virDomainObjPtr vm);
|
||||||
|
Loading…
Reference in New Issue
Block a user