qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>, qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	qemu-trivial@nongnu.org, quintela@redhat.com,
	Michael Tokarev <mjt@tls.msk.ru>,
	Laurent Vivier <laurent@vivier.eu>,
	jfreimann@redhat.com
Subject: Re: [PATCH v2 2/3] virtio-net: add missing object_unref()
Date: Thu, 18 Feb 2021 13:57:51 +0800	[thread overview]
Message-ID: <27e955d5-c413-7cf8-3bea-ce6385b4a125@redhat.com> (raw)
In-Reply-To: <20210210174518.2493928-3-lvivier@redhat.com>


On 2021/2/11 上午1:45, Laurent Vivier wrote:
> failover_add_primary() calls qdev_device_add() and doesn't unref
> the device. Because of that, when the device is unplugged a reference
> is remaining and prevents the cleanup of the object.
>
> This prevents to be able to plugin back the failover primary device,
> with errors like:
>
>    (qemu) device_add vfio-pci,host=0000:41:00.0,id=hostdev0,bus=root.3,failover_pair_id=net0
>    (qemu) device_del hostdev0
>
> We can check with "info qtree" and "info pci" that the device has been removed, and then:
>
>    (qemu) device_add vfio-pci,host=0000:41:00.0,id=hostdev1,bus=root.3,failover_pair_id=net0
>    Error: vfio 0000:41:00.0: device is already attached
>    (qemu) device_add vfio-pci,host=0000:41:00.0,id=hostdev0,bus=root.3,failover_pair_id=net0
>    qemu-kvm: Duplicate ID 'hostdev0' for device
>
> Fixes: 21e8709b29cd ("failover: Remove primary_dev member")
> Cc: quintela@redhat.com
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> Reviewed-by: Jens Freimann <jfreimann@redhat.com>


Acked-by: Jason Wang <jasowang@redhat.com>


> ---
>   hw/net/virtio-net.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 5150f295e8c5..1c5af08dc556 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -862,6 +862,8 @@ static void failover_add_primary(VirtIONet *n, Error **errp)
>           dev = qdev_device_add(opts, &err);
>           if (err) {
>               qemu_opts_del(opts);
> +        } else {
> +            object_unref(OBJECT(dev));
>           }
>       } else {
>           error_setg(errp, "Primary device not found");



  reply	other threads:[~2021-02-18  5:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-10 17:45 [PATCH v2 0/3] failover: trivial cleanup and fix Laurent Vivier
2021-02-10 17:45 ` [PATCH v2 1/3] pci: cleanup failover sanity check Laurent Vivier
2021-02-18  5:56   ` Jason Wang
2021-02-10 17:45 ` [PATCH v2 2/3] virtio-net: add missing object_unref() Laurent Vivier
2021-02-18  5:57   ` Jason Wang [this message]
2021-02-10 17:45 ` [PATCH v2 3/3] failover: really display a warning when the primary device is not found Laurent Vivier
2021-02-18  6:01   ` Jason Wang

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=27e955d5-c413-7cf8-3bea-ce6385b4a125@redhat.com \
    --to=jasowang@redhat.com \
    --cc=jfreimann@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=lvivier@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=quintela@redhat.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 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).