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