render / rpms / libvirt

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