xref: /openbmc/qemu/include/hw/vmstate-if.h (revision 0ce46ab5)
1 /*
2  * VMState interface
3  *
4  * Copyright (c) 2009-2019 Red Hat Inc
5  * This work is licensed under the terms of the GNU GPL, version 2 or later.
6  * See the COPYING file in the top-level directory.
7  */
8 
9 #ifndef VMSTATE_IF_H
10 #define VMSTATE_IF_H
11 
12 #include "qom/object.h"
13 
14 #define TYPE_VMSTATE_IF "vmstate-if"
15 
16 #define VMSTATE_IF_CLASS(klass)                                     \
17     OBJECT_CLASS_CHECK(VMStateIfClass, (klass), TYPE_VMSTATE_IF)
18 #define VMSTATE_IF_GET_CLASS(obj)                           \
19     OBJECT_GET_CLASS(VMStateIfClass, (obj), TYPE_VMSTATE_IF)
20 #define VMSTATE_IF(obj)                             \
21     INTERFACE_CHECK(VMStateIf, (obj), TYPE_VMSTATE_IF)
22 
23 typedef struct VMStateIf VMStateIf;
24 
25 typedef struct VMStateIfClass {
26     InterfaceClass parent_class;
27 
28     char * (*get_id)(VMStateIf *obj);
29 } VMStateIfClass;
30 
31 static inline char *vmstate_if_get_id(VMStateIf *vmif)
32 {
33     if (!vmif) {
34         return NULL;
35     }
36 
37     return VMSTATE_IF_GET_CLASS(vmif)->get_id(vmif);
38 }
39 
40 #endif /* VMSTATE_IF_H */
41