On Wed, Feb 12, 2014 at 05:23:39PM +0000, Daniel P. Berrange wrote: > On Wed, Feb 05, 2014 at 03:10:01PM +0100, Cédric Bosdonnat wrote: > > LXC rootfs can be either a directory or a block device or an image > > file. The first two types have been implemented, but the image file is > > still to be done since LXC auto-guesses the file format at mount time > > and the LXC driver doesn't support the 'auto' format. > > --- > > src/lxc/lxc_native.c | 69 ++++++++++++++++++++++++++++ > > tests/lxcconf2xmldata/lxcconf2xml-simple.xml | 4 ++ > > 2 files changed, 73 insertions(+) > > ACK Actually there's a crash on OOM in this patch due to a double-free of the 'src' and 'dst' strings. I'm going to squash the following change in before pushing it Daniel diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 86d0dd3..af9d34e 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -33,7 +33,9 @@ static virDomainFSDefPtr -lxcCreateFSDef(int type, char *src, char* dst) +lxcCreateFSDef(int type, + const char *src, + const char* dst) { virDomainFSDefPtr def; @@ -42,14 +44,23 @@ lxcCreateFSDef(int type, char *src, char* dst) def->type = type; def->accessmode = VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH; - def->src = src; - def->dst = dst; + if (src && VIR_STRDUP(def->src, src) < 0) + goto error; + if (VIR_STRDUP(def->dst, dst) < 0) + goto error; return def; + + error: + virDomainFSDefFree(def); + return NULL; } static int -lxcAddFSDef(virDomainDefPtr def, int type, char *src, char *dst) +lxcAddFSDef(virDomainDefPtr def, + int type, + const char *src, + const char *dst) { virDomainFSDefPtr fsDef = NULL; @@ -71,30 +82,23 @@ static int lxcSetRootfs(virDomainDefPtr def, virConfPtr properties) { - char *fssrc = NULL; - char *fsdst = NULL; int type = VIR_DOMAIN_FS_TYPE_MOUNT; virConfValuePtr value; if (!(value = virConfGetValue(properties, "lxc.rootfs")) || - !value->str || - (VIR_STRDUP(fssrc, value->str) < 0) || - VIR_STRDUP(fsdst, "/") < 0) - goto error; + !value->str) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Missing lxc.rootfs configuration")); + return -1; + } - if (STRPREFIX(fssrc, "/dev/")) + if (STRPREFIX(value->str, "/dev/")) type = VIR_DOMAIN_FS_TYPE_BLOCK; - - if (lxcAddFSDef(def, type, fssrc, fsdst) < 0) - goto error; + if (lxcAddFSDef(def, type, value->str, "/") < 0) + return -1; return 0; - -error: - VIR_FREE(fssrc); - VIR_FREE(fsdst); - return -1; } virDomainDefPtr -- |: 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