mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
LXC from native: map lxc.cgroup.cpu.*
This commit is contained in:
parent
13b9946eb5
commit
4f3f7aea6c
@ -643,6 +643,36 @@ lxcSetMemTune(virDomainDefPtr def, virConfPtr properties)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
lxcSetCpuTune(virDomainDefPtr def, virConfPtr properties)
|
||||
{
|
||||
virConfValuePtr value;
|
||||
|
||||
if ((value = virConfGetValue(properties, "lxc.cgroup.cpu.shares")) &&
|
||||
value->str && virStrToLong_ul(value->str, NULL, 10,
|
||||
&def->cputune.shares) < 0)
|
||||
goto error;
|
||||
|
||||
if ((value = virConfGetValue(properties,
|
||||
"lxc.cgroup.cpu.cfs_quota_us")) &&
|
||||
value->str && virStrToLong_ll(value->str, NULL, 10,
|
||||
&def->cputune.quota) < 0)
|
||||
goto error;
|
||||
|
||||
if ((value = virConfGetValue(properties,
|
||||
"lxc.cgroup.cpu.cfs_period_us")) &&
|
||||
value->str && virStrToLong_ull(value->str, NULL, 10,
|
||||
&def->cputune.period) < 0)
|
||||
goto error;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("failed to parse integer: '%s'"), value->str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
virDomainDefPtr
|
||||
lxcParseConfigString(const char *config)
|
||||
{
|
||||
@ -719,6 +749,10 @@ lxcParseConfigString(const char *config)
|
||||
if (lxcSetMemTune(vmdef, properties) < 0)
|
||||
goto error;
|
||||
|
||||
/* lxc.cgroup.cpu.* */
|
||||
if (lxcSetCpuTune(vmdef, properties) < 0)
|
||||
goto error;
|
||||
|
||||
goto cleanup;
|
||||
|
||||
error:
|
||||
|
7
tests/lxcconf2xmldata/lxcconf2xml-cputune.config
Normal file
7
tests/lxcconf2xmldata/lxcconf2xml-cputune.config
Normal file
@ -0,0 +1,7 @@
|
||||
lxc.rootfs = /var/lib/lxc/migrate_test/rootfs
|
||||
lxc.utsname = migrate_test
|
||||
lxc.autodev=1
|
||||
|
||||
lxc.cgroup.cpu.shares = 1024
|
||||
lxc.cgroup.cpu.cfs_quota_us = -1
|
||||
lxc.cgroup.cpu.cfs_period_us = 500000
|
29
tests/lxcconf2xmldata/lxcconf2xml-cputune.xml
Normal file
29
tests/lxcconf2xmldata/lxcconf2xml-cputune.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<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' current='0'>1</vcpu>
|
||||
<cputune>
|
||||
<shares>1024</shares>
|
||||
<period>500000</period>
|
||||
<quota>-1</quota>
|
||||
</cputune>
|
||||
<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>
|
@ -110,6 +110,7 @@ mymain(void)
|
||||
DO_TEST("macvlannetwork", false);
|
||||
DO_TEST("idmap", false);
|
||||
DO_TEST("memtune", false);
|
||||
DO_TEST("cputune", false);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user