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