Blame SOURCES/kvm-qdev-add-HotplugHandler-post_plug-callback.patch

383d26
From 5cdd4dfafc5280d312001371c6917ccaf2ba06c3 Mon Sep 17 00:00:00 2001
383d26
From: Stefan Hajnoczi <stefanha@redhat.com>
383d26
Date: Tue, 24 Jul 2018 15:13:07 +0200
383d26
Subject: [PATCH 08/15] qdev: add HotplugHandler->post_plug() callback
383d26
383d26
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
383d26
Message-id: <20180724151308.20500-2-stefanha@redhat.com>
383d26
Patchwork-id: 81485
383d26
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 1/2] qdev: add HotplugHandler->post_plug() callback
383d26
Bugzilla: 1607891
383d26
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
383d26
RH-Acked-by: Pankaj Gupta <pagupta@redhat.com>
383d26
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
383d26
383d26
The ->pre_plug() callback is invoked before the device is realized.  The
383d26
->plug() callback is invoked when the device is being realized but
383d26
before it is reset.
383d26
383d26
This patch adds a ->post_plug() callback which is invoked after the
383d26
device has been reset.  This callback is needed by HotplugHandlers that
383d26
need to wait until after ->reset().
383d26
383d26
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
383d26
Message-Id: <20180716083732.3347-2-stefanha@redhat.com>
383d26
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
383d26
(cherry picked from commit 25e8978817a54745c44d956d8303e6be6f2c4047)
383d26
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 hw/core/hotplug.c    | 10 ++++++++++
383d26
 hw/core/qdev.c       |  4 ++++
383d26
 include/hw/hotplug.h | 11 +++++++++++
383d26
 3 files changed, 25 insertions(+)
383d26
383d26
diff --git a/hw/core/hotplug.c b/hw/core/hotplug.c
383d26
index 17ac986..2253072 100644
383d26
--- a/hw/core/hotplug.c
383d26
+++ b/hw/core/hotplug.c
383d26
@@ -35,6 +35,16 @@ void hotplug_handler_plug(HotplugHandler *plug_handler,
383d26
     }
383d26
 }
383d26
 
383d26
+void hotplug_handler_post_plug(HotplugHandler *plug_handler,
383d26
+                               DeviceState *plugged_dev)
383d26
+{
383d26
+    HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler);
383d26
+
383d26
+    if (hdc->post_plug) {
383d26
+        hdc->post_plug(plug_handler, plugged_dev);
383d26
+    }
383d26
+}
383d26
+
383d26
 void hotplug_handler_unplug_request(HotplugHandler *plug_handler,
383d26
                                     DeviceState *plugged_dev,
383d26
                                     Error **errp)
383d26
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
383d26
index ce7c316..24f1ae7 100644
383d26
--- a/hw/core/qdev.c
383d26
+++ b/hw/core/qdev.c
383d26
@@ -893,6 +893,10 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
383d26
             device_reset(dev);
383d26
         }
383d26
         dev->pending_deleted_event = false;
383d26
+
383d26
+        if (hotplug_ctrl) {
383d26
+            hotplug_handler_post_plug(hotplug_ctrl, dev);
383d26
+        }
383d26
     } else if (!value && dev->realized) {
383d26
         Error **local_errp = NULL;
383d26
         QLIST_FOREACH(bus, &dev->child_bus, sibling) {
383d26
diff --git a/include/hw/hotplug.h b/include/hw/hotplug.h
383d26
index 1a0516a..51541d6 100644
383d26
--- a/include/hw/hotplug.h
383d26
+++ b/include/hw/hotplug.h
383d26
@@ -47,6 +47,8 @@ typedef void (*hotplug_fn)(HotplugHandler *plug_handler,
383d26
  * @parent: Opaque parent interface.
383d26
  * @pre_plug: pre plug callback called at start of device.realize(true)
383d26
  * @plug: plug callback called at end of device.realize(true).
383d26
+ * @post_plug: post plug callback called after device.realize(true) and device
383d26
+ *             reset
383d26
  * @unplug_request: unplug request callback.
383d26
  *                  Used as a means to initiate device unplug for devices that
383d26
  *                  require asynchronous unplug handling.
383d26
@@ -61,6 +63,7 @@ typedef struct HotplugHandlerClass {
383d26
     /* <public> */
383d26
     hotplug_fn pre_plug;
383d26
     hotplug_fn plug;
383d26
+    void (*post_plug)(HotplugHandler *plug_handler, DeviceState *plugged_dev);
383d26
     hotplug_fn unplug_request;
383d26
     hotplug_fn unplug;
383d26
 } HotplugHandlerClass;
383d26
@@ -84,6 +87,14 @@ void hotplug_handler_pre_plug(HotplugHandler *plug_handler,
383d26
                               Error **errp);
383d26
 
383d26
 /**
383d26
+ * hotplug_handler_post_plug:
383d26
+ *
383d26
+ * Call #HotplugHandlerClass.post_plug callback of @plug_handler.
383d26
+ */
383d26
+void hotplug_handler_post_plug(HotplugHandler *plug_handler,
383d26
+                               DeviceState *plugged_dev);
383d26
+
383d26
+/**
383d26
  * hotplug_handler_unplug_request:
383d26
  *
383d26
  * Calls #HotplugHandlerClass.unplug_request callback of @plug_handler.
383d26
-- 
383d26
1.8.3.1
383d26