Patchwork [02/11] kvm, x86: introduce kvm_do_set_mce

login
register
mail settings
Submitter Jin Dongming
Date Oct. 14, 2010, 8:42 a.m.
Message ID <4CB6C28C.4050902@np.css.fujitsu.com>
Download mbox | patch
Permalink /patch/67793/
State New
Headers show

Comments

Jin Dongming - Oct. 14, 2010, 8:42 a.m.
Share the same error handling.

Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Tested-by: Jin Dongming <jin.dongming@np.css.fujitsu.com>
---
 qemu-kvm.c |   31 +++++++++++++++++++------------
 1 files changed, 19 insertions(+), 12 deletions(-)

Patch

diff --git a/qemu-kvm.c b/qemu-kvm.c
index 6f62973..1338e99 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -1130,6 +1130,22 @@  static void sigbus_reraise(void)
     abort();
 }
 
+#if defined(KVM_CAP_MCE) && defined(TARGET_I386)
+static void kvm_do_set_mce(CPUState *env, struct kvm_x86_mce *mce,
+                           int abort_on_error)
+{
+    int r;
+
+    r = kvm_set_mce(env, mce);
+    if (r < 0) {
+        perror("kvm_set_mce FAILED");
+        if (abort_on_error) {
+            abort();
+        }
+    }
+}
+#endif
+
 static void sigbus_handler(int n, struct qemu_signalfd_siginfo *siginfo,
                            void *ctx)
 {
@@ -1365,11 +1381,7 @@  static void kvm_on_sigbus(CPUState *env, siginfo_t *siginfo)
             }
         }
         mce.addr = paddr;
-        r = kvm_set_mce(env, &mce);
-        if (r < 0) {
-            fprintf(stderr, "kvm_set_mce: %s\n", strerror(errno));
-            abort();
-        }
+        kvm_do_set_mce(env, &mce, 1);
     } else
 #endif
     {
@@ -1913,13 +1925,8 @@  static void kvm_do_inject_x86_mce(void *_data)
             return;
         }
     }
-    r = kvm_set_mce(data->env, data->mce);
-    if (r < 0) {
-        perror("kvm_set_mce FAILED");
-        if (data->abort_on_error) {
-            abort();
-        }
-    }
+
+    kvm_do_set_mce(data->env, data->mce, data->abort_on_error);
 }
 #endif