Commit 9781e0401ad7d2d30e48fd532372d4ef80be58b6
1 parent
5c047c0d
Rework vm_state_change notifiers (Jan Kiszka)
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6402 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
4 changed files
with
12 additions
and
37 deletions
audio/audio.c
| @@ -1622,7 +1622,8 @@ static int audio_driver_init (AudioState *s, struct audio_driver *drv) | @@ -1622,7 +1622,8 @@ static int audio_driver_init (AudioState *s, struct audio_driver *drv) | ||
| 1622 | } | 1622 | } |
| 1623 | } | 1623 | } |
| 1624 | 1624 | ||
| 1625 | -static void audio_vm_change_state_handler (void *opaque, int running) | 1625 | +static void audio_vm_change_state_handler (void *opaque, int running, |
| 1626 | + int reason) | ||
| 1626 | { | 1627 | { |
| 1627 | AudioState *s = opaque; | 1628 | AudioState *s = opaque; |
| 1628 | HWVoiceOut *hwo = NULL; | 1629 | HWVoiceOut *hwo = NULL; |
gdbstub.c
| @@ -1867,7 +1867,7 @@ void gdb_set_stop_cpu(CPUState *env) | @@ -1867,7 +1867,7 @@ void gdb_set_stop_cpu(CPUState *env) | ||
| 1867 | } | 1867 | } |
| 1868 | 1868 | ||
| 1869 | #ifndef CONFIG_USER_ONLY | 1869 | #ifndef CONFIG_USER_ONLY |
| 1870 | -static void gdb_vm_stopped(void *opaque, int reason) | 1870 | +static void gdb_vm_state_change(void *opaque, int running, int reason) |
| 1871 | { | 1871 | { |
| 1872 | GDBState *s = gdbserver_state; | 1872 | GDBState *s = gdbserver_state; |
| 1873 | CPUState *env = s->c_cpu; | 1873 | CPUState *env = s->c_cpu; |
| @@ -1875,7 +1875,8 @@ static void gdb_vm_stopped(void *opaque, int reason) | @@ -1875,7 +1875,8 @@ static void gdb_vm_stopped(void *opaque, int reason) | ||
| 1875 | const char *type; | 1875 | const char *type; |
| 1876 | int ret; | 1876 | int ret; |
| 1877 | 1877 | ||
| 1878 | - if (s->state == RS_SYSCALL) | 1878 | + if (running || (reason != EXCP_DEBUG && reason != EXCP_INTERRUPT) || |
| 1879 | + s->state == RS_SYSCALL) | ||
| 1879 | return; | 1880 | return; |
| 1880 | 1881 | ||
| 1881 | /* disable single step if it was enable */ | 1882 | /* disable single step if it was enable */ |
| @@ -1904,10 +1905,8 @@ static void gdb_vm_stopped(void *opaque, int reason) | @@ -1904,10 +1905,8 @@ static void gdb_vm_stopped(void *opaque, int reason) | ||
| 1904 | } | 1905 | } |
| 1905 | tb_flush(env); | 1906 | tb_flush(env); |
| 1906 | ret = GDB_SIGNAL_TRAP; | 1907 | ret = GDB_SIGNAL_TRAP; |
| 1907 | - } else if (reason == EXCP_INTERRUPT) { | ||
| 1908 | - ret = GDB_SIGNAL_INT; | ||
| 1909 | } else { | 1908 | } else { |
| 1910 | - ret = 0; | 1909 | + ret = GDB_SIGNAL_INT; |
| 1911 | } | 1910 | } |
| 1912 | snprintf(buf, sizeof(buf), "T%02xthread:%02x;", ret, env->cpu_index+1); | 1911 | snprintf(buf, sizeof(buf), "T%02xthread:%02x;", ret, env->cpu_index+1); |
| 1913 | put_packet(s, buf); | 1912 | put_packet(s, buf); |
| @@ -2300,7 +2299,7 @@ int gdbserver_start(const char *port) | @@ -2300,7 +2299,7 @@ int gdbserver_start(const char *port) | ||
| 2300 | gdbserver_state = s; | 2299 | gdbserver_state = s; |
| 2301 | qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive, | 2300 | qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive, |
| 2302 | gdb_chr_event, NULL); | 2301 | gdb_chr_event, NULL); |
| 2303 | - qemu_add_vm_stop_handler(gdb_vm_stopped, NULL); | 2302 | + qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL); |
| 2304 | return 0; | 2303 | return 0; |
| 2305 | } | 2304 | } |
| 2306 | #endif | 2305 | #endif |
sysemu.h
| @@ -12,16 +12,12 @@ extern uint8_t qemu_uuid[]; | @@ -12,16 +12,12 @@ extern uint8_t qemu_uuid[]; | ||
| 12 | #define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx" | 12 | #define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx" |
| 13 | 13 | ||
| 14 | typedef struct vm_change_state_entry VMChangeStateEntry; | 14 | typedef struct vm_change_state_entry VMChangeStateEntry; |
| 15 | -typedef void VMChangeStateHandler(void *opaque, int running); | ||
| 16 | -typedef void VMStopHandler(void *opaque, int reason); | 15 | +typedef void VMChangeStateHandler(void *opaque, int running, int reason); |
| 17 | 16 | ||
| 18 | VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, | 17 | VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, |
| 19 | void *opaque); | 18 | void *opaque); |
| 20 | void qemu_del_vm_change_state_handler(VMChangeStateEntry *e); | 19 | void qemu_del_vm_change_state_handler(VMChangeStateEntry *e); |
| 21 | 20 | ||
| 22 | -int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque); | ||
| 23 | -void qemu_del_vm_stop_handler(VMStopHandler *cb, void *opaque); | ||
| 24 | - | ||
| 25 | void vm_start(void); | 21 | void vm_start(void); |
| 26 | void vm_stop(int reason); | 22 | void vm_stop(int reason); |
| 27 | 23 |
vl.c
| @@ -3451,37 +3451,21 @@ void qemu_del_vm_change_state_handler(VMChangeStateEntry *e) | @@ -3451,37 +3451,21 @@ void qemu_del_vm_change_state_handler(VMChangeStateEntry *e) | ||
| 3451 | qemu_free (e); | 3451 | qemu_free (e); |
| 3452 | } | 3452 | } |
| 3453 | 3453 | ||
| 3454 | -static void vm_state_notify(int running) | 3454 | +static void vm_state_notify(int running, int reason) |
| 3455 | { | 3455 | { |
| 3456 | VMChangeStateEntry *e; | 3456 | VMChangeStateEntry *e; |
| 3457 | 3457 | ||
| 3458 | for (e = vm_change_state_head.lh_first; e; e = e->entries.le_next) { | 3458 | for (e = vm_change_state_head.lh_first; e; e = e->entries.le_next) { |
| 3459 | - e->cb(e->opaque, running); | 3459 | + e->cb(e->opaque, running, reason); |
| 3460 | } | 3460 | } |
| 3461 | } | 3461 | } |
| 3462 | 3462 | ||
| 3463 | -/* XXX: support several handlers */ | ||
| 3464 | -static VMStopHandler *vm_stop_cb; | ||
| 3465 | -static void *vm_stop_opaque; | ||
| 3466 | - | ||
| 3467 | -int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque) | ||
| 3468 | -{ | ||
| 3469 | - vm_stop_cb = cb; | ||
| 3470 | - vm_stop_opaque = opaque; | ||
| 3471 | - return 0; | ||
| 3472 | -} | ||
| 3473 | - | ||
| 3474 | -void qemu_del_vm_stop_handler(VMStopHandler *cb, void *opaque) | ||
| 3475 | -{ | ||
| 3476 | - vm_stop_cb = NULL; | ||
| 3477 | -} | ||
| 3478 | - | ||
| 3479 | void vm_start(void) | 3463 | void vm_start(void) |
| 3480 | { | 3464 | { |
| 3481 | if (!vm_running) { | 3465 | if (!vm_running) { |
| 3482 | cpu_enable_ticks(); | 3466 | cpu_enable_ticks(); |
| 3483 | vm_running = 1; | 3467 | vm_running = 1; |
| 3484 | - vm_state_notify(1); | 3468 | + vm_state_notify(1, 0); |
| 3485 | qemu_rearm_alarm_timer(alarm_timer); | 3469 | qemu_rearm_alarm_timer(alarm_timer); |
| 3486 | } | 3470 | } |
| 3487 | } | 3471 | } |
| @@ -3491,12 +3475,7 @@ void vm_stop(int reason) | @@ -3491,12 +3475,7 @@ void vm_stop(int reason) | ||
| 3491 | if (vm_running) { | 3475 | if (vm_running) { |
| 3492 | cpu_disable_ticks(); | 3476 | cpu_disable_ticks(); |
| 3493 | vm_running = 0; | 3477 | vm_running = 0; |
| 3494 | - if (reason != 0) { | ||
| 3495 | - if (vm_stop_cb) { | ||
| 3496 | - vm_stop_cb(vm_stop_opaque, reason); | ||
| 3497 | - } | ||
| 3498 | - } | ||
| 3499 | - vm_state_notify(0); | 3478 | + vm_state_notify(0, reason); |
| 3500 | } | 3479 | } |
| 3501 | } | 3480 | } |
| 3502 | 3481 |