All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: arei.gonglei@huawei.com
Cc: agraf@suse.de, weidong.huang@huawei.com, luonengjun@huawei.com,
	peter.huangpeng@huawei.com, qemu-devel@nongnu.org,
	borntraeger@de.ibm.com, stefanha@redhat.com,
	cornelia.huck@de.ibm.com, pbonzini@redhat.com, rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH v2 1/9] virtio-net: use aliases instead of duplicate qdev properties
Date: Sun, 14 Sep 2014 21:13:01 +0300	[thread overview]
Message-ID: <20140914181301.GB1226@redhat.com> (raw)
In-Reply-To: <1410244510-9292-2-git-send-email-arei.gonglei@huawei.com>

On Tue, Sep 09, 2014 at 02:35:02PM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> 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 <arei.gonglei@huawei.com>
> ---
>  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 ddb5da1..6722156 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -1414,8 +1414,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(),
>  };
>  
> @@ -1456,6 +1454,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 = {

Does -device virtio-net-pci,? still list e.g. the mac property with this
patch?


> -- 
> 1.7.12.4
> 

  reply	other threads:[~2014-09-14 18:10 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-09  6:35 [Qemu-devel] [PATCH v2 0/9] virtio: fix virtio child recount in transports arei.gonglei
2014-09-09  6:35 ` [Qemu-devel] [PATCH v2 1/9] virtio-net: use aliases instead of duplicate qdev properties arei.gonglei
2014-09-14 18:13   ` Michael S. Tsirkin [this message]
2014-09-15  1:03     ` Gonglei (Arei)
2014-09-15  5:36       ` Michael S. Tsirkin
2014-09-15  5:49         ` Gonglei (Arei)
2014-09-15  6:41           ` Michael S. Tsirkin
2014-09-15  7:12             ` Gonglei (Arei)
2014-09-15  8:37               ` Michael S. Tsirkin
2014-09-15  9:06                 ` Gonglei (Arei)
2014-09-15  9:23                 ` Gonglei (Arei)
2014-09-15  9:29                   ` Gonglei (Arei)
2014-09-15  9:59                     ` Michael S. Tsirkin
2014-09-15 14:11                       ` Gonglei (Arei)
2014-09-15  9:58                   ` Michael S. Tsirkin
2014-09-09  6:35 ` [Qemu-devel] [PATCH v2 2/9] virtio: fix virtio-net child refcount in transports arei.gonglei
2014-09-09  6:35 ` [Qemu-devel] [PATCH v2 3/9] virtio/vhost scsi: use aliases instead of duplicate qdev properties arei.gonglei
2014-09-09  6:35 ` [Qemu-devel] [PATCH v2 4/9] virtio/vhost-scsi: fix virtio-scsi/vhost-scsi child refcount in transports arei.gonglei
2014-09-09  6:35 ` [Qemu-devel] [PATCH v2 5/9] virtio-serial: use aliases instead of duplicate qdev properties arei.gonglei
2014-09-09  6:35 ` [Qemu-devel] [PATCH v2 6/9] virtio-serial: fix virtio-serial child refcount in transports arei.gonglei
2014-09-09  6:35 ` [Qemu-devel] [PATCH v2 7/9] virtio-rng: use aliases instead of duplicate qdev properties arei.gonglei
2014-09-09  6:35 ` [Qemu-devel] [PATCH v2 8/9] virtio-rng: fix virtio-rng child refcount in transports arei.gonglei
2014-09-09  6:35 ` [Qemu-devel] [PATCH v2 9/9] virtio-balloon: fix virtio-balloon " arei.gonglei
2014-09-12 11:55 ` [Qemu-devel] [PATCH v2 0/9] virtio: fix virtio child recount " Gonglei (Arei)
2014-09-19  9:52 ` Gonglei (Arei)

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=20140914181301.GB1226@redhat.com \
    --to=mst@redhat.com \
    --cc=agraf@suse.de \
    --cc=arei.gonglei@huawei.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=luonengjun@huawei.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=stefanha@redhat.com \
    --cc=weidong.huang@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.