Commit b56bdb328a9abae5035488e885c8e5fbaa5ce980
1 parent
a9f277ba
delete block device
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2126 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
8 additions
and
1 deletions
hw/usb-msd.c
... | ... | @@ -35,6 +35,7 @@ typedef struct { |
35 | 35 | uint32_t data_len; |
36 | 36 | uint32_t transfer_len; |
37 | 37 | uint32_t tag; |
38 | + BlockDriverState *bs; | |
38 | 39 | SCSIDevice *scsi_dev; |
39 | 40 | int result; |
40 | 41 | /* For async completion. */ |
... | ... | @@ -406,6 +407,7 @@ static void usb_msd_handle_destroy(USBDevice *dev) |
406 | 407 | MSDState *s = (MSDState *)dev; |
407 | 408 | |
408 | 409 | scsi_disk_destroy(s->scsi_dev); |
410 | + bdrv_delete(s->bs); | |
409 | 411 | qemu_free(s); |
410 | 412 | } |
411 | 413 | |
... | ... | @@ -419,7 +421,9 @@ USBDevice *usb_msd_init(const char *filename) |
419 | 421 | return NULL; |
420 | 422 | |
421 | 423 | bdrv = bdrv_new("usb"); |
422 | - bdrv_open(bdrv, filename, 0); | |
424 | + if (bdrv_open(bdrv, filename, 0) < 0) | |
425 | + goto fail; | |
426 | + s->bs = bdrv; | |
423 | 427 | |
424 | 428 | s->dev.speed = USB_SPEED_FULL; |
425 | 429 | s->dev.handle_packet = usb_generic_handle_packet; |
... | ... | @@ -435,4 +439,7 @@ USBDevice *usb_msd_init(const char *filename) |
435 | 439 | s->scsi_dev = scsi_disk_init(bdrv, usb_msd_command_complete, s); |
436 | 440 | usb_msd_handle_reset((USBDevice *)s); |
437 | 441 | return (USBDevice *)s; |
442 | + fail: | |
443 | + qemu_free(s); | |
444 | + return NULL; | |
438 | 445 | } | ... | ... |