diff options
author | Markus Armbruster <armbru@redhat.com> | 2010-05-05 16:36:52 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2010-07-02 13:18:02 +0200 |
commit | f8b6cc0070aab8b75bd082582c829be1353f395f (patch) | |
tree | d521575597a421e5dd9c7cdbc65745031fffe149 /hw/usb-msd.c | |
parent | 14bafc540774baf316e9ce2474e97d5df6cb8e6c (diff) |
qdev: Decouple qdev_prop_drive from DriveInfo
Make the property point to BlockDriverState, cutting out the DriveInfo
middleman. This prepares the ground for block devices that don't have
a DriveInfo.
Currently all user-defined ones have a DriveInfo, because the only way
to define one is -drive & friends (they go through drive_init()).
DriveInfo is closely tied to -drive, and like -drive, it mixes
information about host and guest part of the block device. I'm
working towards a new way to define block devices, with clean
host/guest separation, and I need to get DriveInfo out of the way for
that.
Fortunately, the device models are perfectly happy with
BlockDriverState, except for two places: ide_drive_initfn() and
scsi_disk_initfn() need to check the DriveInfo for a serial number set
with legacy -drive serial=... Use drive_get_by_blockdev() there.
Device model code should now use DriveInfo only when explicitly
dealing with drives defined the old way, i.e. without -device.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/usb-msd.c')
-rw-r--r-- | hw/usb-msd.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 3dbfcabeb1..19a14b4f80 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -522,9 +522,9 @@ static void usb_msd_password_cb(void *opaque, int err) static int usb_msd_initfn(USBDevice *dev) { MSDState *s = DO_UPCAST(MSDState, dev, dev); - DriveInfo *dinfo = s->conf.dinfo; + BlockDriverState *bs = s->conf.bs; - if (!dinfo || !dinfo->bdrv) { + if (!bs) { error_report("usb-msd: drive property not set"); return -1; } @@ -538,21 +538,20 @@ static int usb_msd_initfn(USBDevice *dev) * * The hack is probably a bad idea. */ - s->conf.dinfo = NULL; + s->conf.bs = NULL; s->dev.speed = USB_SPEED_FULL; scsi_bus_new(&s->bus, &s->dev.qdev, 0, 1, usb_msd_command_complete); - s->scsi_dev = scsi_bus_legacy_add_drive(&s->bus, dinfo, 0); + s->scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0); if (!s->scsi_dev) { return -1; } s->bus.qbus.allow_hotplug = 0; usb_msd_handle_reset(dev); - if (bdrv_key_required(dinfo->bdrv)) { + if (bdrv_key_required(bs)) { if (cur_mon) { - monitor_read_bdrv_key_start(cur_mon, dinfo->bdrv, - usb_msd_password_cb, s); + monitor_read_bdrv_key_start(cur_mon, bs, usb_msd_password_cb, s); s->dev.auto_attach = 0; } else { autostart = 0; @@ -610,7 +609,7 @@ static USBDevice *usb_msd_init(const char *filename) if (!dev) { return NULL; } - qdev_prop_set_drive(&dev->qdev, "drive", dinfo); + qdev_prop_set_drive(&dev->qdev, "drive", dinfo->bdrv); if (qdev_init(&dev->qdev) < 0) return NULL; |