Re: [PATCH] xen/manage: unwind partial shutdown watcher setup on error

From: Stefano Stabellini

Date: Wed Apr 08 2026 - 21:43:02 EST


On Tue, 7 Apr 2026, zhaoguohan@xxxxxxxxxx wrote:
> From: GuoHan Zhao <zhaoguohan@xxxxxxxxxx>
>
> setup_shutdown_watcher() registers shutdown_watch first, then the sysrq
> watch, and finally publishes the supported feature-* nodes in xenstore.
> If sysrq watch registration fails, or xenbus_printf() fails after one or
> more feature nodes were created, the function returns immediately without
> undoing the earlier setup.
>
> This leaves the system in a partially initialized state, with registered
> watches and/or stale xenstore entries despite the function reporting
> failure.
>
> Unwind the partial setup before returning an error by unregistering any
> watches that were already registered and removing feature nodes that were
> already published.
>
> Signed-off-by: GuoHan Zhao <zhaoguohan@xxxxxxxxxx>

Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>