qemu: Restore errors when rolling back disk image state

Some operations done to rollback disk image labelling and locking might
overwrite (or clear) the actual error. Remember the original error when
tearing down disk access so that it's not obscured.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1461301
This commit is contained in:
Peter Krempa 2017-09-11 15:28:15 +02:00
parent 6f18150f7b
commit a823d0a62e

View File

@ -94,6 +94,7 @@ qemuDomainPrepareDisk(virQEMUDriverPtr driver,
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
int ret = -1;
virStorageSourcePtr origsrc = NULL;
virErrorPtr orig_err = NULL;
if (overridesrc) {
origsrc = disk->src;
@ -102,6 +103,7 @@ qemuDomainPrepareDisk(virQEMUDriverPtr driver,
/* just tear down the disk access */
if (teardown) {
virErrorPreserveLast(&orig_err);
ret = 0;
goto rollback_cgroup;
}
@ -145,6 +147,8 @@ qemuDomainPrepareDisk(virQEMUDriverPtr driver,
if (origsrc)
disk->src = origsrc;
virErrorRestore(&orig_err);
virObjectUnref(cfg);
return ret;