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