51d9a2
From 12912db55da81fff50119b780b151a0fc864d878 Mon Sep 17 00:00:00 2001
51d9a2
Message-Id: <12912db55da81fff50119b780b151a0fc864d878@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
51d9a2
index ec8469476e..1bc5b662ae 100644
9119d9
--- a/src/qemu/qemu_monitor_json.c
9119d9
+++ b/src/qemu/qemu_monitor_json.c
51d9a2
@@ -740,7 +740,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
 
51d9a2
@@ -756,8 +756,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
-- 
51d9a2
2.18.0
9119d9