[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/5] blockdev: release resources in the error case
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 3/5] blockdev: release resources in the error case |
Date: |
Tue, 4 Jan 2011 15:33:28 +0100 |
Signed-off-by: Juan Quintela <address@hidden>
---
blockdev.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index da619ad..f9bb659 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -467,7 +467,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi,
int *fatal_error)
}
if (!file || !*file) {
*fatal_error = 0;
- return NULL;
+ goto error;
}
if (snapshot) {
/* always use cache=unsafe with snapshot */
@@ -481,7 +481,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi,
int *fatal_error)
} else if (ro == 1) {
if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type
!= IF_NONE) {
fprintf(stderr, "qemu: readonly flag not supported for drive with
this interface\n");
- return NULL;
+ goto error;
}
}
@@ -491,13 +491,16 @@ DriveInfo *drive_init(QemuOpts *opts, int
default_to_scsi, int *fatal_error)
if (ret < 0) {
fprintf(stderr, "qemu: could not open disk image %s: %s\n",
file, strerror(-ret));
- return NULL;
+ goto error;
}
if (bdrv_key_required(dinfo->bdrv))
autostart = 0;
*fatal_error = 0;
return dinfo;
+error:
+ drive_uninit(dinfo);
+ return NULL;
}
void do_commit(Monitor *mon, const QDict *qdict)
--
1.7.3.4
- [Qemu-devel] [PATCH 0/5] Fix migration with NFS & iscsi/Fiber channel, Juan Quintela, 2011/01/04
- [Qemu-devel] [PATCH 2/5] blockdev: don't leak id on removal, Juan Quintela, 2011/01/04
- [Qemu-devel] [PATCH 3/5] blockdev: release resources in the error case,
Juan Quintela <=
- [Qemu-devel] [PATCH 4/5] Reopen files after migration, Juan Quintela, 2011/01/04
- [Qemu-devel] [PATCH 5/5] drive_open: Add invalidate option for block devices, Juan Quintela, 2011/01/04
- [Qemu-devel] [PATCH 1/5] migration: exit with error code, Juan Quintela, 2011/01/04
- [Qemu-devel] Re: [PATCH 0/5] Fix migration with NFS & iscsi/Fiber channel, Juan Quintela, 2011/01/10