提交 b5e0532e 编写于 作者: J Jiri Denemark

qemu: Make qemuProcess{Start,Stop}CPUs easier to follow

As a side effect, the return value of qemuDomainObjEnterMonitorAsync is
not directly used as the return value of qemuProcess{Start,Stop}CPUs.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
上级 dca377db
...@@ -2747,23 +2747,26 @@ qemuProcessStartCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm, ...@@ -2747,23 +2747,26 @@ qemuProcessStartCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm,
} }
VIR_FREE(priv->lockState); VIR_FREE(priv->lockState);
ret = qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob); if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
if (ret == 0) { goto release;
ret = qemuMonitorStartCPUs(priv->mon, conn);
qemuDomainObjExitMonitor(driver, vm);
}
if (ret == 0) { ret = qemuMonitorStartCPUs(priv->mon, conn);
virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason); qemuDomainObjExitMonitor(driver, vm);
} else {
if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState) < 0) if (ret < 0)
VIR_WARN("Unable to release lease on %s", vm->def->name); goto release;
VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));
} virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason);
cleanup: cleanup:
virObjectUnref(cfg); virObjectUnref(cfg);
return ret; return ret;
release:
if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState) < 0)
VIR_WARN("Unable to release lease on %s", vm->def->name);
VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));
goto cleanup;
} }
...@@ -2771,24 +2774,26 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm, ...@@ -2771,24 +2774,26 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm,
virDomainPausedReason reason, virDomainPausedReason reason,
enum qemuDomainAsyncJob asyncJob) enum qemuDomainAsyncJob asyncJob)
{ {
int ret; int ret = -1;
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
VIR_FREE(priv->lockState); VIR_FREE(priv->lockState);
ret = qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob); if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
if (ret == 0) { goto cleanup;
ret = qemuMonitorStopCPUs(priv->mon);
qemuDomainObjExitMonitor(driver, vm);
}
if (ret == 0) { ret = qemuMonitorStopCPUs(priv->mon);
virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, reason); qemuDomainObjExitMonitor(driver, vm);
if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState) < 0)
VIR_WARN("Unable to release lease on %s", vm->def->name);
VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));
}
if (ret < 0)
goto cleanup;
virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, reason);
if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState) < 0)
VIR_WARN("Unable to release lease on %s", vm->def->name);
VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));
cleanup:
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册