From: Laurent Vivier <lvivier@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, jfreimann@redhat.com,
"Michael S. Tsirkin" <mst@redhat.com>,
Laurent Vivier <laurent@vivier.eu>,
quintela@redhat.com
Subject: Re: [PATCH 2/2] virtio-net: add missing object_unref()
Date: Tue, 9 Feb 2021 17:50:00 +0100 [thread overview]
Message-ID: <49622ba7-fdf4-8bbb-282e-747a7a13c34b@redhat.com> (raw)
In-Reply-To: <20210206123955.2196514-3-lvivier@redhat.com>
CC: Michael
On 06/02/2021 13:39, 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>
> ---
> 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");
>
next prev parent reply other threads:[~2021-02-09 16:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-06 12:39 [PATCH 0/2] failover: trivial cleanup and fix Laurent Vivier
2021-02-06 12:39 ` [PATCH 1/2] pci: cleanup failover sanity check Laurent Vivier
2021-02-06 14:32 ` Laurent Vivier
2021-02-08 8:42 ` Jens Freimann
2021-02-09 16:49 ` Laurent Vivier
2021-02-06 12:39 ` [PATCH 2/2] virtio-net: add missing object_unref() Laurent Vivier
2021-02-08 8:45 ` Jens Freimann
2021-02-09 16:50 ` Laurent Vivier [this message]
2021-02-10 13:40 ` [PATCH 0/2] failover: trivial cleanup and fix Laurent Vivier
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=49622ba7-fdf4-8bbb-282e-747a7a13c34b@redhat.com \
--to=lvivier@redhat.com \
--cc=jfreimann@redhat.com \
--cc=laurent@vivier.eu \
--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).