qemu: Remove cleanup label in qemuDomainSnapshotPrepareDiskExternal
Refactor the code to avoid having a cleanup label. This will simplify the change necessary when restricting this check in an upcoming patch. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
6129a04d49
commit
7921e9b088
@ -14983,8 +14983,9 @@ qemuDomainSnapshotPrepareDiskExternal(virDomainDiskDefPtr disk,
|
|||||||
bool active,
|
bool active,
|
||||||
bool reuse)
|
bool reuse)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
int err;
|
||||||
|
int rc;
|
||||||
|
|
||||||
if (disk->src->readonly) {
|
if (disk->src->readonly) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
@ -15010,31 +15011,32 @@ qemuDomainSnapshotPrepareDiskExternal(virDomainDiskDefPtr disk,
|
|||||||
if (virStorageFileInit(snapdisk->src) < 0)
|
if (virStorageFileInit(snapdisk->src) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virStorageFileStat(snapdisk->src, &st) < 0) {
|
rc = virStorageFileStat(snapdisk->src, &st);
|
||||||
if (errno != ENOENT) {
|
err = errno;
|
||||||
virReportSystemError(errno,
|
|
||||||
|
virStorageFileDeinit(snapdisk->src);
|
||||||
|
|
||||||
|
if (rc < 0) {
|
||||||
|
if (err != ENOENT) {
|
||||||
|
virReportSystemError(err,
|
||||||
_("unable to stat for disk %s: %s"),
|
_("unable to stat for disk %s: %s"),
|
||||||
snapdisk->name, snapdisk->src->path);
|
snapdisk->name, snapdisk->src->path);
|
||||||
goto cleanup;
|
return -1;
|
||||||
} else if (reuse) {
|
} else if (reuse) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(err,
|
||||||
_("missing existing file for disk %s: %s"),
|
_("missing existing file for disk %s: %s"),
|
||||||
snapdisk->name, snapdisk->src->path);
|
snapdisk->name, snapdisk->src->path);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (!S_ISBLK(st.st_mode) && st.st_size && !reuse) {
|
} else if (!S_ISBLK(st.st_mode) && st.st_size && !reuse) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("external snapshot file for disk %s already "
|
_("external snapshot file for disk %s already "
|
||||||
"exists and is not a block device: %s"),
|
"exists and is not a block device: %s"),
|
||||||
snapdisk->name, snapdisk->src->path);
|
snapdisk->name, snapdisk->src->path);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virStorageFileDeinit(snapdisk->src);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user