xref: /openbmc/qemu/hw/core/hotplug.c (revision a719a27c)
1 /*
2  * Hotplug handler interface.
3  *
4  * Copyright (c) 2014 Red Hat Inc.
5  *
6  * Authors:
7  *  Igor Mammedov <imammedo@redhat.com>,
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  */
12 #include "hw/hotplug.h"
13 #include "qemu/module.h"
14 
15 void hotplug_handler_plug(HotplugHandler *plug_handler,
16                           DeviceState *plugged_dev,
17                           Error **errp)
18 {
19     HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler);
20 
21     if (hdc->plug) {
22         hdc->plug(plug_handler, plugged_dev, errp);
23     }
24 }
25 
26 void hotplug_handler_unplug(HotplugHandler *plug_handler,
27                             DeviceState *plugged_dev,
28                             Error **errp)
29 {
30     HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler);
31 
32     if (hdc->unplug) {
33         hdc->unplug(plug_handler, plugged_dev, errp);
34     }
35 }
36 
37 static const TypeInfo hotplug_handler_info = {
38     .name          = TYPE_HOTPLUG_HANDLER,
39     .parent        = TYPE_INTERFACE,
40     .class_size = sizeof(HotplugHandlerClass),
41 };
42 
43 static void hotplug_handler_register_types(void)
44 {
45     type_register_static(&hotplug_handler_info);
46 }
47 
48 type_init(hotplug_handler_register_types)
49