On 05/09/2012 07:52 AM, Daniel P. Berrange wrote:
On Wed, May 09, 2012 at 03:36:26PM +0200, Michal Privoznik wrote:
> If users {net-,pool-,}edit but make a mistake in XML all changes
> are permanently lost. However, if virsh is running in interactive
> mode we can as user if he wants to re-edit the file and correct
> the mistakes.
> ---
> + dom_edited = virDomainDefineXML(ctl->conn, doc_edited);
> + if (!dom_edited) {
> + /* Redefine failed. If we are in interactive mode ask user
> + * if he wants to re-edit the XML. */
> + if (!ctl->imode ||
> + vshMakeStdinRaw(&ttyattr, false) < 0)
> + goto cleanup;
I don't see why this has to be restricted to interactive mode
only. I almost always just run
virsh edit foo
and there's no reason why we can't prompt to re-edit here too.
What you want to check is isatty(STDIN) so you can distinguish
batch scripting.
And given that I don't want to bump to a new gnulib version until after
0.9.12, that means we probably should delay an isatty() solution until
after this patch is in:
https://www.redhat.com/archives/libvir-list/2012-May/msg00402.html
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org