virtio-serial: Use a struct to pass config information from proxy

Instead of using a single variable to pass to the virtio_serial_init
function, use a struct so that expanding the number of variables to be
passed on later is easier.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
This commit is contained in:
Amit Shah 2011-02-03 11:22:32 +05:30
parent e0efb993b8
commit 6b331efb73
4 changed files with 21 additions and 15 deletions

View file

@ -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