Skip to contentSkip to conversation

xen: An error handling fix

PATCH In review Markus Armbruster 2 participants 6 messages Mar 14, 2025 – Mar 19, 2025

lore
Share & tools
lore
#0 lore raw

cover xen: An error handling fix

Question to reviewers: should PATCH 2 downgrade to warning, to info, or delete the report entirely?

Markus Armbruster (2):
hw/xen: Fix xen_bus_realize() error handling hw/xen: Downgrade a xen_bus_realize() non-error to warning

 hw/xen/xen-bus.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.48.1
#1 lore raw

PATCH 1/2 hw/xen: Fix xen_bus_realize() error handling

The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call.

xen_bus_realize() is wrong that way: it passes &local_err to xs_node_watch() in a loop. If this fails in more than one iteration, it can trip error_setv()'s assertion.

Fix by clearing @local_err.

Fixes c4583c8c394e (xen-bus: reduce scope of backend watch)
---
 hw/xen/xen-bus.c | 1 +
 1 file changed, 1 insertion(+)
hw/xen/xen-bus.c +1 -0
index 8260f1e1bb..2aacc1436f 100644
@@ -357,6 +357,7 @@ static void xen_bus_realize(BusState *bus, Error **errp)
             error_reportf_err(local_err,
                               "failed to set up '%s' enumeration watch: ",
                               type[i]);
+            local_err = NULL;
         }
 
         g_free(node);
Signature · 1 line
2.48.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] hw/xen: Fix xen_bus_realize() error handling

Quoted 6 lines · Markus Armbruster

The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call.

Quoted 8 lines

xen_bus_realize() is wrong that way: it passes &local_err to xs_node_watch() in a loop. If this fails in more than one iteration, it can trip error_setv()'s assertion.

Fix by clearing @local_err.

Fixes c4583c8c394e (xen-bus: reduce scope of backend watch)
Quoted 19 lines
---
 hw/xen/xen-bus.c | 1 +
 1 file changed, 1 insertion(+)
hw/xen/xen-bus.c +1 -0
index 8260f1e1bb..2aacc1436f 100644
@@ -357,6 +357,7 @@ static void xen_bus_realize(BusState *bus, Error **errp)
             error_reportf_err(local_err,
                               "failed to set up '%s' enumeration watch: ",
                               type[i]);
+            local_err = NULL;
         }
 
         g_free(node);
Signature · 1 line
2.48.1
#3 lore raw

PATCH 2/2 hw/xen: Downgrade a xen_bus_realize() non-error to warning

In reply to Markus Armbruster

xen_bus_realize() reports a failure to set up a watch as error, but it doesn't treat it as one: it simply continues. Report a warning instead.

---
 hw/xen/xen-bus.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
hw/xen/xen-bus.c +3 -4
index 2aacc1436f..f808a01813 100644
@@ -353,10 +353,9 @@ static void xen_bus_realize(BusState *bus, Error **errp)
             xs_node_watch(xenbus->xsh, node, key, xen_bus_backend_changed,
                           xenbus, &local_err);
         if (local_err) {
-            /* This need not be treated as a hard error so don't propagate */
-            error_reportf_err(local_err,
-                              "failed to set up '%s' enumeration watch: ",
-                              type[i]);
+            warn_reportf_err(local_err,
+                             "failed to set up '%s' enumeration watch: ",
+                             type[i]);
             local_err = NULL;
         }
 
Signature · 1 line
2.48.1
Acked-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] hw/xen: Downgrade a xen_bus_realize() non-error to warning

Quoted 5 lines · Markus Armbruster

xen_bus_realize() reports a failure to set up a watch as error, but it doesn't treat it as one: it simply continues. Report a warning instead.

Quoted 25 lines
---
 hw/xen/xen-bus.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
hw/xen/xen-bus.c +3 -4
index 2aacc1436f..f808a01813 100644
@@ -353,10 +353,9 @@ static void xen_bus_realize(BusState *bus, Error **errp)
             xs_node_watch(xenbus->xsh, node, key, xen_bus_backend_changed,
                           xenbus, &local_err);
         if (local_err) {
-            /* This need not be treated as a hard error so don't propagate */
-            error_reportf_err(local_err,
-                              "failed to set up '%s' enumeration watch: ",
-                              type[i]);
+            warn_reportf_err(local_err,
+                             "failed to set up '%s' enumeration watch: ",
+                             type[i]);
             local_err = NULL;
         }
 
Signature · 1 line
2.48.1