Add a 'crashed' label to reuse the cleanup path on domain crash.
---
src/qemu/qemu_hotplug.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index f4eca30..f5490e2 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1508,29 +1508,20 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
qemuDomainObjEnterMonitor(driver, vm);
if (qemuMonitorAttachCharDev(priv->mon, charAlias, &chr->source) < 0) {
- if (qemuDomainObjExitMonitor(driver, vm) < 0) {
- need_remove = false;
- ret = -1;
- goto cleanup;
- }
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
+ goto crashed;
goto audit;
}
if (devstr && qemuMonitorAddDevice(priv->mon, devstr) < 0) {
/* detach associated chardev on error */
qemuMonitorDetachCharDev(priv->mon, charAlias);
- if (qemuDomainObjExitMonitor(driver, vm) < 0) {
- need_remove = false;
- ret = -1;
- goto cleanup;
- }
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
+ goto crashed;
goto audit;
}
- if (qemuDomainObjExitMonitor(driver, vm) < 0) {
- need_remove = false;
- ret = -1;
- goto cleanup;
- }
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
+ goto crashed;
ret = 0;
audit:
@@ -1545,6 +1536,11 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
VIR_FREE(charAlias);
VIR_FREE(devstr);
return ret;
+
+ crashed:
+ need_remove = false;
+ ret = -1;
+ goto cleanup;
}
static int
--
2.0.5