提交 c9f9fa25 编写于 作者: P Peter Krempa

qemu: cgroup: Store auto cpuset instead of re-creating it on demand

The automatic cpuset can be stored along with automatic nodeset and it
does not have to be recreated when used.
上级 84a84bd5
......@@ -642,8 +642,7 @@ qemuSetupCpusetMems(virDomainObjPtr vm)
static int
qemuSetupCpusetCgroup(virDomainObjPtr vm,
virCapsPtr caps)
qemuSetupCpusetCgroup(virDomainObjPtr vm)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
char *cpu_mask = NULL;
......@@ -658,15 +657,10 @@ qemuSetupCpusetCgroup(virDomainObjPtr vm,
if (vm->def->cpumask ||
(vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO)) {
if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) {
virBitmapPtr cpumap;
if (!(cpumap = virCapabilitiesGetCpusForNodemask(caps, priv->autoNodeset)))
goto cleanup;
cpu_mask = virBitmapFormat(cpumap);
virBitmapFree(cpumap);
} else {
if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO)
cpu_mask = virBitmapFormat(priv->autoCpuset);
else
cpu_mask = virBitmapFormat(vm->def->cpumask);
}
if (!cpu_mask)
goto cleanup;
......@@ -896,7 +890,6 @@ qemuSetupCgroup(virQEMUDriverPtr driver,
int *nicindexes)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virCapsPtr caps = NULL;
int ret = -1;
if (!vm->pid) {
......@@ -911,9 +904,6 @@ qemuSetupCgroup(virQEMUDriverPtr driver,
if (!priv->cgroup)
return 0;
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
if (qemuSetupDevicesCgroup(driver, vm) < 0)
goto cleanup;
......@@ -926,12 +916,11 @@ qemuSetupCgroup(virQEMUDriverPtr driver,
if (qemuSetupCpuCgroup(driver, vm) < 0)
goto cleanup;
if (qemuSetupCpusetCgroup(vm, caps) < 0)
if (qemuSetupCpusetCgroup(vm) < 0)
goto cleanup;
ret = 0;
cleanup:
virObjectUnref(caps);
return ret;
}
......
......@@ -458,6 +458,7 @@ qemuDomainObjPrivateFree(void *data)
}
VIR_FREE(priv->cleanupCallbacks);
virBitmapFree(priv->autoNodeset);
virBitmapFree(priv->autoCpuset);
VIR_FREE(priv);
}
......
......@@ -191,7 +191,10 @@ struct _qemuDomainObjPrivate {
char **qemuDevices; /* NULL-terminated list of devices aliases known to QEMU */
bool hookRun; /* true if there was a hook run over this domain */
/* Bitmaps below hold data from the auto NUMA feature */
virBitmapPtr autoNodeset;
virBitmapPtr autoCpuset;
};
typedef enum {
......
......@@ -4333,7 +4333,6 @@ int qemuProcessStart(virConnectPtr conn,
size_t i;
bool rawio_set = false;
char *nodeset = NULL;
virBitmapPtr nodemask = NULL;
unsigned int stop_flags;
virQEMUDriverConfigPtr cfg;
virCapsPtr caps = NULL;
......@@ -4594,10 +4593,14 @@ int qemuProcessStart(virConnectPtr conn,
VIR_DEBUG("Nodeset returned from numad: %s", nodeset);
if (virBitmapParse(nodeset, 0, &nodemask, VIR_DOMAIN_CPUMASK_LEN) < 0)
if (virBitmapParse(nodeset, 0, &priv->autoNodeset,
VIR_DOMAIN_CPUMASK_LEN) < 0)
goto cleanup;
if (!(priv->autoCpuset = virCapabilitiesGetCpusForNodemask(caps,
priv->autoNodeset)))
goto cleanup;
}
priv->autoNodeset = nodemask;
/* "volume" type disk's source must be translated before
* cgroup and security setting.
......@@ -4664,7 +4667,7 @@ int qemuProcessStart(virConnectPtr conn,
migrateFrom, stdin_fd, snapshot, vmop,
&buildCommandLineCallbacks, false,
qemuCheckFips(),
nodemask,
priv->autoNodeset,
&nnicindexes, &nicindexes)))
goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册