mirror of
https://github.com/libvirt/libvirt.git
synced 2026-10-02 12:20:06 -05:00
virsh: blockresize: Introduce '--extend' flag
Use the new VIR_DOMAIN_BLOCK_RESIZE_EXTEND to prevent accidentally shrinking a disk and thus destroying data. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
1 parent
47ed93c216
commit
6499c0a28f
2 files changed
+13
-1
No files matched your search
@@ -1642,7 +1642,7 @@ blockresize
|
||||
|
||||
::
|
||||
|
||||
blockresize domain path ([size] | [--capacity])
|
||||
blockresize domain path ([size] | [--capacity]) [--extend]
|
||||
|
||||
Resize a block device of domain while the domain is running, *path*
|
||||
specifies the absolute path of the block device; it corresponds
|
||||
@@ -1650,6 +1650,11 @@ to a unique target name (<target dev='name'/>) or source file (<source
|
||||
file='name'/>) for one of the disk devices attached to *domain* (see
|
||||
also ``domblklist`` for listing these names).
|
||||
|
||||
The *--extend* flag instructs the hypervisor to ensure that the new size isn't
|
||||
smaller than the old size, thus prevents (accidental) shrinking of the block
|
||||
device which may lead to data loss. Users are encouraged to always use this
|
||||
flag unless communicating with an older hypervisor.
|
||||
|
||||
For image formats without metadata (raw) stored inside fixed-size storage (e.g.
|
||||
block devices) the --capacity flag can be used to resize the device to the
|
||||
full size of the backing device.
|
||||
|
||||
@@ -3339,6 +3339,10 @@ static const vshCmdOptDef opts_blockresize[] = {
|
||||
.type = VSH_OT_BOOL,
|
||||
.help = N_("resize to capacity of source (block device)")
|
||||
},
|
||||
{.name = "extend",
|
||||
.type = VSH_OT_BOOL,
|
||||
.help = N_("ensure that the new size is larger than actual capacity (prevent shrink)")
|
||||
},
|
||||
{.name = NULL}
|
||||
};
|
||||
|
||||
@@ -3352,6 +3356,9 @@ cmdBlockresize(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
VSH_ALTERNATIVE_OPTIONS("size", "capacity");
|
||||
|
||||
if (vshCommandOptBool(cmd, "extend"))
|
||||
flags |= VIR_DOMAIN_BLOCK_RESIZE_EXTEND;
|
||||
|
||||
if (vshCommandOptString(ctl, cmd, "path", (const char **) &path) < 0)
|
||||
return false;
|
||||
|
||||
|
||||
Reference in new issue
Block a user