All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] console: Fix segfault on screendump without VGA adapter
@ 2011-11-18 15:47 Alexander Graf
  2011-11-20  9:31 ` [Qemu-devel] [PATCH] creen dump not supported when no console Cao,Bing Bu
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Graf @ 2011-11-18 15:47 UTC (permalink / raw)
  To: qemu-devel Developers

When trying to create a screen dump without having any VGA adapter
inside the guest, QEMU segfaults.

This is because it's trying to switch back to the "previous" screen
it was on before dumping the VGA screen. Unfortunately, in my case
there simply is no previous screen so it accesses a NULL pointer.

Fix it by checking if previous_active_console is actually available.

This is 1.0 material.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 console.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/console.c b/console.c
index f6fe441..ed6a653 100644
--- a/console.c
+++ b/console.c
@@ -186,7 +186,9 @@ void vga_hw_screen_dump(const char *filename)
         consoles[0]->hw_screen_dump(consoles[0]->hw, filename);
     }
 
-    console_select(previous_active_console->index);
+    if (previous_active_console) {
+        console_select(previous_active_console->index);
+    }
 }
 
 void vga_hw_text_update(console_ch_t *chardata)
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH] creen dump not supported when no console
  2011-11-18 15:47 [Qemu-devel] [PATCH] console: Fix segfault on screendump without VGA adapter Alexander Graf
@ 2011-11-20  9:31 ` Cao,Bing Bu
  2011-11-20 11:02   ` Paolo Bonzini
  2011-11-21 12:30   ` [Qemu-devel] [PATCH] creen dump not supported when no console Markus Armbruster
  0 siblings, 2 replies; 5+ messages in thread
From: Cao,Bing Bu @ 2011-11-20  9:31 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cao,Bing Bu

I have tested the issue use "-vga none -nographic" option.
QEMU segment faults.

But i think there is no any text and graphic console created in this case.
The console[0] is NULL.

The vga_hw_screen_dump() should return before console_select().
What do you think?


---
 console.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/console.c b/console.c
index f6fe441..957948e 100644
--- a/console.c
+++ b/console.c
@@ -184,6 +184,9 @@ void vga_hw_screen_dump(const char *filename)
     console_select(0);
     if (consoles[0] && consoles[0]->hw_screen_dump) {
         consoles[0]->hw_screen_dump(consoles[0]->hw, filename);
+    } else {
+	fprintf(stderr,"no any console,could not screen dump \n");
+	return;
     }
 
     console_select(previous_active_console->index);
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] creen dump not supported when no console
  2011-11-20  9:31 ` [Qemu-devel] [PATCH] creen dump not supported when no console Cao,Bing Bu
@ 2011-11-20 11:02   ` Paolo Bonzini
  2011-11-22  1:26     ` [Qemu-devel] [PATCH][V2] Can't screendump without a console Cao,Bing Bu
  2011-11-21 12:30   ` [Qemu-devel] [PATCH] creen dump not supported when no console Markus Armbruster
  1 sibling, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2011-11-20 11:02 UTC (permalink / raw)
  To: Cao,Bing Bu; +Cc: qemu-devel

On 11/20/2011 10:31 AM, Cao,Bing Bu wrote:
> +    } else {
> +	fprintf(stderr,"no any console,could not screen dump \n");
> +	return;

This should be error_printf.

Paolo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] creen dump not supported when no console
  2011-11-20  9:31 ` [Qemu-devel] [PATCH] creen dump not supported when no console Cao,Bing Bu
  2011-11-20 11:02   ` Paolo Bonzini
@ 2011-11-21 12:30   ` Markus Armbruster
  1 sibling, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2011-11-21 12:30 UTC (permalink / raw)
  To: Cao,Bing Bu; +Cc: qemu-devel

"Cao,Bing Bu" <mars@linux.vnet.ibm.com> writes:

> I have tested the issue use "-vga none -nographic" option.
> QEMU segment faults.
>
> But i think there is no any text and graphic console created in this case.
> The console[0] is NULL.
>
> The vga_hw_screen_dump() should return before console_select().
> What do you think?
>
>
> ---
>  console.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/console.c b/console.c
> index f6fe441..957948e 100644
> --- a/console.c
> +++ b/console.c
> @@ -184,6 +184,9 @@ void vga_hw_screen_dump(const char *filename)
>      console_select(0);
>      if (consoles[0] && consoles[0]->hw_screen_dump) {
>          consoles[0]->hw_screen_dump(consoles[0]->hw, filename);
> +    } else {
> +	fprintf(stderr,"no any console,could not screen dump \n");
> +	return;
>      }
>  
>      console_select(previous_active_console->index);

Tab damage.

Subject misspells "screendump".

Error message could use some polish.  Suggest "Can't screendump without
a console".

Please don't use printf & friends for output to the monitor user, it
doesn't go to the monitor unless the monitor happens to be on stdio.
Use error_printf() & friends.

Except when the command is in QMP, and you need nice error reports in
QMP.  Then use qerror_report().  Yes, that's a pain to use.

Except when the command is already implemented in QAPI.  Then you use
error_set() instead.  Yes, that one's a PITA, too.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH][V2] Can't screendump without a console
  2011-11-20 11:02   ` Paolo Bonzini
@ 2011-11-22  1:26     ` Cao,Bing Bu
  0 siblings, 0 replies; 5+ messages in thread
From: Cao,Bing Bu @ 2011-11-22  1:26 UTC (permalink / raw)
  To: armbru, pbonzini; +Cc: Cao, Bing Bu, QEMU Developers

When usinge "-vga none -nographic" option.
There is no any text and graphic console created in this case.
screen dump not supported without console.


Signed-off-by: Cao,Bing Bu <mars@linux.vnet.ibm.com>
---
  console.c |    4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/console.c b/console.c
index f6fe441..6071ef3 100644
--- a/console.c
+++ b/console.c
@@ -184,8 +184,10 @@ void vga_hw_screen_dump(const char *filename)
      console_select(0);
      if (consoles[0] && consoles[0]->hw_screen_dump) {
          consoles[0]->hw_screen_dump(consoles[0]->hw, filename);
+    } else {
+        error_printf("no any console,could not screen dump \n");
+        return;
      }
-
      console_select(previous_active_console->index);
  }

-- 
1.7.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-11-22  1:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-18 15:47 [Qemu-devel] [PATCH] console: Fix segfault on screendump without VGA adapter Alexander Graf
2011-11-20  9:31 ` [Qemu-devel] [PATCH] creen dump not supported when no console Cao,Bing Bu
2011-11-20 11:02   ` Paolo Bonzini
2011-11-22  1:26     ` [Qemu-devel] [PATCH][V2] Can't screendump without a console Cao,Bing Bu
2011-11-21 12:30   ` [Qemu-devel] [PATCH] creen dump not supported when no console Markus Armbruster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.