Commit 56a14938 authored by Gerd Hoffmann's avatar Gerd Hoffmann Committed by Anthony Liguori
Browse files

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: default avatarGerd Hoffmann <kraxel@redhat.com>
Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
parent 3f84865a
Loading
Loading
Loading
Loading
+0 −18
Original line number Diff line number Diff line
@@ -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);
            }
        }
    }
}

+0 −3
Original line number Diff line number Diff line
@@ -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;
+8 −0
Original line number Diff line number Diff line
@@ -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,
+2 −0
Original line number Diff line number Diff line
@@ -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)
+0 −8
Original line number Diff line number Diff line
@@ -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(),
Loading