diff options
Diffstat (limited to 'hw')
-rw-r--r-- | hw/char/virtio-serial-bus.c | 3 | ||||
-rw-r--r-- | hw/core/qdev.c | 2 | ||||
-rw-r--r-- | hw/s390x/s390-virtio-bus.c | 28 | ||||
-rw-r--r-- | hw/s390x/virtio-ccw.c | 28 | ||||
-rw-r--r-- | hw/scsi/esp-pci.c | 2 | ||||
-rw-r--r-- | hw/scsi/esp.c | 2 | ||||
-rw-r--r-- | hw/scsi/lsi53c895a.c | 2 | ||||
-rw-r--r-- | hw/scsi/megasas.c | 2 | ||||
-rw-r--r-- | hw/scsi/scsi-bus.c | 5 | ||||
-rw-r--r-- | hw/scsi/spapr_vscsi.c | 2 | ||||
-rw-r--r-- | hw/scsi/virtio-scsi.c | 3 | ||||
-rw-r--r-- | hw/scsi/vmw_pvscsi.c | 2 | ||||
-rw-r--r-- | hw/usb/dev-storage.c | 4 | ||||
-rw-r--r-- | hw/usb/dev-uas.c | 2 | ||||
-rw-r--r-- | hw/virtio/virtio-pci.c | 29 | ||||
-rw-r--r-- | hw/virtio/virtio.c | 24 |
16 files changed, 123 insertions, 17 deletions
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 3787ad2e1d..cc3d1dd27a 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -911,7 +911,8 @@ static int virtio_serial_device_init(VirtIODevice *vdev) sizeof(struct virtio_console_config)); /* Spawn a new virtio-serial bus on which the ports will ride as devices */ - qbus_create_inplace(&vser->bus.qbus, TYPE_VIRTIO_SERIAL_BUS, qdev, NULL); + qbus_create_inplace(&vser->bus.qbus, TYPE_VIRTIO_SERIAL_BUS, qdev, + vdev->bus_name); vser->bus.qbus.allow_hotplug = 1; vser->bus.vser = vser; QTAILQ_INIT(&vser->ports); diff --git a/hw/core/qdev.c b/hw/core/qdev.c index ab1d8f52f1..069ac9034c 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -208,7 +208,7 @@ void qdev_unplug(DeviceState *dev, Error **errp) { DeviceClass *dc = DEVICE_GET_CLASS(dev); - if (!dev->parent_bus->allow_hotplug) { + if (dev->parent_bus && !dev->parent_bus->allow_hotplug) { error_set(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name); return; } diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c index 2cff6b794d..5a3d97c037 100644 --- a/hw/s390x/s390-virtio-bus.c +++ b/hw/s390x/s390-virtio-bus.c @@ -197,9 +197,20 @@ static int s390_virtio_serial_init(VirtIOS390Device *s390_dev) DeviceState *qdev = DEVICE(s390_dev); VirtIOS390Bus *bus; int r; + char *bus_name; bus = DO_UPCAST(VirtIOS390Bus, bus, qdev->parent_bus); + /* + * For command line compatibility, this sets the virtio-serial-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) { return -1; @@ -224,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) { @@ -669,7 +692,10 @@ static void virtio_s390_bus_new(VirtioBusState *bus, VirtIOS390Device *dev) { DeviceState *qdev = DEVICE(dev); BusState *qbus; - qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_S390_BUS, qdev, NULL); + char virtio_bus_name[] = "virtio-bus"; + + qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_S390_BUS, qdev, + virtio_bus_name); qbus = BUS(bus); qbus->allow_hotplug = 1; } diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index c0f26460a9..76e6d32b72 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -593,6 +593,18 @@ static int virtio_ccw_serial_init(VirtioCcwDevice *ccw_dev) { VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(ccw_dev); DeviceState *vdev = DEVICE(&dev->vdev); + DeviceState *proxy = DEVICE(ccw_dev); + char *bus_name; + + /* + * For command line compatibility, this sets the virtio-serial-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(&ccw_dev->bus)); if (qdev_init(vdev) < 0) { @@ -668,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) { @@ -1062,8 +1086,10 @@ static void virtio_ccw_bus_new(VirtioBusState *bus, VirtioCcwDevice *dev) { DeviceState *qdev = DEVICE(dev); BusState *qbus; + char virtio_bus_name[] = "virtio-bus"; - qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_CCW_BUS, qdev, NULL); + qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_CCW_BUS, qdev, + virtio_bus_name); qbus = BUS(bus); qbus->allow_hotplug = 1; } diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c index 3ca5c8c673..029789ae39 100644 --- a/hw/scsi/esp-pci.c +++ b/hw/scsi/esp-pci.c @@ -354,7 +354,7 @@ static int esp_pci_scsi_init(PCIDevice *dev) pci_register_bar(&pci->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &pci->io); s->irq = pci->dev.irq[0]; - scsi_bus_new(&s->bus, &dev->qdev, &esp_pci_scsi_info); + scsi_bus_new(&s->bus, &dev->qdev, &esp_pci_scsi_info, NULL); if (!dev->qdev.hotplugged) { return scsi_bus_legacy_handle_cmdline(&s->bus); } diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 17adbecf8c..0c81a50398 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -681,7 +681,7 @@ static int sysbus_esp_init(SysBusDevice *dev) qdev_init_gpio_in(&dev->qdev, sysbus_esp_gpio_demux, 2); - scsi_bus_new(&s->bus, &dev->qdev, &esp_scsi_info); + scsi_bus_new(&s->bus, &dev->qdev, &esp_scsi_info, NULL); return scsi_bus_legacy_handle_cmdline(&s->bus); } diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index c601b2943d..22b8e98697 100644 --- a/hw/scsi/lsi53c895a.c +++ b/hw/scsi/lsi53c895a.c @@ -2099,7 +2099,7 @@ static int lsi_scsi_init(PCIDevice *dev) pci_register_bar(&s->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->ram_io); QTAILQ_INIT(&s->queue); - scsi_bus_new(&s->bus, &dev->qdev, &lsi_scsi_info); + scsi_bus_new(&s->bus, &dev->qdev, &lsi_scsi_info, NULL); if (!dev->qdev.hotplugged) { return scsi_bus_legacy_handle_cmdline(&s->bus); } diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index 14b0552045..4934a815ce 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -2159,7 +2159,7 @@ static int megasas_scsi_init(PCIDevice *dev) s->frames[i].state = s; } - scsi_bus_new(&s->bus, &dev->qdev, &megasas_scsi_info); + scsi_bus_new(&s->bus, &dev->qdev, &megasas_scsi_info, NULL); scsi_bus_legacy_handle_cmdline(&s->bus); return 0; } diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 6239ee1465..53ea906433 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -72,9 +72,10 @@ static void scsi_device_unit_attention_reported(SCSIDevice *s) } /* Create a scsi bus, and attach devices to it. */ -void scsi_bus_new(SCSIBus *bus, DeviceState *host, const SCSIBusInfo *info) +void scsi_bus_new(SCSIBus *bus, DeviceState *host, const SCSIBusInfo *info, + const char *bus_name) { - qbus_create_inplace(&bus->qbus, TYPE_SCSI_BUS, host, NULL); + qbus_create_inplace(&bus->qbus, TYPE_SCSI_BUS, host, bus_name); bus->busnr = next_scsi_bus++; bus->info = info; bus->qbus.allow_hotplug = 1; diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c index 3d322d5d1e..e8978bfef1 100644 --- a/hw/scsi/spapr_vscsi.c +++ b/hw/scsi/spapr_vscsi.c @@ -915,7 +915,7 @@ static int spapr_vscsi_init(VIOsPAPRDevice *dev) dev->crq.SendFunc = vscsi_do_crq; - scsi_bus_new(&s->bus, &dev->qdev, &vscsi_scsi_info); + scsi_bus_new(&s->bus, &dev->qdev, &vscsi_scsi_info, NULL); if (!dev->qdev.hotplugged) { scsi_bus_legacy_handle_cmdline(&s->bus); } diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 84b3ac795d..08dd3f34c3 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -624,7 +624,8 @@ static int virtio_scsi_device_init(VirtIODevice *vdev) return ret; } - scsi_bus_new(&s->bus, qdev, &virtio_scsi_scsi_info); + scsi_bus_new(&s->bus, qdev, &virtio_scsi_scsi_info, vdev->bus_name); + if (!qdev->hotplugged) { scsi_bus_legacy_handle_cmdline(&s->bus); } diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c index 4b4a58fd38..48d12f42dd 100644 --- a/hw/scsi/vmw_pvscsi.c +++ b/hw/scsi/vmw_pvscsi.c @@ -1088,7 +1088,7 @@ pvscsi_init(PCIDevice *pci_dev) return -ENOMEM; } - scsi_bus_new(&s->bus, &pci_dev->qdev, &pvscsi_scsi_info); + scsi_bus_new(&s->bus, &pci_dev->qdev, &pvscsi_scsi_info, NULL); pvscsi_reset_state(s); return 0; diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 06f0171c46..1073901af1 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -623,7 +623,7 @@ static int usb_msd_initfn_storage(USBDevice *dev) } usb_desc_init(dev); - scsi_bus_new(&s->bus, &s->dev.qdev, &usb_msd_scsi_info_storage); + scsi_bus_new(&s->bus, &s->dev.qdev, &usb_msd_scsi_info_storage, NULL); scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0, !!s->removable, s->conf.bootindex, s->serial); if (!scsi_dev) { @@ -650,7 +650,7 @@ static int usb_msd_initfn_bot(USBDevice *dev) usb_desc_create_serial(dev); usb_desc_init(dev); - scsi_bus_new(&s->bus, &s->dev.qdev, &usb_msd_scsi_info_bot); + scsi_bus_new(&s->bus, &s->dev.qdev, &usb_msd_scsi_info_bot, NULL); s->bus.qbus.allow_hotplug = 0; usb_msd_handle_reset(dev); diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c index c8c42eefb5..6efab62544 100644 --- a/hw/usb/dev-uas.c +++ b/hw/usb/dev-uas.c @@ -888,7 +888,7 @@ static int usb_uas_init(USBDevice *dev) QTAILQ_INIT(&uas->requests); uas->status_bh = qemu_bh_new(usb_uas_send_status_bh, uas); - scsi_bus_new(&uas->bus, &uas->dev.qdev, &usb_uas_scsi_info); + scsi_bus_new(&uas->bus, &uas->dev.qdev, &usb_uas_scsi_info, NULL); return 0; } diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 41bb41eb2e..ec0066b6d4 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -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; @@ -1297,6 +1309,8 @@ static int virtio_serial_pci_init(VirtIOPCIProxy *vpci_dev) { VirtIOSerialPCI *dev = VIRTIO_SERIAL_PCI(vpci_dev); DeviceState *vdev = DEVICE(&dev->vdev); + DeviceState *proxy = DEVICE(vpci_dev); + char *bus_name; if (vpci_dev->class_code != PCI_CLASS_COMMUNICATION_OTHER && vpci_dev->class_code != PCI_CLASS_DISPLAY_OTHER && /* qemu 0.10 */ @@ -1310,6 +1324,16 @@ static int virtio_serial_pci_init(VirtIOPCIProxy *vpci_dev) vpci_dev->nvectors = dev->vdev.serial.max_virtserial_ports + 1; } + /* + * For command line compatibility, this sets the virtio-serial-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; @@ -1474,7 +1498,10 @@ static void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev) { DeviceState *qdev = DEVICE(dev); BusState *qbus; - qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_PCI_BUS, qdev, NULL); + char virtio_bus_name[] = "virtio-bus"; + + qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_PCI_BUS, qdev, + virtio_bus_name); qbus = BUS(bus); qbus->allow_hotplug = 1; } diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 0f88c251c1..53a0d90468 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1087,6 +1087,18 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq) return &vq->host_notifier; } +void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name) +{ + if (vdev->bus_name) { + g_free(vdev->bus_name); + vdev->bus_name = NULL; + } + + if (bus_name) { + vdev->bus_name = g_strdup(bus_name); + } +} + static int virtio_device_init(DeviceState *qdev) { VirtIODevice *vdev = VIRTIO_DEVICE(qdev); @@ -1099,11 +1111,23 @@ static int virtio_device_init(DeviceState *qdev) return 0; } +static int virtio_device_exit(DeviceState *qdev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(qdev); + + if (vdev->bus_name) { + g_free(vdev->bus_name); + vdev->bus_name = NULL; + } + return 0; +} + static void virtio_device_class_init(ObjectClass *klass, void *data) { /* Set the default value here. */ DeviceClass *dc = DEVICE_CLASS(klass); dc->init = virtio_device_init; + dc->exit = virtio_device_exit; dc->bus_type = TYPE_VIRTIO_BUS; } |