On Tue, Jul 29, 2008 at 01:27:42PM +0100, Richard W.M. Jones wrote:
but with much more sanity checking. The editor is $EDITOR or vi,
and
it does the right thing if the user doesn't modify the file, or if
another user edits the configuration at the same time.
[...]
+ /* Compare original XML with edited. Has it changed at all? */
+ if (STREQ (doc, doc_edited)) {
+ vshPrint(ctl, _("Domain %s XML configuration not changed.\n"),
+ virDomainGetName (dom));
+ ret = TRUE;
+ goto cleanup;
+ }
Hum, I would check for basic well-formedness here because it just
too easy to break the XML file while editing with a text editor
http://xmlsoft.org/html/libxml-parser.html#xmlReadMemory
if the call fails to build a parsed document suggest to reedit from
scratch, based on the current buffer or just abort the edit.
Numerous newbies will get trapped in vi, get lost and looking for
a safe exit path :-)
Daniel
--
Red Hat Virtualization group
http://redhat.com/virtualization/
Daniel Veillard | virtualization library
http://libvirt.org/
veillard(a)redhat.com | libxml GNOME XML XSLT toolkit
http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine
http://rpmfind.net/