---
tools/virsh.c | 12 +++++++++++-
tools/virsh.pod | 6 +++++-
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 3cdf043..f81e923 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1409,6 +1409,7 @@ static const vshCmdInfo info_undefine[] = {
static const vshCmdOptDef opts_undefine[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name or
uuid")},
+ {"undefine-managed-state", VSH_OT_BOOL, 0, N_("remove domain managed
state file")},
{NULL, 0, 0, NULL}
};
@@ -1419,6 +1420,14 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
bool ret = true;
const char *name = NULL;
int id;
+ int flags = 0;
+ int undefine_managed_state = vshCommandOptBool(cmd,
"undefine-managed-state");
+
+ if (undefine_managed_state)
+ flags |= VIR_DOMAIN_UNDEFINE_MANAGED_STATE;
+
+ if (!undefine_managed_state)
+ flags = -1;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
@@ -1440,7 +1449,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
VSH_BYNAME|VSH_BYUUID)))
return false;
- if (virDomainUndefine(dom) == 0) {
+ if (((flags == -1) ? virDomainUndefine(dom) :
+ virDomainUndefineWithFlags(dom, flags)) == 0) {
vshPrint(ctl, _("Domain %s has been undefined\n"), name);
} else {
vshError(ctl, _("Failed to undefine domain %s"), name);
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 8b820d2..393d014 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -804,11 +804,15 @@ hypervisor.
Output the device used for the TTY console of the domain. If the information
is not available the processes will provide an exit code of 1.
-=item B<undefine> I<domain-id>
+=item B<undefine> I<domain-id> optional I<--undefine-managed-state>
Undefine the configuration for an inactive domain. Since it's not running
the domain name or UUID must be used as the I<domain-id>.
+If I<--undefine-managed-state> is specified, the managed state file will
+be removed along with the domain undefine peocess, the entire domain
+undefine process will fail if it fails on removing the managed state file.
+
=item B<vcpucount> I<domain-id> optional I<--maximum>
I<--current>
I<--config> I<--live>
--
1.7.6