|
|
9ae3a8 |
From 582eb6c9eef89809283e8d79b3f39e1ae9eeb64a Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Jeffrey Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 17 Jan 2017 19:51:30 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 1/3] gluster: correctly propagate errors
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Jeffrey Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
Message-id: <9299039bbb1797e4e61cdc8b4be062efeb152abb.1484682588.git.jcody@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 73254
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.4 qemu-kvm 1/3] gluster: correctly propagate errors
|
|
|
9ae3a8 |
Bugzilla: 1151859
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit a7451cb850d115f257080aff3fbc54f255ebf8f7)
|
|
|
9ae3a8 |
Signed-off-by: Jeff Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/gluster.c | 29 +++++++++++++++--------------
|
|
|
9ae3a8 |
1 file changed, 15 insertions(+), 14 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/gluster.c b/block/gluster.c
|
|
|
9ae3a8 |
index 1793386..248a031 100644
|
|
|
9ae3a8 |
--- a/block/gluster.c
|
|
|
9ae3a8 |
+++ b/block/gluster.c
|
|
|
9ae3a8 |
@@ -182,7 +182,8 @@ out:
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char *filename)
|
|
|
9ae3a8 |
+static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char *filename,
|
|
|
9ae3a8 |
+ Error **errp)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
struct glfs *glfs = NULL;
|
|
|
9ae3a8 |
int ret;
|
|
|
9ae3a8 |
@@ -190,8 +191,8 @@ static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char *filename)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
ret = qemu_gluster_parseuri(gconf, filename);
|
|
|
9ae3a8 |
if (ret < 0) {
|
|
|
9ae3a8 |
- error_report("Usage: file=gluster[+transport]://[server[:port]]/"
|
|
|
9ae3a8 |
- "volname/image[?socket=...]");
|
|
|
9ae3a8 |
+ error_setg(errp, "Usage: file=gluster[+transport]://[server[:port]]/"
|
|
|
9ae3a8 |
+ "volname/image[?socket=...]");
|
|
|
9ae3a8 |
errno = -ret;
|
|
|
9ae3a8 |
goto out;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -218,9 +219,11 @@ static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char *filename)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
ret = glfs_init(glfs);
|
|
|
9ae3a8 |
if (ret) {
|
|
|
9ae3a8 |
- error_report("Gluster connection failed for server=%s port=%d "
|
|
|
9ae3a8 |
- "volume=%s image=%s transport=%s", gconf->server, gconf->port,
|
|
|
9ae3a8 |
- gconf->volname, gconf->image, gconf->transport);
|
|
|
9ae3a8 |
+ error_setg_errno(errp, errno,
|
|
|
9ae3a8 |
+ "Gluster connection failed for server=%s port=%d "
|
|
|
9ae3a8 |
+ "volume=%s image=%s transport=%s", gconf->server,
|
|
|
9ae3a8 |
+ gconf->port, gconf->volname, gconf->image,
|
|
|
9ae3a8 |
+ gconf->transport);
|
|
|
9ae3a8 |
goto out;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
return glfs;
|
|
|
9ae3a8 |
@@ -328,17 +331,15 @@ static int qemu_gluster_open(BlockDriverState *bs, QDict *options,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
opts = qemu_opts_create_nofail(&runtime_opts);
|
|
|
9ae3a8 |
qemu_opts_absorb_qdict(opts, options, &local_err);
|
|
|
9ae3a8 |
- if (error_is_set(&local_err)) {
|
|
|
9ae3a8 |
- qerror_report_err(local_err);
|
|
|
9ae3a8 |
- error_free(local_err);
|
|
|
9ae3a8 |
+ if (local_err) {
|
|
|
9ae3a8 |
+ error_propagate(errp, local_err);
|
|
|
9ae3a8 |
ret = -EINVAL;
|
|
|
9ae3a8 |
goto out;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
filename = qemu_opt_get(opts, "filename");
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- s->glfs = qemu_gluster_init(gconf, filename);
|
|
|
9ae3a8 |
+ s->glfs = qemu_gluster_init(gconf, filename, errp);
|
|
|
9ae3a8 |
if (!s->glfs) {
|
|
|
9ae3a8 |
ret = -errno;
|
|
|
9ae3a8 |
goto out;
|
|
|
9ae3a8 |
@@ -406,7 +407,7 @@ static int qemu_gluster_reopen_prepare(BDRVReopenState *state,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
gconf = g_malloc0(sizeof(GlusterConf));
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- reop_s->glfs = qemu_gluster_init(gconf, state->bs->filename);
|
|
|
9ae3a8 |
+ reop_s->glfs = qemu_gluster_init(gconf, state->bs->filename, errp);
|
|
|
9ae3a8 |
if (reop_s->glfs == NULL) {
|
|
|
9ae3a8 |
ret = -errno;
|
|
|
9ae3a8 |
goto exit;
|
|
|
9ae3a8 |
@@ -481,9 +482,9 @@ static int qemu_gluster_create(const char *filename,
|
|
|
9ae3a8 |
int64_t total_size = 0;
|
|
|
9ae3a8 |
GlusterConf *gconf = g_malloc0(sizeof(GlusterConf));
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- glfs = qemu_gluster_init(gconf, filename);
|
|
|
9ae3a8 |
+ glfs = qemu_gluster_init(gconf, filename, errp);
|
|
|
9ae3a8 |
if (!glfs) {
|
|
|
9ae3a8 |
- ret = -errno;
|
|
|
9ae3a8 |
+ ret = -EINVAL;
|
|
|
9ae3a8 |
goto out;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|