7a3408
From 5c9c53f6c1a8223fdd65f2acb0f5db2cba0f6fd0 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <5c9c53f6c1a8223fdd65f2acb0f5db2cba0f6fd0@dist-git>
9119d9
From: Jiri Denemark <jdenemar@redhat.com>
9119d9
Date: Thu, 9 Oct 2014 10:38:39 +0200
9119d9
Subject: [PATCH] RHEL: Add support for QMP I/O error reason
9119d9
7a3408
RHEL-only
9119d9
9119d9
Adds support for __com.redhat_reason on I/O error events. The code will
9119d9
fallback to upstream nospace boolean if the reason is not present and
9119d9
complain if neither of these is found.
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1119784
9119d9
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/qemu/qemu_monitor_json.c | 12 +++++++++---
9119d9
 1 file changed, 9 insertions(+), 3 deletions(-)
9119d9
9119d9
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
7a3408
index fd567e4..065c7fe 100644
9119d9
--- a/src/qemu/qemu_monitor_json.c
9119d9
+++ b/src/qemu/qemu_monitor_json.c
7a3408
@@ -584,7 +584,7 @@ qemuMonitorJSONHandleIOError(qemuMonitorPtr mon, virJSONValuePtr data)
9119d9
 {
9119d9
     const char *device;
9119d9
     const char *action;
9119d9
-    const char *reason = "";
9119d9
+    const char *reason;
9119d9
     bool nospc = false;
9119d9
     int actionID;
9119d9
 
7a3408
@@ -600,8 +600,14 @@ qemuMonitorJSONHandleIOError(qemuMonitorPtr mon, virJSONValuePtr data)
7a3408
     if ((device = virJSONValueObjectGetString(data, "device")) == NULL)
9119d9
         VIR_WARN("missing device in disk io error event");
9119d9
 
9119d9
-    if (virJSONValueObjectGetBoolean(data, "nospace", &nospc) == 0 && nospc)
9119d9
-        reason = "enospc";
9119d9
+    reason = virJSONValueObjectGetString(data, "__com.redhat_reason");
9119d9
+    if (!reason) {
9119d9
+        if (virJSONValueObjectGetBoolean(data, "nospace", &nospc) != 0) {
9119d9
+            VIR_WARN("neither __com.redhat_reason nor nospace found in disk "
9119d9
+                     "io error event");
9119d9
+        }
9119d9
+        reason = nospc ? "enospc" : "";
9119d9
+    }
9119d9
 
9119d9
     if ((actionID = qemuMonitorIOErrorActionTypeFromString(action)) < 0) {
9119d9
         VIR_WARN("unknown disk io error action '%s'", action);
9119d9
-- 
7a3408
2.4.5
9119d9