aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2006-08-19 11:58:59 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2006-08-19 11:58:59 +0000
commitb56bdb328a9abae5035488e885c8e5fbaa5ce980 (patch)
tree114c69de015ef4a6b6abc736e38bb79ebe691e4b
parenta9f277ba8f9490fc01b9d518ed6932c816fa4604 (diff)
delete block device
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2126 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--hw/usb-msd.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index 7d1f35d064..e4cfca0fef 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -35,6 +35,7 @@ typedef struct {
uint32_t data_len;
uint32_t transfer_len;
uint32_t tag;
+ BlockDriverState *bs;
SCSIDevice *scsi_dev;
int result;
/* For async completion. */
@@ -406,6 +407,7 @@ static void usb_msd_handle_destroy(USBDevice *dev)
MSDState *s = (MSDState *)dev;
scsi_disk_destroy(s->scsi_dev);
+ bdrv_delete(s->bs);
qemu_free(s);
}
@@ -419,7 +421,9 @@ USBDevice *usb_msd_init(const char *filename)
return NULL;
bdrv = bdrv_new("usb");
- bdrv_open(bdrv, filename, 0);
+ if (bdrv_open(bdrv, filename, 0) < 0)
+ goto fail;
+ s->bs = bdrv;
s->dev.speed = USB_SPEED_FULL;
s->dev.handle_packet = usb_generic_handle_packet;
@@ -435,4 +439,7 @@ USBDevice *usb_msd_init(const char *filename)
s->scsi_dev = scsi_disk_init(bdrv, usb_msd_command_complete, s);
usb_msd_handle_reset((USBDevice *)s);
return (USBDevice *)s;
+ fail:
+ qemu_free(s);
+ return NULL;
}