]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh-volume: add support for --reflink
authorChen Hanxiao <chenhanxiao@cn.fujitsu.com>
Tue, 3 Feb 2015 03:05:27 +0000 (11:05 +0800)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 3 Feb 2015 16:37:30 +0000 (11:37 -0500)
Add support for --reflink to the virsh 'vol-create-from' and 'vol-clone'
commands to signify usage of the VIR_STORAGE_VOL_CREATE_REFLINK flag in the
ensuing virStorageVolCreateXMLFrom API call.

Updated the man page to describe the new flag.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
tools/virsh-volume.c
tools/virsh.pod

index d585ee272d2953ae58572d5472f03f93534c2ca2..db94154a7f7d0f32e7bddd9370eb00772edc04e6 100644 (file)
@@ -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"));
index 804458e3679e9ea42e5dbe5d1e3709aefad9994b..e367e04ccfac0b22b07d8eba3b7771b373120ce2 100644 (file)
@@ -3160,6 +3160,7 @@ B<Example>
 
 =item B<vol-create-from> I<pool-or-uuid> I<FILE> [I<--inputpool>
 I<pool-or-uuid>] I<vol-name-or-key-or-path> [I<--prealloc-metadata>]
+[I<--reflink>]
 
 Create a volume, using another volume as input.
 I<pool-or-uuid> is the name or UUID of the storage pool to create the volume in.
@@ -3171,6 +3172,9 @@ I<vol-name-or-key-or-path> is the name or key or path of the source volume.
 support full allocation). This option creates a sparse image file with metadata,
 resulting in higher performance compared to images with no preallocation and
 only slightly higher initial disk space usage.
+When I<--reflink> is specified, perform a COW lightweight copy,
+where the data blocks are copied only when modified.
+If this is not possible, the copy fails.
 
 =item B<vol-create-as> I<pool-or-uuid> I<name> I<capacity>
 [I<--allocation> I<size>] [I<--format> I<string>] [I<--backing-vol>
@@ -3205,7 +3209,7 @@ resulting in higher performance compared to images with no preallocation and
 only slightly higher initial disk space usage.
 
 =item B<vol-clone> [I<--pool> I<pool-or-uuid>] I<vol-name-or-key-or-path>
-I<name> [I<--prealloc-metadata>]
+I<name> [I<--prealloc-metadata>] [I<--reflink>]
 
 Clone an existing volume.  Less powerful, but easier to type, version of
 B<vol-create-from>.
@@ -3217,6 +3221,9 @@ I<name> is the name of the new volume.
 support full allocation). This option creates a sparse image file with metadata,
 resulting in higher performance compared to images with no preallocation and
 only slightly higher initial disk space usage.
+When I<--reflink> is specified, perform a COW lightweight copy,
+where the data blocks are copied only when modified.
+If this is not possible, the copy fails.
 
 =item B<vol-delete> [I<--pool> I<pool-or-uuid>] I<vol-name-or-key-or-path>