When domain startup fails, domain cleanup calls libxlNetworkUnwindDevices, which calls virGetConnectNetwork, which is a top level API entry point, which resets the initial saved error, leading to clients seeing: error: An error occurred, but the cause is unknown This preserves the error from before virGetConnectNetwork is called. Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx> --- src/libxl/libxl_domain.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 17b347de4e..bda110e9e6 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -830,12 +830,17 @@ libxlNetworkUnwindDevices(virDomainDef *def) /* cleanup actual device */ virDomainNetRemoveHostdev(def, net); if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) { - g_autoptr(virConnect) conn = virGetConnectNetwork(); + g_autoptr(virConnect) conn = NULL; + virErrorPtr save_err; + + virErrorPreserveLast(&save_err); + conn = virGetConnectNetwork(); if (conn) virDomainNetReleaseActualDevice(conn, def, net); else VIR_WARN("Unable to release network device '%s'", NULLSTR(net->ifname)); + virErrorRestore(&save_err); } } } -- 2.36.1