--- src/lxc/lxc_native.c | 27 ++++++++++++++++ .../lxcconf2xmldata/lxcconf2xml-cpusettune.config | 8 +++++ tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml | 36 ++++++++++++++++++++++ tests/lxcconf2xmltest.c | 1 + 4 files changed, 72 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 80b7e74..635eb89 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -812,6 +812,29 @@ lxcSetCpuTune(virDomainDefPtr def, virPropertiesPtr properties) return 0; } +static int +lxcSetCpusetTune(virDomainDefPtr def, virPropertiesPtr properties) +{ + char *value; + + if ((value = virPropertiesLookup(properties, "lxc.cgroup.cpuset.cpus"))) { + if (virBitmapParse(value, 0, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) + return -1; + + def->placement_mode = VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC; + } + + if ((value = virPropertiesLookup(properties, "lxc.cgroup.cpuset.mems"))) { + def->numatune.memory.placement_mode = VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_STATIC; + def->numatune.memory.mode = VIR_DOMAIN_NUMATUNE_MEM_STRICT; + if (virBitmapParse(value, 0, &def->numatune.memory.nodemask, + VIR_DOMAIN_CPUMASK_LEN) < 0) + return -1; + } + + return 0; +} + virDomainDefPtr lxcParseConfigString(const char *config, const char *fstab, @@ -914,6 +937,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..0ece9fc --- /dev/null +++ b/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.config @@ -0,0 +1,8 @@ +lxc.mount.entry = /etc/resolv.conf etc/resolv.conf none bind,ro 0 0 +lxc.rootfs = /var/lib/lxc/migrate_test/rootfs +lxc.utsname = migrate_test +lxc.autodev=1 +lxc.mount = /var/lib/lxc/migrate_test/fstab + +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..d22a7fe --- /dev/null +++ b/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml @@ -0,0 +1,36 @@ +<domain type='lxc'> + <name>migrate_test</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>4035770</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> + <filesystem type='mount' accessmode='passthrough'> + <source dir='/etc/resolv.conf'/> + <target dir='/etc/resolv.conf'/> + <readonly/> + </filesystem> + <filesystem type='ram' accessmode='passthrough'> + <source usage='2017885' units='KiB'/> + <target dir='/run'/> + </filesystem> + </devices> +</domain> diff --git a/tests/lxcconf2xmltest.c b/tests/lxcconf2xmltest.c index 096a050..da94db4 100644 --- a/tests/lxcconf2xmltest.c +++ b/tests/lxcconf2xmltest.c @@ -113,6 +113,7 @@ mymain(void) DO_TEST("idmap"); DO_TEST("memtune"); DO_TEST("cputune"); + DO_TEST("cpusettune"); return ret; } -- 1.8.5.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list