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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Share the same error handling.

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

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
 
-- 
1.7.1.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux