|
33 | 33 | #include "qemu/error-report.h"
|
34 | 34 | #include "qemu/queue.h"
|
35 | 35 | #include "qemu/compiler.h"
|
| 36 | +#include "qom/object.h" |
36 | 37 |
|
37 | 38 | #ifndef _WIN32
|
38 | 39 | #include <sys/wait.h>
|
@@ -184,6 +185,61 @@ int qemu_init_main_loop(Error **errp)
|
184 | 185 | return 0;
|
185 | 186 | }
|
186 | 187 |
|
| 188 | +static void main_loop_update_params(EventLoopBase *base, Error **errp) |
| 189 | +{ |
| 190 | + if (!qemu_aio_context) { |
| 191 | + error_setg(errp, "qemu aio context not ready"); |
| 192 | + return; |
| 193 | + } |
| 194 | + |
| 195 | + aio_context_set_aio_params(qemu_aio_context, base->aio_max_batch, errp); |
| 196 | +} |
| 197 | + |
| 198 | +MainLoop *mloop; |
| 199 | + |
| 200 | +static void main_loop_init(EventLoopBase *base, Error **errp) |
| 201 | +{ |
| 202 | + MainLoop *m = MAIN_LOOP(base); |
| 203 | + |
| 204 | + if (mloop) { |
| 205 | + error_setg(errp, "only one main-loop instance allowed"); |
| 206 | + return; |
| 207 | + } |
| 208 | + |
| 209 | + main_loop_update_params(base, errp); |
| 210 | + |
| 211 | + mloop = m; |
| 212 | + return; |
| 213 | +} |
| 214 | + |
| 215 | +static bool main_loop_can_be_deleted(EventLoopBase *base) |
| 216 | +{ |
| 217 | + return false; |
| 218 | +} |
| 219 | + |
| 220 | +static void main_loop_class_init(ObjectClass *oc, void *class_data) |
| 221 | +{ |
| 222 | + EventLoopBaseClass *bc = EVENT_LOOP_BASE_CLASS(oc); |
| 223 | + |
| 224 | + bc->init = main_loop_init; |
| 225 | + bc->update_params = main_loop_update_params; |
| 226 | + bc->can_be_deleted = main_loop_can_be_deleted; |
| 227 | +} |
| 228 | + |
| 229 | +static const TypeInfo main_loop_info = { |
| 230 | + .name = TYPE_MAIN_LOOP, |
| 231 | + .parent = TYPE_EVENT_LOOP_BASE, |
| 232 | + .class_init = main_loop_class_init, |
| 233 | + .instance_size = sizeof(MainLoop), |
| 234 | +}; |
| 235 | + |
| 236 | +static void main_loop_register_types(void) |
| 237 | +{ |
| 238 | + type_register_static(&main_loop_info); |
| 239 | +} |
| 240 | + |
| 241 | +type_init(main_loop_register_types) |
| 242 | + |
187 | 243 | static int max_priority;
|
188 | 244 |
|
189 | 245 | #ifndef _WIN32
|
|
0 commit comments