Blame SOURCES/0018-qmp-add-__com.redhat_reason-to-the-BLOCK_IO_ERROR-ev.patch

76daa3
From 2f9487b60f700de33551208c543f5d3b4fa89236 Mon Sep 17 00:00:00 2001
76daa3
From: Luiz Capitulino <lcapitulino@redhat.com>
76daa3
Date: Wed, 15 Mar 2017 13:25:17 +0100
76daa3
Subject: qmp: add __com.redhat_reason to the BLOCK_IO_ERROR event
76daa3
76daa3
Patchwork-id: 64969
76daa3
O-Subject: [RHEL7.2 qemu-kvm-rhev PATCH 1/2] qmp: add error reason to the BLOCK_IO_ERROR event
76daa3
Bugzilla: 1199174
76daa3
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
76daa3
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
76daa3
RH-Acked-by: Eric Blake <eblake@redhat.com>
76daa3
76daa3
This commit forward ports the following RHEL-7.0 commit to RHEL-7.2:
76daa3
76daa3
  commit 771a3a333eb0c9299a69a78ddb9c4181850b827d
76daa3
  Author: Laszlo Ersek <lersek@redhat.com>
76daa3
  Date:   Thu Nov 21 16:27:18 2013 +0100
76daa3
76daa3
  error reason in BLOCK_IO_ERROR / BLOCK_JOB_ERROR events (RHEL 6->7 fwd)
76daa3
76daa3
I had to redo the work because now events use the QAPI, but it
76daa3
was straightforward.
76daa3
76daa3
There's one significant difference though: this commit does not
76daa3
extend the BLOCK_JOB_ERROR event as did the RHEL-7.0 commit. The
76daa3
reason is that this extension was supposed to be used only by vdsm
76daa3
and I don't think there's a requirement to have the extension
76daa3
in BLOCK_JOB_ERROR too. Let's not spread it.
76daa3
76daa3
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
76daa3
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
76daa3
(cherry picked from commit 75f90eaead001dfd1b529695bf6b99daeb62b78c)
76daa3
76daa3
Rebase notes (2.9.0):
76daa3
- moved documentation to schema
76daa3
76daa3
(cherry picked from commit d54503313357e3b24bd465e62deaa26178b4296c)
76daa3
---
76daa3
 block/block-backend.c | 27 +++++++++++++++++++++++----
76daa3
 qapi/block-core.json  | 17 ++++++++++++++++-
76daa3
 2 files changed, 39 insertions(+), 5 deletions(-)
76daa3
76daa3
diff --git a/block/block-backend.c b/block/block-backend.c
76daa3
index 7405024..dd131cf 100644
76daa3
--- a/block/block-backend.c
76daa3
+++ b/block/block-backend.c
76daa3
@@ -1422,9 +1422,25 @@ BlockErrorAction blk_get_error_action(BlockBackend *blk, bool is_read,
76daa3
     }
76daa3
 }
76daa3
 
76daa3
+/* https://bugzilla.redhat.com/show_bug.cgi?id=1199174 */
76daa3
+static RHEL7BlockErrorReason get_rhel7_error_reason(int error)
76daa3
+{
76daa3
+	switch (error) {
76daa3
+	case ENOSPC:
76daa3
+        return RHEL7_BLOCK_ERROR_REASON_ENOSPC;
76daa3
+	case EPERM:
76daa3
+        return RHEL7_BLOCK_ERROR_REASON_EPERM;
76daa3
+	case EIO:
76daa3
+        return RHEL7_BLOCK_ERROR_REASON_EIO;
76daa3
+	default:
76daa3
+        return RHEL7_BLOCK_ERROR_REASON_EOTHER;
76daa3
+    }
76daa3
+}
76daa3
+
76daa3
 static void send_qmp_error_event(BlockBackend *blk,
76daa3
                                  BlockErrorAction action,
76daa3
-                                 bool is_read, int error)
76daa3
+                                 bool is_read, int error,
76daa3
+                                 RHEL7BlockErrorReason res)
76daa3
 {
76daa3
     IoOperationType optype;
76daa3
 
76daa3
@@ -1433,7 +1449,7 @@ static void send_qmp_error_event(BlockBackend *blk,
76daa3
                                    bdrv_get_node_name(blk_bs(blk)), optype,
76daa3
                                    action, blk_iostatus_is_enabled(blk),
76daa3
                                    error == ENOSPC, strerror(error),
76daa3
-                                   &error_abort);
76daa3
+                                   res, &error_abort);
76daa3
 }
76daa3
 
76daa3
 /* This is done by device models because, while the block layer knows
76daa3
@@ -1443,7 +1459,10 @@ static void send_qmp_error_event(BlockBackend *blk,
76daa3
 void blk_error_action(BlockBackend *blk, BlockErrorAction action,
76daa3
                       bool is_read, int error)
76daa3
 {
76daa3
+    RHEL7BlockErrorReason res;
76daa3
+
76daa3
     assert(error >= 0);
76daa3
+    res = get_rhel7_error_reason(error);
76daa3
 
76daa3
     if (action == BLOCK_ERROR_ACTION_STOP) {
76daa3
         /* First set the iostatus, so that "info block" returns an iostatus
76daa3
@@ -1461,10 +1480,10 @@ void blk_error_action(BlockBackend *blk, BlockErrorAction action,
76daa3
          * also ensures that the STOP/RESUME pair of events is emitted.
76daa3
          */
76daa3
         qemu_system_vmstop_request_prepare();
76daa3
-        send_qmp_error_event(blk, action, is_read, error);
76daa3
+        send_qmp_error_event(blk, action, is_read, error, res);
76daa3
         qemu_system_vmstop_request(RUN_STATE_IO_ERROR);
76daa3
     } else {
76daa3
-        send_qmp_error_event(blk, action, is_read, error);
76daa3
+        send_qmp_error_event(blk, action, is_read, error, res);
76daa3
     }
76daa3
 }
76daa3
 
76daa3
diff --git a/qapi/block-core.json b/qapi/block-core.json
76daa3
index 033457c..68ad316 100644
76daa3
--- a/qapi/block-core.json
76daa3
+++ b/qapi/block-core.json
76daa3
@@ -3351,6 +3351,19 @@
76daa3
             'fatal'      : 'bool' } }
76daa3
 
76daa3
 ##
76daa3
+# @RHEL7BlockErrorReason:
76daa3
+#
76daa3
+# Block I/O error reason
76daa3
+#
76daa3
+# @eio:  errno EIO
76daa3
+# @eperm: errno EPERM
76daa3
+# @enospc: errno ENOSPC
76daa3
+# @eother: any errno other than EIO, EPERM, ENOSPC
76daa3
+##
76daa3
+{ 'enum': 'RHEL7BlockErrorReason',
76daa3
+  'data': [ 'enospc', 'eperm', 'eio', 'eother' ] }
76daa3
+
76daa3
+##
76daa3
 # @BLOCK_IO_ERROR:
76daa3
 #
76daa3
 # Emitted when a disk I/O error occurs
76daa3
@@ -3376,6 +3389,8 @@
76daa3
 #          (This field is a debugging aid for humans, it should not
76daa3
 #           be parsed by applications) (since: 2.2)
76daa3
 #
76daa3
+# @__com.redhat_reason: error reason
76daa3
+#
76daa3
 # Note: If action is "stop", a STOP event will eventually follow the
76daa3
 # BLOCK_IO_ERROR event
76daa3
 #
76daa3
@@ -3394,7 +3409,7 @@
76daa3
 { 'event': 'BLOCK_IO_ERROR',
76daa3
   'data': { 'device': 'str', 'node-name': 'str', 'operation': 'IoOperationType',
76daa3
             'action': 'BlockErrorAction', '*nospace': 'bool',
76daa3
-            'reason': 'str' } }
76daa3
+            'reason': 'str', '__com.redhat_reason': 'RHEL7BlockErrorReason' } }
76daa3
 
76daa3
 ##
76daa3
 # @BLOCK_JOB_COMPLETED:
76daa3
-- 
76daa3
1.8.3.1
76daa3