[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 01/12] virtio-net: use aliases instead of duplica
From: |
arei.gonglei |
Subject: |
[Qemu-devel] [PATCH v3 01/12] virtio-net: use aliases instead of duplicate qdev properties |
Date: |
Tue, 30 Sep 2014 17:49:33 +0800 |
From: Gonglei <address@hidden>
virtio-net-pci, virtio-net-s390, and virtio-net-ccw all duplicate the
qdev properties of their VirtIONet child. This approach does not work
well with string or pointer properties since we must be careful about
leaking or double-freeing them.
Use the QOM alias property to forward property accesses to the
VirtIONet child. This way no duplication is necessary.
Signed-off-by: Gonglei <address@hidden>
Reviewed-by: Cornelia Huck <address@hidden>
---
hw/s390x/s390-virtio-bus.c | 3 +--
hw/s390x/virtio-ccw.c | 3 +--
hw/virtio/virtio-pci.c | 3 +--
3 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index 6b6fb61..5b5d595 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -161,6 +161,7 @@ static void s390_virtio_net_instance_init(Object *obj)
VirtIONetS390 *dev = VIRTIO_NET_S390(obj);
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_NET);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+ qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
}
static int s390_virtio_blk_init(VirtIOS390Device *s390_dev)
@@ -493,10 +494,8 @@ static unsigned virtio_s390_get_features(DeviceState *d)
/**************** S390 Virtio Bus Device Descriptions *******************/
static Property s390_virtio_net_properties[] = {
- DEFINE_NIC_PROPERTIES(VirtIONetS390, vdev.nic_conf),
DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features),
DEFINE_VIRTIO_NET_FEATURES(VirtIOS390Device, host_features),
- DEFINE_VIRTIO_NET_PROPERTIES(VirtIONetS390, vdev.net_conf),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 33a1d86..7d67577 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -794,6 +794,7 @@ static void virtio_ccw_net_instance_init(Object *obj)
VirtIONetCcw *dev = VIRTIO_NET_CCW(obj);
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_NET);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+ qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
}
static int virtio_ccw_blk_init(VirtioCcwDevice *ccw_dev)
@@ -1374,8 +1375,6 @@ static int virtio_ccw_load_config(DeviceState *d,
QEMUFile *f)
static Property virtio_ccw_net_properties[] = {
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
DEFINE_VIRTIO_NET_FEATURES(VirtioCcwDevice, host_features[0]),
- DEFINE_VIRTIO_NET_PROPERTIES(VirtIONetCcw, vdev.net_conf),
- DEFINE_NIC_PROPERTIES(VirtIONetCcw, vdev.nic_conf),
DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index f560814..155fac9 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1425,8 +1425,6 @@ static Property virtio_net_properties[] = {
VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false),
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
DEFINE_VIRTIO_NET_FEATURES(VirtIOPCIProxy, host_features),
- DEFINE_NIC_PROPERTIES(VirtIONetPCI, vdev.nic_conf),
- DEFINE_VIRTIO_NET_PROPERTIES(VirtIONetPCI, vdev.net_conf),
DEFINE_PROP_END_OF_LIST(),
};
@@ -1467,6 +1465,7 @@ static void virtio_net_pci_instance_init(Object *obj)
VirtIONetPCI *dev = VIRTIO_NET_PCI(obj);
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_NET);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+ qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
}
static const TypeInfo virtio_net_pci_info = {
--
1.7.12.4
- [Qemu-devel] [PATCH v3 00/12] virtio: fix virtio child recount in transports, arei.gonglei, 2014/09/30
- [Qemu-devel] [PATCH v3 01/12] virtio-net: use aliases instead of duplicate qdev properties,
arei.gonglei <=
- [Qemu-devel] [PATCH v3 04/12] virtio/vhost-scsi: fix virtio-scsi/vhost-scsi child refcount in transports, arei.gonglei, 2014/09/30
- [Qemu-devel] [PATCH v3 05/12] virtio-serial: use aliases instead of duplicate qdev properties, arei.gonglei, 2014/09/30
- [Qemu-devel] [PATCH v3 03/12] virtio/vhost-scsi: use aliases instead of duplicate qdev properties, arei.gonglei, 2014/09/30
- [Qemu-devel] [PATCH v3 02/12] virtio-net: fix virtio-net child refcount in transports, arei.gonglei, 2014/09/30
- [Qemu-devel] [PATCH v3 09/12] virtio-balloon: fix virtio-balloon child refcount in transports, arei.gonglei, 2014/09/30
- [Qemu-devel] [PATCH v3 07/12] virtio-rng: use aliases instead of duplicate qdev properties, arei.gonglei, 2014/09/30
- [Qemu-devel] [PATCH v3 10/12] virtio-9p: use aliases instead of duplicate qdev properties, arei.gonglei, 2014/09/30
- [Qemu-devel] [PATCH v3 11/12] virtio-9p: fix virtio-9p child refcount in transports, arei.gonglei, 2014/09/30
- [Qemu-devel] [PATCH v3 08/12] virtio-rng: fix virtio-rng child refcount in transports, arei.gonglei, 2014/09/30