qemu: Error prompt when saving a shutoff domain

"qemudDomainSaveFlag" goto wrong label "endjob", which will cause
error when security manager trying to restore label (regression).

As it's more reasonable to check if vm is shutoff immediately, and
return right away if it is, remove the checking in "qemudDomainSaveFlag",
and add checking in "qemudDomainSave".

* src/qemu/qemu_driver.c
This commit is contained in:
Osier Yang 2011-02-17 11:18:47 +08:00
parent 51ff630fdc
commit cd951ad2ec

View File

@ -4303,7 +4303,9 @@ endjob:
return ret; return ret;
} }
/* this internal function expects the driver lock to already be held on entry */ /* This internal function expects the driver lock to already be held on
* entry and the vm must be active.
*/
static int qemudDomainSaveFlag(struct qemud_driver *driver, virDomainPtr dom, static int qemudDomainSaveFlag(struct qemud_driver *driver, virDomainPtr dom,
virDomainObjPtr vm, const char *path, virDomainObjPtr vm, const char *path,
int compressed) int compressed)
@ -4332,12 +4334,6 @@ static int qemudDomainSaveFlag(struct qemud_driver *driver, virDomainPtr dom,
if (qemuDomainObjBeginJobWithDriver(driver, vm) < 0) if (qemuDomainObjBeginJobWithDriver(driver, vm) < 0)
goto cleanup; goto cleanup;
if (!virDomainObjIsActive(vm)) {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
goto endjob;
}
priv->jobActive = QEMU_JOB_SAVE; priv->jobActive = QEMU_JOB_SAVE;
memset(&priv->jobInfo, 0, sizeof(priv->jobInfo)); memset(&priv->jobInfo, 0, sizeof(priv->jobInfo));
@ -4656,6 +4652,12 @@ static int qemudDomainSave(virDomainPtr dom, const char *path)
goto cleanup; goto cleanup;
} }
if (!virDomainObjIsActive(vm)) {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
goto cleanup;
}
ret = qemudDomainSaveFlag(driver, dom, vm, path, compressed); ret = qemudDomainSaveFlag(driver, dom, vm, path, compressed);
cleanup: cleanup: