Commit dda9b29f61b198681346191a52be417bc195b0df
Committed by
Anthony Liguori
1 parent
55ddfe8e
Add qemu_unregister_reset
Will be used by '-boot once=...', and should also help in other use cases. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
2 changed files
with
16 additions
and
2 deletions
hw/hw.h
... | ... | @@ -261,6 +261,7 @@ void unregister_savevm(const char *idstr, void *opaque); |
261 | 261 | typedef void QEMUResetHandler(void *opaque); |
262 | 262 | |
263 | 263 | void qemu_register_reset(QEMUResetHandler *func, void *opaque); |
264 | +void qemu_unregister_reset(QEMUResetHandler *func, void *opaque); | |
264 | 265 | |
265 | 266 | /* handler to set the boot_device order for a specific type of QEMUMachine */ |
266 | 267 | /* return 0 if success */ | ... | ... |
vl.c
... | ... | @@ -3509,12 +3509,25 @@ void qemu_register_reset(QEMUResetHandler *func, void *opaque) |
3509 | 3509 | TAILQ_INSERT_TAIL(&reset_handlers, re, entry); |
3510 | 3510 | } |
3511 | 3511 | |
3512 | -void qemu_system_reset(void) | |
3512 | +void qemu_unregister_reset(QEMUResetHandler *func, void *opaque) | |
3513 | 3513 | { |
3514 | 3514 | QEMUResetEntry *re; |
3515 | 3515 | |
3516 | - /* reset all devices */ | |
3517 | 3516 | TAILQ_FOREACH(re, &reset_handlers, entry) { |
3517 | + if (re->func == func && re->opaque == opaque) { | |
3518 | + TAILQ_REMOVE(&reset_handlers, re, entry); | |
3519 | + qemu_free(re); | |
3520 | + return; | |
3521 | + } | |
3522 | + } | |
3523 | +} | |
3524 | + | |
3525 | +void qemu_system_reset(void) | |
3526 | +{ | |
3527 | + QEMUResetEntry *re, *nre; | |
3528 | + | |
3529 | + /* reset all devices */ | |
3530 | + TAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) { | |
3518 | 3531 | re->func(re->opaque); |
3519 | 3532 | } |
3520 | 3533 | } | ... | ... |