qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: fred.konrad@greensocs.com
To: aliguori@us.ibm.com, qemu-devel@nongnu.org
Cc: cornelia.huck@de.ibm.com, peter.maydell@linaro.org,
	mark.burton@greensocs.com, fred.konrad@greensocs.com
Subject: [Qemu-devel] [PATCH v3 4/7] virtio-net-s390: switch to the new API.
Date: Thu, 11 Apr 2013 16:29:59 +0200	[thread overview]
Message-ID: <1365690602-22729-5-git-send-email-fred.konrad@greensocs.com> (raw)
In-Reply-To: <1365690602-22729-1-git-send-email-fred.konrad@greensocs.com>

From: KONRAD Frederic <fred.konrad@greensocs.com>

Here the virtio-net-s390 is modified for the new API. The device
virtio-net-s390 extends virtio-s390-device as before. It creates and
connects a virtio-net-device during the init. The properties are not modified.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
 hw/s390x/s390-virtio-bus.c | 29 +++++++++++++++++++----------
 hw/s390x/s390-virtio-bus.h | 13 +++++++++++--
 2 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index 2708af8..ca0e301 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -149,17 +149,25 @@ static int s390_virtio_device_init(VirtIOS390Device *dev, VirtIODevice *vdev)
     return 0;
 }
 
-static int s390_virtio_net_init(VirtIOS390Device *dev)
+static int s390_virtio_net_init(VirtIOS390Device *s390_dev)
 {
-    VirtIODevice *vdev;
+    VirtIONetS390 *dev = VIRTIO_NET_S390(s390_dev);
+    DeviceState *vdev = DEVICE(&dev->vdev);
 
-    vdev = virtio_net_init((DeviceState *)dev, &dev->nic, &dev->net,
-                           dev->host_features);
-    if (!vdev) {
+    virtio_net_set_config_size(&dev->vdev, s390_dev->host_features);
+    qdev_set_parent_bus(vdev, BUS(&s390_dev->bus));
+    if (qdev_init(vdev) < 0) {
         return -1;
     }
 
-    return s390_virtio_device_init(dev, vdev);
+    return s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev));
+}
+
+static void s390_virtio_net_instance_init(Object *obj)
+{
+    VirtIONetS390 *dev = VIRTIO_NET_S390(obj);
+    object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_NET);
+    object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
 }
 
 static int s390_virtio_blk_init(VirtIOS390Device *s390_dev)
@@ -425,9 +433,9 @@ static const VirtIOBindings virtio_s390_bindings = {
 };
 
 static Property s390_virtio_net_properties[] = {
-    DEFINE_NIC_PROPERTIES(VirtIOS390Device, nic),
+    DEFINE_NIC_PROPERTIES(VirtIONetS390, vdev.nic_conf),
     DEFINE_VIRTIO_NET_FEATURES(VirtIOS390Device, host_features),
-    DEFINE_VIRTIO_NET_PROPERTIES(VirtIOS390Device, net),
+    DEFINE_VIRTIO_NET_PROPERTIES(VirtIONetS390, vdev.net_conf),
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -441,9 +449,10 @@ static void s390_virtio_net_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo s390_virtio_net = {
-    .name          = "virtio-net-s390",
+    .name          = TYPE_VIRTIO_NET_S390,
     .parent        = TYPE_VIRTIO_S390_DEVICE,
-    .instance_size = sizeof(VirtIOS390Device),
+    .instance_size = sizeof(VirtIONetS390),
+    .instance_init = s390_virtio_net_instance_init,
     .class_init    = s390_virtio_net_class_init,
 };
 
diff --git a/hw/s390x/s390-virtio-bus.h b/hw/s390x/s390-virtio-bus.h
index 1daf753..925ed2b 100644
--- a/hw/s390x/s390-virtio-bus.h
+++ b/hw/s390x/s390-virtio-bus.h
@@ -89,9 +89,7 @@ struct VirtIOS390Device {
     ram_addr_t feat_offs;
     uint8_t feat_len;
     VirtIODevice *vdev;
-    NICConf nic;
     uint32_t host_features;
-    virtio_net_conf net;
     VirtIORNGConf rng;
     VirtioBusState bus;
 };
@@ -151,4 +149,15 @@ typedef struct VirtIOSerialS390 {
     VirtIOSerial vdev;
 } VirtIOSerialS390;
 
+/* virtio-net-s390 */
+
+#define TYPE_VIRTIO_NET_S390 "virtio-net-s390"
+#define VIRTIO_NET_S390(obj) \
+        OBJECT_CHECK(VirtIONetS390, (obj), TYPE_VIRTIO_NET_S390)
+
+typedef struct VirtIONetS390 {
+    VirtIOS390Device parent_obj;
+    VirtIONet vdev;
+} VirtIONetS390;
+
 #endif
-- 
1.8.1.4

  parent reply	other threads:[~2013-04-11 14:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-11 14:29 [Qemu-devel] [PATCH v3 0/7] virtio-net refactoring fred.konrad
2013-04-11 14:29 ` [Qemu-devel] [PATCH v3 1/7] virtio: add two functions to VirtioDeviceClass fred.konrad
2013-04-11 14:29 ` [Qemu-devel] [PATCH v3 2/7] virtio-net: add the virtio-net device fred.konrad
2013-04-11 14:29 ` [Qemu-devel] [PATCH v3 3/7] virtio-net-pci: switch to the new API fred.konrad
2013-04-11 14:29 ` fred.konrad [this message]
2013-04-11 14:30 ` [Qemu-devel] [PATCH v3 5/7] virtio-net-ccw: " fred.konrad
2013-04-11 14:30 ` [Qemu-devel] [PATCH v3 6/7] virtio-net: cleanup: use QOM cast fred.konrad
2013-04-18  8:41   ` Michael S. Tsirkin
2013-04-18 11:34     ` KONRAD Frédéric
2013-04-18 11:01       ` Michael S. Tsirkin
2013-04-18 12:52       ` Anthony Liguori
2013-04-18 12:50     ` Anthony Liguori
2013-04-18 13:28       ` Paolo Bonzini
2013-04-11 14:30 ` [Qemu-devel] [PATCH v3 7/7] virtio-net: cleanup: init and exit function fred.konrad
2013-04-15  9:02 ` [Qemu-devel] [PATCH v3 0/7] virtio-net refactoring Cornelia Huck
2013-04-22 18:37 ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1365690602-22729-5-git-send-email-fred.konrad@greensocs.com \
    --to=fred.konrad@greensocs.com \
    --cc=aliguori@us.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=mark.burton@greensocs.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).