[PATCH] rpc: report error from filing to add timer

Daniel P. Berrangé posted 1 patch 1 month, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20240722145639.2848139-1-berrange@redhat.com
src/rpc/virnetclientstream.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] rpc: report error from filing to add timer
Posted by Daniel P. Berrangé 1 month, 2 weeks ago
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 src/rpc/virnetclientstream.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c
index 98034d737d..380b785869 100644
--- a/src/rpc/virnetclientstream.c
+++ b/src/rpc/virnetclientstream.c
@@ -725,6 +725,8 @@ int virNetClientStreamEventAddCallback(virNetClientStream *st,
                             virNetClientStreamEventTimer,
                             st,
                             virObjectUnref)) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Unable to add timer to event loop"));
         virObjectUnref(st);
         goto cleanup;
     }
-- 
2.45.2
Re: [PATCH] rpc: report error from filing to add timer
Posted by Laine Stump 1 month, 2 weeks ago
s/filing/failing/ in the summary line :-)

On 7/22/24 10:56 AM, Daniel P. Berrangé wrote:
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   src/rpc/virnetclientstream.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c
> index 98034d737d..380b785869 100644
> --- a/src/rpc/virnetclientstream.c
> +++ b/src/rpc/virnetclientstream.c
> @@ -725,6 +725,8 @@ int virNetClientStreamEventAddCallback(virNetClientStream *st,
>                               virNetClientStreamEventTimer,
>                               st,
>                               virObjectUnref)) < 0) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("Unable to add timer to event loop"));
>           virObjectUnref(st);
>           goto cleanup;
>       }

virNetClientStreamEventAddCallback() already reports an error for one of 
two possible failures (attempting to add a timer callback when one is 
already set). Would it maybe be more appropriate to instead add an error 
message when the 2nd half of virNetClientStreamEventAddCallback() (a 
call to virEventAddTimeout()) fails?

(It does look like virEventAddTimeout() itself doesn't log errors. 
Although a separate issue, I also noticed that some of the other places 
that call virEventAddTimeout() log an error when it fails, and some of 
them don't.)