Patchwork [v2,10/24] kvm: Handle kvm_init_vcpu errors

login
register
mail settings
Submitter Jan Kiszka
Date Feb. 1, 2011, 9:15 p.m.
Message ID <32347af81fedcc230f482384f517a31aef73bad4.1296594961.git.jan.kiszka@web.de>
Download mbox | patch
Permalink /patch/81392/
State New
Headers show

Comments

Jan Kiszka - Feb. 1, 2011, 9:15 p.m.
From: Jan Kiszka <jan.kiszka@siemens.com>

Do not ignore errors of kvm_init_vcpu, they are fatal.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 cpus.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

Patch

diff --git a/cpus.c b/cpus.c
index 312c7a2..8475757 100644
--- a/cpus.c
+++ b/cpus.c
@@ -273,12 +273,18 @@  void qemu_main_loop_start(void)
 void qemu_init_vcpu(void *_env)
 {
     CPUState *env = _env;
+    int r;
 
     env->nr_cores = smp_cores;
     env->nr_threads = smp_threads;
-    if (kvm_enabled())
-        kvm_init_vcpu(env);
-    return;
+
+    if (kvm_enabled()) {
+        r = kvm_init_vcpu(env);
+        if (r < 0) {
+            fprintf(stderr, "kvm_init_vcpu failed: %s\n", strerror(-r));
+            exit(1);
+        }
+    }
 }
 
 int qemu_cpu_self(void *env)
@@ -604,11 +610,16 @@  static int qemu_cpu_exec(CPUState *env);
 static void *kvm_cpu_thread_fn(void *arg)
 {
     CPUState *env = arg;
+    int r;
 
     qemu_mutex_lock(&qemu_global_mutex);
     qemu_thread_self(env->thread);
 
-    kvm_init_vcpu(env);
+    r = kvm_init_vcpu(env);
+    if (r < 0) {
+        fprintf(stderr, "kvm_init_vcpu failed: %s\n", strerror(-r));
+        exit(1);
+    }
 
     kvm_init_ipi(env);