Fix handling of security driver restore failures in QEMU domain save

In cases where the security driver failed to restore a label after a
guest has saved, we mistakenly jumped to the error cleanup paths.
This is not good, because the operation has in fact completed and
cannot be rolled back completely. Label restore is non-critical, so
just log the problem instead. Also add a missing restore call in
the error cleanup path

* src/qemu/qemu_driver.c: Fix handling of security driver
  restore failures in QEMU domain save
This commit is contained in:
Daniel P. Berrange 2010-04-22 17:16:47 +01:00
parent 712048bd9a
commit 51cd0196e5

View File

@ -4976,16 +4976,13 @@ static int qemudDomainSaveFlag(virDomainPtr dom, const char *path,
driver->securityDriver && driver->securityDriver &&
driver->securityDriver->domainRestoreSavedStateLabel && driver->securityDriver->domainRestoreSavedStateLabel &&
driver->securityDriver->domainRestoreSavedStateLabel(vm, path) == -1) driver->securityDriver->domainRestoreSavedStateLabel(vm, path) == -1)
goto endjob; VIR_WARN("failed to restore save state label on %s", path);
if (cgroup != NULL) { if (cgroup != NULL) {
rc = virCgroupDenyDevicePath(cgroup, path); rc = virCgroupDenyDevicePath(cgroup, path);
if (rc != 0) { if (rc != 0)
virReportSystemError(-rc, VIR_WARN("Unable to deny device %s for %s %d",
_("Unable to deny device %s for %s"), path, vm->def->name, rc);
path, vm->def->name);
goto endjob;
}
} }
ret = 0; ret = 0;
@ -5004,7 +5001,8 @@ static int qemudDomainSaveFlag(virDomainPtr dom, const char *path,
endjob: endjob:
if (vm) { if (vm) {
if (ret != 0 && header.was_running && priv->mon) { if (ret != 0) {
if (header.was_running && priv->mon) {
qemuDomainObjEnterMonitorWithDriver(driver, vm); qemuDomainObjEnterMonitorWithDriver(driver, vm);
rc = qemuMonitorStartCPUs(priv->mon, dom->conn); rc = qemuMonitorStartCPUs(priv->mon, dom->conn);
qemuDomainObjExitMonitorWithDriver(driver, vm); qemuDomainObjExitMonitorWithDriver(driver, vm);
@ -5014,14 +5012,18 @@ endjob:
vm->state = VIR_DOMAIN_RUNNING; vm->state = VIR_DOMAIN_RUNNING;
} }
if (ret != 0 && cgroup != NULL) { if (cgroup != NULL) {
rc = virCgroupDenyDevicePath(cgroup, path); rc = virCgroupDenyDevicePath(cgroup, path);
if (rc != 0) { if (rc != 0)
virReportSystemError(-rc, VIR_WARN("Unable to deny device %s for %s: %d",
_("Unable to deny device %s for %s"), path, vm->def->name, rc);
path, vm->def->name);
goto endjob;
} }
if ((!bypassSecurityDriver) &&
driver->securityDriver &&
driver->securityDriver->domainRestoreSavedStateLabel &&
driver->securityDriver->domainRestoreSavedStateLabel(vm, path) == -1)
VIR_WARN("failed to restore save state label on %s", path);
} }
if (qemuDomainObjEndJob(vm) == 0) if (qemuDomainObjEndJob(vm) == 0)