qemu: Emit event if 'cont' fails

Some operations, APIs needs domain to be paused prior operation can be
performed, e.g. (managed-) save of a domain. The processors should be
restored in the end. However, if 'cont' fails for some reason, we log a
message but this is not sufficient as an event should be emitted as
well. Mgmt application can then decide what to do.
This commit is contained in:
Michal Privoznik 2012-11-05 15:33:12 +01:00
parent adb29a8869
commit a08fc66d90

View File

@ -2994,8 +2994,12 @@ endjob:
rc = qemuProcessStartCPUs(driver, vm, dom->conn,
VIR_DOMAIN_RUNNING_SAVE_CANCELED,
QEMU_ASYNC_JOB_SAVE);
if (rc < 0)
if (rc < 0) {
VIR_WARN("Unable to resume guest CPUs after save failure");
event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_SUSPENDED,
VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR);
}
}
}
if (qemuDomainObjEndAsyncJob(driver, vm) == 0)
@ -3452,6 +3456,9 @@ endjob:
if (resume && qemuProcessStartCPUs(driver, vm, dom->conn,
VIR_DOMAIN_RUNNING_UNPAUSED,
QEMU_ASYNC_JOB_DUMP) < 0) {
event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_SUSPENDED,
VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR);
if (virGetLastError() == NULL)
virReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("resuming after dump failed"));
@ -10669,6 +10676,7 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn,
{
virDomainObjPtr vm = *vmptr;
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainEventPtr event = NULL;
bool resume = false;
int ret = -1;
@ -10705,8 +10713,6 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn,
goto cleanup;
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_HALT) {
virDomainEventPtr event;
event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT);
qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, 0);
@ -10716,18 +10722,20 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn,
ignore_value(qemuDomainObjEndJob(driver, vm));
resume = false;
vm = NULL;
if (event)
qemuDomainEventQueue(driver, event);
}
cleanup:
if (resume && virDomainObjIsActive(vm) &&
qemuProcessStartCPUs(driver, vm, conn,
VIR_DOMAIN_RUNNING_UNPAUSED,
QEMU_ASYNC_JOB_NONE) < 0 &&
virGetLastError() == NULL) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("resuming after snapshot failed"));
QEMU_ASYNC_JOB_NONE) < 0) {
event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_SUSPENDED,
VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR);
if (virGetLastError() == NULL) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("resuming after snapshot failed"));
}
}
endjob:
@ -10738,6 +10746,9 @@ endjob:
ret = -1;
}
if (event)
qemuDomainEventQueue(driver, event);
return ret;
}
@ -11238,10 +11249,17 @@ endjob:
if (resume && vm && virDomainObjIsActive(vm) &&
qemuProcessStartCPUs(driver, vm, conn,
VIR_DOMAIN_RUNNING_UNPAUSED,
QEMU_ASYNC_JOB_NONE) < 0 &&
virGetLastError() == NULL) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("resuming after snapshot failed"));
QEMU_ASYNC_JOB_NONE) < 0) {
virDomainEventPtr event = NULL;
event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_SUSPENDED,
VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR);
if (event)
qemuDomainEventQueue(driver, event);
if (virGetLastError() == NULL) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("resuming after snapshot failed"));
}
return -1;
}
@ -12818,10 +12836,17 @@ cleanup:
if (resume && virDomainObjIsActive(vm) &&
qemuProcessStartCPUs(driver, vm, conn,
VIR_DOMAIN_RUNNING_UNPAUSED,
QEMU_ASYNC_JOB_NONE) < 0 &&
virGetLastError() == NULL) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("resuming after drive-reopen failed"));
QEMU_ASYNC_JOB_NONE) < 0) {
virDomainEventPtr event = NULL;
event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_SUSPENDED,
VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR);
if (event)
qemuDomainEventQueue(driver, event);
if (virGetLastError() == NULL) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("resuming after drive-reopen failed"));
}
}
return ret;
}