提交 a08fc66d 编写于 作者: M Michal Privoznik

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.
上级 adb29a88
......@@ -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,19 +10722,21 @@ 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) {
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:
if (vm && qemuDomainObjEndJob(driver, vm) == 0) {
......@@ -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) {
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,11 +12836,18 @@ cleanup:
if (resume && virDomainObjIsActive(vm) &&
qemuProcessStartCPUs(driver, vm, conn,
VIR_DOMAIN_RUNNING_UNPAUSED,
QEMU_ASYNC_JOB_NONE) < 0 &&
virGetLastError() == NULL) {
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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册