diff options
author | KONRAD Frederic <fred.konrad@greensocs.com> | 2013-03-21 15:15:18 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2013-03-26 09:26:36 -0500 |
commit | 0ac8e139274245320b1c56f6e9ec9318c2da963a (patch) | |
tree | 1595e0b94a0800ad5b535fafa6e68c15ee1e682a /hw | |
parent | c908ea1052f8c6391c2d321693220130846f703c (diff) |
virtio-scsi: cleanup: use QOM casts.
As the virtio-scsi-pci and virtio-scsi-s390 are switched to the new API,
we can use QOM casts.
Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Tested-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Message-id: 1363875320-7985-9-git-send-email-fred.konrad@greensocs.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/virtio-scsi.c | 46 | ||||
-rw-r--r-- | hw/virtio-scsi.h | 2 |
2 files changed, 27 insertions, 21 deletions
diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c index 56d1b272f7..c341d24a0c 100644 --- a/hw/virtio-scsi.c +++ b/hw/virtio-scsi.c @@ -172,6 +172,7 @@ static void virtio_scsi_complete_req(VirtIOSCSIReq *req) { VirtIOSCSI *s = req->dev; VirtQueue *vq = req->vq; + VirtIODevice *vdev = VIRTIO_DEVICE(s); virtqueue_push(vq, &req->elem, req->qsgl.size + req->elem.in_sg[0].iov_len); qemu_sglist_destroy(&req->qsgl); if (req->sreq) { @@ -179,7 +180,7 @@ static void virtio_scsi_complete_req(VirtIOSCSIReq *req) scsi_req_unref(req->sreq); } g_free(req); - virtio_notify(&s->vdev, vq); + virtio_notify(vdev, vq); } static void virtio_scsi_bad_req(void) @@ -566,16 +567,16 @@ static void virtio_scsi_reset(VirtIODevice *vdev) */ static void virtio_scsi_save(QEMUFile *f, void *opaque) { - VirtIOSCSI *s = opaque; - virtio_save(&s->vdev, f); + VirtIODevice *vdev = VIRTIO_DEVICE(opaque); + virtio_save(vdev, f); } static int virtio_scsi_load(QEMUFile *f, void *opaque, int version_id) { - VirtIOSCSI *s = opaque; + VirtIODevice *vdev = VIRTIO_DEVICE(opaque); int ret; - ret = virtio_load(&s->vdev, f); + ret = virtio_load(vdev, f); if (ret) { return ret; } @@ -587,9 +588,10 @@ static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev, { VirtIOSCSIReq *req = virtio_scsi_pop_req(s, s->event_vq); VirtIOSCSIEvent *evt; + VirtIODevice *vdev = VIRTIO_DEVICE(s); int in_size; - if (!(s->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK)) { + if (!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) { return; } @@ -633,7 +635,7 @@ static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev, static void virtio_scsi_handle_event(VirtIODevice *vdev, VirtQueue *vq) { - VirtIOSCSI *s = (VirtIOSCSI *)vdev; + VirtIOSCSI *s = VIRTIO_SCSI(vdev); if (s->events_dropped) { virtio_scsi_push_event(s, NULL, VIRTIO_SCSI_T_NO_EVENT, 0); @@ -643,8 +645,9 @@ static void virtio_scsi_handle_event(VirtIODevice *vdev, VirtQueue *vq) static void virtio_scsi_change(SCSIBus *bus, SCSIDevice *dev, SCSISense sense) { VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus); + VirtIODevice *vdev = VIRTIO_DEVICE(s); - if (((s->vdev.guest_features >> VIRTIO_SCSI_F_CHANGE) & 1) && + if (((vdev->guest_features >> VIRTIO_SCSI_F_CHANGE) & 1) && dev->type != TYPE_ROM) { virtio_scsi_push_event(s, dev, VIRTIO_SCSI_T_PARAM_CHANGE, sense.asc | (sense.ascq << 8)); @@ -654,8 +657,9 @@ static void virtio_scsi_change(SCSIBus *bus, SCSIDevice *dev, SCSISense sense) static void virtio_scsi_hotplug(SCSIBus *bus, SCSIDevice *dev) { VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus); + VirtIODevice *vdev = VIRTIO_DEVICE(s); - if ((s->vdev.guest_features >> VIRTIO_SCSI_F_HOTPLUG) & 1) { + if ((vdev->guest_features >> VIRTIO_SCSI_F_HOTPLUG) & 1) { virtio_scsi_push_event(s, dev, VIRTIO_SCSI_T_TRANSPORT_RESET, VIRTIO_SCSI_EVT_RESET_RESCAN); } @@ -664,8 +668,9 @@ static void virtio_scsi_hotplug(SCSIBus *bus, SCSIDevice *dev) static void virtio_scsi_hot_unplug(SCSIBus *bus, SCSIDevice *dev) { VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus); + VirtIODevice *vdev = VIRTIO_DEVICE(s); - if ((s->vdev.guest_features >> VIRTIO_SCSI_F_HOTPLUG) & 1) { + if ((vdev->guest_features >> VIRTIO_SCSI_F_HOTPLUG) & 1) { virtio_scsi_push_event(s, dev, VIRTIO_SCSI_T_TRANSPORT_RESET, VIRTIO_SCSI_EVT_RESET_REMOVED); } @@ -692,6 +697,7 @@ static VirtIODevice *virtio_scsi_common_init(DeviceState *dev, VirtIOSCSI **ps) { VirtIOSCSI *s = *ps; + VirtIODevice *vdev = VIRTIO_DEVICE(s); static int virtio_scsi_id; int i; @@ -717,17 +723,17 @@ static VirtIODevice *virtio_scsi_common_init(DeviceState *dev, s->conf = *proxyconf; /* TODO set up vdev function pointers */ - s->vdev.get_config = virtio_scsi_get_config; - s->vdev.set_config = virtio_scsi_set_config; - s->vdev.get_features = virtio_scsi_get_features; - s->vdev.reset = virtio_scsi_reset; - - s->ctrl_vq = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE, - virtio_scsi_handle_ctrl); - s->event_vq = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE, + vdev->get_config = virtio_scsi_get_config; + vdev->set_config = virtio_scsi_set_config; + vdev->get_features = virtio_scsi_get_features; + vdev->reset = virtio_scsi_reset; + + s->ctrl_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE, + virtio_scsi_handle_ctrl); + s->event_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE, virtio_scsi_handle_event); for (i = 0; i < s->conf.num_queues; i++) { - s->cmd_vqs[i] = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE, + s->cmd_vqs[i] = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE, virtio_scsi_handle_cmd); } @@ -739,7 +745,7 @@ static VirtIODevice *virtio_scsi_common_init(DeviceState *dev, register_savevm(dev, "virtio-scsi", virtio_scsi_id++, 1, virtio_scsi_save, virtio_scsi_load, s); - return &s->vdev; + return vdev; } VirtIODevice *virtio_scsi_init(DeviceState *dev, VirtIOSCSIConf *proxyconf) diff --git a/hw/virtio-scsi.h b/hw/virtio-scsi.h index 758c29bafa..fe2c7d6337 100644 --- a/hw/virtio-scsi.h +++ b/hw/virtio-scsi.h @@ -38,7 +38,7 @@ struct VirtIOSCSIConf { }; typedef struct VirtIOSCSI { - VirtIODevice vdev; + VirtIODevice parent_obj; DeviceState *qdev; VirtIOSCSIConf conf; |