[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 50/61] virtio-serial : cleanup : init and exit funct
From: |
fred . konrad |
Subject: |
[Qemu-devel] [PATCH 50/61] virtio-serial : cleanup : init and exit functions. |
Date: |
Mon, 7 Jan 2013 19:41:03 +0100 |
From: KONRAD Frederic <address@hidden>
This remove old init and exit function as they are no longer needed.
This shouldn't been applyied before virtio-serial-pci and
virtio-serial-s390 refactoring.
Signed-off-by: KONRAD Frederic <address@hidden>
---
hw/virtio-serial-bus.c | 94 ++++++++++++--------------------------------------
1 file changed, 22 insertions(+), 72 deletions(-)
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 5186191..f1c7d75 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -904,51 +904,39 @@ static int virtser_port_qdev_exit(DeviceState *qdev)
return 0;
}
-static VirtIODevice *virtio_serial_common_init(DeviceState *dev,
- virtio_serial_conf *conf,
- VirtIODevice **pvdev)
+static int virtio_serial_device_init(VirtIODevice *vdev)
{
- VirtIOSerial *vser;
- VirtIODevice *vdev = *pvdev;
+ DeviceState *qdev = DEVICE(vdev);
+ VirtIOSerial *vser = VIRTIO_SERIAL(vdev);
uint32_t i, max_supported_ports;
- if (!conf->max_virtserial_ports)
- return NULL;
+ if (!vser->serial.max_virtserial_ports) {
+ return -1;
+ }
/* Each port takes 2 queues, and one pair is for the control queue */
max_supported_ports = VIRTIO_PCI_QUEUE_MAX / 2 - 1;
- if (conf->max_virtserial_ports > max_supported_ports) {
+ if (vser->serial.max_virtserial_ports > max_supported_ports) {
error_report("maximum ports supported: %u", max_supported_ports);
- return NULL;
+ return -1;
}
- /*
- * We have two cases here : the old virtio-serial-pci device, and the
- * refactored virtio-serial.
- */
- if (vdev == NULL) {
- /* virtio-serial-pci */
- vdev = virtio_common_init("virtio-serial", VIRTIO_ID_CONSOLE,
- sizeof(struct virtio_console_config),
- sizeof(VirtIOSerial));
- vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
- } else {
- /* virtio-serial */
- virtio_init(vdev, "virtio-serial", VIRTIO_ID_CONSOLE,
- sizeof(struct virtio_console_config));
- vser = VIRTIO_SERIAL(vdev);
- }
+
+ virtio_init(vdev, "virtio-serial", VIRTIO_ID_CONSOLE,
+ 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, dev, NULL);
+ qbus_create_inplace(&vser->bus.qbus, TYPE_VIRTIO_SERIAL_BUS, qdev, NULL);
vser->bus.qbus.allow_hotplug = 1;
vser->bus.vser = vser;
QTAILQ_INIT(&vser->ports);
- vser->bus.max_nr_ports = conf->max_virtserial_ports;
- vser->ivqs = g_malloc(conf->max_virtserial_ports * sizeof(VirtQueue *));
- vser->ovqs = g_malloc(conf->max_virtserial_ports * sizeof(VirtQueue *));
+ vser->bus.max_nr_ports = vser->serial.max_virtserial_ports;
+ vser->ivqs = g_malloc(vser->serial.max_virtserial_ports
+ * sizeof(VirtQueue *));
+ vser->ovqs = g_malloc(vser->serial.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);
@@ -973,8 +961,8 @@ static VirtIODevice *virtio_serial_common_init(DeviceState
*dev,
vser->ovqs[i] = virtio_add_queue(vdev, 128, handle_output);
}
- vser->config.max_nr_ports = tswap32(conf->max_virtserial_ports);
- vser->ports_map = g_malloc0(((conf->max_virtserial_ports + 31) / 32)
+ vser->config.max_nr_ports = tswap32(vser->serial.max_virtserial_ports);
+ vser->ports_map = g_malloc0(((vser->serial.max_virtserial_ports + 31) / 32)
* sizeof(vser->ports_map[0]));
/*
* Reserve location 0 for a console port for backward compat
@@ -988,7 +976,7 @@ static VirtIODevice *virtio_serial_common_init(DeviceState
*dev,
vser->vdev.set_status = set_status;
vser->vdev.reset = vser_reset;
- vser->qdev = dev;
+ vser->qdev = qdev;
vser->post_load = NULL;
@@ -996,38 +984,10 @@ static VirtIODevice
*virtio_serial_common_init(DeviceState *dev,
* Register for the savevm section with the virtio-console name
* to preserve backward compat
*/
- register_savevm(dev, "virtio-console", -1, 3, virtio_serial_save,
+ register_savevm(qdev, "virtio-console", -1, 3, virtio_serial_save,
virtio_serial_load, vser);
- return vdev;
-}
-
-/*
- * The two following functions will be cleaned up at the end.
- */
-
-VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *conf)
-{
- VirtIODevice *vdev = NULL;
- return virtio_serial_common_init(dev, conf, &vdev);
-}
-
-void virtio_serial_exit(VirtIODevice *vdev)
-{
- VirtIOSerial *vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
-
- unregister_savevm(vser->qdev, "virtio-console", vser);
-
- g_free(vser->ivqs);
- g_free(vser->ovqs);
- g_free(vser->ports_map);
- if (vser->post_load) {
- g_free(vser->post_load->connected);
- qemu_del_timer(vser->post_load->timer);
- qemu_free_timer(vser->post_load->timer);
- g_free(vser->post_load);
- }
- virtio_cleanup(vdev);
+ return 0;
}
static void virtio_serial_port_class_init(ObjectClass *klass, void *data)
@@ -1055,16 +1015,6 @@ void virtio_serial_set_conf(DeviceState *dev,
virtio_serial_conf *serial)
memcpy(&(s->serial), serial, sizeof(virtio_serial_conf));
}
-static int virtio_serial_device_init(VirtIODevice *vdev)
-{
- DeviceState *qdev = DEVICE(vdev);
- VirtIOSerial *vser = VIRTIO_SERIAL(vdev);
- if (virtio_serial_common_init(qdev, &(vser->serial), &vdev) == NULL) {
- return -1;
- }
- return 0;
-}
-
static int virtio_serial_device_exit(DeviceState *dev)
{
VirtIOSerial *vser = VIRTIO_SERIAL(dev);
--
1.7.11.7
- [Qemu-devel] [PATCH 33/61] virtio-balloon : add the virtio-balloon device., (continued)
- [Qemu-devel] [PATCH 33/61] virtio-balloon : add the virtio-balloon device., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 34/61] virtio-balloon-pci : switch to the new API., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 32/61] virtio-balloon : show the VirtIOBalloon structure., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 36/61] virtio-balloon : cleanup : QOM casts., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 35/61] virtio-balloon : cleanup : init and exit function., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 40/61] virtio-rng : add virtio-rng device., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 41/61] virtio-rng-s390 : switch to the new API., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 43/61] virtio-rng.c : cleanup : init and exit functions., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 49/61] virtio-serial-s390 : switch to the new API., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 48/61] virtio-serial-pci : switch to the new API., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 50/61] virtio-serial : cleanup : init and exit functions.,
fred . konrad <=
- [Qemu-devel] [PATCH 42/61] virtio-rng-pci : switch to the new API., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 47/61] virtio-serial : add the virtio-serial device., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 61/61] virtio : cleanup : init and exit function., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 51/61] virtio-serial : cleanup : use QOM casts., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 56/61] virtio-9p : cleanup : QOM casts., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 59/61] s390-virtio-bus : cleanup, fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 57/61] virtio : remove the function pointer., fred . konrad, 2013/01/07