When editing a domain with 'virsh edit' and failing validation, the
usual message pops up:
Failed. Try again? [y,n,f,?]:
The option 'f' (force) is pretty unusable. It tries to step into the
same puddle again and again when it can at least try to force the
definition.
This patch adds support for relaxing definition in virsh-edit and makes
'virsh edit <domain>' more usable, mainly for testing.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
tools/virsh-domain.c | 5 +++++
tools/virsh-edit.c | 5 ++++-
tools/virsh.c | 4 ++--
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 2506b89..3dd676c 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -11265,6 +11265,11 @@ cmdEdit(vshControl *ctl, const vshCmd *cmd)
} while (0)
#define EDIT_DEFINE \
(dom_edited = vshDomainDefine(ctl->conn, doc_edited, define_flags))
+#define EDIT_RELAX \
+ do { \
+ define_flags &= ~VIR_DOMAIN_DEFINE_VALIDATE; \
+ } while (0);
+
#include "virsh-edit.c"
vshPrint(ctl, _("Domain %s XML configuration edited.\n"),
diff --git a/tools/virsh-edit.c b/tools/virsh-edit.c
index 41a6d53..3186998 100644
--- a/tools/virsh-edit.c
+++ b/tools/virsh-edit.c
@@ -1,7 +1,7 @@
/*
* virsh-edit.c: Implementation of generic virsh *-edit intelligence
*
- * Copyright (C) 2012 Red Hat, Inc.
+ * Copyright (C) 2012, 2015 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -119,6 +119,9 @@ do {
break;
case 'f':
+#ifdef EDIT_RELAX
+ EDIT_RELAX;
+#endif
goto redefine;
break;
diff --git a/tools/virsh.c b/tools/virsh.c
index aba34ce..5b154e1 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1,7 +1,7 @@
/*
* virsh.c: a shell to exercise the libvirt API
*
- * Copyright (C) 2005, 2007-2014 Red Hat, Inc.
+ * Copyright (C) 2005, 2007-2015 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -541,7 +541,7 @@ vshAskReedit(vshControl *ctl, const char *msg)
"",
_("y - yes, start editor again"),
_("n - no, throw away my changes"),
- _("f - force, try to redefine again"),
+ _("f - force, try to redefine again (without
validation)"),
_("? - print this help"),
NULL);
continue;
--
2.3.0