yeahuh / rpms / qemu-kvm

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