mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
qemu: Pin the emulator when only cpuset is specified
According to our recent changes (clarifications), we should be pinning qemu's emulator processes using the <vcpu> 'cpuset' attribute in case there is no <emulatorpin> specified. This however doesn't work entirely as expected and this patch should resolve all the remaining issues.
This commit is contained in:
parent
837993d845
commit
ba63d8f7d8
@ -501,7 +501,7 @@ int qemuSetupCgroupVcpuPin(virCgroupPtr cgroup,
|
|||||||
|
|
||||||
for (i = 0; i < nvcpupin; i++) {
|
for (i = 0; i < nvcpupin; i++) {
|
||||||
if (vcpuid == vcpupin[i]->vcpuid) {
|
if (vcpuid == vcpupin[i]->vcpuid) {
|
||||||
return qemuSetupCgroupEmulatorPin(cgroup, vcpupin[i]);
|
return qemuSetupCgroupEmulatorPin(cgroup, vcpupin[i]->cpumask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,12 +509,12 @@ int qemuSetupCgroupVcpuPin(virCgroupPtr cgroup,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int qemuSetupCgroupEmulatorPin(virCgroupPtr cgroup,
|
int qemuSetupCgroupEmulatorPin(virCgroupPtr cgroup,
|
||||||
virDomainVcpuPinDefPtr vcpupin)
|
virBitmapPtr cpumask)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
char *new_cpus = NULL;
|
char *new_cpus = NULL;
|
||||||
|
|
||||||
new_cpus = virBitmapFormat(vcpupin->cpumask);
|
new_cpus = virBitmapFormat(cpumask);
|
||||||
if (!new_cpus) {
|
if (!new_cpus) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("failed to convert cpu mask"));
|
_("failed to convert cpu mask"));
|
||||||
@ -643,6 +643,7 @@ cleanup:
|
|||||||
int qemuSetupCgroupForEmulator(struct qemud_driver *driver,
|
int qemuSetupCgroupForEmulator(struct qemud_driver *driver,
|
||||||
virDomainObjPtr vm)
|
virDomainObjPtr vm)
|
||||||
{
|
{
|
||||||
|
virBitmapPtr cpumask = NULL;
|
||||||
virCgroupPtr cgroup = NULL;
|
virCgroupPtr cgroup = NULL;
|
||||||
virCgroupPtr cgroup_emulator = NULL;
|
virCgroupPtr cgroup_emulator = NULL;
|
||||||
virDomainDefPtr def = vm->def;
|
virDomainDefPtr def = vm->def;
|
||||||
@ -690,12 +691,18 @@ int qemuSetupCgroupForEmulator(struct qemud_driver *driver,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->cputune.emulatorpin &&
|
if (def->cputune.emulatorpin)
|
||||||
qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPUSET)) {
|
cpumask = def->cputune.emulatorpin->cpumask;
|
||||||
rc = qemuSetupCgroupEmulatorPin(cgroup_emulator,
|
else if (def->cpumask)
|
||||||
def->cputune.emulatorpin);
|
cpumask = def->cpumask;
|
||||||
if (rc < 0)
|
|
||||||
goto cleanup;
|
if (cpumask) {
|
||||||
|
if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPUSET)) {
|
||||||
|
rc = qemuSetupCgroupEmulatorPin(cgroup_emulator, cpumask);
|
||||||
|
if (rc < 0)
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
cpumask = NULL; /* sanity */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (period || quota) {
|
if (period || quota) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* qemu_cgroup.h: QEMU cgroup management
|
* qemu_cgroup.h: QEMU cgroup management
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2007, 2009-2011 Red Hat, Inc.
|
* Copyright (C) 2006-2007, 2009-2012 Red Hat, Inc.
|
||||||
* Copyright (C) 2006 Daniel P. Berrange
|
* Copyright (C) 2006 Daniel P. Berrange
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@ -57,7 +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 qemuSetupCgroupEmulatorPin(virCgroupPtr cgroup, virBitmapPtr cpumask);
|
||||||
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);
|
||||||
|
@ -4245,7 +4245,8 @@ qemudDomainPinEmulator(virDomainPtr dom,
|
|||||||
if (virCgroupForDomain(driver->cgroup, vm->def->name,
|
if (virCgroupForDomain(driver->cgroup, vm->def->name,
|
||||||
&cgroup_dom, 0) == 0) {
|
&cgroup_dom, 0) == 0) {
|
||||||
if (virCgroupForEmulator(cgroup_dom, &cgroup_emulator, 0) == 0) {
|
if (virCgroupForEmulator(cgroup_dom, &cgroup_emulator, 0) == 0) {
|
||||||
if (qemuSetupCgroupEmulatorPin(cgroup_emulator, newVcpuPin[0]) < 0) {
|
if (qemuSetupCgroupEmulatorPin(cgroup_emulator,
|
||||||
|
newVcpuPin[0]->cpumask) < 0) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("failed to set cpuset.cpus in cgroup"
|
_("failed to set cpuset.cpus in cgroup"
|
||||||
" for emulator threads"));
|
" for emulator threads"));
|
||||||
|
@ -2024,11 +2024,12 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set CPU affinities for emulator threads if emulatorpin xml provided. */
|
/* Set CPU affinities for emulator threads. */
|
||||||
static int
|
static int
|
||||||
qemuProcessSetEmulatorAffinites(virConnectPtr conn,
|
qemuProcessSetEmulatorAffinites(virConnectPtr conn,
|
||||||
virDomainObjPtr vm)
|
virDomainObjPtr vm)
|
||||||
{
|
{
|
||||||
|
virBitmapPtr cpumask;
|
||||||
virDomainDefPtr def = vm->def;
|
virDomainDefPtr def = vm->def;
|
||||||
virNodeInfo nodeinfo;
|
virNodeInfo nodeinfo;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -2036,15 +2037,14 @@ qemuProcessSetEmulatorAffinites(virConnectPtr conn,
|
|||||||
if (virNodeGetInfo(conn, &nodeinfo) != 0)
|
if (virNodeGetInfo(conn, &nodeinfo) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!def->cputune.emulatorpin)
|
if (def->cputune.emulatorpin)
|
||||||
return 0;
|
cpumask = def->cputune.emulatorpin->cpumask;
|
||||||
|
else if (def->cpumask)
|
||||||
if (virProcessInfoSetAffinity(vm->pid,
|
cpumask = def->cpumask;
|
||||||
def->cputune.emulatorpin->cpumask) < 0) {
|
else
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
ret = 0;
|
ret = virProcessInfoSetAffinity(vm->pid, cpumask);
|
||||||
cleanup:
|
cleanup:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user