From ed5950909d99cb9e4ce73cb3044370b3c5d7d58a Mon Sep 17 00:00:00 2001 From: Li Yang Date: Wed, 14 May 2014 02:15:37 -0400 Subject: [PATCH] virsh: reject undefine --wipe-storage without also naming storage For now, if only '--wipe-storage' is assigned, user can undefine a domain normally. But actually '--wipe-storage' doesn't do anything, and this may confuse user. Better is to require that '--wipe-storage' only works if the user specifies volumes to be removed. Before: $ virsh undefine virt-tests-vm1 --wipe-storage Domain virt-tests-vm1 has been undefined After: $ virsh undefine virt-tests-vm1 --wipe-storage error: '--wipe-storage' requires '--storage ' or '--remove-all-storage' Signed-off-by: Li Yang Signed-off-by: Eric Blake --- tools/virsh-domain.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index d8183ee580..84a6706e6c 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -2979,9 +2979,15 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) size_t i; size_t j; - ignore_value(vshCommandOptString(cmd, "storage", &vol_string)); + if (!(vol_string || remove_all_storage) && wipe_storage) { + vshError(ctl, + _("'--wipe-storage' requires '--storage ' or " + "'--remove-all-storage'")); + return false; + } + if (managed_save) { flags |= VIR_DOMAIN_UNDEFINE_MANAGED_SAVE; managed_save_safe = true; -- GitLab