Skip to content

Commit

Permalink
virtio-scsi: fix the command line compatibility.
Browse files Browse the repository at this point in the history
The bus name is wrong since the refactoring.

This keeps the behaviour of the command line.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
Tested-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Message-id: 1367330931-12994-6-git-send-email-fred.konrad@greensocs.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
  • Loading branch information
konrad-fred authored and Anthony Liguori committed May 3, 2013
1 parent 80270a1 commit 6f32a6b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
12 changes: 12 additions & 0 deletions hw/s390x/s390-virtio-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,18 @@ static int s390_virtio_scsi_init(VirtIOS390Device *s390_dev)
{
VirtIOSCSIS390 *dev = VIRTIO_SCSI_S390(s390_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
DeviceState *qdev = DEVICE(s390_dev);
char *bus_name;

/*
* For command line compatibility, this sets the virtio-scsi-device bus
* name as before.
*/
if (qdev->id) {
bus_name = g_strdup_printf("%s.0", qdev->id);
virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev), bus_name);
g_free(bus_name);
}

qdev_set_parent_bus(vdev, BUS(&s390_dev->bus));
if (qdev_init(vdev) < 0) {
Expand Down
12 changes: 12 additions & 0 deletions hw/s390x/virtio-ccw.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,18 @@ static int virtio_ccw_scsi_init(VirtioCcwDevice *ccw_dev)
{
VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
DeviceState *qdev = DEVICE(ccw_dev);
char *bus_name;

/*
* For command line compatibility, this sets the virtio-scsi-device bus
* name as before.
*/
if (qdev->id) {
bus_name = g_strdup_printf("%s.0", qdev->id);
virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev), bus_name);
g_free(bus_name);
}

qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
if (qdev_init(vdev) < 0) {
Expand Down
3 changes: 2 additions & 1 deletion hw/scsi/virtio-scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,8 @@ static int virtio_scsi_device_init(VirtIODevice *vdev)
return ret;
}

scsi_bus_new(&s->bus, qdev, &virtio_scsi_scsi_info, NULL);
scsi_bus_new(&s->bus, qdev, &virtio_scsi_scsi_info, vdev->bus_name);

if (!qdev->hotplugged) {
scsi_bus_legacy_handle_cmdline(&s->bus);
}
Expand Down
12 changes: 12 additions & 0 deletions hw/virtio/virtio-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1106,11 +1106,23 @@ static int virtio_scsi_pci_init_pci(VirtIOPCIProxy *vpci_dev)
VirtIOSCSIPCI *dev = VIRTIO_SCSI_PCI(vpci_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev);
DeviceState *proxy = DEVICE(vpci_dev);
char *bus_name;

if (vpci_dev->nvectors == DEV_NVECTORS_UNSPECIFIED) {
vpci_dev->nvectors = vs->conf.num_queues + 3;
}

/*
* For command line compatibility, this sets the virtio-scsi-device bus
* name as before.
*/
if (proxy->id) {
bus_name = g_strdup_printf("%s.0", proxy->id);
virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev), bus_name);
g_free(bus_name);
}

qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
if (qdev_init(vdev) < 0) {
return -1;
Expand Down
1 change: 0 additions & 1 deletion include/hw/virtio/virtio-scsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,4 @@ typedef struct {
int virtio_scsi_common_init(VirtIOSCSICommon *vs);
int virtio_scsi_common_exit(VirtIOSCSICommon *vs);


#endif /* _QEMU_VIRTIO_SCSI_H */

0 comments on commit 6f32a6b

Please sign in to comment.