Blame SOURCES/kvm-blockjob-expose-error-string-via-query.patch

1bdc94
From 08fa409a1ec90e383103a12f3d06205ef5941062 Mon Sep 17 00:00:00 2001
1bdc94
From: Kevin Wolf <kwolf@redhat.com>
1bdc94
Date: Tue, 26 Jun 2018 09:47:50 +0200
1bdc94
Subject: [PATCH 21/89] blockjob: expose error string via query
1bdc94
1bdc94
RH-Author: Kevin Wolf <kwolf@redhat.com>
1bdc94
Message-id: <20180626094856.6924-8-kwolf@redhat.com>
1bdc94
Patchwork-id: 81059
1bdc94
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 07/73] blockjob: expose error string via query
1bdc94
Bugzilla: 1513543
1bdc94
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
1bdc94
RH-Acked-by: Max Reitz <mreitz@redhat.com>
1bdc94
RH-Acked-by: Fam Zheng <famz@redhat.com>
1bdc94
1bdc94
From: John Snow <jsnow@redhat.com>
1bdc94
1bdc94
When we've reached the concluded state, we need to expose the error
1bdc94
state if applicable. Add the new field.
1bdc94
1bdc94
This should be sufficient for determining if a job completed
1bdc94
successfully or not after concluding; if we want to discriminate
1bdc94
based on how it failed more mechanically, we can always add an
1bdc94
explicit return code enumeration later.
1bdc94
1bdc94
I didn't bother to make it only show up if we are in the concluded
1bdc94
state; I don't think it's necessary.
1bdc94
1bdc94
Cc: qemu-stable@nongnu.org
1bdc94
Signed-off-by: John Snow <jsnow@redhat.com>
1bdc94
Reviewed-by: Eric Blake <eblake@redhat.com>
1bdc94
Reviewed-by: Alberto Garcia <berto@igalia.com>
1bdc94
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1bdc94
(cherry picked from commit ab9ba614556ac5b0f8d96b99e0dba19f1e28d6c2)
1bdc94
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1bdc94
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
---
1bdc94
 blockjob.c           | 2 ++
1bdc94
 qapi/block-core.json | 6 +++++-
1bdc94
 2 files changed, 7 insertions(+), 1 deletion(-)
1bdc94
1bdc94
diff --git a/blockjob.c b/blockjob.c
1bdc94
index b39d0f8..6746cad 100644
1bdc94
--- a/blockjob.c
1bdc94
+++ b/blockjob.c
1bdc94
@@ -839,6 +839,8 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **errp)
1bdc94
     info->status    = job->status;
1bdc94
     info->auto_finalize = job->auto_finalize;
1bdc94
     info->auto_dismiss  = job->auto_dismiss;
1bdc94
+    info->has_error = job->ret != 0;
1bdc94
+    info->error     = job->ret ? g_strdup(strerror(-job->ret)) : NULL;
1bdc94
     return info;
1bdc94
 }
1bdc94
 
1bdc94
diff --git a/qapi/block-core.json b/qapi/block-core.json
1bdc94
index 5aac0c7..9012d00 100644
1bdc94
--- a/qapi/block-core.json
1bdc94
+++ b/qapi/block-core.json
1bdc94
@@ -1172,6 +1172,9 @@
1bdc94
 # @auto-dismiss: Job will dismiss itself when CONCLUDED, moving to the NULL
1bdc94
 #                state and disappearing from the query list. (since 2.12)
1bdc94
 #
1bdc94
+# @error: Error information if the job did not complete successfully.
1bdc94
+#         Not set if the job completed successfully. (since 2.12.1)
1bdc94
+#
1bdc94
 # Since: 1.1
1bdc94
 ##
1bdc94
 { 'struct': 'BlockJobInfo',
1bdc94
@@ -1179,7 +1182,8 @@
1bdc94
            'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'int',
1bdc94
            'io-status': 'BlockDeviceIoStatus', 'ready': 'bool',
1bdc94
            'status': 'BlockJobStatus',
1bdc94
-           'auto-finalize': 'bool', 'auto-dismiss': 'bool' } }
1bdc94
+           'auto-finalize': 'bool', 'auto-dismiss': 'bool',
1bdc94
+           '*error': 'str' } }
1bdc94
 
1bdc94
 ##
1bdc94
 # @query-block-jobs:
1bdc94
-- 
1bdc94
1.8.3.1
1bdc94