qapi: Reject multiple and empty feature descriptions
[qemu/kevin.git] / include / sysemu / block-backend-common.h
blob780cea7305aadd131e3e2974053ab33e86a00ac9
1 /*
2 * QEMU Block backends
4 * Copyright (C) 2014-2016 Red Hat, Inc.
6 * Authors:
7 * Markus Armbruster <armbru@redhat.com>,
9 * This work is licensed under the terms of the GNU LGPL, version 2.1
10 * or later. See the COPYING.LIB file in the top-level directory.
13 #ifndef BLOCK_BACKEND_COMMON_H
14 #define BLOCK_BACKEND_COMMON_H
16 #include "qemu/iov.h"
17 #include "block/throttle-groups.h"
20 * TODO Have to include block/block.h for a bunch of block layer
21 * types. Unfortunately, this pulls in the whole BlockDriverState
22 * API, which we don't want used by many BlockBackend users. Some of
23 * the types belong here, and the rest should be split into a common
24 * header and one for the BlockDriverState API.
26 #include "block/block.h"
28 /* Callbacks for block device models */
29 typedef struct BlockDevOps {
32 * Global state (GS) API. These functions run under the BQL.
34 * See include/block/block-global-state.h for more information about
35 * the GS API.
39 * Runs when virtual media changed (monitor commands eject, change)
40 * Argument load is true on load and false on eject.
41 * Beware: doesn't run when a host device's physical media
42 * changes. Sure would be useful if it did.
43 * Device models with removable media must implement this callback.
45 void (*change_media_cb)(void *opaque, bool load, Error **errp);
47 * Runs when an eject request is issued from the monitor, the tray
48 * is closed, and the medium is locked.
49 * Device models that do not implement is_medium_locked will not need
50 * this callback. Device models that can lock the medium or tray might
51 * want to implement the callback and unlock the tray when "force" is
52 * true, even if they do not support eject requests.
54 void (*eject_request_cb)(void *opaque, bool force);
57 * Is the virtual medium locked into the device?
58 * Device models implement this only when device has such a lock.
60 bool (*is_medium_locked)(void *opaque);
63 * Runs when the backend receives a drain request.
65 void (*drained_begin)(void *opaque);
67 * Runs when the backend's last drain request ends.
69 void (*drained_end)(void *opaque);
71 * Is the device still busy?
73 bool (*drained_poll)(void *opaque);
76 * I/O API functions. These functions are thread-safe.
78 * See include/block/block-io.h for more information about
79 * the I/O API.
83 * Is the virtual tray open?
84 * Device models implement this only when the device has a tray.
86 bool (*is_tray_open)(void *opaque);
89 * Runs when the size changed (e.g. monitor command block_resize)
91 void (*resize_cb)(void *opaque);
92 } BlockDevOps;
95 * This struct is embedded in (the private) BlockBackend struct and contains
96 * fields that must be public. This is in particular for QLIST_ENTRY() and
97 * friends so that BlockBackends can be kept in lists outside block-backend.c
99 typedef struct BlockBackendPublic {
100 ThrottleGroupMember throttle_group_member;
101 } BlockBackendPublic;
103 #endif /* BLOCK_BACKEND_COMMON_H */