]> git.proxmox.com Git - lxc.git/commitdiff
use a better way to set /var/lib/vz as default
authorDietmar Maurer <dietmar@proxmox.com>
Sat, 11 Apr 2015 09:41:00 +0000 (11:41 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Sat, 11 Apr 2015 09:41:00 +0000 (11:41 +0200)
debian/lxc.dirs
debian/lxc.install
debian/patches/do-not-use-config-path-for-rootfs.patch [new file with mode: 0644]
debian/patches/fix-rootfs-mount-point.patch [deleted file]
debian/patches/series
debian/patches/use-var-lib-vz-as-default-dir.patch [new file with mode: 0644]
debian/rules

index 54ff22da01f72adb6eb52a04535fb88c3f7cf82b..ddc4cf7893451d647532514e717521d6b24d45c6 100644 (file)
@@ -1,3 +1,3 @@
 var/cache/lxc
-var/lib/vz
+var/lib/lxc
 var/log/lxc
index 6152de1cd313fb9696cbdae5c0ade1e7057c9a5d..fb84335a2cd6c3bc12668bd827226337130e7a9b 100644 (file)
@@ -4,5 +4,6 @@ usr/share/man
 usr/share/lxc
 usr/lib/*/*.so.*
 usr/lib/*/lxc/lxc-*
+usr/lib/*/lxc/rootfs/README
 lib/systemd
 etc
\ No newline at end of file
diff --git a/debian/patches/do-not-use-config-path-for-rootfs.patch b/debian/patches/do-not-use-config-path-for-rootfs.patch
new file mode 100644 (file)
index 0000000..6efbdc1
--- /dev/null
@@ -0,0 +1,18 @@
+Index: new/src/lxc/lxccontainer.c
+===================================================================
+--- new.orig/src/lxc/lxccontainer.c
++++ new/src/lxc/lxccontainer.c
+@@ -819,10 +819,10 @@ static struct bdev *do_bdev_create(struc
+               dest = alloca(len);
+               ret = snprintf(dest, len, "%s", rpath);
+       } else {
+-              const char *lxcpath = lxcapi_get_config_path(c);
+-              len = strlen(c->name) + strlen(lxcpath) + 9;
++              const char *rootfs_path = "/var/lib/lxc";
++              len = strlen(c->name) + strlen(rootfs_path) + 9;
+               dest = alloca(len);
+-              ret = snprintf(dest, len, "%s/%s/rootfs", lxcpath, c->name);
++              ret = snprintf(dest, len, "%s/%s/rootfs", rootfs_path, c->name);
+       }
+       if (ret < 0 || ret >= len)
+               return NULL;
diff --git a/debian/patches/fix-rootfs-mount-point.patch b/debian/patches/fix-rootfs-mount-point.patch
deleted file mode 100644 (file)
index 074abc5..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-Index: new/doc/lxc-create.sgml.in
-===================================================================
---- new.orig/doc/lxc-create.sgml.in
-+++ new/doc/lxc-create.sgml.in
-@@ -128,7 +128,7 @@ Foundation, Inc., 51 Franklin Street, Fi
-         <para>
-           'backingstore' is one of 'dir', 'lvm', 'loop', 'btrfs', 'zfs', or 'best'.  The
-           default is 'dir', meaning that the container root filesystem
--          will be a directory under <filename>@LXCPATH@/container/rootfs</filename>.
-+          will be a directory under <filename>@LXCROOTFSMOUNT@/rootfs/ctname</filename>.
-           This backing store type allows the optional
-           <replaceable>--dir ROOTFS</replaceable> to be specified, meaning
-           that the container rootfs should be placed under the specified path,
-Index: new/src/lxc/lxccontainer.c
-===================================================================
---- new.orig/src/lxc/lxccontainer.c
-+++ new/src/lxc/lxccontainer.c
-@@ -812,17 +812,16 @@ static struct bdev *do_bdev_create(struc
-       struct bdev *bdev;
-       int ret;
--      /* rootfs.path or lxcpath/lxcname/rootfs */
-+      /* rootfs.path or LXCROOTFSMOUNT/rootfs/lxcname */
-       if (c->lxc_conf->rootfs.path && access(c->lxc_conf->rootfs.path, F_OK) == 0) {
-               const char *rpath = c->lxc_conf->rootfs.path;
-               len = strlen(rpath) + 1;
-               dest = alloca(len);
-               ret = snprintf(dest, len, "%s", rpath);
-       } else {
--              const char *lxcpath = lxcapi_get_config_path(c);
--              len = strlen(c->name) + strlen(lxcpath) + 9;
-+              len = strlen(c->name) + strlen(LXCROOTFSMOUNT) + 9;
-               dest = alloca(len);
--              ret = snprintf(dest, len, "%s/%s/rootfs", lxcpath, c->name);
-+              ret = snprintf(dest, len, "%s/rootfs/%s", LXCROOTFSMOUNT, c->name);
-       }
-       if (ret < 0 || ret >= len)
-               return NULL;
-@@ -2708,7 +2707,7 @@ static struct lxc_container *lxcapi_clon
-       fclose(fout);
-       c->lxc_conf->rootfs.path = origroot;
--      sprintf(newpath, "%s/%s/rootfs", lxcpath, newname);
-+      sprintf(newpath, "%s/rootfs/%s", LXCROOTFSMOUNT, newname);
-       if (mkdir(newpath, 0755) < 0) {
-               SYSERROR("error creating %s", newpath);
-               goto out;
-Index: new/src/lxc/bdev.c
-===================================================================
---- new.orig/src/lxc/bdev.c
-+++ new/src/lxc/bdev.c
-@@ -459,11 +459,11 @@ static int dir_clonepaths(struct bdev *o
-       if (!orig->dest || !orig->src)
-               return -1;
--      len = strlen(lxcpath) + strlen(cname) + strlen("rootfs") + 3;
-+      len = strlen(LXCROOTFSMOUNT) + strlen(cname) + strlen("rootfs") + 3;
-       new->src = malloc(len);
-       if (!new->src)
-               return -1;
--      ret = snprintf(new->src, len, "%s/%s/rootfs", lxcpath, cname);
-+      ret = snprintf(new->src, len, "%s/rootfs/%s", LXCROOTFSMOUNT, cname);
-       if (ret < 0 || ret >= len)
-               return -1;
-       if ((new->dest = strdup(new->src)) == NULL)
-@@ -612,8 +612,8 @@ static int zfs_clone(const char *opath,
-       } else
-               zfsroot = lxc_global_config_value("lxc.bdev.zfs.root");
--      ret = snprintf(option, MAXPATHLEN, "-omountpoint=%s/%s/rootfs",
--              lxcpath, nname);
-+      ret = snprintf(option, MAXPATHLEN, "-omountpoint=%s/rootfs/%s",
-+               LXCROOTFSMOUNT, nname);
-       if (ret < 0  || ret >= MAXPATHLEN)
-               return -1;
-@@ -689,11 +689,11 @@ static int zfs_clonepaths(struct bdev *o
-               return -1;
-       }
--      len = strlen(lxcpath) + strlen(cname) + strlen("rootfs") + 3;
-+      len = strlen(LXCROOTFSMOUNT) + strlen(cname) + strlen("rootfs") + 3;
-       new->src = malloc(len);
-       if (!new->src)
-               return -1;
--      ret = snprintf(new->src, len, "%s/%s/rootfs", lxcpath, cname);
-+      ret = snprintf(new->src, len, "%s/rootfs/%s", LXCROOTFSMOUNT, cname);
-       if (ret < 0 || ret >= len)
-               return -1;
-       if ((new->dest = strdup(new->src)) == NULL)
-@@ -1047,11 +1047,11 @@ static int lvm_clonepaths(struct bdev *o
-                       return -1;
-       }
--      len = strlen(lxcpath) + strlen(cname) + strlen("rootfs") + 3;
-+      len = strlen(LXCROOTFSMOUNT) + strlen(cname) + strlen("rootfs") + 3;
-       new->dest = malloc(len);
-       if (!new->dest)
-               return -1;
--      ret = snprintf(new->dest, len, "%s/%s/rootfs", lxcpath, cname);
-+      ret = snprintf(new->dest, len, "%s/rootfs/%s", LXCROOTFSMOUNT, cname);
-       if (ret < 0 || ret >= len)
-               return -1;
-       if (mkdir_p(new->dest, 0755) < 0)
-@@ -1473,11 +1473,11 @@ static int btrfs_clonepaths(struct bdev
-                               orig->type);
-                       return -1;
-               }
--              len = strlen(lxcpath) + strlen(cname) + strlen("rootfs") + 3;
-+              len = strlen(LXCROOTFSMOUNT) + strlen(cname) + strlen("rootfs") + 3;
-               new->src = malloc(len);
-               if (!new->src)
-                       return -1;
--              ret = snprintf(new->src, len, "%s/%s/rootfs", lxcpath, cname);
-+              ret = snprintf(new->src, len, "%s/rootfs/%s", LXCROOTFSMOUNT, cname);
-               if (ret < 0 || ret >= len)
-                       return -1;
-       } else {
-@@ -2021,7 +2021,7 @@ static int loop_clonepaths(struct bdev *
-       if (!orig->dest || !orig->src)
-               return -1;
--      len = strlen(lxcpath) + strlen(cname) + strlen("rootdev") + 3;
-+      len = strlen(LXCROOTFSMOUNT) + strlen(lxcpath) + strlen(cname) + strlen("rootdev") + 3;
-       srcdev = alloca(len);
-       ret = snprintf(srcdev, len, "%s/%s/rootdev", lxcpath, cname);
-       if (ret < 0 || ret >= len)
-@@ -2037,7 +2037,7 @@ static int loop_clonepaths(struct bdev *
-       new->dest = malloc(len);
-       if (!new->dest)
-               return -1;
--      ret = snprintf(new->dest, len, "%s/%s/rootfs", lxcpath, cname);
-+      ret = snprintf(new->dest, len, "%s/rootfs/%s", LXCROOTFSMOUNT, cname);
-       if (ret < 0 || ret >= len)
-               return -1;
-Index: new/src/lxc/conf.c
-===================================================================
---- new.orig/src/lxc/conf.c
-+++ new/src/lxc/conf.c
-@@ -1851,20 +1851,13 @@ static int mount_entry_on_absolute_rootf
-       unsigned long mntflags;
-       char *mntdata;
-       int r, ret = 0, offset;
--      const char *lxcpath;
-       FILE *pathfile = NULL;
-       char *pathdirname = NULL;
-       bool optional = hasmntopt(mntent, "optional") != NULL;
--      lxcpath = lxc_global_config_value("lxc.lxcpath");
--      if (!lxcpath) {
--              ERROR("Out of memory");
--              return -1;
--      }
--
-       /* if rootfs->path is a blockdev path, allow container fstab to
--       * use $lxcpath/CN/rootfs as the target prefix */
--      r = snprintf(path, MAXPATHLEN, "%s/%s/rootfs", lxcpath, lxc_name);
-+       * use LXCROOTFSMOUNT/rootfs/CN as the target prefix */
-+      r = snprintf(path, MAXPATHLEN, "%s/rootfs/%s", LXCROOTFSMOUNT, lxc_name);
-       if (r < 0 || r >= MAXPATHLEN)
-               goto skipvarlib;
index 62fbc994be0076af4b69440f73ca4b79fe751beb..51eef6560b3e8c0a0594ba5451729c77a4712e5f 100644 (file)
@@ -1,5 +1,6 @@
 fix-systemd-service-depends.patch
 fix-default-lxc-config.patch
-fix-rootfs-mount-point.patch
-do-dot-call-chown_mapped_root-on-etc-pve.patch
 include-linux-sched.patch
+do-dot-call-chown_mapped_root-on-etc-pve.patch
+use-var-lib-vz-as-default-dir.patch
+do-not-use-config-path-for-rootfs.patch
diff --git a/debian/patches/use-var-lib-vz-as-default-dir.patch b/debian/patches/use-var-lib-vz-as-default-dir.patch
new file mode 100644 (file)
index 0000000..3d181d9
--- /dev/null
@@ -0,0 +1,34 @@
+Index: new/src/lxc/bdev.c
+===================================================================
+--- new.orig/src/lxc/bdev.c
++++ new/src/lxc/bdev.c
+@@ -3499,6 +3499,8 @@ static struct bdev * do_bdev_create(cons
+       return bdev;
+ }
++#define PVE_DEFAULT_DIR "/var/lib/vz"
++
+ /*
+  * bdev_create:
+  * Create a backing store for a container.
+@@ -3516,6 +3518,20 @@ struct bdev *bdev_create(const char *des
+       struct bdev *bdev;
+       char *best_options[] = {"btrfs", "zfs", "lvm", "dir", NULL};
++      if ((!type || (strcmp(type, "dir") == 0)) && !specs->dir) {
++              int len = strlen(PVE_DEFAULT_DIR) + strlen(cname) + strlen("rootfs") + 3;
++              specs->dir = malloc(len);
++              if (!specs->dir) {
++                      return NULL;
++              }
++              int ret = snprintf(specs->dir, len, "%s/rootfs/%s", PVE_DEFAULT_DIR, cname);
++              if (ret < 0 || ret >= len) {
++                      free(specs->dir);
++                      specs->dir = NULL;
++                      return NULL;
++              }
++      }
++      
+       if (!type)
+               return do_bdev_create(dest, "dir", cname, specs);
index ffc46f73042db9487c9a8040dd1acd8976802093..997ce91bf624d85e9ff832dc0b354f7b42daf847 100755 (executable)
@@ -15,7 +15,6 @@ override_dh_auto_configure:
        --with-distro=debian \
        --with-init-script=systemd \
        --with-config-path=/etc/pve/lxc \
-       --with-rootfs-path=/var/lib/vz \
        --enable-apparmor       \
        --enable-doc    \
        --enable-api-docs \
@@ -36,9 +35,9 @@ override_dh_install:
        dh_apparmor -p lxc --profile-name=usr.bin.lxc-start
 
        # do not include dirs on /etc/pve
-       rmdir $(CURDIR)/debian/tmp/etc/pve/lxc
-       rmdir $(CURDIR)/debian/tmp/etc/pve
+#      rmdir $(CURDIR)/debian/tmp/etc/pve/lxc
+#      rmdir $(CURDIR)/debian/tmp/etc/pve
 
-       rm $(CURDIR)/debian/tmp/var/lib/vz/README
+#      rm $(CURDIR)/debian/tmp/var/lib/lxc/README
 
        dh_install --fail-missing