thebeanogamer / rpms / qemu-kvm

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