On 02/01/2015 10:14 PM, Chen Hanxiao wrote:
add support for --reflink to specify
VIR_STORAGE_VOL_CREATE_REFLINK flag.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
tools/virsh-volume.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
What about the man page (virsh.pod) to describe --reflink?
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index d585ee2..db94154 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -204,6 +204,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "prealloc-metadata"))
flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
+
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
return false;
@@ -378,6 +379,7 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "prealloc-metadata"))
flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
+
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
return false;
@@ -441,6 +443,10 @@ static const vshCmdOptDef opts_vol_create_from[] = {
.type = VSH_OT_BOOL,
.help = N_("preallocate metadata (for qcow2 instead of full
allocation)")
},
+ {.name = "reflink",
+ .type = VSH_OT_BOOL,
+ .help = N_("use btrfs COW lightweight copy")
+ },
{.name = NULL}
};
@@ -460,6 +466,9 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "prealloc-metadata"))
flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
+ if (vshCommandOptBool(cmd, "reflink"))
+ flags |= VIR_STORAGE_VOL_CREATE_REFLINK;
+
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
goto cleanup;
@@ -554,6 +563,10 @@ static const vshCmdOptDef opts_vol_clone[] = {
.type = VSH_OT_BOOL,
.help = N_("preallocate metadata (for qcow2 instead of full
allocation)")
},
+ {.name = "reflink",
+ .type = VSH_OT_BOOL,
+ .help = N_("use btrfs COW lightweight copy")
+ },
{.name = NULL}
};
@@ -574,6 +587,9 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "prealloc-metadata"))
flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
+ if (vshCommandOptBool(cmd, "reflink"))
+ flags |= VIR_STORAGE_VOL_CREATE_REFLINK;
+
origpool = virStoragePoolLookupByVolume(origvol);
if (!origpool) {
vshError(ctl, "%s", _("failed to get parent pool"));