[libvirt] [PATCH] virsh: Fix checking for reconnect conditions
Eric Blake
eblake at redhat.com
Mon Jan 2 16:47:24 UTC 2012
On 01/02/2012 09:15 AM, Peter Krempa wrote:
> virshReportError() function frees the most recent error reported from
> libvirt. Condition that checks if connection to the daemon was broken
> during last command was then limited to check for SIGPIPE signal not
> taking into account possible errors signalized without SIGPIPE.
>
> This patch moves the check before the error is freed, to take into
> account code that does not emit SIGPIPE while failing.
>
> * tools/virsh.c: - move check for broken connection before error print.
> ---
> tools/virsh.c | 21 ++++++++++++---------
> 1 files changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/tools/virsh.c b/tools/virsh.c
> index e089f7b..2ed1186 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -17041,20 +17041,23 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd)
> if (enable_timing)
> GETTIMEOFDAY(&after);
>
> + /* try to automatically catch disconnections */
> + if (!ret &&
> + ((last_error != NULL) &&
> + (((last_error->code == VIR_ERR_SYSTEM_ERROR) &&
> + (last_error->domain == VIR_FROM_REMOTE)) ||
> + (last_error->code == VIR_ERR_RPC) ||
> + (last_error->code == VIR_ERR_NO_CONNECT) ||
> + (last_error->code == VIR_ERR_INVALID_CONN))))
> + disconnected++;
> +
> if (!ret)
> virshReportError(ctl);
>
> - /* try to automatically catch disconnections */
> - if (!ret &&
> - ((disconnected != 0) ||
> - ((last_error != NULL) &&
> - (((last_error->code == VIR_ERR_SYSTEM_ERROR) &&
> - (last_error->domain == VIR_FROM_REMOTE)) ||
> - (last_error->code == VIR_ERR_RPC) ||
> - (last_error->code == VIR_ERR_NO_CONNECT) ||
> - (last_error->code == VIR_ERR_INVALID_CONN)))))
> + if (!ret && disconnected != 0)
> vshReconnect(ctl);
>
> +
> if (STREQ(cmd->def->name, "quit")) /* hack ... */
Why the blank line added there? ACK with that nit fixed.
--
Eric Blake eblake at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120102/0c79eb45/attachment-0001.sig>
More information about the libvir-list
mailing list