[lxc-devel] [lxc/master] lvm: Updates lvcreate to wipe signatures if supported
tomponline on Github
lxc-bot at linuxcontainers.org
Tue Mar 19 18:25:59 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 1614 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190319/5d99d11c/attachment.bin>
-------------- next part --------------
From 08e5cc803ac865b3619a917add46aafcb0efca13 Mon Sep 17 00:00:00 2001
From: tomponline <tomp at tomp.uk>
Date: Tue, 19 Mar 2019 18:14:25 +0000
Subject: [PATCH] lvm: Updates lvcreate to wipe signatures if supported,
fallbacks to old command if not.
Signed-off-by: tomponline <tomp at tomp.uk>
---
src/lxc/storage/lvm.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/src/lxc/storage/lvm.c b/src/lxc/storage/lvm.c
index 0c580bb4ae..1b66e55de2 100644
--- a/src/lxc/storage/lvm.c
+++ b/src/lxc/storage/lvm.c
@@ -55,6 +55,7 @@ struct lvcreate_args {
const char *lv;
const char *thinpool;
const char *fstype;
+ bool sigwipe;
/* snapshot specific arguments */
const char *source_lv;
@@ -76,12 +77,19 @@ static int lvm_create_exec_wrapper(void *data)
(void)setenv("LVM_SUPPRESS_FD_WARNINGS", "1", 1);
if (args->thinpool)
- execlp("lvcreate", "lvcreate", "-qq", "--thinpool", args->thinpool,
- "-V", args->size, args->vg, "-n", args->lv,
- (char *)NULL);
+ if(args->sigwipe)
+ execlp("lvcreate", "lvcreate", "-Wy", "--yes", "--thinpool", args->thinpool,
+ "-V", args->size, args->vg, "-n", args->lv, (char *)NULL);
+ else
+ execlp("lvcreate", "lvcreate", "-qq", "--thinpool", args->thinpool,
+ "-V", args->size, args->vg, "-n", args->lv, (char *)NULL);
else
- execlp("lvcreate", "lvcreate", "-qq", "-L", args->size, args->vg, "-n",
- args->lv, (char *)NULL);
+ if(args->sigwipe)
+ execlp("lvcreate", "lvcreate", "-Wy", "--yes", "-L", args->size, args->vg, "-n",
+ args->lv, (char *)NULL);
+ else
+ execlp("lvcreate", "lvcreate", "-qq", "-L", args->size, args->vg, "-n",
+ args->lv, (char *)NULL);
return -1;
}
@@ -177,10 +185,18 @@ static int do_lvm_create(const char *path, uint64_t size, const char *thinpool)
cmd_args.vg = vg;
cmd_args.lv = lv;
cmd_args.size = sz;
+ cmd_args.sigwipe = true;
TRACE("Creating new lvm storage volume \"%s\" on volume group \"%s\" "
"of size \"%s\"", lv, vg, sz);
ret = run_command(cmd_output, sizeof(cmd_output),
lvm_create_exec_wrapper, (void *)&cmd_args);
+
+ //If lvcreate is old and doesn't support signature wiping, try again without it.
+ if (strstr(cmd_output, "Error during parsing of command line") != NULL) {
+ cmd_args.sigwipe = false;
+ ret = run_command(cmd_output, sizeof(cmd_output),
+ lvm_create_exec_wrapper, (void *)&cmd_args);
+ }
if (ret < 0) {
ERROR("Failed to create logical volume \"%s\": %s", lv,
cmd_output);
More information about the lxc-devel
mailing list