mirror of https://gitee.com/openkylin/libvirt.git
qemu: Add support for setting vCPU and I/O thread scheduler setting
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1178986 Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
8680ea9749
commit
104ba5966a
|
@ -4620,6 +4620,11 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
|
|||
}
|
||||
|
||||
virCgroupFree(&cgroup_vcpu);
|
||||
|
||||
if (qemuProcessSetSchedParams(i, cpupids[i],
|
||||
vm->def->cputune.nvcpusched,
|
||||
vm->def->cputune.vcpusched) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
for (i = oldvcpus - 1; i >= nvcpus; i--) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* qemu_process.c: QEMU process management
|
||||
*
|
||||
* Copyright (C) 2006-2014 Red Hat, Inc.
|
||||
* Copyright (C) 2006-2015 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -2574,6 +2574,57 @@ qemuProcessSetIOThreadsAffinity(virDomainObjPtr vm)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* Set Scheduler parameters for vCPU or I/O threads. */
|
||||
int
|
||||
qemuProcessSetSchedParams(int id,
|
||||
pid_t pid,
|
||||
size_t nsp,
|
||||
virDomainThreadSchedParamPtr sp)
|
||||
{
|
||||
bool val = false;
|
||||
size_t i = 0;
|
||||
virDomainThreadSchedParamPtr s = NULL;
|
||||
|
||||
for (i = 0; i < nsp; i++) {
|
||||
if (virBitmapGetBit(sp[i].ids, id, &val) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Cannot get bit from bitmap"));
|
||||
}
|
||||
if (val) {
|
||||
s = &sp[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!s)
|
||||
return 0;
|
||||
|
||||
return virProcessSetScheduler(pid, s->scheduler, s->priority);
|
||||
}
|
||||
|
||||
static int
|
||||
qemuProcessSetSchedulers(virDomainObjPtr vm)
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||
size_t i = 0;
|
||||
|
||||
for (i = 0; i < priv->nvcpupids; i++) {
|
||||
if (qemuProcessSetSchedParams(i, priv->vcpupids[i],
|
||||
vm->def->cputune.nvcpusched,
|
||||
vm->def->cputune.vcpusched) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < priv->niothreadpids; i++) {
|
||||
if (qemuProcessSetSchedParams(i + 1, priv->iothreadpids[i],
|
||||
vm->def->cputune.niothreadsched,
|
||||
vm->def->cputune.iothreadsched) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
qemuProcessInitPasswords(virConnectPtr conn,
|
||||
virQEMUDriverPtr driver,
|
||||
|
@ -4869,6 +4920,10 @@ int qemuProcessStart(virConnectPtr conn,
|
|||
if (qemuProcessSetIOThreadsAffinity(vm) < 0)
|
||||
goto cleanup;
|
||||
|
||||
VIR_DEBUG("Setting scheduler parameters");
|
||||
if (qemuProcessSetSchedulers(vm) < 0)
|
||||
goto cleanup;
|
||||
|
||||
VIR_DEBUG("Setting any required VM passwords");
|
||||
if (qemuProcessInitPasswords(conn, driver, vm, asyncJob) < 0)
|
||||
goto cleanup;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* qemu_process.h: QEMU process management
|
||||
*
|
||||
* Copyright (C) 2006-2012 Red Hat, Inc.
|
||||
* Copyright (C) 2006-2012, 2015 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -104,4 +104,7 @@ virBitmapPtr qemuPrepareCpumap(virQEMUDriverPtr driver,
|
|||
|
||||
int qemuProcessReadLog(int fd, char *buf, int buflen, int off, bool skipchar);
|
||||
|
||||
int qemuProcessSetSchedParams(int id, pid_t pid, size_t nsp,
|
||||
virDomainThreadSchedParamPtr sp);
|
||||
|
||||
#endif /* __QEMU_PROCESS_H__ */
|
||||
|
|
Loading…
Reference in New Issue