mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
virsh-volume: add support for --reflink
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>
This commit is contained in:
parent
47dd6c4335
commit
219ea41d8d
@ -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"));
|
||||
|
@ -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>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user