diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2006-08-19 11:58:59 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2006-08-19 11:58:59 +0000 |
commit | b56bdb328a9abae5035488e885c8e5fbaa5ce980 (patch) | |
tree | 114c69de015ef4a6b6abc736e38bb79ebe691e4b /hw/usb-msd.c | |
parent | a9f277ba8f9490fc01b9d518ed6932c816fa4604 (diff) | |
download | qemu-b56bdb328a9abae5035488e885c8e5fbaa5ce980.zip qemu-b56bdb328a9abae5035488e885c8e5fbaa5ce980.tar.gz qemu-b56bdb328a9abae5035488e885c8e5fbaa5ce980.tar.bz2 |
delete block device
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2126 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/usb-msd.c')
-rw-r--r-- | hw/usb-msd.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 7d1f35d..e4cfca0 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; } |