Share the same error handling.
Signed-off-by: Hidetoshi Seto <[email protected]>
Tested-by: Jin Dongming <[email protected]>
---
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html