]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
add dir support
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Fri, 21 Feb 2014 20:36:06 +0000 (14:36 -0600)
committerStéphane Graber <stgraber@ubuntu.com>
Sat, 22 Feb 2014 23:33:59 +0000 (18:33 -0500)
It used to be supported with the lxc-create.in script, and
the manpage says it's supported...  So let's just support it.

Now

sudo lxc-create -t download --dir /opt/ab -n ab

works, creating the container rootfs under /opt/ab.  This
generally isn't something I'd recommend, however telling users
to use a different lxc-path isn't as friendly as I'd like,
because each lxcpath requires separate lxc-ls and lxc-autostart
runs.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/bdev.c
src/lxc/bdev.h
src/lxc/lxc_create.c

index 6d8860967264415a17d21649e6fd865afd4590ed..952cfebecbd6fb90cb76de2e98abd27a903cd494 100644 (file)
@@ -477,7 +477,10 @@ static int dir_destroy(struct bdev *orig)
 static int dir_create(struct bdev *bdev, const char *dest, const char *n,
                        struct bdev_specs *specs)
 {
-       bdev->src = strdup(dest);
+       if (specs->dir)
+               bdev->src = strdup(specs->dir);
+       else
+               bdev->src = strdup(dest);
        bdev->dest = strdup(dest);
        if (!bdev->src || !bdev->dest) {
                ERROR("Out of memory");
index 7efc1647f5ffa7c6d892f9e063b13c0771571123..cc0bf02bfb52e52de75c15f9a2a93b2d9117ad77 100644 (file)
@@ -48,6 +48,7 @@ struct bdev_specs {
                char *lv;
                char *thinpool; // lvm thin pool to use, if any
        } lvm;
+       char *dir;
 };
 
 struct bdev_ops {
index a3684c16fe200d868f6420642ec7755b7c02c035..eee6ffd7984b624b576fb0dc4eedd7a087ab6a15 100644 (file)
@@ -256,8 +256,7 @@ int main(int argc, char *argv[])
                        spec.lvm.thinpool = my_args.thinpool;
        }
        if (my_args.dir) {
-               ERROR("--dir is not yet supported");
-               exit(1);
+               spec.dir = my_args.dir;
        }
 
        if (strcmp(my_args.bdevtype, "_unset") == 0)