If starting a CH domain fails an error is reported and
virCHProcessStart() calls virCHProcessStop() to clean up any
residues. Problem is, inside of virCHProcessStop() some public
APIs might be called (e.g. virNetworkLookupByName(),
virNetworkPortLookupByUUID() and/or virNetworkPortDelete()). Per
our design, public APIs reset last error which means the useful
error reported earlier is lost.
Fix this by calling virErrorPreserveLast() + virErrorRestore()
combo inside of virCHProcessStop().
Signed-off-by: Kirill Shchetiniuk <kshcheti@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
unsigned int hostdev_flags = VIR_HOSTDEV_SP_PCI;
virCHDomainObjPrivate *priv = vm->privateData;
virDomainDef *def = vm->def;
+ virErrorPtr orig_err = NULL;
size_t i;
VIR_DEBUG("Stopping VM name=%s pid=%d reason=%d",
vm->def->name, (int)vm->pid, (int)reason);
+ virErrorPreserveLast(&orig_err);
+
if (priv->monitor) {
g_clear_pointer(&priv->monitor, virCHMonitorClose);
}
virHostdevReAttachDomainDevices(driver->hostdevMgr, CH_DRIVER_NAME, def,
hostdev_flags);
+
+ virErrorRestore(&orig_err);
return 0;
}