2 * Hotplug handler interface.
4 * Copyright (c) 2014 Red Hat Inc.
7 * Igor Mammedov <imammedo@redhat.com>,
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
15 #include "qom/object.h"
17 #define TYPE_HOTPLUG_HANDLER "hotplug-handler"
19 #define HOTPLUG_HANDLER_CLASS(klass) \
20 OBJECT_CLASS_CHECK(HotplugHandlerClass, (klass), TYPE_HOTPLUG_HANDLER)
21 #define HOTPLUG_HANDLER_GET_CLASS(obj) \
22 OBJECT_GET_CLASS(HotplugHandlerClass, (obj), TYPE_HOTPLUG_HANDLER)
23 #define HOTPLUG_HANDLER(obj) \
24 INTERFACE_CHECK(HotplugHandler, (obj), TYPE_HOTPLUG_HANDLER)
27 typedef struct HotplugHandler
{
34 * @plug_handler: a device performing plug/uplug action
35 * @plugged_dev: a device that has been (un)plugged
36 * @errp: returns an error if this function fails
38 typedef void (*hotplug_fn
)(HotplugHandler
*plug_handler
,
39 DeviceState
*plugged_dev
, Error
**errp
);
44 * Interface to be implemented by a device performing
45 * hardware (un)plug functions.
47 * @parent: Opaque parent interface.
48 * @pre_plug: pre plug callback called at start of device.realize(true)
49 * @plug: plug callback called at end of device.realize(true).
50 * @unplug_request: unplug request callback.
51 * Used as a means to initiate device unplug for devices that
52 * require asynchronous unplug handling.
53 * @unplug: unplug callback.
54 * Used for device removal with devices that implement
55 * asynchronous and synchronous (surprise) removal.
57 typedef struct HotplugHandlerClass
{
59 InterfaceClass parent
;
64 hotplug_fn unplug_request
;
66 } HotplugHandlerClass
;
69 * hotplug_handler_plug:
71 * Call #HotplugHandlerClass.plug callback of @plug_handler.
73 void hotplug_handler_plug(HotplugHandler
*plug_handler
,
74 DeviceState
*plugged_dev
,
78 * hotplug_handler_pre_plug:
80 * Call #HotplugHandlerClass.pre_plug callback of @plug_handler.
82 void hotplug_handler_pre_plug(HotplugHandler
*plug_handler
,
83 DeviceState
*plugged_dev
,
87 * hotplug_handler_unplug_request:
89 * Calls #HotplugHandlerClass.unplug_request callback of @plug_handler.
91 void hotplug_handler_unplug_request(HotplugHandler
*plug_handler
,
92 DeviceState
*plugged_dev
,
95 * hotplug_handler_unplug:
97 * Calls #HotplugHandlerClass.unplug callback of @plug_handler.
99 void hotplug_handler_unplug(HotplugHandler
*plug_handler
,
100 DeviceState
*plugged_dev
,