mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 13:35:17 +00:00
lxcSetCpusetTune: Refactor memory clearing
Use automatic memory clearing for virBitmap and remove a reuse of a temporary string. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
17159773ee
commit
6181d8a61b
@ -926,32 +926,28 @@ lxcSetCpuTune(virDomainDef *def, virConf *properties)
|
||||
static int
|
||||
lxcSetCpusetTune(virDomainDef *def, virConf *properties)
|
||||
{
|
||||
g_autofree char *value = NULL;
|
||||
virBitmap *nodeset = NULL;
|
||||
g_autofree char *cpus = NULL;
|
||||
g_autofree char *mems = NULL;
|
||||
g_autoptr(virBitmap) nodeset = NULL;
|
||||
|
||||
if (virConfGetValueString(properties, "lxc.cgroup.cpuset.cpus",
|
||||
&value) > 0) {
|
||||
if (virBitmapParse(value, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0)
|
||||
&cpus) > 0) {
|
||||
if (virBitmapParse(cpus, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0)
|
||||
return -1;
|
||||
def->placement_mode = VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC;
|
||||
g_free(value);
|
||||
value = NULL;
|
||||
}
|
||||
|
||||
if (virConfGetValueString(properties, "lxc.cgroup.cpuset.mems",
|
||||
&value) > 0) {
|
||||
if (virBitmapParse(value, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0)
|
||||
&mems) > 0) {
|
||||
if (virBitmapParse(mems, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0)
|
||||
return -1;
|
||||
if (virDomainNumatuneSet(def->numa,
|
||||
def->placement_mode ==
|
||||
VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC,
|
||||
VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC,
|
||||
VIR_DOMAIN_NUMATUNE_MEM_STRICT,
|
||||
nodeset) < 0) {
|
||||
virBitmapFree(nodeset);
|
||||
nodeset) < 0)
|
||||
return -1;
|
||||
}
|
||||
virBitmapFree(nodeset);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user