On Thu, Jan 08, 2015 at 15:48:22 +0000, Daniel Berrange wrote:
The 'virsh define', 'virsh create' and 'virsh
edit' commands
get XML validation enabled by default, with a --skip-validate
option to disable it.
Hmm, I definitely agree with enabling validation for 'virsh edit', which
is something users run interactively. However, enabling it by default
for create and define is something that is likely to cause issues for
scripts that use virsh. I suggest adding --validate option for them so
that it can be enabled by validation should be turned of by default for
them.
The quality of error reporting from libxml2 varies depending
on the type of XML error made. Sometimes it is quite clear
and useful, other times it is obscure & inaccurate. At least
the user will see an error now, rather than having their
XML modification silently disappear.
---
tests/cpuset | 2 +-
tools/virsh-domain.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++------
2 files changed, 79 insertions(+), 10 deletions(-)
...
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 750411b..a652942 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
...
@@ -7184,11 +7238,10 @@ cmdCreate(vshControl *ctl, const vshCmd
*cmd)
flags |= VIR_DOMAIN_START_PAUSED;
if (vshCommandOptBool(cmd, "autodestroy"))
flags |= VIR_DOMAIN_START_AUTODESTROY;
+ if (vshCommandOptBool(cmd, "skip-validate"))
+ flags &= ~VIR_DOMAIN_DEFINE_VALIDATE;
s/VIR_DOMAIN_DEFINE_VALIDATE/VIR_DOMAIN_START_VALIDATE/
- if (nfds)
- dom = virDomainCreateXMLWithFiles(ctl->conn, buffer, nfds, fds, flags);
- else
- dom = virDomainCreateXML(ctl->conn, buffer, flags);
+ dom = vshDomainCreateXML(ctl->conn, buffer, nfds, fds, flags);
if (!dom) {
vshError(ctl, _("Failed to create domain from %s"), from);
Jirka