--- src/lxc/lxc_native.c | 30 ++++++++++++++++++++++ .../lxcconf2xmldata/lxcconf2xml-cpusettune.config | 6 +++++ tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml | 27 +++++++++++++++++++ tests/lxcconf2xmltest.c | 1 + 4 files changed, 64 insertions(+) create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-cpusettune.config create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 65a1d0d..ee8fa75 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -673,6 +673,32 @@ error: return -1; } +static int +lxcSetCpusetTune(virDomainDefPtr def, virConfPtr properties) +{ + virConfValuePtr value; + + if ((value = virConfGetValue(properties, "lxc.cgroup.cpuset.cpus")) && + value->str) { + if (virBitmapParse(value->str, 0, &def->cpumask, + VIR_DOMAIN_CPUMASK_LEN) < 0) + return -1; + + def->placement_mode = VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC; + } + + if ((value = virConfGetValue(properties, "lxc.cgroup.cpuset.mems")) && + value->str) { + def->numatune.memory.placement_mode = VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_STATIC; + def->numatune.memory.mode = VIR_DOMAIN_NUMATUNE_MEM_STRICT; + if (virBitmapParse(value->str, 0, &def->numatune.memory.nodemask, + VIR_DOMAIN_CPUMASK_LEN) < 0) + return -1; + } + + return 0; +} + virDomainDefPtr lxcParseConfigString(const char *config) { @@ -753,6 +779,10 @@ lxcParseConfigString(const char *config) if (lxcSetCpuTune(vmdef, properties) < 0) goto error; + /* lxc.cgroup.cpuset.* */ + if (lxcSetCpusetTune(vmdef, properties) < 0) + goto error; + goto cleanup; error: diff --git a/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.config b/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.config new file mode 100644 index 0000000..a550f57 --- /dev/null +++ b/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.config @@ -0,0 +1,6 @@ +lxc.rootfs = /var/lib/lxc/migrate_test/rootfs +lxc.utsname = migrate_test +lxc.autodev=1 + +lxc.cgroup.cpuset.cpus = 1,2,5-7 +lxc.cgroup.cpuset.mems = 1-4 diff --git a/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml b/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml new file mode 100644 index 0000000..1b8fb0c --- /dev/null +++ b/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml @@ -0,0 +1,27 @@ +<domain type='lxc'> + <name>migrate_test</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>65536</memory> + <currentMemory unit='KiB'>0</currentMemory> + <vcpu placement='static' cpuset='1-2,5-7' current='0'>1</vcpu> + <numatune> + <memory mode='strict' nodeset='1-4'/> + </numatune> + <os> + <type>exe</type> + <init>/sbin/init</init> + </os> + <features> + <privnet/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <filesystem type='mount' accessmode='passthrough'> + <source dir='/var/lib/lxc/migrate_test/rootfs'/> + <target dir='/'/> + </filesystem> + </devices> +</domain> diff --git a/tests/lxcconf2xmltest.c b/tests/lxcconf2xmltest.c index 1148cd3..6bee5c5 100644 --- a/tests/lxcconf2xmltest.c +++ b/tests/lxcconf2xmltest.c @@ -111,6 +111,7 @@ mymain(void) DO_TEST("idmap", false); DO_TEST("memtune", false); DO_TEST("cputune", false); + DO_TEST("cpusettune", false); return ret; } -- 1.8.5.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list