From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LQ39Q-0000Nr-7R for qemu-devel@nongnu.org; Thu, 22 Jan 2009 12:15:32 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LQ39P-0000NM-H5 for qemu-devel@nongnu.org; Thu, 22 Jan 2009 12:15:31 -0500 Received: from [199.232.76.173] (port=52655 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LQ39P-0000NG-BK for qemu-devel@nongnu.org; Thu, 22 Jan 2009 12:15:31 -0500 Received: from savannah.gnu.org ([199.232.41.3]:52529 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LQ39P-00061A-3D for qemu-devel@nongnu.org; Thu, 22 Jan 2009 12:15:31 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LQ39O-0004EG-M2 for qemu-devel@nongnu.org; Thu, 22 Jan 2009 17:15:30 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LQ39O-0004EB-9x for qemu-devel@nongnu.org; Thu, 22 Jan 2009 17:15:30 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Thu, 22 Jan 2009 17:15:30 +0000 Subject: [Qemu-devel] [6402] Rework vm_state_change notifiers (Jan Kiszka) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 6402 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6402 Author: aliguori Date: 2009-01-22 17:15:29 +0000 (Thu, 22 Jan 2009) Log Message: ----------- Rework vm_state_change notifiers (Jan Kiszka) Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/audio/audio.c trunk/gdbstub.c trunk/sysemu.h trunk/vl.c Modified: trunk/audio/audio.c =================================================================== --- trunk/audio/audio.c 2009-01-22 17:15:25 UTC (rev 6401) +++ trunk/audio/audio.c 2009-01-22 17:15:29 UTC (rev 6402) @@ -1622,7 +1622,8 @@ } } -static void audio_vm_change_state_handler (void *opaque, int running) +static void audio_vm_change_state_handler (void *opaque, int running, + int reason) { AudioState *s = opaque; HWVoiceOut *hwo = NULL; Modified: trunk/gdbstub.c =================================================================== --- trunk/gdbstub.c 2009-01-22 17:15:25 UTC (rev 6401) +++ trunk/gdbstub.c 2009-01-22 17:15:29 UTC (rev 6402) @@ -1867,7 +1867,7 @@ } #ifndef CONFIG_USER_ONLY -static void gdb_vm_stopped(void *opaque, int reason) +static void gdb_vm_state_change(void *opaque, int running, int reason) { GDBState *s = gdbserver_state; CPUState *env = s->c_cpu; @@ -1875,7 +1875,8 @@ const char *type; int ret; - if (s->state == RS_SYSCALL) + if (running || (reason != EXCP_DEBUG && reason != EXCP_INTERRUPT) || + s->state == RS_SYSCALL) return; /* disable single step if it was enable */ @@ -1904,10 +1905,8 @@ } tb_flush(env); ret = GDB_SIGNAL_TRAP; - } else if (reason == EXCP_INTERRUPT) { - ret = GDB_SIGNAL_INT; } else { - ret = 0; + ret = GDB_SIGNAL_INT; } snprintf(buf, sizeof(buf), "T%02xthread:%02x;", ret, env->cpu_index+1); put_packet(s, buf); @@ -2300,7 +2299,7 @@ gdbserver_state = s; qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive, gdb_chr_event, NULL); - qemu_add_vm_stop_handler(gdb_vm_stopped, NULL); + qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL); return 0; } #endif Modified: trunk/sysemu.h =================================================================== --- trunk/sysemu.h 2009-01-22 17:15:25 UTC (rev 6401) +++ trunk/sysemu.h 2009-01-22 17:15:29 UTC (rev 6402) @@ -12,16 +12,12 @@ #define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx" typedef struct vm_change_state_entry VMChangeStateEntry; -typedef void VMChangeStateHandler(void *opaque, int running); -typedef void VMStopHandler(void *opaque, int reason); +typedef void VMChangeStateHandler(void *opaque, int running, int reason); VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, void *opaque); void qemu_del_vm_change_state_handler(VMChangeStateEntry *e); -int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque); -void qemu_del_vm_stop_handler(VMStopHandler *cb, void *opaque); - void vm_start(void); void vm_stop(int reason); Modified: trunk/vl.c =================================================================== --- trunk/vl.c 2009-01-22 17:15:25 UTC (rev 6401) +++ trunk/vl.c 2009-01-22 17:15:29 UTC (rev 6402) @@ -3451,37 +3451,21 @@ qemu_free (e); } -static void vm_state_notify(int running) +static void vm_state_notify(int running, int reason) { VMChangeStateEntry *e; for (e = vm_change_state_head.lh_first; e; e = e->entries.le_next) { - e->cb(e->opaque, running); + e->cb(e->opaque, running, reason); } } -/* XXX: support several handlers */ -static VMStopHandler *vm_stop_cb; -static void *vm_stop_opaque; - -int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque) -{ - vm_stop_cb = cb; - vm_stop_opaque = opaque; - return 0; -} - -void qemu_del_vm_stop_handler(VMStopHandler *cb, void *opaque) -{ - vm_stop_cb = NULL; -} - void vm_start(void) { if (!vm_running) { cpu_enable_ticks(); vm_running = 1; - vm_state_notify(1); + vm_state_notify(1, 0); qemu_rearm_alarm_timer(alarm_timer); } } @@ -3491,12 +3475,7 @@ if (vm_running) { cpu_disable_ticks(); vm_running = 0; - if (reason != 0) { - if (vm_stop_cb) { - vm_stop_cb(vm_stop_opaque, reason); - } - } - vm_state_notify(0); + vm_state_notify(0, reason); } }