qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] vl.c: Exit QEMU early if no machine is found
@ 2012-07-23 16:42 riegamaths
  2012-08-09  8:00 ` Markus Armbruster
  2012-08-09  8:19 ` Stefan Hajnoczi
  0 siblings, 2 replies; 3+ messages in thread
From: riegamaths @ 2012-07-23 16:42 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Stefan Hajnoczi, Dunrong Huang,
	Andreas Färber

From: Dunrong Huang <riegamaths@gmail.com>

We check whether the variable machine is NULL or not before accessing
it. If machine is NULL, exit QEMU with an error, this can avoids a
segfault error.

Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
---
 vl.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/vl.c b/vl.c
index 8904db1..0d145dc 100644
--- a/vl.c
+++ b/vl.c
@@ -3205,6 +3205,11 @@ int main(int argc, char **argv, char **envp)
     }
     loc_set_none();
 
+    if (machine == NULL) {
+        fprintf(stderr, "No machine found.\n");
+        exit(1);
+    }
+
     if (machine->hw_version) {
         qemu_set_version(machine->hw_version);
     }
@@ -3247,11 +3252,6 @@ int main(int argc, char **argv, char **envp)
         data_dir = CONFIG_QEMU_DATADIR;
     }
 
-    if (machine == NULL) {
-        fprintf(stderr, "No machine found.\n");
-        exit(1);
-    }
-
     /*
      * Default to max_cpus = smp_cpus, in case the user doesn't
      * specify a max_cpus value.
-- 
1.7.8.6

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

* Re: [Qemu-devel] [PATCH] vl.c: Exit QEMU early if no machine is found
  2012-07-23 16:42 [Qemu-devel] [PATCH] vl.c: Exit QEMU early if no machine is found riegamaths
@ 2012-08-09  8:00 ` Markus Armbruster
  2012-08-09  8:19 ` Stefan Hajnoczi
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Armbruster @ 2012-08-09  8:00 UTC (permalink / raw)
  To: riegamaths
  Cc: Anthony Liguori, qemu-devel, Andreas Färber, Stefan Hajnoczi

riegamaths@gmail.com writes:

> From: Dunrong Huang <riegamaths@gmail.com>
>
> We check whether the variable machine is NULL or not before accessing
> it. If machine is NULL, exit QEMU with an error, this can avoids a
> segfault error.
>
> Signed-off-by: Dunrong Huang <riegamaths@gmail.com>

Commit message lacks detail on how to reproduce the SEGV.  This does the
trick:

    $ qemu-system-xtensa -cpu help

Reviewed-by: Markus Armbruster <armbru@redhat.com>

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

* Re: [Qemu-devel] [PATCH] vl.c: Exit QEMU early if no machine is found
  2012-07-23 16:42 [Qemu-devel] [PATCH] vl.c: Exit QEMU early if no machine is found riegamaths
  2012-08-09  8:00 ` Markus Armbruster
@ 2012-08-09  8:19 ` Stefan Hajnoczi
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2012-08-09  8:19 UTC (permalink / raw)
  To: riegamaths; +Cc: Anthony Liguori, qemu-devel, Andreas Färber

On Tue, Jul 24, 2012 at 12:42:20AM +0800, riegamaths@gmail.com wrote:
> From: Dunrong Huang <riegamaths@gmail.com>
> 
> We check whether the variable machine is NULL or not before accessing
> it. If machine is NULL, exit QEMU with an error, this can avoids a
> segfault error.
> 
> Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
> ---
>  vl.c |   10 +++++-----
>  1 files changed, 5 insertions(+), 5 deletions(-)

Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches

Stefan

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

end of thread, other threads:[~2012-08-09  8:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-23 16:42 [Qemu-devel] [PATCH] vl.c: Exit QEMU early if no machine is found riegamaths
2012-08-09  8:00 ` Markus Armbruster
2012-08-09  8:19 ` Stefan Hajnoczi

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).