[PATCH 8/8] tools: virsh: Reset error when keepalive registration fails

Peter Krempa posted 8 patches 5 years, 2 months ago
[PATCH 8/8] tools: virsh: Reset error when keepalive registration fails
Posted by Peter Krempa 5 years, 2 months ago
We try to enable keepalive oportunistically. If it's not supported by
the connection driver and it was not explicitly requested we keep the
error object set and can report it in some cases accidentally:

--- stdout ---
TEST: /home/pipo/libvirt/tests/virsh-self-test
      !                                        1   FAILED
--- stderr ---
error: parameter 'target' of command 'attach-disk' must be listed before optional parameters
error: this function is not supported by the connection driver: virConnectSetKeepAlive
-------

Clear the stored libvirt error.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 tools/virsh.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/virsh.c b/tools/virsh.c
index 954778b626..a6bfbbbb87 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -176,6 +176,7 @@ virshConnect(vshControl *ctl, const char *uri, bool readonly)
         }
         vshDebug(ctl, VSH_ERR_INFO, "%s",
                  _("Failed to setup keepalive on connection\n"));
+        vshResetLibvirtError();
     }

  cleanup:
-- 
2.28.0

Re: [PATCH 8/8] tools: virsh: Reset error when keepalive registration fails
Posted by Ján Tomko 5 years, 2 months ago
On a Thursday in 2020, Peter Krempa wrote:
>We try to enable keepalive oportunistically. If it's not supported by

*opportunistically

>the connection driver and it was not explicitly requested we keep the
>error object set and can report it in some cases accidentally:

I was going to complain about the trailing ':' when I realized 'git am'
dropped everything below. Consider indenting it or using a different
separator.

Jano
>
>--- stdout ---
>TEST: /home/pipo/libvirt/tests/virsh-self-test
>      !                                        1   FAILED
>--- stderr ---
>error: parameter 'target' of command 'attach-disk' must be listed before optional parameters
>error: this function is not supported by the connection driver: virConnectSetKeepAlive
>-------
>
>Clear the stored libvirt error.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> tools/virsh.c | 1 +
> 1 file changed, 1 insertion(+)
Re: [PATCH 8/8] tools: virsh: Reset error when keepalive registration fails
Posted by Peter Krempa 5 years, 2 months ago
On Thu, Nov 12, 2020 at 16:17:22 +0100, Ján Tomko wrote:
> On a Thursday in 2020, Peter Krempa wrote:
> > We try to enable keepalive oportunistically. If it's not supported by
> 
> *opportunistically
> 
> > the connection driver and it was not explicitly requested we keep the
> > error object set and can report it in some cases accidentally:
> 
> I was going to complain about the trailing ':' when I realized 'git am'
> dropped everything below. Consider indenting it or using a different
> separator.

oops, I've copypasted from test output and it didn't occur to me.

> 
> Jano
> > 
> > --- stdout ---
> > TEST: /home/pipo/libvirt/tests/virsh-self-test
> >      !                                        1   FAILED
> > --- stderr ---
> > error: parameter 'target' of command 'attach-disk' must be listed before optional parameters
> > error: this function is not supported by the connection driver: virConnectSetKeepAlive
> > -------
> > 
> > Clear the stored libvirt error.
> > 
> > Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> > ---
> > tools/virsh.c | 1 +
> > 1 file changed, 1 insertion(+)