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:
Peter Krempa committed 2026-04-15 14:02:04 +02:00
1 parent 47ed93c216
commit 6499c0a28f
2 files changed
+13 -1

No files matched your search

+7
View File
@@ -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;