[libvirt] [PATCH v2 0/2] add support for --reflink to virsh

v2: add man page patch Chen Hanxiao (2): virsh-volume: add support for --reflink man: add --reflink man page of virsh tools/virsh-volume.c | 16 ++++++++++++++++ tools/virsh.pod | 9 ++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) -- 2.1.0

add support for --reflink to specify VIR_STORAGE_VOL_CREATE_REFLINK flag. Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com> --- tools/virsh-volume.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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")); -- 2.1.0

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com> --- tools/virsh.pod | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/virsh.pod b/tools/virsh.pod index 804458e..c0bd99b 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -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. +[I<--reflink>] When --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. +[I<--reflink>] When --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> -- 2.1.0

On 02/02/2015 10:05 PM, Chen Hanxiao wrote:
v2: add man page patch
Chen Hanxiao (2): virsh-volume: add support for --reflink man: add --reflink man page of virsh
tools/virsh-volume.c | 16 ++++++++++++++++ tools/virsh.pod | 9 ++++++++- 2 files changed, 24 insertions(+), 1 deletion(-)
I combined the two patches, cleaned up the verbiage a bit, and pushed. John

-----Original Message----- From: John Ferlan [mailto:jferlan@redhat.com] Sent: Wednesday, February 04, 2015 12:39 AM To: Chen, Hanxiao/陈 晗霄; libvir-list@redhat.com Subject: Re: [libvirt] [PATCH v2 0/2] add support for --reflink to virsh
On 02/02/2015 10:05 PM, Chen Hanxiao wrote:
v2: add man page patch
Chen Hanxiao (2): virsh-volume: add support for --reflink man: add --reflink man page of virsh
tools/virsh-volume.c | 16 ++++++++++++++++ tools/virsh.pod | 9 ++++++++- 2 files changed, 24 insertions(+), 1 deletion(-)
I combined the two patches, cleaned up the verbiage a bit, and pushed.
Thanks for your help. Regards, - Chen
participants (3)
-
Chen Hanxiao
-
Chen, Hanxiao
-
John Ferlan