@ -811,19 +811,19 @@ void virtio_serial_port_qdev_register(VirtIOSerialPortInfo *info)
qdev_register ( & info - > qdev ) ;
}
VirtIODevice * virtio_serial_init ( DeviceState * dev , uint32_t max_nr_ports )
VirtIODevice * virtio_serial_init ( DeviceState * dev , virtio_serial_conf * conf )
{
VirtIOSerial * vser ;
VirtIODevice * vdev ;
uint32_t i , max_supported_ports ;
if ( ! max_nr _ports)
if ( ! conf - > max_virtserial _ports)
return NULL ;
/* Each port takes 2 queues, and one pair is for the control queue */
max_supported_ports = VIRTIO_PCI_QUEUE_MAX / 2 - 1 ;
if ( max_nr _ports > max_supported_ports ) {
if ( conf - > max_virtserial _ports > max_supported_ports ) {
error_report ( " maximum ports supported: %u " , max_supported_ports ) ;
return NULL ;
}
@ -839,9 +839,9 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)
vser - > bus - > vser = vser ;
QTAILQ_INIT ( & vser - > ports ) ;
vser - > bus - > max_nr_ports = max_nr _ports;
vser - > ivqs = qemu_malloc ( max_nr _ports * sizeof ( VirtQueue * ) ) ;
vser - > ovqs = qemu_malloc ( max_nr _ports * sizeof ( VirtQueue * ) ) ;
vser - > bus - > max_nr_ports = conf - > max_virtserial _ports;
vser - > ivqs = qemu_malloc ( conf - > max_virtserial _ports * sizeof ( VirtQueue * ) ) ;
vser - > ovqs = qemu_malloc ( conf - > max_virtserial _ports * sizeof ( VirtQueue * ) ) ;
/* Add a queue for host to guest transfers for port 0 (backward compat) */
vser - > ivqs [ 0 ] = virtio_add_queue ( vdev , 128 , handle_input ) ;
@ -866,8 +866,8 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)
vser - > ovqs [ i ] = virtio_add_queue ( vdev , 128 , handle_output ) ;
}
vser - > config . max_nr_ports = max_nr _ports;
vser - > ports_map = qemu_mallocz ( ( ( max_nr _ports + 31 ) / 32 )
vser - > config . max_nr_ports = conf - > max_virtserial _ports;
vser - > ports_map = qemu_mallocz ( ( ( conf - > max_virtserial _ports + 31 ) / 32 )
* sizeof ( vser - > ports_map [ 0 ] ) ) ;
/*
* Reserve location 0 for a console port for backward compat