提交 6f08cbb8 编写于 作者: J Jiri Denemark

qemu: Simplify error handling in qemuProcessReconnect

Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
上级 8c9ff996
...@@ -3341,6 +3341,7 @@ qemuProcessReconnect(void *opaque) ...@@ -3341,6 +3341,7 @@ qemuProcessReconnect(void *opaque)
size_t i; size_t i;
int ret; int ret;
unsigned int stopFlags = 0; unsigned int stopFlags = 0;
bool jobStarted = false;
VIR_FREE(data); VIR_FREE(data);
...@@ -3351,13 +3352,14 @@ qemuProcessReconnect(void *opaque) ...@@ -3351,13 +3352,14 @@ qemuProcessReconnect(void *opaque)
cfg = virQEMUDriverGetConfig(driver); cfg = virQEMUDriverGetConfig(driver);
priv = obj->privateData; priv = obj->privateData;
if (qemuDomainObjBeginJob(driver, obj, QEMU_JOB_MODIFY) < 0)
goto error;
jobStarted = true;
/* XXX If we ever gonna change pid file pattern, come up with /* XXX If we ever gonna change pid file pattern, come up with
* some intelligence here to deal with old paths. */ * some intelligence here to deal with old paths. */
if (!(priv->pidfile = virPidFileBuildPath(cfg->stateDir, obj->def->name))) if (!(priv->pidfile = virPidFileBuildPath(cfg->stateDir, obj->def->name)))
goto killvm; goto error;
if (qemuDomainObjBeginJob(driver, obj, QEMU_JOB_MODIFY) < 0)
goto killvm;
virNWFilterReadLockFilterUpdates(); virNWFilterReadLockFilterUpdates();
...@@ -3427,7 +3429,6 @@ qemuProcessReconnect(void *opaque) ...@@ -3427,7 +3429,6 @@ qemuProcessReconnect(void *opaque)
VIR_DEBUG("Finishing shutdown sequence for domain %s", VIR_DEBUG("Finishing shutdown sequence for domain %s",
obj->def->name); obj->def->name);
qemuProcessShutdownOrReboot(driver, obj); qemuProcessShutdownOrReboot(driver, obj);
qemuDomainObjEndJob(driver, obj);
goto cleanup; goto cleanup;
} }
...@@ -3500,12 +3501,18 @@ qemuProcessReconnect(void *opaque) ...@@ -3500,12 +3501,18 @@ qemuProcessReconnect(void *opaque)
if (virAtomicIntInc(&driver->nactive) == 1 && driver->inhibitCallback) if (virAtomicIntInc(&driver->nactive) == 1 && driver->inhibitCallback)
driver->inhibitCallback(true, driver->inhibitOpaque); driver->inhibitCallback(true, driver->inhibitOpaque);
qemuDomainObjEndJob(driver, obj); cleanup:
goto cleanup; if (jobStarted)
qemuDomainObjEndJob(driver, obj);
if (!virDomainObjIsActive(obj))
qemuDomainRemoveInactive(driver, obj);
virDomainObjEndAPI(&obj);
virObjectUnref(conn);
virObjectUnref(cfg);
virNWFilterUnlockFilterUpdates();
return;
error: error:
qemuDomainObjEndJob(driver, obj);
killvm:
if (virDomainObjIsActive(obj)) { if (virDomainObjIsActive(obj)) {
/* We can't get the monitor back, so must kill the VM /* We can't get the monitor back, so must kill the VM
* to remove danger of it ending up running twice if * to remove danger of it ending up running twice if
...@@ -3523,14 +3530,7 @@ qemuProcessReconnect(void *opaque) ...@@ -3523,14 +3530,7 @@ qemuProcessReconnect(void *opaque)
} }
qemuProcessStop(driver, obj, state, stopFlags); qemuProcessStop(driver, obj, state, stopFlags);
} }
goto cleanup;
qemuDomainRemoveInactive(driver, obj);
cleanup:
virDomainObjEndAPI(&obj);
virObjectUnref(conn);
virObjectUnref(cfg);
virNWFilterUnlockFilterUpdates();
} }
static int static int
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册