All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jin Dongming <jin.dongming@np.css.fujitsu.com>
To: KVM list <kvm@vger.kernel.org>
Cc: Dean Nelson <dnelson@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	Avi Kivity <avi@redhat.com>, Huang Ying <ying.huang@intel.com>,
	Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: [PATCH 02/11] kvm, x86: introduce kvm_do_set_mce
Date: Thu, 14 Oct 2010 17:42:52 +0900	[thread overview]
Message-ID: <4CB6C28C.4050902@np.css.fujitsu.com> (raw)

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(-)

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


WARNING: multiple messages have this Message-ID (diff)
From: Jin Dongming <jin.dongming@np.css.fujitsu.com>
To: KVM list <kvm@vger.kernel.org>
Cc: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>,
	Dean Nelson <dnelson@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	Avi Kivity <avi@redhat.com>, Huang Ying <ying.huang@intel.com>
Subject: [Qemu-devel] [PATCH 02/11] kvm, x86: introduce kvm_do_set_mce
Date: Thu, 14 Oct 2010 17:42:52 +0900	[thread overview]
Message-ID: <4CB6C28C.4050902@np.css.fujitsu.com> (raw)

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(-)

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

             reply	other threads:[~2010-10-14  8:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-14  8:42 Jin Dongming [this message]
2010-10-14  8:42 ` [Qemu-devel] [PATCH 02/11] kvm, x86: introduce kvm_do_set_mce Jin Dongming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CB6C28C.4050902@np.css.fujitsu.com \
    --to=jin.dongming@np.css.fujitsu.com \
    --cc=avi@redhat.com \
    --cc=dnelson@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=seto.hidetoshi@jp.fujitsu.com \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.