From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jens Freimann <jfreimann@redhat.com>
Cc: peter.maydell@linaro.org, jasowang@redhat.com,
qemu-devel@nongnu.org, dgilbert@redhat.com
Subject: Re: [PATCH v2 3/4] net/virtio: avoid passing NULL to qdev_set_parent_bus
Date: Wed, 20 Nov 2019 10:04:01 -0500 [thread overview]
Message-ID: <20191120100034-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20191120143859.24584-4-jfreimann@redhat.com>
On Wed, Nov 20, 2019 at 03:38:58PM +0100, Jens Freimann wrote:
> Make sure we don't pass NULL to qdev_set_parent_bus(). Also simplify
> code a bit and fix a typo.
> This fixes CID 1407224.
>
> Fixes: 9711cd0dfc3f ("net/virtio: add failover support")
> Signed-off-by: Jens Freimann <jfreimann@redhat.com>
patch itself is ok I think
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
but some questions on the commit log
> ---
> hw/net/virtio-net.c | 42 +++++++++++++++++++++++++-----------------
> 1 file changed, 25 insertions(+), 17 deletions(-)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index ac4d19109e..78f1e4e87c 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -2805,25 +2805,33 @@ static bool failover_replug_primary(VirtIONet *n, Error **errp)
> n->primary_device_opts = qemu_opts_from_qdict(
> qemu_find_opts("device"),
> n->primary_device_dict, errp);
> - }
> - if (n->primary_device_opts) {
> - if (n->primary_dev) {
> - n->primary_bus = n->primary_dev->parent_bus;
> - }
> - qdev_set_parent_bus(n->primary_dev, n->primary_bus);
> - n->primary_should_be_hidden = false;
> - qemu_opt_set_bool(n->primary_device_opts,
> - "partially_hotplugged", true, errp);
> - hotplug_ctrl = qdev_get_hotplug_handler(n->primary_dev);
> - if (hotplug_ctrl) {
> - hotplug_handler_pre_plug(hotplug_ctrl, n->primary_dev, errp);
> - hotplug_handler_plug(hotplug_ctrl, n->primary_dev, errp);
> + if (!n->primary_device_opts) {
> + error_setg(errp, "virtio_net: couldn't find primary device opts");
> + goto out;
> }
> - if (!n->primary_dev) {
> + }
> + if (!n->primary_dev) {
> error_setg(errp, "virtio_net: couldn't find primary device");
> - }
> + goto out;
> }
> - return *errp != NULL;
> +
> + n->primary_bus = n->primary_dev->parent_bus;
> + if (!n->primary_bus) {
> + error_setg(errp, "virtio_net: couldn't find primary bus");
> + goto out;
> + }
> + qdev_set_parent_bus(n->primary_dev, n->primary_bus);
> + n->primary_should_be_hidden = false;
> + qemu_opt_set_bool(n->primary_device_opts,
> + "partially_hotplugged", true, errp);
> + hotplug_ctrl = qdev_get_hotplug_handler(n->primary_dev);
> + if (hotplug_ctrl) {
> + hotplug_handler_pre_plug(hotplug_ctrl, n->primary_dev, errp);
> + hotplug_handler_plug(hotplug_ctrl, n->primary_dev, errp);
> + }
> +
> +out:
> + return *errp == NULL;
> }
>
> static void virtio_net_handle_migration_primary(VirtIONet *n,
So the logic actually was inverted here? Then ... how did this work?
and how was it tested?
Also, pls mention the change in the commit log.
> @@ -2852,7 +2860,7 @@ static void virtio_net_handle_migration_primary(VirtIONet *n,
> warn_report("couldn't unplug primary device");
> }
> } else if (migration_has_failed(s)) {
> - /* We already unplugged the device let's plugged it back */
> + /* We already unplugged the device let's plug it back */
> if (!failover_replug_primary(n, &err)) {
> if (err) {
> error_report_err(err);
> --
> 2.21.0
next prev parent reply other threads:[~2019-11-20 15:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-20 14:38 [PATCH v2 0/4] net/virtio: fixes for failover Jens Freimann
2019-11-20 14:38 ` [PATCH v2 1/4] net/virtio: fix dev_unplug_pending Jens Freimann
2019-11-20 14:38 ` [PATCH v2 2/4] net/virtio: return early when failover primary alread added Jens Freimann
2019-11-20 14:38 ` [PATCH v2 3/4] net/virtio: avoid passing NULL to qdev_set_parent_bus Jens Freimann
2019-11-20 15:04 ` Michael S. Tsirkin [this message]
2019-11-20 15:22 ` Jens Freimann
2019-11-20 14:38 ` [PATCH v2 4/4] net/virtio: return error when device_opts arg is NULL Jens Freimann
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=20191120100034-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=dgilbert@redhat.com \
--cc=jasowang@redhat.com \
--cc=jfreimann@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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).