From patchwork Mon Jan 7 18:40:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fred.konrad@greensocs.com X-Patchwork-Id: 210036 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A4A052C009A for ; Tue, 8 Jan 2013 05:44:16 +1100 (EST) Received: from localhost ([::1]:52152 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsHgE-0007Hz-Py for incoming@patchwork.ozlabs.org; Mon, 07 Jan 2013 13:44:14 -0500 Received: from eggs.gnu.org ([208.118.235.92]:56683) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsHef-0005UZ-TU for qemu-devel@nongnu.org; Mon, 07 Jan 2013 13:42:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TsHee-0005yW-Ni for qemu-devel@nongnu.org; Mon, 07 Jan 2013 13:42:37 -0500 Received: from greensocs.com ([87.106.252.221]:53019 helo=s15328186.onlinehome-server.info) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsHee-0005yL-D4 for qemu-devel@nongnu.org; Mon, 07 Jan 2013 13:42:36 -0500 Received: from localhost (unknown [127.0.0.1]) by s15328186.onlinehome-server.info (Postfix) with ESMTP id D61EA439E52; Mon, 7 Jan 2013 18:42:35 +0000 (UTC) Received: from s15328186.onlinehome-server.info ([127.0.0.1]) by localhost (s15328186.onlinehome-server.info [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pPJhSFvUsbsC; Mon, 7 Jan 2013 19:42:32 +0100 (CET) Received: by s15328186.onlinehome-server.info (Postfix, from userid 491) id 562BD439E3F; Mon, 7 Jan 2013 19:42:26 +0100 (CET) Received: from compaq.katmai.xl.cx.katmai.xl.cx (lan31-11-83-155-143-136.fbx.proxad.net [83.155.143.136]) by s15328186.onlinehome-server.info (Postfix) with ESMTPSA id 8D08D439E42; Mon, 7 Jan 2013 19:42:24 +0100 (CET) From: fred.konrad@greensocs.com To: qemu-devel@nongnu.org, aliguori@us.ibm.com Date: Mon, 7 Jan 2013 19:40:54 +0100 Message-Id: <1357584074-10852-42-git-send-email-fred.konrad@greensocs.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1357584074-10852-1-git-send-email-fred.konrad@greensocs.com> References: <1357584074-10852-1-git-send-email-fred.konrad@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 87.106.252.221 Cc: kwolf@redhat.com, peter.maydell@linaro.org, e.voevodin@samsung.com, mst@redhat.com, mark.burton@greensocs.com, agraf@suse.de, amit.shah@redhat.com, aneesh.kumar@linux.vnet.ibm.com, stefanha@redhat.com, cornelia.huck@de.ibm.com, pbonzini@redhat.com, afaerber@suse.de, fred.konrad@greensocs.com Subject: [Qemu-devel] [PATCH 41/61] virtio-rng-s390 : switch to the new API. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: KONRAD Frederic Here the virtio-rng-s390 is modified for the new API. The device virtio-rng-s390 extends virtio-s390-device as before. It creates and connects a virtio-rng during the init. The properties are not modified. Signed-off-by: KONRAD Frederic --- hw/s390-virtio-bus.c | 35 ++++++++++++++++++----------------- hw/s390-virtio-bus.h | 13 ++++++++++++- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c index 569cac2..f3e1f07 100644 --- a/hw/s390-virtio-bus.c +++ b/hw/s390-virtio-bus.c @@ -229,16 +229,25 @@ static void s390_virtio_scsi_instance_init(Object *obj) object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); } -static int s390_virtio_rng_init(VirtIOS390Device *dev) +static int s390_virtio_rng_init(VirtIOS390Device *s390_dev) { - VirtIODevice *vdev; - - vdev = virtio_rng_init((DeviceState *)dev, &dev->rng); - if (!vdev) { + VirtIORNGS390 *dev = VIRTIO_RNG_S390(s390_dev); + DeviceState *vdev = DEVICE(&dev->vdev); + virtio_rng_set_conf(vdev, &(dev->rng)); + qdev_set_parent_bus(vdev, BUS(s390_dev->bus)); + if (qdev_init(vdev) < 0) { return -1; } + return s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev)); +} - return s390_virtio_device_init(dev, vdev); +static void s390_virtio_rng_instance_init(Object *obj) +{ + VirtIORNGS390 *dev = VIRTIO_RNG_S390(obj); + object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_RNG); + object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); + object_property_add_link(obj, "rng", TYPE_RNG_BACKEND, + (Object **)&dev->rng.rng, NULL); } static uint64_t s390_virtio_device_vq_token(VirtIOS390Device *dev, int vq) @@ -498,14 +507,6 @@ static TypeInfo s390_virtio_serial = { .class_init = s390_virtio_serial_class_init, }; -static void s390_virtio_rng_initfn(Object *obj) -{ - VirtIOS390Device *dev = VIRTIO_S390_DEVICE(obj); - - object_property_add_link(obj, "rng", TYPE_RNG_BACKEND, - (Object **)&dev->rng.rng, NULL); -} - static void s390_virtio_rng_class_init(ObjectClass *klass, void *data) { VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass); @@ -514,10 +515,10 @@ static void s390_virtio_rng_class_init(ObjectClass *klass, void *data) } static TypeInfo s390_virtio_rng = { - .name = "virtio-rng-s390", + .name = TYPE_VIRTIO_RNG_S390, .parent = TYPE_VIRTIO_S390_DEVICE, - .instance_size = sizeof(VirtIOS390Device), - .instance_init = s390_virtio_rng_initfn, + .instance_size = sizeof(VirtIORNGS390), + .instance_init = s390_virtio_rng_instance_init, .class_init = s390_virtio_rng_class_init, }; diff --git a/hw/s390-virtio-bus.h b/hw/s390-virtio-bus.h index 62c2b1c..3eb9b69 100644 --- a/hw/s390-virtio-bus.h +++ b/hw/s390-virtio-bus.h @@ -87,7 +87,6 @@ struct VirtIOS390Device { VirtIODevice *vdev; uint32_t host_features; virtio_serial_conf serial; - VirtIORNGConf rng; VirtioBusState *bus; }; @@ -149,5 +148,17 @@ typedef struct VirtIOSCSIS390 { VirtIOSCSIConf scsi; } VirtIOSCSIS390; +/* virtio-rng-s390 */ + +#define TYPE_VIRTIO_RNG_S390 "virtio-rng-s390" +#define VIRTIO_RNG_S390(obj) \ + OBJECT_CHECK(VirtIORNGS390, (obj), TYPE_VIRTIO_RNG_S390) + +typedef struct VirtIORNGS390 { + VirtIOS390Device parent_obj; + VirtIORNG vdev; + VirtIORNGConf rng; +} VirtIORNGS390; + #endif