qemu: snapshot: Move error preservation to qemuDomainSnapshotDiskDataCleanup

Make qemuDomainSnapshotDiskDataCleanup cleanup section friendly by
moving the error preservation code inside it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2019-08-28 09:33:27 +02:00
parent 93a0f72ef4
commit e1b61f2cd5

View File

@ -15271,11 +15271,14 @@ qemuDomainSnapshotDiskDataCleanup(qemuDomainSnapshotDiskDataPtr data,
virQEMUDriverPtr driver, virQEMUDriverPtr driver,
virDomainObjPtr vm) virDomainObjPtr vm)
{ {
virErrorPtr orig_err;
size_t i; size_t i;
if (!data) if (!data)
return; return;
virErrorPreserveLast(&orig_err);
for (i = 0; i < ndata; i++) { for (i = 0; i < ndata; i++) {
/* on success of the snapshot the 'src' and 'persistsrc' properties will /* on success of the snapshot the 'src' and 'persistsrc' properties will
* be set to NULL by qemuDomainSnapshotUpdateDiskSources */ * be set to NULL by qemuDomainSnapshotUpdateDiskSources */
@ -15299,6 +15302,7 @@ qemuDomainSnapshotDiskDataCleanup(qemuDomainSnapshotDiskDataPtr data,
} }
VIR_FREE(data); VIR_FREE(data);
virErrorRestore(&orig_err);
} }
@ -15506,7 +15510,6 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
bool reuse = (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT) != 0; bool reuse = (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT) != 0;
qemuDomainSnapshotDiskDataPtr diskdata = NULL; qemuDomainSnapshotDiskDataPtr diskdata = NULL;
size_t ndiskdata = 0; size_t ndiskdata = 0;
virErrorPtr orig_err = NULL;
if (virDomainObjCheckActive(vm) < 0) if (virDomainObjCheckActive(vm) < 0)
return -1; return -1;
@ -15565,12 +15568,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
ret = 0; ret = 0;
cleanup: cleanup:
if (ret < 0)
virErrorPreserveLast(&orig_err);
qemuDomainSnapshotDiskDataCleanup(diskdata, ndiskdata, driver, vm); qemuDomainSnapshotDiskDataCleanup(diskdata, ndiskdata, driver, vm);
virErrorRestore(&orig_err);
return ret; return ret;
} }