[libvirt] [PATCH 10/16] LXC from native: migrate memory tuning
Daniel P. Berrange
berrange at redhat.com
Fri Jan 24 13:50:42 UTC 2014
On Tue, Jan 14, 2014 at 02:49:59PM +0100, Cédric Bosdonnat wrote:
> ---
> src/lxc/lxc_native.c | 26 ++++++++++++++++
> tests/lxcconf2xmldata/lxcconf2xml-memtune.config | 12 ++++++++
> tests/lxcconf2xmldata/lxcconf2xml-memtune.xml | 38 ++++++++++++++++++++++++
> tests/lxcconf2xmltest.c | 1 +
> 4 files changed, 77 insertions(+)
> create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-memtune.config
> create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-memtune.xml
>
> diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
> index 7cb5125..582924e 100644
> --- a/src/lxc/lxc_native.c
> +++ b/src/lxc/lxc_native.c
> @@ -767,6 +767,29 @@ lxcCreateIdmap(virDomainDefPtr def, virPropertiesPtr properties)
> return 0;
> }
>
> +static void
> +lxcSetMemTune(virDomainDefPtr def, virPropertiesPtr properties)
> +{
> + char *value = NULL;
> +
> + if ((value = virPropertiesLookup(properties,
> + "lxc.cgroup.memory.limit_in_bytes")) && STRNEQ(value, "-1")) {
> + unsigned long long size = lxcConvertSize(value, 0) / 1024;
> + def->mem.max_balloon = size;
> + def->mem.hard_limit = size;
> + }
> +
> + if ((value = virPropertiesLookup(properties,
> + "lxc.cgroup.memory.soft_limit_in_bytes")) &&
> + STRNEQ(value, "-1"))
> + def->mem.soft_limit = lxcConvertSize(value, 0) / 1024;
> +
> + if ((value = virPropertiesLookup(properties,
> + "lxc.cgroup.memory.memsw.limit_in_bytes")) &&
> + STRNEQ(value, "-1"))
> + def->mem.swap_hard_limit = lxcConvertSize(value, 0) / 1024;
> +}
These calls to lxcConvertSize need to deal with error propagation to
the caller
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the libvir-list
mailing list