mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
Introduce VIR_DOMAIN_PAUSED_API_ERROR
Some APIs (migration, save/restore, snapshot, ...) require a domain to be suspended temporarily. In case resuming the domain fails, the domain will be unexpectedly left paused when the API finishes. This situation is reported via VIR_DOMAIN_EVENT_SUSPENDED event with VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR detail. But we do not have a corresponding reason for VIR_DOMAIN_PAUSED state and the reason would remain set to the value used when the domain was paused. So the state reason would suggest the operation is still running. This patch changes the state reason to a new VIR_DOMAIN_PAUSED_API_ERROR to make it clear the API that paused the domain already finished, but failed to resume the domain. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
6414046e9c
commit
b1b037fa5b
@ -148,6 +148,7 @@ typedef enum {
|
||||
VIR_DOMAIN_PAUSED_STARTING_UP = 11, /* the domain is being started (Since: 1.2.14) */
|
||||
VIR_DOMAIN_PAUSED_POSTCOPY = 12, /* paused for post-copy migration (Since: 1.3.3) */
|
||||
VIR_DOMAIN_PAUSED_POSTCOPY_FAILED = 13, /* paused after failed post-copy (Since: 1.3.3) */
|
||||
VIR_DOMAIN_PAUSED_API_ERROR = 14, /* Some APIs (e.g., migration, snapshot) internally need to suspend a domain. This paused state reason is used when resume operation at the end of such API fails. (Since: 9.2.0) */
|
||||
|
||||
# ifdef VIR_ENUM_SENTINELS
|
||||
VIR_DOMAIN_PAUSED_LAST /* (Since: 0.9.10) */
|
||||
|
@ -1163,6 +1163,7 @@ VIR_ENUM_IMPL(virDomainPausedReason,
|
||||
"starting up",
|
||||
"post-copy",
|
||||
"post-copy failed",
|
||||
"api error",
|
||||
);
|
||||
|
||||
VIR_ENUM_IMPL(virDomainShutdownReason,
|
||||
|
@ -11376,6 +11376,9 @@ qemuDomainPausedReasonToSuspendedEvent(virDomainPausedReason reason)
|
||||
case VIR_DOMAIN_PAUSED_POSTCOPY:
|
||||
return VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY;
|
||||
|
||||
case VIR_DOMAIN_PAUSED_API_ERROR:
|
||||
return VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR;
|
||||
|
||||
case VIR_DOMAIN_PAUSED_UNKNOWN:
|
||||
case VIR_DOMAIN_PAUSED_USER:
|
||||
case VIR_DOMAIN_PAUSED_SAVE:
|
||||
|
@ -2727,6 +2727,10 @@ qemuDomainSaveInternal(virQEMUDriver *driver,
|
||||
virDomainEventLifecycleNewFromObj(vm,
|
||||
VIR_DOMAIN_EVENT_SUSPENDED,
|
||||
VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR));
|
||||
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
|
||||
virDomainObjSetState(vm, VIR_DOMAIN_PAUSED,
|
||||
VIR_DOMAIN_PAUSED_API_ERROR);
|
||||
}
|
||||
}
|
||||
virErrorRestore(&save_err);
|
||||
}
|
||||
@ -3254,6 +3258,10 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom,
|
||||
event = virDomainEventLifecycleNewFromObj(vm,
|
||||
VIR_DOMAIN_EVENT_SUSPENDED,
|
||||
VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR);
|
||||
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
|
||||
virDomainObjSetState(vm, VIR_DOMAIN_PAUSED,
|
||||
VIR_DOMAIN_PAUSED_API_ERROR);
|
||||
}
|
||||
if (virGetLastErrorCode() == VIR_ERR_OK)
|
||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||
"%s", _("resuming after dump failed"));
|
||||
|
@ -326,6 +326,10 @@ qemuSnapshotCreateActiveInternal(virQEMUDriver *driver,
|
||||
event = virDomainEventLifecycleNewFromObj(vm,
|
||||
VIR_DOMAIN_EVENT_SUSPENDED,
|
||||
VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR);
|
||||
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
|
||||
virDomainObjSetState(vm, VIR_DOMAIN_PAUSED,
|
||||
VIR_DOMAIN_PAUSED_API_ERROR);
|
||||
}
|
||||
if (virGetLastErrorCode() == VIR_ERR_OK) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
||||
_("resuming after snapshot failed"));
|
||||
@ -1398,6 +1402,10 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *driver,
|
||||
VIR_DOMAIN_EVENT_SUSPENDED,
|
||||
VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR);
|
||||
virObjectEventStateQueue(driver->domainEventState, event);
|
||||
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
|
||||
virDomainObjSetState(vm, VIR_DOMAIN_PAUSED,
|
||||
VIR_DOMAIN_PAUSED_API_ERROR);
|
||||
}
|
||||
if (virGetLastErrorCode() == VIR_ERR_OK) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
||||
_("resuming after snapshot failed"));
|
||||
|
@ -192,6 +192,7 @@ VIR_ENUM_IMPL(virshDomainPausedReason,
|
||||
N_("starting up"),
|
||||
N_("post-copy"),
|
||||
N_("post-copy failed"),
|
||||
N_("api error"),
|
||||
);
|
||||
|
||||
VIR_ENUM_DECL(virshDomainShutdownReason);
|
||||
|
Loading…
Reference in New Issue
Block a user