[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 03/16] LXC from native: migrate fstab and lxc.mount.entry



On Tue, Jan 14, 2014 at 02:49:52PM +0100, Cédric Bosdonnat wrote:
> Tmpfs default usage is computed based on the host physical memory. To
> test this more easily, the value is computed outside the parse method.
> ---
>  src/lxc/lxc_container.c                      |   2 +-
>  src/lxc/lxc_container.h                      |   2 +
>  src/lxc/lxc_native.c                         | 295 ++++++++++++++++++++++++++-
>  tests/lxcconf2xmldata/lxcconf2xml-simple.xml |   9 +
>  4 files changed, 302 insertions(+), 6 deletions(-)

> +static unsigned long long
> +lxcConvertSize(const char *size, unsigned long memory)
> +{
> +    unsigned long long value = 0;
> +    char *unit = NULL;
> +
> +    /* Split the string into value and unit */
> +    if (virStrToLong_ull(size, &unit, 10, &value) < 0)
> +        return 0;
> +
> +    if (STREQ(unit, "%")) {
> +        value = value * memory * 1024 / 100;
> +
> +    } else if (virScaleInteger(&value, unit, 1, ULLONG_MAX) < 0)
> +        return 0;
> +
> +    return value;
> +}

This needs to virReportError in error cases. I'd probably
suggest that the return value be an output parameter instead
so we can return '-1' in an error case.

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 :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]