1
2
3
4
5
6
7
8
9
10
11
12#include "qemu/osdep.h"
13#include "hw/hotplug.h"
14#include "qemu/module.h"
15
16void hotplug_handler_pre_plug(HotplugHandler *plug_handler,
17 DeviceState *plugged_dev,
18 Error **errp)
19{
20 HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler);
21
22 if (hdc->pre_plug) {
23 hdc->pre_plug(plug_handler, plugged_dev, errp);
24 }
25}
26
27void hotplug_handler_plug(HotplugHandler *plug_handler,
28 DeviceState *plugged_dev,
29 Error **errp)
30{
31 HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler);
32
33 if (hdc->plug) {
34 hdc->plug(plug_handler, plugged_dev, errp);
35 }
36}
37
38void hotplug_handler_post_plug(HotplugHandler *plug_handler,
39 DeviceState *plugged_dev)
40{
41 HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler);
42
43 if (hdc->post_plug) {
44 hdc->post_plug(plug_handler, plugged_dev);
45 }
46}
47
48void hotplug_handler_unplug_request(HotplugHandler *plug_handler,
49 DeviceState *plugged_dev,
50 Error **errp)
51{
52 HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler);
53
54 if (hdc->unplug_request) {
55 hdc->unplug_request(plug_handler, plugged_dev, errp);
56 }
57}
58
59void hotplug_handler_unplug(HotplugHandler *plug_handler,
60 DeviceState *plugged_dev,
61 Error **errp)
62{
63 HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler);
64
65 if (hdc->unplug) {
66 hdc->unplug(plug_handler, plugged_dev, errp);
67 }
68}
69
70static const TypeInfo hotplug_handler_info = {
71 .name = TYPE_HOTPLUG_HANDLER,
72 .parent = TYPE_INTERFACE,
73 .class_size = sizeof(HotplugHandlerClass),
74};
75
76static void hotplug_handler_register_types(void)
77{
78 type_register_static(&hotplug_handler_info);
79}
80
81type_init(hotplug_handler_register_types)
82