[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 18/61] virtio-net-s390 : switch to the new API.
From: |
fred . konrad |
Subject: |
[Qemu-devel] [PATCH 18/61] virtio-net-s390 : switch to the new API. |
Date: |
Mon, 7 Jan 2013 19:40:31 +0100 |
From: KONRAD Frederic <address@hidden>
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 during the init. The properties are not modified.
Signed-off-by: KONRAD Frederic <address@hidden>
---
hw/s390-virtio-bus.c | 32 ++++++++++++++++++++------------
hw/s390-virtio-bus.h | 15 +++++++++++++--
2 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index d40fb8b..8a2c8b3 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -151,16 +151,23 @@ 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;
-
- vdev = virtio_net_init((DeviceState *)dev, &dev->nic, &dev->net);
- if (!vdev) {
+ VirtIONetS390 *dev = VIRTIO_NET_S390(s390_dev);
+ DeviceState *vdev = DEVICE(&dev->vdev);
+ virtio_net_set_conf(vdev, &(dev->net), &(dev->nic));
+ 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_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)
@@ -409,12 +416,12 @@ static const VirtIOBindings virtio_s390_bindings = {
};
static Property s390_virtio_net_properties[] = {
- DEFINE_NIC_PROPERTIES(VirtIOS390Device, nic),
- DEFINE_PROP_UINT32("x-txtimer", VirtIOS390Device,
+ DEFINE_NIC_PROPERTIES(VirtIONetS390, nic),
+ DEFINE_PROP_UINT32("x-txtimer", VirtIONetS390,
net.txtimer, TX_TIMER_INTERVAL),
- DEFINE_PROP_INT32("x-txburst", VirtIOS390Device,
+ DEFINE_PROP_INT32("x-txburst", VirtIONetS390,
net.txburst, TX_BURST),
- DEFINE_PROP_STRING("tx", VirtIOS390Device, net.tx),
+ DEFINE_PROP_STRING("tx", VirtIONetS390, net.tx),
DEFINE_PROP_END_OF_LIST(),
};
@@ -428,9 +435,10 @@ static void s390_virtio_net_class_init(ObjectClass *klass,
void *data)
}
static 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/s390-virtio-bus.h b/hw/s390-virtio-bus.h
index f5d0b94..f67ca51 100644
--- a/hw/s390-virtio-bus.h
+++ b/hw/s390-virtio-bus.h
@@ -85,10 +85,8 @@ struct VirtIOS390Device {
ram_addr_t feat_offs;
uint8_t feat_len;
VirtIODevice *vdev;
- NICConf nic;
uint32_t host_features;
virtio_serial_conf serial;
- virtio_net_conf net;
VirtIOSCSIConf scsi;
VirtIORNGConf rng;
VirtioBusState *bus;
@@ -127,5 +125,18 @@ typedef struct VirtIOBlkS390 {
VirtIOBlkConf blk;
} VirtIOBlkS390;
+/* 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;
+ virtio_net_conf net;
+ NICConf nic;
+} VirtIONetS390;
+
#endif
--
1.7.11.7
- [Qemu-devel] [PATCH 09/61] virtio-blk : don't use pointer for configuration., (continued)
- [Qemu-devel] [PATCH 09/61] virtio-blk : don't use pointer for configuration., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 10/61] virtio-blk : add the virtio-blk device., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 12/61] virtio-blk-s390 : switch to the new API., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 11/61] virtio-blk-pci : switch to new API., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 14/61] virtio-blk : cleanup : remove qdev field., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 16/61] virtio-net : add the virtio-net device., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 17/61] virtio-net-pci : switch to the new API., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 15/61] virtio-net : show the VirtIONet structure., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 13/61] virtio-blk : cleanup : use QOM cast., fred . konrad, 2013/01/07
- [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 <=
- [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