xref: /openbmc/qemu/include/scsi/pr-manager.h (revision 44b1ff31)
1 #ifndef PR_MANAGER_H
2 #define PR_MANAGER_H
3 
4 #include "qom/object.h"
5 #include "qapi/qmp/qdict.h"
6 #include "qapi/visitor.h"
7 #include "qom/object_interfaces.h"
8 #include "block/aio.h"
9 
10 #define TYPE_PR_MANAGER "pr-manager"
11 
12 #define PR_MANAGER_CLASS(klass) \
13      OBJECT_CLASS_CHECK(PRManagerClass, (klass), TYPE_PR_MANAGER)
14 #define PR_MANAGER_GET_CLASS(obj) \
15      OBJECT_GET_CLASS(PRManagerClass, (obj), TYPE_PR_MANAGER)
16 #define PR_MANAGER(obj) \
17      OBJECT_CHECK(PRManager, (obj), TYPE_PR_MANAGER)
18 
19 struct sg_io_hdr;
20 
21 typedef struct PRManager {
22     /* <private> */
23     Object parent;
24 } PRManager;
25 
26 /**
27  * PRManagerClass:
28  * @parent_class: the base class
29  * @run: callback invoked in thread pool context
30  */
31 typedef struct PRManagerClass {
32     /* <private> */
33     ObjectClass parent_class;
34 
35     /* <public> */
36     int (*run)(PRManager *pr_mgr, int fd, struct sg_io_hdr *hdr);
37 } PRManagerClass;
38 
39 BlockAIOCB *pr_manager_execute(PRManager *pr_mgr,
40                                AioContext *ctx, int fd,
41                                struct sg_io_hdr *hdr,
42                                BlockCompletionFunc *complete,
43                                void *opaque);
44 
45 #ifdef CONFIG_LINUX
46 PRManager *pr_manager_lookup(const char *id, Error **errp);
47 #else
48 static inline PRManager *pr_manager_lookup(const char *id, Error **errp)
49 {
50     /* The classes do not exist at all!  */
51     error_setg(errp, "No persistent reservation manager with id '%s'", id);
52     return NULL;
53 }
54 #endif
55 
56 #endif
57