Re: [PATCH v3 10/21] LXC from native: convert lxc.id_map into <idmap>

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

 



On Wed, Feb 05, 2014 at 03:10:08PM +0100, Cédric Bosdonnat wrote:
> ---
>  src/lxc/lxc_native.c                           | 44 ++++++++++++++++++++++++++
>  tests/lxcconf2xmldata/lxcconf2xml-idmap.config |  5 +++
>  tests/lxcconf2xmldata/lxcconf2xml-idmap.xml    | 28 ++++++++++++++++
>  tests/lxcconf2xmltest.c                        |  1 +
>  4 files changed, 78 insertions(+)
>  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-idmap.config
>  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-idmap.xml
> 
> diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
> index b413e42..dd706f8 100644
> --- a/src/lxc/lxc_native.c
> +++ b/src/lxc/lxc_native.c

> +static int
> +lxcIdmapWalkCallback(const char *name, virConfValuePtr value, void *data)
> +{
> +    virDomainDefPtr def = data;
> +    virDomainIdMapEntryPtr idmap = NULL;
> +    char type;
> +    unsigned long start, target, count;
> +
> +    if (STRNEQ(name, "lxc.id_map") || !value->str)
> +        return 0;
> +
> +    if (sscanf(value->str, "%c %lu %lu %lu", &type,
> +               &target, &start, &count) != 4) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid lxc.id_map: '%s'"),
> +                       value->str);
> +        return -1;
> +    }
> +
> +    if (VIR_ALLOC(idmap) < 0)
> +        return -1;

This alloc is bogus since we assign to 'idmap' a few lines later.
I'm removing it when i push.

> +
> +    if (type == 'u') {
> +        if (VIR_EXPAND_N(def->idmap.uidmap, def->idmap.nuidmap, 1) < 0)
> +            return -1;
> +        idmap = &def->idmap.uidmap[def->idmap.nuidmap - 1];
> +    } else if (type == 'g') {
> +        if (VIR_EXPAND_N(def->idmap.gidmap, def->idmap.ngidmap, 1) < 0)
> +            return -1;
> +        idmap = &def->idmap.gidmap[def->idmap.ngidmap - 1];
> +    } else {
> +        return -1;
> +    }
> +
> +    idmap->start = start;
> +    idmap->target = target;
> +    idmap->count = count;
> +
> +    return 0;
> +}


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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]