]>
Commit | Line | Data |
---|---|---|
9f117d41 IM |
1 | /* |
2 | * Hotplug handler interface. | |
3 | * | |
4 | * Copyright (c) 2014 Red Hat Inc. | |
5 | * | |
6 | * Authors: | |
7 | * Igor Mammedov <[email protected]>, | |
8 | * | |
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. | |
11 | */ | |
18c86e2b | 12 | #include "qemu/osdep.h" |
9f117d41 IM |
13 | #include "hw/hotplug.h" |
14 | #include "qemu/module.h" | |
15 | ||
41346263 IM |
16 | void 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 | ||
9f117d41 IM |
27 | void 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 | ||
14d5a28f IM |
38 | void hotplug_handler_unplug_request(HotplugHandler *plug_handler, |
39 | DeviceState *plugged_dev, | |
40 | Error **errp) | |
9f117d41 IM |
41 | { |
42 | HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler); | |
43 | ||
14d5a28f IM |
44 | if (hdc->unplug_request) { |
45 | hdc->unplug_request(plug_handler, plugged_dev, errp); | |
9f117d41 IM |
46 | } |
47 | } | |
48 | ||
181a2c63 IM |
49 | void hotplug_handler_unplug(HotplugHandler *plug_handler, |
50 | DeviceState *plugged_dev, | |
51 | Error **errp) | |
52 | { | |
53 | HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler); | |
54 | ||
55 | if (hdc->unplug) { | |
56 | hdc->unplug(plug_handler, plugged_dev, errp); | |
57 | } | |
58 | } | |
59 | ||
9f117d41 IM |
60 | static const TypeInfo hotplug_handler_info = { |
61 | .name = TYPE_HOTPLUG_HANDLER, | |
62 | .parent = TYPE_INTERFACE, | |
63 | .class_size = sizeof(HotplugHandlerClass), | |
64 | }; | |
65 | ||
66 | static void hotplug_handler_register_types(void) | |
67 | { | |
68 | type_register_static(&hotplug_handler_info); | |
69 | } | |
70 | ||
71 | type_init(hotplug_handler_register_types) |