* [Qemu-devel] [PATCH] optionally specify vm stop message
@ 2009-01-15 10:37 Gleb Natapov
2009-01-15 20:46 ` Anthony Liguori
0 siblings, 1 reply; 10+ messages in thread
From: Gleb Natapov @ 2009-01-15 10:37 UTC (permalink / raw)
To: qemu-devel
Should be applied on top of ENOSPC series.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/gdbstub.c b/gdbstub.c
index a3ff07a..0c6a695 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1928,7 +1928,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...)
gdb_current_syscall_cb = cb;
s->state = RS_SYSCALL;
#ifndef CONFIG_USER_ONLY
- vm_stop(EXCP_DEBUG);
+ vm_stop(EXCP_DEBUG, NULL);
#endif
s->state = RS_IDLE;
va_start(va, fmt);
@@ -2002,7 +2002,7 @@ static void gdb_read_byte(GDBState *s, int ch)
if (vm_running) {
/* when the CPU is running, we cannot do anything except stop
it when receiving a char */
- vm_stop(EXCP_INTERRUPT);
+ vm_stop(EXCP_INTERRUPT, NULL);
} else
#endif
{
@@ -2253,7 +2253,7 @@ static void gdb_chr_event(void *opaque, int event)
{
switch (event) {
case CHR_EVENT_RESET:
- vm_stop(EXCP_INTERRUPT);
+ vm_stop(EXCP_INTERRUPT, NULL);
gdb_has_xml = 0;
break;
default:
diff --git a/hw/ide.c b/hw/ide.c
index 2d2cead..adc15a7 100644
--- a/hw/ide.c
+++ b/hw/ide.c
@@ -999,7 +999,7 @@ static void ide_sector_write(IDEState *s)
if (ret == -ENOSPC) {
s->bmdma->ide_if = s;
s->bmdma->status |= BM_STATUS_PIO_RETRY;
- vm_stop(0);
+ vm_stop(0, "No more space on a disk");
} else
ide_rw_error(s);
return;
@@ -1058,7 +1058,7 @@ static void ide_write_dma_cb(void *opaque, int ret)
if (ret < 0) {
if (ret == -ENOSPC) {
bm->status |= BM_STATUS_DMA_RETRY;
- vm_stop(0);
+ vm_stop(0, "No more space on a disk");
} else
ide_dma_error(s);
return;
diff --git a/migration-exec.c b/migration-exec.c
index caeed4b..0fb8ce4 100644
--- a/migration-exec.c
+++ b/migration-exec.c
@@ -124,7 +124,7 @@ int exec_start_incoming_migration(const char *command)
dprintf("Unable to apply qemu wrapper to popen file\n");
return -errno;
}
- vm_stop(0); /* just in case */
+ vm_stop(0, NULL); /* just in case */
ret = qemu_loadvm_state(f);
if (ret < 0) {
fprintf(stderr, "load of migration failed\n");
diff --git a/migration-tcp.c b/migration-tcp.c
index 6fc1943..3b3bf10 100644
--- a/migration-tcp.c
+++ b/migration-tcp.c
@@ -161,7 +161,7 @@ static void tcp_accept_incoming_migration(void *opaque)
goto out;
}
- vm_stop(0); /* just in case */
+ vm_stop(0, NULL); /* just in case */
ret = qemu_loadvm_state(f);
if (ret < 0) {
fprintf(stderr, "load of migration failed\n");
diff --git a/migration.c b/migration.c
index 0ef777a..10b308c 100644
--- a/migration.c
+++ b/migration.c
@@ -213,7 +213,7 @@ void migrate_fd_put_ready(void *opaque)
dprintf("iterate\n");
if (qemu_savevm_state_iterate(s->file) == 1) {
dprintf("done iterating\n");
- vm_stop(0);
+ vm_stop(0, NULL);
bdrv_flush_all();
qemu_savevm_state_complete(s->file);
diff --git a/monitor.c b/monitor.c
index 7ff9890..f6fb546 100644
--- a/monitor.c
+++ b/monitor.c
@@ -491,7 +491,7 @@ static void do_log(const char *items)
static void do_stop(void)
{
- vm_stop(EXCP_INTERRUPT);
+ vm_stop(EXCP_INTERRUPT, NULL);
}
static void do_cont(void)
diff --git a/savevm.c b/savevm.c
index 729e849..badac22 100644
--- a/savevm.c
+++ b/savevm.c
@@ -770,7 +770,7 @@ int qemu_savevm_state(QEMUFile *f)
int ret;
saved_vm_running = vm_running;
- vm_stop(0);
+ vm_stop(0, NULL);
bdrv_flush_all();
@@ -1037,7 +1037,7 @@ void do_savevm(const char *name)
qemu_aio_flush();
saved_vm_running = vm_running;
- vm_stop(0);
+ vm_stop(0, NULL);
must_delete = 0;
if (name) {
@@ -1133,7 +1133,7 @@ void do_loadvm(const char *name)
qemu_aio_flush();
saved_vm_running = vm_running;
- vm_stop(0);
+ vm_stop(0, NULL);
for(i = 0; i <= nb_drives; i++) {
bs1 = drives_table[i].bdrv;
diff --git a/sysemu.h b/sysemu.h
index 47c1fea..4687def 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -23,7 +23,7 @@ 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);
+void vm_stop(int reason, const char *msg);
int64_t cpu_get_ticks(void);
void cpu_enable_ticks(void);
diff --git a/vl.c b/vl.c
index e29072b..8646f3d 100644
--- a/vl.c
+++ b/vl.c
@@ -3438,7 +3438,7 @@ void vm_start(void)
}
}
-void vm_stop(int reason)
+void vm_stop(int reason, const char *msg)
{
if (vm_running) {
cpu_disable_ticks();
@@ -3449,6 +3449,8 @@ void vm_stop(int reason)
}
}
vm_state_notify(0);
+ if (msg)
+ term_printf("%s\n", msg);
}
}
@@ -3745,7 +3747,7 @@ static int main_loop(void)
if (shutdown_requested) {
ret = EXCP_INTERRUPT;
if (no_shutdown) {
- vm_stop(0);
+ vm_stop(0, NULL);
no_shutdown = 0;
}
else
@@ -3763,7 +3765,7 @@ static int main_loop(void)
}
if (unlikely(ret == EXCP_DEBUG)) {
gdb_set_stop_cpu(cur_cpu);
- vm_stop(EXCP_DEBUG);
+ vm_stop(EXCP_DEBUG, NULL);
}
/* If all cpus are halted then wait until the next IRQ */
/* XXX: use timeout computed from timers */
--
Gleb.
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] optionally specify vm stop message
2009-01-15 10:37 [Qemu-devel] [PATCH] optionally specify vm stop message Gleb Natapov
@ 2009-01-15 20:46 ` Anthony Liguori
2009-01-16 7:14 ` Gleb Natapov
0 siblings, 1 reply; 10+ messages in thread
From: Anthony Liguori @ 2009-01-15 20:46 UTC (permalink / raw)
To: qemu-devel
Gleb Natapov wrote:
> Should be applied on top of ENOSPC series.
>
How about just adding a new vm_stop reason? That will work out better
when we introduce the improved monitor.
Regards,
Anthony Liguori
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> diff --git a/gdbstub.c b/gdbstub.c
> index a3ff07a..0c6a695 100644
> --- a/gdbstub.c
> +++ b/gdbstub.c
> @@ -1928,7 +1928,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...)
> gdb_current_syscall_cb = cb;
> s->state = RS_SYSCALL;
> #ifndef CONFIG_USER_ONLY
> - vm_stop(EXCP_DEBUG);
> + vm_stop(EXCP_DEBUG, NULL);
> #endif
> s->state = RS_IDLE;
> va_start(va, fmt);
> @@ -2002,7 +2002,7 @@ static void gdb_read_byte(GDBState *s, int ch)
> if (vm_running) {
> /* when the CPU is running, we cannot do anything except stop
> it when receiving a char */
> - vm_stop(EXCP_INTERRUPT);
> + vm_stop(EXCP_INTERRUPT, NULL);
> } else
> #endif
> {
> @@ -2253,7 +2253,7 @@ static void gdb_chr_event(void *opaque, int event)
> {
> switch (event) {
> case CHR_EVENT_RESET:
> - vm_stop(EXCP_INTERRUPT);
> + vm_stop(EXCP_INTERRUPT, NULL);
> gdb_has_xml = 0;
> break;
> default:
> diff --git a/hw/ide.c b/hw/ide.c
> index 2d2cead..adc15a7 100644
> --- a/hw/ide.c
> +++ b/hw/ide.c
> @@ -999,7 +999,7 @@ static void ide_sector_write(IDEState *s)
> if (ret == -ENOSPC) {
> s->bmdma->ide_if = s;
> s->bmdma->status |= BM_STATUS_PIO_RETRY;
> - vm_stop(0);
> + vm_stop(0, "No more space on a disk");
> } else
> ide_rw_error(s);
> return;
> @@ -1058,7 +1058,7 @@ static void ide_write_dma_cb(void *opaque, int ret)
> if (ret < 0) {
> if (ret == -ENOSPC) {
> bm->status |= BM_STATUS_DMA_RETRY;
> - vm_stop(0);
> + vm_stop(0, "No more space on a disk");
> } else
> ide_dma_error(s);
> return;
> diff --git a/migration-exec.c b/migration-exec.c
> index caeed4b..0fb8ce4 100644
> --- a/migration-exec.c
> +++ b/migration-exec.c
> @@ -124,7 +124,7 @@ int exec_start_incoming_migration(const char *command)
> dprintf("Unable to apply qemu wrapper to popen file\n");
> return -errno;
> }
> - vm_stop(0); /* just in case */
> + vm_stop(0, NULL); /* just in case */
> ret = qemu_loadvm_state(f);
> if (ret < 0) {
> fprintf(stderr, "load of migration failed\n");
> diff --git a/migration-tcp.c b/migration-tcp.c
> index 6fc1943..3b3bf10 100644
> --- a/migration-tcp.c
> +++ b/migration-tcp.c
> @@ -161,7 +161,7 @@ static void tcp_accept_incoming_migration(void *opaque)
> goto out;
> }
>
> - vm_stop(0); /* just in case */
> + vm_stop(0, NULL); /* just in case */
> ret = qemu_loadvm_state(f);
> if (ret < 0) {
> fprintf(stderr, "load of migration failed\n");
> diff --git a/migration.c b/migration.c
> index 0ef777a..10b308c 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -213,7 +213,7 @@ void migrate_fd_put_ready(void *opaque)
> dprintf("iterate\n");
> if (qemu_savevm_state_iterate(s->file) == 1) {
> dprintf("done iterating\n");
> - vm_stop(0);
> + vm_stop(0, NULL);
>
> bdrv_flush_all();
> qemu_savevm_state_complete(s->file);
> diff --git a/monitor.c b/monitor.c
> index 7ff9890..f6fb546 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -491,7 +491,7 @@ static void do_log(const char *items)
>
> static void do_stop(void)
> {
> - vm_stop(EXCP_INTERRUPT);
> + vm_stop(EXCP_INTERRUPT, NULL);
> }
>
> static void do_cont(void)
> diff --git a/savevm.c b/savevm.c
> index 729e849..badac22 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -770,7 +770,7 @@ int qemu_savevm_state(QEMUFile *f)
> int ret;
>
> saved_vm_running = vm_running;
> - vm_stop(0);
> + vm_stop(0, NULL);
>
> bdrv_flush_all();
>
> @@ -1037,7 +1037,7 @@ void do_savevm(const char *name)
> qemu_aio_flush();
>
> saved_vm_running = vm_running;
> - vm_stop(0);
> + vm_stop(0, NULL);
>
> must_delete = 0;
> if (name) {
> @@ -1133,7 +1133,7 @@ void do_loadvm(const char *name)
> qemu_aio_flush();
>
> saved_vm_running = vm_running;
> - vm_stop(0);
> + vm_stop(0, NULL);
>
> for(i = 0; i <= nb_drives; i++) {
> bs1 = drives_table[i].bdrv;
> diff --git a/sysemu.h b/sysemu.h
> index 47c1fea..4687def 100644
> --- a/sysemu.h
> +++ b/sysemu.h
> @@ -23,7 +23,7 @@ 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);
> +void vm_stop(int reason, const char *msg);
>
> int64_t cpu_get_ticks(void);
> void cpu_enable_ticks(void);
> diff --git a/vl.c b/vl.c
> index e29072b..8646f3d 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3438,7 +3438,7 @@ void vm_start(void)
> }
> }
>
> -void vm_stop(int reason)
> +void vm_stop(int reason, const char *msg)
> {
> if (vm_running) {
> cpu_disable_ticks();
> @@ -3449,6 +3449,8 @@ void vm_stop(int reason)
> }
> }
> vm_state_notify(0);
> + if (msg)
> + term_printf("%s\n", msg);
> }
> }
>
> @@ -3745,7 +3747,7 @@ static int main_loop(void)
> if (shutdown_requested) {
> ret = EXCP_INTERRUPT;
> if (no_shutdown) {
> - vm_stop(0);
> + vm_stop(0, NULL);
> no_shutdown = 0;
> }
> else
> @@ -3763,7 +3765,7 @@ static int main_loop(void)
> }
> if (unlikely(ret == EXCP_DEBUG)) {
> gdb_set_stop_cpu(cur_cpu);
> - vm_stop(EXCP_DEBUG);
> + vm_stop(EXCP_DEBUG, NULL);
> }
> /* If all cpus are halted then wait until the next IRQ */
> /* XXX: use timeout computed from timers */
> --
> Gleb.
>
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] optionally specify vm stop message
2009-01-15 20:46 ` Anthony Liguori
@ 2009-01-16 7:14 ` Gleb Natapov
2009-01-16 15:26 ` Anthony Liguori
0 siblings, 1 reply; 10+ messages in thread
From: Gleb Natapov @ 2009-01-16 7:14 UTC (permalink / raw)
To: qemu-devel
On Thu, Jan 15, 2009 at 02:46:06PM -0600, Anthony Liguori wrote:
> Gleb Natapov wrote:
>> Should be applied on top of ENOSPC series.
>>
>
> How about just adding a new vm_stop reason? That will work out better
> when we introduce the improved monitor.
>
We may want to specify different message for the same reason. For
instance we may want to print the name of the file we failed to write
to. Also non zero reasons a handled differently by vm_stop. Don't know
why.
--
Gleb.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] optionally specify vm stop message
2009-01-16 7:14 ` Gleb Natapov
@ 2009-01-16 15:26 ` Anthony Liguori
2009-01-16 16:24 ` [Qemu-devel] " Jan Kiszka
0 siblings, 1 reply; 10+ messages in thread
From: Anthony Liguori @ 2009-01-16 15:26 UTC (permalink / raw)
To: qemu-devel
Gleb Natapov wrote:
> On Thu, Jan 15, 2009 at 02:46:06PM -0600, Anthony Liguori wrote:
>
>> Gleb Natapov wrote:
>>
>>> Should be applied on top of ENOSPC series.
>>>
>>>
>> How about just adding a new vm_stop reason? That will work out better
>> when we introduce the improved monitor.
>>
>>
> We may want to specify different message for the same reason. For
> instance we may want to print the name of the file we failed to write
> to.
I'm thinking about this from a management tool perspective. When we
have a better monitor interface, this would generate an async
notification. Instead of generating an arbitrary string, it could send
a reason code that has a well defined meaning.
For now, within vm_stop, it can say if (reason == VM_STOP_ENOSPC)
printf("ran out of space"); or something.
There are other places we stop a vm, like when -no-shutdown is used,
where using a reason code would be very useful.
> Also non zero reasons a handled differently by vm_stop. Don't know
> why.
>
It's an ugly hack for gdbstub. It notifies gdb when a breakpoint
occurs. We have far too many state tracking mechanisms. Anyway, gdb
can pass something like VM_STOP_BP and that can be used to trigger the
callback.
Regards,
Anthony Liguori
> --
> Gleb.
>
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] Re: [PATCH] optionally specify vm stop message
2009-01-16 15:26 ` Anthony Liguori
@ 2009-01-16 16:24 ` Jan Kiszka
2009-01-16 16:27 ` Anthony Liguori
0 siblings, 1 reply; 10+ messages in thread
From: Jan Kiszka @ 2009-01-16 16:24 UTC (permalink / raw)
To: qemu-devel
Anthony Liguori wrote:
> Gleb Natapov wrote:
>> On Thu, Jan 15, 2009 at 02:46:06PM -0600, Anthony Liguori wrote:
>>
>>> Gleb Natapov wrote:
>>>
>>>> Should be applied on top of ENOSPC series.
>>>>
>>> How about just adding a new vm_stop reason? That will work out
>>> better when we introduce the improved monitor.
>>>
>>>
>> We may want to specify different message for the same reason. For
>> instance we may want to print the name of the file we failed to write
>> to.
>
> I'm thinking about this from a management tool perspective. When we
> have a better monitor interface, this would generate an async
> notification. Instead of generating an arbitrary string, it could send
> a reason code that has a well defined meaning.
>
> For now, within vm_stop, it can say if (reason == VM_STOP_ENOSPC)
> printf("ran out of space"); or something.
>
> There are other places we stop a vm, like when -no-shutdown is used,
> where using a reason code would be very useful.
>
>> Also non zero reasons a handled differently by vm_stop. Don't know
>> why.
>>
>
> It's an ugly hack for gdbstub. It notifies gdb when a breakpoint
> occurs. We have far too many state tracking mechanisms. Anyway, gdb
> can pass something like VM_STOP_BP and that can be used to trigger the
> callback.
It's not only used for breakpoints but any stop condition that should be
reported to the gdb frontend (so far: EXCP_DEBUG and EXCP_INTERRUPT).
Not sure, though, how to deal with ENOSPC - it's not a guest fault, it's
a host problem. From that POV, gdb should not receive it.
Nevertheless, gdb_vm_stopped should better do the filtering, not the
caller of vm_stop by passing 0 for "any other reason gdb should be
bothered with".
Jan
--
Siemens AG, Corporate Technology, CT SE 26
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] Re: [PATCH] optionally specify vm stop message
2009-01-16 16:24 ` [Qemu-devel] " Jan Kiszka
@ 2009-01-16 16:27 ` Anthony Liguori
2009-01-16 16:36 ` Jan Kiszka
0 siblings, 1 reply; 10+ messages in thread
From: Anthony Liguori @ 2009-01-16 16:27 UTC (permalink / raw)
To: qemu-devel
Jan Kiszka wrote:
> Anthony Liguori wrote:
>
>>> Also non zero reasons a handled differently by vm_stop. Don't know
>>> why.
>>>
>>>
>> It's an ugly hack for gdbstub. It notifies gdb when a breakpoint
>> occurs. We have far too many state tracking mechanisms. Anyway, gdb
>> can pass something like VM_STOP_BP and that can be used to trigger the
>> callback.
>>
>
> It's not only used for breakpoints but any stop condition that should be
> reported to the gdb frontend (so far: EXCP_DEBUG and EXCP_INTERRUPT).
> Not sure, though, how to deal with ENOSPC - it's not a guest fault, it's
> a host problem. From that POV, gdb should not receive it.
>
We already have a vm_change_state_handler that is invoked whenever a
guest starts running or stops running. gdb should be able to use that
and look at env->exception_index, no?
Regards,
Anthony Liguori
> Nevertheless, gdb_vm_stopped should better do the filtering, not the
> caller of vm_stop by passing 0 for "any other reason gdb should be
> bothered with".
>
> Jan
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] Re: [PATCH] optionally specify vm stop message
2009-01-16 16:27 ` Anthony Liguori
@ 2009-01-16 16:36 ` Jan Kiszka
2009-01-16 16:45 ` Jan Kiszka
0 siblings, 1 reply; 10+ messages in thread
From: Jan Kiszka @ 2009-01-16 16:36 UTC (permalink / raw)
To: qemu-devel
Anthony Liguori wrote:
> Jan Kiszka wrote:
>> Anthony Liguori wrote:
>>
>>>> Also non zero reasons a handled differently by vm_stop. Don't know
>>>> why.
>>>>
>>> It's an ugly hack for gdbstub. It notifies gdb when a breakpoint
>>> occurs. We have far too many state tracking mechanisms. Anyway, gdb
>>> can pass something like VM_STOP_BP and that can be used to trigger the
>>> callback.
>>>
>>
>> It's not only used for breakpoints but any stop condition that should be
>> reported to the gdb frontend (so far: EXCP_DEBUG and EXCP_INTERRUPT).
>> Not sure, though, how to deal with ENOSPC - it's not a guest fault, it's
>> a host problem. From that POV, gdb should not receive it.
>>
>
> We already have a vm_change_state_handler that is invoked whenever a
> guest starts running or stops running. gdb should be able to use that
> and look at env->exception_index, no?
I don't think env->exception_index is set when you issue "stop" from the
monitor, e.g. Moreover, that would be an ugly (out-of-band) API as well.
Jan
--
Siemens AG, Corporate Technology, CT SE 26
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] Re: [PATCH] optionally specify vm stop message
2009-01-16 16:36 ` Jan Kiszka
@ 2009-01-16 16:45 ` Jan Kiszka
2009-01-16 17:02 ` Jan Kiszka
0 siblings, 1 reply; 10+ messages in thread
From: Jan Kiszka @ 2009-01-16 16:45 UTC (permalink / raw)
To: qemu-devel
Jan Kiszka wrote:
> Anthony Liguori wrote:
>> Jan Kiszka wrote:
>>> Anthony Liguori wrote:
>>>
>>>>> Also non zero reasons a handled differently by vm_stop. Don't know
>>>>> why.
>>>>>
>>>> It's an ugly hack for gdbstub. It notifies gdb when a breakpoint
>>>> occurs. We have far too many state tracking mechanisms. Anyway, gdb
>>>> can pass something like VM_STOP_BP and that can be used to trigger the
>>>> callback.
>>>>
>>> It's not only used for breakpoints but any stop condition that should be
>>> reported to the gdb frontend (so far: EXCP_DEBUG and EXCP_INTERRUPT).
>>> Not sure, though, how to deal with ENOSPC - it's not a guest fault, it's
>>> a host problem. From that POV, gdb should not receive it.
>>>
>> We already have a vm_change_state_handler that is invoked whenever a
>> guest starts running or stops running. gdb should be able to use that
>> and look at env->exception_index, no?
>
> I don't think env->exception_index is set when you issue "stop" from the
> monitor, e.g. Moreover, that would be an ugly (out-of-band) API as well.
>
The point is that vm_stop can be issued from any context, not just from
a vcpu. So there may be no env channel at this point.
Jan
--
Siemens AG, Corporate Technology, CT SE 26
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] Re: [PATCH] optionally specify vm stop message
2009-01-16 16:45 ` Jan Kiszka
@ 2009-01-16 17:02 ` Jan Kiszka
2009-01-16 17:14 ` Anthony Liguori
0 siblings, 1 reply; 10+ messages in thread
From: Jan Kiszka @ 2009-01-16 17:02 UTC (permalink / raw)
To: qemu-devel
Jan Kiszka wrote:
> Jan Kiszka wrote:
>> Anthony Liguori wrote:
>>> Jan Kiszka wrote:
>>>> Anthony Liguori wrote:
>>>>
>>>>>> Also non zero reasons a handled differently by vm_stop. Don't know
>>>>>> why.
>>>>>>
>>>>> It's an ugly hack for gdbstub. It notifies gdb when a breakpoint
>>>>> occurs. We have far too many state tracking mechanisms. Anyway, gdb
>>>>> can pass something like VM_STOP_BP and that can be used to trigger the
>>>>> callback.
>>>>>
>>>> It's not only used for breakpoints but any stop condition that should be
>>>> reported to the gdb frontend (so far: EXCP_DEBUG and EXCP_INTERRUPT).
>>>> Not sure, though, how to deal with ENOSPC - it's not a guest fault, it's
>>>> a host problem. From that POV, gdb should not receive it.
>>>>
>>> We already have a vm_change_state_handler that is invoked whenever a
>>> guest starts running or stops running. gdb should be able to use that
>>> and look at env->exception_index, no?
>> I don't think env->exception_index is set when you issue "stop" from the
>> monitor, e.g. Moreover, that would be an ugly (out-of-band) API as well.
>>
>
> The point is that vm_stop can be issued from any context, not just from
> a vcpu. So there may be no env channel at this point.
But we could enhance the state-change callback interface.... WARNING,
untested quick-hack to overcome vm_stop_cb follows!
Jan
-------->
diff --git a/audio/audio.c b/audio/audio.c
index 762c2e3..e2635c0 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1622,7 +1622,8 @@ static int audio_driver_init (AudioState *s, struct audio_driver *drv)
}
}
-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;
diff --git a/gdbstub.c b/gdbstub.c
index 6db6d22..984acbd 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1991,7 +1991,7 @@ void gdb_set_stop_cpu(CPUState *env)
}
#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;
@@ -1999,7 +1999,8 @@ static void gdb_vm_stopped(void *opaque, int reason)
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 */
@@ -2028,10 +2029,8 @@ static void gdb_vm_stopped(void *opaque, int reason)
}
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);
@@ -2424,7 +2423,7 @@ int gdbserver_start(const char *port)
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
diff --git a/sysemu.h b/sysemu.h
index 55f8d79..d8df642 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -12,16 +12,12 @@ extern uint8_t qemu_uuid[];
#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);
diff --git a/vl.c b/vl.c
index be6819d..5192303 100644
--- a/vl.c
+++ b/vl.c
@@ -3404,37 +3404,21 @@ void qemu_del_vm_change_state_handler(VMChangeStateEntry *e)
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);
}
}
@@ -3444,12 +3428,7 @@ void vm_stop(int reason)
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);
}
}
--
Siemens AG, Corporate Technology, CT SE 26
Corporate Competence Center Embedded Linux
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] Re: [PATCH] optionally specify vm stop message
2009-01-16 17:02 ` Jan Kiszka
@ 2009-01-16 17:14 ` Anthony Liguori
0 siblings, 0 replies; 10+ messages in thread
From: Anthony Liguori @ 2009-01-16 17:14 UTC (permalink / raw)
To: qemu-devel
Jan Kiszka wrote:
> But we could enhance the state-change callback interface.... WARNING,
> untested quick-hack to overcome vm_stop_cb follows!
>
Yes, this would be much better, although having it tested is an obvious
prereq :-)
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2009-01-16 17:14 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-15 10:37 [Qemu-devel] [PATCH] optionally specify vm stop message Gleb Natapov
2009-01-15 20:46 ` Anthony Liguori
2009-01-16 7:14 ` Gleb Natapov
2009-01-16 15:26 ` Anthony Liguori
2009-01-16 16:24 ` [Qemu-devel] " Jan Kiszka
2009-01-16 16:27 ` Anthony Liguori
2009-01-16 16:36 ` Jan Kiszka
2009-01-16 16:45 ` Jan Kiszka
2009-01-16 17:02 ` Jan Kiszka
2009-01-16 17:14 ` Anthony Liguori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).