Skip to content

Commit

Permalink
virtio-scsi: Add 'iothread' property to virtio-scsi
Browse files Browse the repository at this point in the history
Similar to this property in virtio-blk for dataplane, add it as a QOM
link in virtio-scsi and an alias in virtio-scsi-pci and virtio-scsi-ccw,
in order to assign an iothread to the device.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Fam Zheng authored and bonzini committed Sep 30, 2014
1 parent c8075ca commit 19d339f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions hw/s390x/virtio-ccw.c
Expand Up @@ -938,6 +938,8 @@ static void virtio_ccw_scsi_instance_init(Object *obj)

virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
TYPE_VIRTIO_SCSI);
object_property_add_alias(obj, "iothread", OBJECT(&dev->vdev), "iothread",
&error_abort);
}

#ifdef CONFIG_VHOST_SCSI
Expand Down
11 changes: 11 additions & 0 deletions hw/scsi/virtio-scsi.c
Expand Up @@ -728,6 +728,16 @@ static void virtio_scsi_device_realize(DeviceState *dev, Error **errp)
virtio_scsi_save, virtio_scsi_load, s);
}

static void virtio_scsi_instance_init(Object *obj)
{
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(obj);

object_property_add_link(obj, "iothread", TYPE_IOTHREAD,
(Object **)&vs->conf.iothread,
qdev_prop_allow_set_link_before_realize,
OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
}

void virtio_scsi_common_unrealize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
Expand Down Expand Up @@ -786,6 +796,7 @@ static const TypeInfo virtio_scsi_info = {
.name = TYPE_VIRTIO_SCSI,
.parent = TYPE_VIRTIO_SCSI_COMMON,
.instance_size = sizeof(VirtIOSCSI),
.instance_init = virtio_scsi_instance_init,
.class_init = virtio_scsi_class_init,
};

Expand Down
2 changes: 2 additions & 0 deletions hw/virtio/virtio-pci.c
Expand Up @@ -1186,6 +1186,8 @@ static void virtio_scsi_pci_instance_init(Object *obj)

virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
TYPE_VIRTIO_SCSI);
object_property_add_alias(obj, "iothread", OBJECT(&dev->vdev), "iothread",
&error_abort);
}

static const TypeInfo virtio_scsi_pci_info = {
Expand Down
1 change: 1 addition & 0 deletions include/hw/virtio/virtio-scsi.h
Expand Up @@ -151,6 +151,7 @@ struct VirtIOSCSIConf {
uint32_t cmd_per_lun;
char *vhostfd;
char *wwpn;
IOThread *iothread;
};

typedef struct VirtIOSCSICommon {
Expand Down

0 comments on commit 19d339f

Please sign in to comment.