diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2009-09-25 21:42:46 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-10-05 09:32:49 -0500 |
commit | 56a14938809331372b6cdb2afcb14d9818de4cbf (patch) | |
tree | 256e324375f698356af28158f601b2301a673ba5 /hw | |
parent | 3f84865ade594a2ec1ef613ab5fd11949f3d49de (diff) |
drive cleanup fixes.
Changes:
* drive_uninit() wants a DriveInfo now.
* drive_uninit() also calls bdrv_delete(),
so callers don't need to do that.
* drive_uninit() calls are moved over to the ->exit()
callbacks, destroy_bdrvs() is zapped.
* setting bdrv->private is not needed any more as the
only user (destroy_bdrvs) is gone.
* usb-storage needs no drive_uninit, scsi-disk will
handle that.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/device-hotplug.c | 18 | ||||
-rw-r--r-- | hw/pci-hotplug.c | 3 | ||||
-rw-r--r-- | hw/scsi-disk.c | 8 | ||||
-rw-r--r-- | hw/scsi-generic.c | 2 | ||||
-rw-r--r-- | hw/usb-msd.c | 8 | ||||
-rw-r--r-- | hw/virtio-blk.c | 1 | ||||
-rw-r--r-- | hw/virtio-pci.c | 9 |
7 files changed, 19 insertions, 30 deletions
diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c index 69779caef5..c0cfd31d4d 100644 --- a/hw/device-hotplug.c +++ b/hw/device-hotplug.c @@ -62,21 +62,3 @@ void destroy_nic(dev_match_fn *match_fn, void *arg) } } } - -void destroy_bdrvs(dev_match_fn *match_fn, void *arg) -{ - DriveInfo *dinfo; - struct BlockDriverState *bs; - - QTAILQ_FOREACH(dinfo, &drives, next) { - bs = dinfo->bdrv; - if (bs) { - if (bs->private && match_fn(bs->private, arg)) { - drive_uninit(bs); - bdrv_delete(bs); - } - } - } -} - - diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index 990ab3b1c3..2cc43c3f24 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -234,9 +234,6 @@ void pci_device_hot_remove_success(PCIDevice *d) class_code = d->config_read(d, PCI_CLASS_DEVICE+1, 1); switch(class_code) { - case PCI_BASE_CLASS_STORAGE: - destroy_bdrvs(pci_match_fn, d); - break; case PCI_BASE_CLASS_NETWORK: destroy_nic(pci_match_fn, d); break; diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 0f029f897d..3940726f2b 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -936,6 +936,13 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, } } +static void scsi_destroy(SCSIDevice *dev) +{ + SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev); + + drive_uninit(s->dinfo); +} + static int scsi_disk_initfn(SCSIDevice *dev) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev); @@ -969,6 +976,7 @@ static SCSIDeviceInfo scsi_disk_info = { .qdev.desc = "virtual scsi disk or cdrom", .qdev.size = sizeof(SCSIDiskState), .init = scsi_disk_initfn, + .destroy = scsi_destroy, .send_command = scsi_send_command, .read_data = scsi_read_data, .write_data = scsi_write_data, diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c index 86d1e54a5f..6a89989996 100644 --- a/hw/scsi-generic.c +++ b/hw/scsi-generic.c @@ -668,6 +668,8 @@ static void scsi_destroy(SCSIDevice *d) qemu_free(r); r = n; } + + drive_uninit(s->dinfo); } static int scsi_generic_initfn(SCSIDevice *dev) diff --git a/hw/usb-msd.c b/hw/usb-msd.c index a19b31d68e..e090014f74 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -508,13 +508,6 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) return ret; } -static void usb_msd_handle_destroy(USBDevice *dev) -{ - MSDState *s = (MSDState *)dev; - - drive_uninit(s->dinfo->bdrv); -} - static int usb_msd_initfn(USBDevice *dev) { MSDState *s = DO_UPCAST(MSDState, dev, dev); @@ -599,7 +592,6 @@ static struct USBDeviceInfo msd_info = { .handle_reset = usb_msd_handle_reset, .handle_control = usb_msd_handle_control, .handle_data = usb_msd_handle_data, - .handle_destroy = usb_msd_handle_destroy, .qdev.props = (Property[]) { DEFINE_PROP_DRIVE("drive", MSDState, dinfo), DEFINE_PROP_END_OF_LIST(), diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index 2d6d71afa1..2630b99304 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -504,7 +504,6 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, DriveInfo *dinfo) strncpy(s->serial_str, ps, sizeof(s->serial_str)); else snprintf(s->serial_str, sizeof(s->serial_str), "0"); - s->bs->private = dev; bdrv_guess_geometry(s->bs, &cylinders, &heads, &secs); bdrv_set_geometry_hint(s->bs, cylinders, heads, secs); diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index c6fbaacb25..7b86bfc9ef 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -458,6 +458,14 @@ static int virtio_blk_init_pci(PCIDevice *pci_dev) return 0; } +static int virtio_blk_exit_pci(PCIDevice *pci_dev) +{ + VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); + + drive_uninit(proxy->dinfo); + return 0; +} + static int virtio_console_init_pci(PCIDevice *pci_dev) { VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); @@ -519,6 +527,7 @@ static PCIDeviceInfo virtio_info[] = { .qdev.name = "virtio-blk-pci", .qdev.size = sizeof(VirtIOPCIProxy), .init = virtio_blk_init_pci, + .exit = virtio_blk_exit_pci, .qdev.props = (Property[]) { DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0), DEFINE_PROP_DRIVE("drive", VirtIOPCIProxy, dinfo), |