]> git.proxmox.com Git - mirror_qemu.git/blame - include/hw/hotplug.h
Use DECLARE_*CHECKER* macros
[mirror_qemu.git] / include / hw / hotplug.h
CommitLineData
9f117d41
IM
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#ifndef HOTPLUG_H
13#define HOTPLUG_H
14
15#include "qom/object.h"
9f117d41
IM
16
17#define TYPE_HOTPLUG_HANDLER "hotplug-handler"
18
db1015e9 19typedef struct HotplugHandlerClass HotplugHandlerClass;
8110fa1d
EH
20DECLARE_CLASS_CHECKERS(HotplugHandlerClass, HOTPLUG_HANDLER,
21 TYPE_HOTPLUG_HANDLER)
9f117d41
IM
22#define HOTPLUG_HANDLER(obj) \
23 INTERFACE_CHECK(HotplugHandler, (obj), TYPE_HOTPLUG_HANDLER)
24
aa1b35b9 25typedef struct HotplugHandler HotplugHandler;
9f117d41
IM
26
27/**
28 * hotplug_fn:
29 * @plug_handler: a device performing plug/uplug action
30 * @plugged_dev: a device that has been (un)plugged
31 * @errp: returns an error if this function fails
32 */
33typedef void (*hotplug_fn)(HotplugHandler *plug_handler,
34 DeviceState *plugged_dev, Error **errp);
35
36/**
37 * HotplugDeviceClass:
38 *
39 * Interface to be implemented by a device performing
40 * hardware (un)plug functions.
41 *
42 * @parent: Opaque parent interface.
41346263
IM
43 * @pre_plug: pre plug callback called at start of device.realize(true)
44 * @plug: plug callback called at end of device.realize(true).
14d5a28f
IM
45 * @unplug_request: unplug request callback.
46 * Used as a means to initiate device unplug for devices that
47 * require asynchronous unplug handling.
181a2c63
IM
48 * @unplug: unplug callback.
49 * Used for device removal with devices that implement
b4952c36 50 * asynchronous and synchronous (surprise) removal.
9f117d41 51 */
db1015e9 52struct HotplugHandlerClass {
9f117d41
IM
53 /* <private> */
54 InterfaceClass parent;
55
56 /* <public> */
41346263 57 hotplug_fn pre_plug;
9f117d41 58 hotplug_fn plug;
14d5a28f 59 hotplug_fn unplug_request;
181a2c63 60 hotplug_fn unplug;
db1015e9 61};
9f117d41
IM
62
63/**
64 * hotplug_handler_plug:
65 *
66 * Call #HotplugHandlerClass.plug callback of @plug_handler.
67 */
68void hotplug_handler_plug(HotplugHandler *plug_handler,
69 DeviceState *plugged_dev,
70 Error **errp);
71
41346263
IM
72/**
73 * hotplug_handler_pre_plug:
74 *
75 * Call #HotplugHandlerClass.pre_plug callback of @plug_handler.
76 */
77void hotplug_handler_pre_plug(HotplugHandler *plug_handler,
78 DeviceState *plugged_dev,
79 Error **errp);
80
9f117d41 81/**
14d5a28f 82 * hotplug_handler_unplug_request:
9f117d41 83 *
14d5a28f 84 * Calls #HotplugHandlerClass.unplug_request callback of @plug_handler.
9f117d41 85 */
14d5a28f
IM
86void hotplug_handler_unplug_request(HotplugHandler *plug_handler,
87 DeviceState *plugged_dev,
88 Error **errp);
181a2c63
IM
89/**
90 * hotplug_handler_unplug:
91 *
92 * Calls #HotplugHandlerClass.unplug callback of @plug_handler.
93 */
94void hotplug_handler_unplug(HotplugHandler *plug_handler,
95 DeviceState *plugged_dev,
96 Error **errp);
9f117d41 97#endif