mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: Obtain job before checking if domain is live
Since obtaining a job can wait for another job to finish, the state might change in the meantime. And checking it more than once is pointless. Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
8264c70e0b
commit
a781eae8c1
@ -5388,25 +5388,19 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_VCPU_GUEST) {
|
if (flags & VIR_DOMAIN_VCPU_GUEST) {
|
||||||
|
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (!virDomainObjIsActive(vm)) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
_("vCPU count provided by the guest agent can only be "
|
_("vCPU count provided by the guest agent can only be "
|
||||||
"requested for live domains"));
|
"requested for live domains"));
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (!qemuDomainAgentAvailable(vm, true))
|
if (!qemuDomainAgentAvailable(vm, true))
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
||||||
_("domain is not running"));
|
|
||||||
goto endjob;
|
|
||||||
}
|
|
||||||
|
|
||||||
qemuDomainObjEnterAgent(vm);
|
qemuDomainObjEnterAgent(vm);
|
||||||
ncpuinfo = qemuAgentGetVCPUs(priv->agent, &cpuinfo);
|
ncpuinfo = qemuAgentGetVCPUs(priv->agent, &cpuinfo);
|
||||||
qemuDomainObjExitAgent(vm);
|
qemuDomainObjExitAgent(vm);
|
||||||
@ -17796,10 +17790,13 @@ qemuDomainPMSuspendForDuration(virDomainPtr dom,
|
|||||||
if (virDomainPMSuspendForDurationEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainPMSuspendForDurationEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (!virDomainObjIsActive(vm)) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
"%s", _("domain is not running"));
|
"%s", _("domain is not running"));
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_WAKEUP) &&
|
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_WAKEUP) &&
|
||||||
@ -17808,7 +17805,7 @@ qemuDomainPMSuspendForDuration(virDomainPtr dom,
|
|||||||
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
||||||
_("Unable to suspend domain due to "
|
_("Unable to suspend domain due to "
|
||||||
"missing system_wakeup monitor command"));
|
"missing system_wakeup monitor command"));
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm->def->pm.s3 || vm->def->pm.s4) {
|
if (vm->def->pm.s3 || vm->def->pm.s4) {
|
||||||
@ -17817,29 +17814,20 @@ qemuDomainPMSuspendForDuration(virDomainPtr dom,
|
|||||||
target == VIR_NODE_SUSPEND_TARGET_HYBRID)) {
|
target == VIR_NODE_SUSPEND_TARGET_HYBRID)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("S3 state is disabled for this domain"));
|
_("S3 state is disabled for this domain"));
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm->def->pm.s4 == VIR_TRISTATE_BOOL_NO &&
|
if (vm->def->pm.s4 == VIR_TRISTATE_BOOL_NO &&
|
||||||
target == VIR_NODE_SUSPEND_TARGET_DISK) {
|
target == VIR_NODE_SUSPEND_TARGET_DISK) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("S4 state is disabled for this domain"));
|
_("S4 state is disabled for this domain"));
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (!qemuDomainAgentAvailable(vm, true))
|
if (!qemuDomainAgentAvailable(vm, true))
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
"%s", _("domain is not running"));
|
|
||||||
goto endjob;
|
|
||||||
}
|
|
||||||
|
|
||||||
qemuDomainObjEnterAgent(vm);
|
qemuDomainObjEnterAgent(vm);
|
||||||
ret = qemuAgentSuspend(priv->agent, target);
|
ret = qemuAgentSuspend(priv->agent, target);
|
||||||
qemuDomainObjExitAgent(vm);
|
qemuDomainObjExitAgent(vm);
|
||||||
@ -17942,24 +17930,18 @@ qemuDomainQemuAgentCommand(virDomainPtr domain,
|
|||||||
if (virDomainQemuAgentCommandEnsureACL(domain->conn, vm->def) < 0)
|
if (virDomainQemuAgentCommandEnsureACL(domain->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
"%s", _("domain is not running"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
|
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!qemuDomainAgentAvailable(vm, true))
|
|
||||||
goto endjob;
|
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (!virDomainObjIsActive(vm)) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
"%s", _("domain is not running"));
|
"%s", _("domain is not running"));
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!qemuDomainAgentAvailable(vm, true))
|
||||||
|
goto endjob;
|
||||||
|
|
||||||
qemuDomainObjEnterAgent(vm);
|
qemuDomainObjEnterAgent(vm);
|
||||||
ret = qemuAgentArbitraryCommand(priv->agent, cmd, &result, timeout);
|
ret = qemuAgentArbitraryCommand(priv->agent, cmd, &result, timeout);
|
||||||
qemuDomainObjExitAgent(vm);
|
qemuDomainObjExitAgent(vm);
|
||||||
|
Loading…
Reference in New Issue
Block a user