mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virsh: Add --delete-snapshots flag for undefine and vol-delete
https://bugzilla.redhat.com/show_bug.cgi?id=1281710 Commit id '3c7590e0a' added the flag to the rbd backend, but provided no means via virsh to use the flag. This patch adds a '--delete-snapshots' option to both the "undefine" and "vol-delete" commands. For "undefine", the flag is combined with the "--remove-all-storage" flag in order to add the appropriate flag for the virStorageVolDelete call; whereas, for the "vol-delete" command, just the flag is sufficient since it's only operating on one volume. Currently only supported for rbd backends.
This commit is contained in:
@@ -887,6 +887,11 @@ static const vshCmdOptDef opts_vol_delete[] = {
|
||||
.type = VSH_OT_STRING,
|
||||
.help = N_("pool name or uuid")
|
||||
},
|
||||
{.name = "delete-snapshots",
|
||||
.type = VSH_OT_BOOL,
|
||||
.help = N_("delete snapshots associated with volume (must be "
|
||||
"supported by storage driver)")
|
||||
},
|
||||
{.name = NULL}
|
||||
};
|
||||
|
||||
@@ -896,11 +901,16 @@ cmdVolDelete(vshControl *ctl, const vshCmd *cmd)
|
||||
virStorageVolPtr vol;
|
||||
bool ret = true;
|
||||
const char *name;
|
||||
bool delete_snapshots = vshCommandOptBool(cmd, "delete-snapshots");
|
||||
unsigned int flags = 0;
|
||||
|
||||
if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
|
||||
return false;
|
||||
|
||||
if (virStorageVolDelete(vol, 0) == 0) {
|
||||
if (delete_snapshots)
|
||||
flags |= VIR_STORAGE_VOL_DELETE_WITH_SNAPSHOTS;
|
||||
|
||||
if (virStorageVolDelete(vol, flags) == 0) {
|
||||
vshPrint(ctl, _("Vol %s deleted\n"), name);
|
||||
} else {
|
||||
vshError(ctl, _("Failed to delete vol %s"), name);
|
||||
|
||||
Reference in New Issue
Block a user