]>
git.proxmox.com Git - mirror_qemu.git/blob - include/qemu/module.h
9cd305de59a6cb6024ffbcf052d2fab8aace88c6
2 * QEMU Module Infrastructure
4 * Copyright IBM, Corp. 2009
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
18 #define DSO_STAMP_FUN glue(qemu_stamp, CONFIG_STAMP)
19 #define DSO_STAMP_FUN_STR stringify(DSO_STAMP_FUN)
22 void DSO_STAMP_FUN(void);
23 /* This is a dummy symbol to identify a loaded DSO as a QEMU module, so we can
24 * distinguish "version mismatch" from "not a QEMU module", when the stamp
25 * check fails during module loading */
26 void qemu_module_dummy(void);
28 #define module_init(function, type) \
29 static void __attribute__((constructor)) do_qemu_init_ ## function(void) \
31 register_dso_module_init(function, type); \
34 /* This should not be used directly. Use block_init etc. instead. */
35 #define module_init(function, type) \
36 static void __attribute__((constructor)) do_qemu_init_ ## function(void) \
38 register_module_init(function, type); \
43 MODULE_INIT_MIGRATION
,
48 MODULE_INIT_XEN_BACKEND
,
50 MODULE_INIT_FUZZ_TARGET
,
54 #define block_init(function) module_init(function, MODULE_INIT_BLOCK)
55 #define opts_init(function) module_init(function, MODULE_INIT_OPTS)
56 #define type_init(function) module_init(function, MODULE_INIT_QOM)
57 #define trace_init(function) module_init(function, MODULE_INIT_TRACE)
58 #define xen_backend_init(function) module_init(function, \
59 MODULE_INIT_XEN_BACKEND)
60 #define libqos_init(function) module_init(function, MODULE_INIT_LIBQOS)
61 #define fuzz_target_init(function) module_init(function, \
62 MODULE_INIT_FUZZ_TARGET)
63 #define migration_init(function) module_init(function, MODULE_INIT_MIGRATION)
64 #define block_module_load_one(lib) module_load_one("block-", lib, false)
65 #define ui_module_load_one(lib) module_load_one("ui-", lib, false)
66 #define audio_module_load_one(lib) module_load_one("audio-", lib, false)
68 void register_module_init(void (*fn
)(void), module_init_type type
);
69 void register_dso_module_init(void (*fn
)(void), module_init_type type
);
71 void module_call_init(module_init_type type
);
72 bool module_load_one(const char *prefix
, const char *lib_name
, bool mayfail
);
73 void module_load_qom_one(const char *type
);
74 void module_load_qom_all(void);
77 * DOC: module info annotation macros
79 * `scripts/modinfo-collect.py` will collect module info,
80 * using the preprocessor and -DQEMU_MODINFO.
82 * `scripts/modinfo-generate.py` will create a module meta-data database
83 * from the collected information so qemu knows about module
84 * dependencies and QOM objects implemented by modules.
86 * See `*.modinfo` and `modinfo.c` in the build directory to check the
90 # define modinfo(kind, value) \
91 MODINFO_START kind value MODINFO_END
93 # define modinfo(kind, value)
101 * This module implements QOM type @name.
103 #define module_obj(name) modinfo(obj, name)
110 * This module depends on module @name.
112 #define module_dep(name) modinfo(dep, name)
117 * @name: target architecture
119 * This module is for target architecture @arch.
121 * Note that target-dependent modules are tagged automatically, so
122 * this is only needed in case target-independent modules should be
123 * restricted. Use case example: the ccw bus is implemented by s390x
126 #define module_arch(name) modinfo(arch, name)
131 * @name: QemuOpts name
133 * This module registers QemuOpts @name.
135 #define module_opts(name) modinfo(opts, name)
138 * module info database
140 * scripts/modinfo-generate.c will build this using the data collected
141 * by scripts/modinfo-collect.py
143 typedef struct QemuModinfo QemuModinfo
;
151 extern const QemuModinfo qemu_modinfo
[];
152 void module_init_info(const QemuModinfo
*info
);