[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 35/61] virtio-balloon : cleanup : init and exit func
From: |
fred . konrad |
Subject: |
[Qemu-devel] [PATCH 35/61] virtio-balloon : cleanup : init and exit function. |
Date: |
Mon, 7 Jan 2013 19:40:48 +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-balloon-pci refactoring.
Signed-off-by: KONRAD Frederic <address@hidden>
---
hw/virtio-balloon.c | 68 ++++++++++-------------------------------------------
1 file changed, 12 insertions(+), 56 deletions(-)
diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c
index fc94e3e..3990a6b 100644
--- a/hw/virtio-balloon.c
+++ b/hw/virtio-balloon.c
@@ -224,27 +224,14 @@ static int virtio_balloon_load(QEMUFile *f, void *opaque,
int version_id)
return 0;
}
-static VirtIODevice *virtio_balloon_common_init(DeviceState *dev,
- VirtIOBalloon **ps)
+static int virtio_balloon_device_init(VirtIODevice *vdev)
{
- VirtIOBalloon *s = *ps;
+ DeviceState *qdev = DEVICE(vdev);
+ VirtIOBalloon *s = VIRTIO_BALLOON(vdev);
int ret;
- /*
- * We have two cases here : the old virtio-balloon-x device, and the
- * refactored virtio-balloon.
- * This will disappear later in the serie.
- */
- int old_device = (s == NULL);
- if (s == NULL) {
- /* old virtio-balloon-pci or virtio-balloon-s390, no memory allocated
*/
- s = (VirtIOBalloon *)virtio_common_init("virtio-balloon",
- VIRTIO_ID_BALLOON,
- 8, sizeof(VirtIOBalloon));
- } else {
- /* new API virtio-balloon. ( memory allocated by qdev ) */
- virtio_init(VIRTIO_DEVICE(s), "virtio-balloon", VIRTIO_ID_BALLOON, 8);
- }
+ virtio_init(vdev, "virtio-balloon", VIRTIO_ID_BALLOON, 8);
+
/*
* This will disappear later in the serie.
* We will use VirtioDeviceClass instead.
@@ -255,53 +242,22 @@ static VirtIODevice
*virtio_balloon_common_init(DeviceState *dev,
ret = qemu_add_balloon_handler(virtio_balloon_to_target,
virtio_balloon_stat, s);
- if ((ret < 0) && (old_device)) {
- virtio_cleanup(&s->vdev);
- return NULL;
- }
+
if (ret < 0) {
virtio_common_cleanup(VIRTIO_DEVICE(s));
- return NULL;
+ return -1;
}
- s->ivq = virtio_add_queue(&s->vdev, 128, virtio_balloon_handle_output);
- s->dvq = virtio_add_queue(&s->vdev, 128, virtio_balloon_handle_output);
- s->svq = virtio_add_queue(&s->vdev, 128, virtio_balloon_receive_stats);
+ s->ivq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);
+ s->dvq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);
+ s->svq = virtio_add_queue(vdev, 128, virtio_balloon_receive_stats);
reset_stats(s);
- s->qdev = dev;
- register_savevm(dev, "virtio-balloon", -1, 1,
+ s->qdev = qdev;
+ register_savevm(qdev, "virtio-balloon", -1, 1,
virtio_balloon_save, virtio_balloon_load, s);
- return &s->vdev;
-}
-
-/*
- * This two functions will be removed later in the serie.
- */
-VirtIODevice *virtio_balloon_init(DeviceState *dev)
-{
- VirtIOBalloon *s = NULL;
- return virtio_balloon_common_init(dev, &s);
-}
-
-void virtio_balloon_exit(VirtIODevice *vdev)
-{
- VirtIOBalloon *s = DO_UPCAST(VirtIOBalloon, vdev, vdev);
-
- qemu_remove_balloon_handler(s);
- unregister_savevm(s->qdev, "virtio-balloon", s);
- virtio_cleanup(vdev);
-}
-
-static int virtio_balloon_device_init(VirtIODevice *vdev)
-{
- DeviceState *qdev = DEVICE(vdev);
- VirtIOBalloon *s = VIRTIO_BALLOON(vdev);
- if (virtio_balloon_common_init(qdev, &s) == NULL) {
- return -1;
- }
return 0;
}
--
1.7.11.7
- [Qemu-devel] [PATCH 20/61] virtio-net : cleanup : init and exit function., (continued)
- [Qemu-devel] [PATCH 20/61] virtio-net : cleanup : init and exit function., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 18/61] virtio-net-s390 : switch to the new API., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 23/61] virtio-scsi : don't use pointer for configuration., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 21/61] virtio-net : cleanup : remove qdev field., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 19/61] virtio-net : cleanup : use QOM cast., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 30/61] virtio-scsi : cleanup : init and exit functions., fred . konrad, 2013/01/07
- [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 <=
- [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, 2013/01/07
- [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