qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Juan Quintela" <quintela@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH v2 25/27] failover: Caller of this two functions already have primary_dev
Date: Wed, 18 Nov 2020 09:37:46 +0100	[thread overview]
Message-ID: <20201118083748.1328-26-quintela@redhat.com> (raw)
In-Reply-To: <20201118083748.1328-1-quintela@redhat.com>

Pass it as an argument.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/net/virtio-net.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 746ed3fb71..b37e9cd1d9 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3093,17 +3093,17 @@ void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
     n->netclient_type = g_strdup(type);
 }
 
-static bool failover_unplug_primary(VirtIONet *n)
+static bool failover_unplug_primary(VirtIONet *n, DeviceState *dev)
 {
     HotplugHandler *hotplug_ctrl;
     PCIDevice *pci_dev;
     Error *err = NULL;
 
-    hotplug_ctrl = qdev_get_hotplug_handler(n->primary_dev);
+    hotplug_ctrl = qdev_get_hotplug_handler(dev);
     if (hotplug_ctrl) {
-        pci_dev = PCI_DEVICE(n->primary_dev);
+        pci_dev = PCI_DEVICE(dev);
         pci_dev->partially_hotplugged = true;
-        hotplug_handler_unplug_request(hotplug_ctrl, n->primary_dev, &err);
+        hotplug_handler_unplug_request(hotplug_ctrl, dev, &err);
         if (err) {
             error_report_err(err);
             return false;
@@ -3114,30 +3114,31 @@ static bool failover_unplug_primary(VirtIONet *n)
     return true;
 }
 
-static bool failover_replug_primary(VirtIONet *n, Error **errp)
+static bool failover_replug_primary(VirtIONet *n, DeviceState *dev,
+                                    Error **errp)
 {
     Error *err = NULL;
     HotplugHandler *hotplug_ctrl;
-    PCIDevice *pdev = PCI_DEVICE(n->primary_dev);
+    PCIDevice *pdev = PCI_DEVICE(dev);
     BusState *primary_bus;
 
     if (!pdev->partially_hotplugged) {
         return true;
     }
-    primary_bus = n->primary_dev->parent_bus;
+    primary_bus = dev->parent_bus;
     if (!primary_bus) {
         error_setg(errp, "virtio_net: couldn't find primary bus");
         return false;
     }
-    qdev_set_parent_bus(n->primary_dev, primary_bus, &error_abort);
+    qdev_set_parent_bus(dev, primary_bus, &error_abort);
     qatomic_set(&n->failover_primary_hidden, false);
-    hotplug_ctrl = qdev_get_hotplug_handler(n->primary_dev);
+    hotplug_ctrl = qdev_get_hotplug_handler(dev);
     if (hotplug_ctrl) {
-        hotplug_handler_pre_plug(hotplug_ctrl, n->primary_dev, &err);
+        hotplug_handler_pre_plug(hotplug_ctrl, dev, &err);
         if (err) {
             goto out;
         }
-        hotplug_handler_plug(hotplug_ctrl, n->primary_dev, &err);
+        hotplug_handler_plug(hotplug_ctrl, dev, &err);
     }
 
 out:
@@ -3161,7 +3162,7 @@ static void virtio_net_handle_migration_primary(VirtIONet *n,
     }
 
     if (migration_in_setup(s) && !should_be_hidden) {
-        if (failover_unplug_primary(n)) {
+        if (failover_unplug_primary(n, n->primary_dev)) {
             vmstate_unregister(VMSTATE_IF(n->primary_dev),
                                qdev_get_vmsd(n->primary_dev),
                                n->primary_dev);
@@ -3172,7 +3173,7 @@ static void virtio_net_handle_migration_primary(VirtIONet *n,
         }
     } else if (migration_has_failed(s)) {
         /* We already unplugged the device let's plug it back */
-        if (!failover_replug_primary(n, &err)) {
+        if (!failover_replug_primary(n, n->primary_dev, &err)) {
             if (err) {
                 error_report_err(err);
             }
-- 
2.26.2



  parent reply	other threads:[~2020-11-18  9:02 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-18  8:37 [PATCH v2 00/27] Virtio net failover fixes Juan Quintela
2020-11-18  8:37 ` [PATCH v2 01/27] migration: Network Failover can't work with a paused guest Juan Quintela
2020-11-25 12:05   ` Dr. David Alan Gilbert
2020-12-02 10:13   ` Michael S. Tsirkin
2020-12-02 10:27     ` Daniel P. Berrangé
2020-12-02 10:31       ` Michael S. Tsirkin
2020-12-02 10:33         ` Michael S. Tsirkin
2020-12-02 10:51           ` Juan Quintela
2020-12-02 10:55             ` Daniel P. Berrangé
2020-12-02 11:19               ` Michael S. Tsirkin
2020-12-02 11:26                 ` Daniel P. Berrangé
2020-12-02 11:37                   ` Michael S. Tsirkin
2020-12-02 12:01                     ` Daniel P. Berrangé
2020-12-03 11:21                       ` Michael S. Tsirkin
2020-12-03 11:32                         ` Daniel P. Berrangé
2020-12-03 11:40                           ` Michael S. Tsirkin
2020-12-03 11:43                             ` Dr. David Alan Gilbert
2020-12-03 12:02                               ` Michael S. Tsirkin
2020-12-03 12:04                                 ` Dr. David Alan Gilbert
2020-12-03 12:11                               ` Michael S. Tsirkin
2020-12-03 12:16                                 ` Daniel P. Berrangé
2020-12-08 18:48                                   ` Michael S. Tsirkin
2020-12-03 11:45                             ` Daniel P. Berrangé
2020-12-03 12:01                               ` Michael S. Tsirkin
2020-12-03 12:06                                 ` Daniel P. Berrangé
2020-12-03 12:13                                   ` Michael S. Tsirkin
2020-12-08 18:32                       ` Michael S. Tsirkin
2020-12-02 10:34         ` Daniel P. Berrangé
2020-11-18  8:37 ` [PATCH v2 02/27] failover: fix indentantion Juan Quintela
2020-11-18  8:37 ` [PATCH v2 03/27] failover: Use always atomics for primary_should_be_hidden Juan Quintela
2020-11-18  8:37 ` [PATCH v2 04/27] failover: primary bus is only used once, and where it is set Juan Quintela
2020-11-18  8:37 ` [PATCH v2 05/27] failover: Remove unused parameter Juan Quintela
2020-11-18  8:37 ` [PATCH v2 06/27] failover: Remove external partially_hotplugged property Juan Quintela
2020-11-18  8:37 ` [PATCH v2 07/27] failover: qdev_device_add() returns err or dev set Juan Quintela
2020-11-18  8:37 ` [PATCH v2 08/27] failover: Rename bool to failover_primary_hidden Juan Quintela
2020-11-18  8:37 ` [PATCH v2 09/27] failover: g_strcmp0() knows how to handle NULL Juan Quintela
2020-11-18  8:37 ` [PATCH v2 10/27] failover: Remove primary_device_opts Juan Quintela
2020-11-18  8:37 ` [PATCH v2 11/27] failover: remove standby_id variable Juan Quintela
2020-11-18  8:37 ` [PATCH v2 12/27] failover: Remove primary_device_dict Juan Quintela
2020-11-18  8:37 ` [PATCH v2 13/27] failover: Remove memory leak Juan Quintela
2020-11-18  8:37 ` [PATCH v2 14/27] failover: simplify virtio_net_find_primary() Juan Quintela
2020-11-18  8:37 ` [PATCH v2 15/27] failover: should_be_hidden() should take a bool Juan Quintela
2020-11-18  8:37 ` [PATCH v2 16/27] failover: Rename function to hide_device() Juan Quintela
2020-11-18  8:37 ` [PATCH v2 17/27] failover: virtio_net_connect_failover_devices() does nothing Juan Quintela
2020-11-18  8:37 ` [PATCH v2 18/27] failover: Rename to failover_find_primary_device() Juan Quintela
2020-11-18  8:37 ` [PATCH v2 19/27] failover: simplify qdev_device_add() failover case Juan Quintela
2020-11-18  8:37 ` [PATCH v2 20/27] failover: simplify qdev_device_add() Juan Quintela
2020-11-18  8:37 ` [PATCH v2 21/27] failover: make sure that id always exist Juan Quintela
2020-11-18  8:37 ` [PATCH v2 22/27] failover: remove failover_find_primary_device() error parameter Juan Quintela
2020-11-18  8:37 ` [PATCH v2 23/27] failover: split failover_find_primary_device_id() Juan Quintela
2020-11-18  8:37 ` [PATCH v2 24/27] failover: We don't need to cache primary_device_id anymore Juan Quintela
2020-11-18  8:37 ` Juan Quintela [this message]
2020-11-18  8:37 ` [PATCH v2 26/27] failover: simplify failover_unplug_primary Juan Quintela
2020-11-18  8:37 ` [PATCH v2 27/27] failover: Remove primary_dev member Juan Quintela
2020-11-18  8:53 ` [PATCH v2 00/27] Virtio net failover fixes Michael S. Tsirkin
2020-12-02 10:16   ` Juan Quintela
2020-12-02 10:30     ` Michael S. Tsirkin
2020-12-02  9:55 ` Michael S. Tsirkin

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=20201118083748.1328-26-quintela@redhat.com \
    --to=quintela@redhat.com \
    --cc=berrange@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --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).