
On Tue, Jan 14, 2014 at 02:49:58PM +0100, Cédric Bosdonnat wrote:
--- src/lxc/lxc_native.c | 41 ++++++++++++++++++++++++++ tests/lxcconf2xmldata/lxcconf2xml-idmap.config | 6 ++++ tests/lxcconf2xmldata/lxcconf2xml-idmap.xml | 32 ++++++++++++++++++++ tests/lxcconf2xmltest.c | 1 + 4 files changed, 80 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 a99bc1c..7cb5125 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -730,6 +730,43 @@ error: return -1; }
+static int +lxcCreateIdmap(virDomainDefPtr def, virPropertiesPtr properties) +{ + char *value = NULL; + virDomainIdMapEntryPtr idmap = NULL; + char type; + unsigned long start, target, count; + + value = virPropertiesLookup(properties, "lxc.id_map"); + while (value) { + if (sscanf(value, "%c %lu %lu %lu", &type, &target, &start, &count) != 4) + return -1;
Need a virReportError here.
+ + if (VIR_ALLOC(idmap) < 0) + return -1; + + 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; + + value = virPropertiesLookup(properties, NULL); + } + + 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 :|