Patchwork [08/18] kvm: Handle kvm_init_vcpu errors

login
register
mail settings
Submitter Jan Kiszka
Date Jan. 10, 2011, 8:32 a.m.
Message ID <740eaec778a1336c041f7eefe2d2dd6a40525e9e.1294648329.git.jan.kiszka@web.de>
Download mbox | patch
Permalink /patch/78087/
State New
Headers show

Comments

Jan Kiszka - Jan. 10, 2011, 8:32 a.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 |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

Patch

diff --git a/cpus.c b/cpus.c
index b6f1cfb..33b604e 100644
--- a/cpus.c
+++ b/cpus.c
@@ -412,14 +412,19 @@  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);
+        r = kvm_init_vcpu(env);
+        if (r < 0) {
+            fprintf(stderr, "kvm_init_vcpu failed: %s\n", strerror(r));
+            exit(1);
+        }
         qemu_kvm_init_cpu_signals(env);
     }
-    return;
 }
 
 int qemu_cpu_self(void *env)
@@ -710,11 +715,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);
+    }
     qemu_kvm_init_cpu_signals(env);
 
     /* signal CPU creation */