[libvirt] [PATCH v2 04/18] LXC from native: migrate fstab and lxc.mount.entry

Daniel P. Berrange berrange at redhat.com
Tue Feb 4 12:28:26 UTC 2014


On Thu, Jan 30, 2014 at 10:55:52AM +0100, Cédric Bosdonnat wrote:
> Tmpfs relative size and default 50% size values aren't supported as
> we have no idea of the available memory at the conversion time.
> ---
>  src/lxc/lxc_container.c                         |   2 +-
>  src/lxc/lxc_container.h                         |   2 +
>  src/lxc/lxc_native.c                            | 245 +++++++++++++++++++++++-
>  tests/lxcconf2xmldata/lxcconf2xml-fstab.config  |  37 ++++
>  tests/lxcconf2xmldata/lxcconf2xml-simple.config |   4 +-
>  tests/lxcconf2xmldata/lxcconf2xml-simple.xml    |   9 +
>  tests/lxcconf2xmltest.c                         |  60 +++---
>  7 files changed, 330 insertions(+), 29 deletions(-)
>  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-fstab.config


> +static int
> +lxcAddFstabLine(virDomainDefPtr def, lxcFstabPtr fstab)
> +{
> +    char *src = NULL;
> +    char *dst = NULL;
> +    char **options = virStringSplit(fstab->options, ",", 0);
> +    bool readonly;
> +    int type = VIR_DOMAIN_FS_TYPE_MOUNT;
> +    unsigned long long usage = 0;
> +
> +    if (fstab->dst[0] != '/') {
> +        if (virAsprintf(&dst, "/%s", fstab->dst) < 0)
> +            goto error;
> +    } else if (VIR_STRDUP(dst, fstab->dst) < 0)
> +        goto error;

Nit-pick: i think it'd be slightly clearer if you did

     } else {
         if (VIR_STRDUP(dst, fstab->dst) < 0)
           goto error;
     }

because we prefer that if/else both match in their
use of {}

> +
> +    /* Check that we don't add basic mounts */
> +    if (lxcIsBasicMountLocation(dst)) {
> +        VIR_FREE(dst);
> +        return 0;
> +    }
> +
> +    if (STREQ(fstab->type, "tmpfs")) {
> +        char *sizeStr = NULL;
> +        size_t i;
> +        type = VIR_DOMAIN_FS_TYPE_RAM;
> +
> +        for (i = 0; options[i]; i++) {
> +            if ((sizeStr = STRSKIP(options[i], "size="))) {
> +                if (lxcConvertSize(sizeStr, &usage) < 0)
> +                    goto error;
> +                break;
> +            }
> +        }
> +        if (!sizeStr) {
> +            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                           _("missing tmpfs size, set the size option"));
> +            goto error;
> +        }
> +    } else if (VIR_STRDUP(src, fstab->src) < 0)
> +        goto error;

And here too - add {} in the 'else { ..strdup bits.. }' 


ACK with the nitpick fixed.

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