yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-gluster-Correctly-propagate-errors-when-volume-isn-t.patch

9ae3a8
From 22e47c104ff73885357a0be7b94270f3955427ea Mon Sep 17 00:00:00 2001
9ae3a8
From: Jeffrey Cody <jcody@redhat.com>
9ae3a8
Date: Tue, 17 Jan 2017 19:51:31 +0100
9ae3a8
Subject: [PATCH 2/3] gluster: Correctly propagate errors when volume isn't
9ae3a8
 accessible
9ae3a8
9ae3a8
RH-Author: Jeffrey Cody <jcody@redhat.com>
9ae3a8
Message-id: <963a714d4eae919df79e2031e02c77af5a8697e2.1484682588.git.jcody@redhat.com>
9ae3a8
Patchwork-id: 73256
9ae3a8
O-Subject: [RHEL-7.4 qemu-kvm 2/3] gluster: Correctly propagate errors when volume isn't accessible
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: Peter Krempa <pkrempa@redhat.com>
9ae3a8
9ae3a8
The docs for glfs_init suggest that the function sets errno on every
9ae3a8
failure. In fact it doesn't. As other functions such as
9ae3a8
qemu_gluster_open() in the gluster block code report their errors based
9ae3a8
on this fact we need to make sure that errno is set on each failure.
9ae3a8
9ae3a8
This fixes a crash of qemu-img/qemu when a gluster brick isn't
9ae3a8
accessible from given host while the server serving the volume
9ae3a8
description is.
9ae3a8
9ae3a8
Thread 1 (Thread 0x7ffff7fba740 (LWP 203880)):
9ae3a8
 #0  0x00007ffff77673f8 in glfs_lseek () from /usr/lib64/libgfapi.so.0
9ae3a8
 #1  0x0000555555574a68 in qemu_gluster_getlength ()
9ae3a8
 #2  0x0000555555565742 in refresh_total_sectors ()
9ae3a8
 #3  0x000055555556914f in bdrv_open_common ()
9ae3a8
 #4  0x000055555556e8e8 in bdrv_open ()
9ae3a8
 #5  0x000055555556f02f in bdrv_open_image ()
9ae3a8
 #6  0x000055555556e5f6 in bdrv_open ()
9ae3a8
 #7  0x00005555555c5775 in bdrv_new_open ()
9ae3a8
 #8  0x00005555555c5b91 in img_info ()
9ae3a8
 #9  0x00007ffff62c9c05 in __libc_start_main () from /lib64/libc.so.6
9ae3a8
 #10 0x00005555555648ad in _start ()
9ae3a8
9ae3a8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
(cherry picked from commit 4557117d9eed8cadc360aec23b42fc39a7011864)
9ae3a8
Signed-off-by: Jeff Cody <jcody@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 block/gluster.c | 7 ++++++-
9ae3a8
 1 file changed, 6 insertions(+), 1 deletion(-)
9ae3a8
9ae3a8
diff --git a/block/gluster.c b/block/gluster.c
9ae3a8
index 248a031..5266dce 100644
9ae3a8
--- a/block/gluster.c
9ae3a8
+++ b/block/gluster.c
9ae3a8
@@ -224,6 +224,11 @@ static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char *filename,
9ae3a8
                          "volume=%s image=%s transport=%s", gconf->server,
9ae3a8
                          gconf->port, gconf->volname, gconf->image,
9ae3a8
                          gconf->transport);
9ae3a8
+
9ae3a8
+        /* glfs_init sometimes doesn't set errno although docs suggest that */
9ae3a8
+        if (errno == 0)
9ae3a8
+            errno = EINVAL;
9ae3a8
+
9ae3a8
         goto out;
9ae3a8
     }
9ae3a8
     return glfs;
9ae3a8
@@ -484,7 +489,7 @@ static int qemu_gluster_create(const char *filename,
9ae3a8
 
9ae3a8
     glfs = qemu_gluster_init(gconf, filename, errp);
9ae3a8
     if (!glfs) {
9ae3a8
-        ret = -EINVAL;
9ae3a8
+        ret = -errno;
9ae3a8
         goto out;
9ae3a8
     }
9ae3a8
 
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8