mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-27 23:15:18 +00:00
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: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
dca377dbd6
commit
b5e0532e04
@ -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);
|
ret = qemuMonitorStartCPUs(priv->mon, conn);
|
||||||
qemuDomainObjExitMonitor(driver, vm);
|
qemuDomainObjExitMonitor(driver, vm);
|
||||||
}
|
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret < 0)
|
||||||
|
goto release;
|
||||||
|
|
||||||
virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason);
|
virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason);
|
||||||
} else {
|
|
||||||
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:
|
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,
|
|||||||
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);
|
ret = qemuMonitorStopCPUs(priv->mon);
|
||||||
qemuDomainObjExitMonitor(driver, vm);
|
qemuDomainObjExitMonitor(driver, vm);
|
||||||
}
|
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, reason);
|
virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, reason);
|
||||||
if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState) < 0)
|
if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState) < 0)
|
||||||
VIR_WARN("Unable to release lease on %s", vm->def->name);
|
VIR_WARN("Unable to release lease on %s", vm->def->name);
|
||||||
VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));
|
VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));
|
||||||
}
|
|
||||||
|
|
||||||
|
cleanup:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user