Revision 6b331efb hw/virtio-serial-bus.c

b/hw/virtio-serial-bus.c
811 811
    qdev_register(&info->qdev);
812 812
}
813 813

  
814
VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)
814
VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *conf)
815 815
{
816 816
    VirtIOSerial *vser;
817 817
    VirtIODevice *vdev;
818 818
    uint32_t i, max_supported_ports;
819 819

  
820
    if (!max_nr_ports)
820
    if (!conf->max_virtserial_ports)
821 821
        return NULL;
822 822

  
823 823
    /* Each port takes 2 queues, and one pair is for the control queue */
824 824
    max_supported_ports = VIRTIO_PCI_QUEUE_MAX / 2 - 1;
825 825

  
826
    if (max_nr_ports > max_supported_ports) {
826
    if (conf->max_virtserial_ports > max_supported_ports) {
827 827
        error_report("maximum ports supported: %u", max_supported_ports);
828 828
        return NULL;
829 829
    }
......
839 839
    vser->bus->vser = vser;
840 840
    QTAILQ_INIT(&vser->ports);
841 841

  
842
    vser->bus->max_nr_ports = max_nr_ports;
843
    vser->ivqs = qemu_malloc(max_nr_ports * sizeof(VirtQueue *));
844
    vser->ovqs = qemu_malloc(max_nr_ports * sizeof(VirtQueue *));
842
    vser->bus->max_nr_ports = conf->max_virtserial_ports;
843
    vser->ivqs = qemu_malloc(conf->max_virtserial_ports * sizeof(VirtQueue *));
844
    vser->ovqs = qemu_malloc(conf->max_virtserial_ports * sizeof(VirtQueue *));
845 845

  
846 846
    /* Add a queue for host to guest transfers for port 0 (backward compat) */
847 847
    vser->ivqs[0] = virtio_add_queue(vdev, 128, handle_input);
......
866 866
        vser->ovqs[i] = virtio_add_queue(vdev, 128, handle_output);
867 867
    }
868 868

  
869
    vser->config.max_nr_ports = max_nr_ports;
870
    vser->ports_map = qemu_mallocz(((max_nr_ports + 31) / 32)
869
    vser->config.max_nr_ports = conf->max_virtserial_ports;
870
    vser->ports_map = qemu_mallocz(((conf->max_virtserial_ports + 31) / 32)
871 871
        * sizeof(vser->ports_map[0]));
872 872
    /*
873 873
     * Reserve location 0 for a console port for backward compat

Also available in: Unified diff