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 16/27] failover: Rename function to hide_device()
Date: Wed, 18 Nov 2020 09:37:37 +0100	[thread overview]
Message-ID: <20201118083748.1328-17-quintela@redhat.com> (raw)
In-Reply-To: <20201118083748.1328-1-quintela@redhat.com>

You should not use pasive.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/hw/qdev-core.h | 28 +++++++++++++++-------------
 hw/core/qdev.c         |  4 ++--
 hw/net/virtio-net.c    |  7 +++----
 3 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 250f4edef6..6ac86db44e 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -81,16 +81,17 @@ typedef void (*BusUnrealize)(BusState *bus);
  * </note>
  *
  * # Hiding a device #
- * To hide a device, a DeviceListener function should_be_hidden() needs to
+ * To hide a device, a DeviceListener function hide_device() needs to
  * be registered.
- * It can be used to defer adding a device and therefore hide it from the
- * guest. The handler registering to this DeviceListener can save the QOpts
- * passed to it for re-using it later and must return that it wants the device
- * to be/remain hidden or not. When the handler function decides the device
- * shall not be hidden it will be added in qdev_device_add() and
- * realized as any other device. Otherwise qdev_device_add() will return early
- * without adding the device. The guest will not see a "hidden" device
- * until it was marked don't hide and qdev_device_add called again.
+ * It can be used to defer adding a device and therefore hide it from
+ * the guest. The handler registering to this DeviceListener can save
+ * the QOpts passed to it for re-using it later. It must return if it
+ * wants the device to be hidden or visible. When the handler function
+ * decides the device shall be visible it will be added with
+ * qdev_device_add() and realized as any other device. Otherwise
+ * qdev_device_add() will return early without adding the device. The
+ * guest will not see a "hidden" device until it was marked visible
+ * and qdev_device_add called again.
  *
  */
 struct DeviceClass {
@@ -196,11 +197,12 @@ struct DeviceListener {
     void (*realize)(DeviceListener *listener, DeviceState *dev);
     void (*unrealize)(DeviceListener *listener, DeviceState *dev);
     /*
-     * This callback is called upon init of the DeviceState and allows to
-     * inform qdev that a device should be hidden, depending on the device
-     * opts, for example, to hide a standby device.
+     * This callback is called upon init of the DeviceState and
+     * informs qdev if a device should be visible or hidden.  We can
+     * hide a failover device depending for example on the device
+     * opts.
      */
-    bool (*should_be_hidden)(DeviceListener *listener, QemuOpts *device_opts);
+    bool (*hide_device)(DeviceListener *listener, QemuOpts *device_opts);
     QTAILQ_ENTRY(DeviceListener) link;
 };
 
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 8f4b8f3cc1..cbdff0b6c6 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -217,8 +217,8 @@ bool qdev_should_hide_device(QemuOpts *opts)
     DeviceListener *listener;
 
     QTAILQ_FOREACH(listener, &device_listeners, link) {
-        if (listener->should_be_hidden) {
-            if (listener->should_be_hidden(listener, opts)) {
+        if (listener->hide_device) {
+            if (listener->hide_device(listener, opts)) {
                 return true;
             }
         }
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 9f12d33da0..747614ff2a 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3161,8 +3161,8 @@ static void virtio_net_migration_state_notifier(Notifier *notifier, void *data)
     virtio_net_handle_migration_primary(n, s);
 }
 
-static bool virtio_net_primary_should_be_hidden(DeviceListener *listener,
-                                                QemuOpts *device_opts)
+static bool failover_hide_primary_device(DeviceListener *listener,
+                                         QemuOpts *device_opts)
 {
     VirtIONet *n = container_of(listener, VirtIONet, primary_listener);
     bool hide;
@@ -3220,8 +3220,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
     }
 
     if (n->failover) {
-        n->primary_listener.should_be_hidden =
-            virtio_net_primary_should_be_hidden;
+        n->primary_listener.hide_device = failover_hide_primary_device;
         qatomic_set(&n->failover_primary_hidden, true);
         device_listener_register(&n->primary_listener);
         n->migration_state.notify = virtio_net_migration_state_notifier;
-- 
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 ` Juan Quintela [this message]
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 ` [PATCH v2 25/27] failover: Caller of this two functions already have primary_dev Juan Quintela
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-17-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).