Revision 5e52e5f9

b/hw/virtio-serial-bus.c
39 39
    /* Arrays of ivqs and ovqs: one per port */
40 40
    VirtQueue **ivqs, **ovqs;
41 41

  
42
    VirtIOSerialBus *bus;
42
    VirtIOSerialBus bus;
43 43

  
44 44
    DeviceState *qdev;
45 45

  
......
331 331
    case VIRTIO_CONSOLE_DEVICE_READY:
332 332
        if (!cpkt.value) {
333 333
            error_report("virtio-serial-bus: Guest failure in adding device %s\n",
334
                         vser->bus->qbus.name);
334
                         vser->bus.qbus.name);
335 335
            break;
336 336
        }
337 337
        /*
......
346 346
    case VIRTIO_CONSOLE_PORT_READY:
347 347
        if (!cpkt.value) {
348 348
            error_report("virtio-serial-bus: Guest failure in adding port %u for device %s\n",
349
                         port->id, vser->bus->qbus.name);
349
                         port->id, vser->bus.qbus.name);
350 350
            break;
351 351
        }
352 352
        /*
......
473 473

  
474 474
    vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
475 475

  
476
    if (vser->bus->max_nr_ports > 1) {
476
    if (vser->bus.max_nr_ports > 1) {
477 477
        features |= (1 << VIRTIO_CONSOLE_F_MULTIPORT);
478 478
    }
479 479
    return features;
......
650 650
    .print_dev = virtser_bus_dev_print,
651 651
};
652 652

  
653
static VirtIOSerialBus *virtser_bus_new(DeviceState *dev)
654
{
655
    VirtIOSerialBus *bus;
656

  
657
    bus = FROM_QBUS(VirtIOSerialBus, qbus_create(&virtser_bus_info, dev, NULL));
658
    bus->qbus.allow_hotplug = 1;
659

  
660
    return bus;
661
}
662

  
663 653
static void virtser_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
664 654
{
665 655
    VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, qdev);
......
843 833
    vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
844 834

  
845 835
    /* Spawn a new virtio-serial bus on which the ports will ride as devices */
846
    vser->bus = virtser_bus_new(dev);
847
    vser->bus->vser = vser;
836
    qbus_create_inplace(&vser->bus.qbus, &virtser_bus_info, dev, NULL);
837
    vser->bus.qbus.allow_hotplug = 1;
838
    vser->bus.vser = vser;
848 839
    QTAILQ_INIT(&vser->ports);
849 840

  
850
    vser->bus->max_nr_ports = conf->max_virtserial_ports;
841
    vser->bus.max_nr_ports = conf->max_virtserial_ports;
851 842
    vser->ivqs = qemu_malloc(conf->max_virtserial_ports * sizeof(VirtQueue *));
852 843
    vser->ovqs = qemu_malloc(conf->max_virtserial_ports * sizeof(VirtQueue *));
853 844

  
......
867 858
    /* control queue: guest to host */
868 859
    vser->c_ovq = virtio_add_queue(vdev, 32, control_out);
869 860

  
870
    for (i = 1; i < vser->bus->max_nr_ports; i++) {
861
    for (i = 1; i < vser->bus.max_nr_ports; i++) {
871 862
        /* Add a per-port queue for host to guest transfers */
872 863
        vser->ivqs[i] = virtio_add_queue(vdev, 128, handle_input);
873 864
        /* Add a per-per queue for guest to host transfers */

Also available in: Unified diff