yeahuh / rpms / qemu-kvm

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