qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: riegamaths@gmail.com
To: qemu-devel <qemu-devel@nongnu.org>
Cc: "Anthony Liguori" <aliguori@us.ibm.com>,
	"Stefan Hajnoczi" <stefanha@linux.vnet.ibm.com>,
	"Dunrong Huang" <riegamaths@gmail.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH] vl.c: Exit QEMU early if no machine is found
Date: Tue, 24 Jul 2012 00:42:20 +0800	[thread overview]
Message-ID: <1343061740-14870-1-git-send-email-riegamaths@gmail.com> (raw)

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

             reply	other threads:[~2012-07-23 16:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-23 16:42 riegamaths [this message]
2012-08-09  8:00 ` [Qemu-devel] [PATCH] vl.c: Exit QEMU early if no machine is found Markus Armbruster
2012-08-09  8:19 ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343061740-14870-1-git-send-email-riegamaths@gmail.com \
    --to=riegamaths@gmail.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).