Skip to content

Commit

Permalink
gluster: Correctly propagate errors when volume isn't accessible
Browse files Browse the repository at this point in the history
The docs for glfs_init suggest that the function sets errno on every
failure. In fact it doesn't. As other functions such as
qemu_gluster_open() in the gluster block code report their errors based
on this fact we need to make sure that errno is set on each failure.

This fixes a crash of qemu-img/qemu when a gluster brick isn't
accessible from given host while the server serving the volume
description is.

Thread 1 (Thread 0x7ffff7fba740 (LWP 203880)):
 #0  0x00007ffff77673f8 in glfs_lseek () from /usr/lib64/libgfapi.so.0
 Torlus#1  0x0000555555574a68 in qemu_gluster_getlength ()
 Torlus#2  0x0000555555565742 in refresh_total_sectors ()
 Torlus#3  0x000055555556914f in bdrv_open_common ()
 Torlus#4  0x000055555556e8e8 in bdrv_open ()
 Torlus#5  0x000055555556f02f in bdrv_open_image ()
 Torlus#6  0x000055555556e5f6 in bdrv_open ()
 Torlus#7  0x00005555555c5775 in bdrv_new_open ()
 Torlus#8  0x00005555555c5b91 in img_info ()
 qemu#9  0x00007ffff62c9c05 in __libc_start_main () from /lib64/libc.so.6
 qemu#10 0x00005555555648ad in _start ()

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
pipo authored and stefanhaRH committed May 9, 2014
1 parent 02ce232 commit 4557117
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion block/gluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char *filename,
"volume=%s image=%s transport=%s", gconf->server,
gconf->port, gconf->volname, gconf->image,
gconf->transport);

/* glfs_init sometimes doesn't set errno although docs suggest that */
if (errno == 0)
errno = EINVAL;

goto out;
}
return glfs;
Expand Down Expand Up @@ -482,7 +487,7 @@ static int qemu_gluster_create(const char *filename,

glfs = qemu_gluster_init(gconf, filename, errp);
if (!glfs) {
ret = -EINVAL;
ret = -errno;
goto out;
}

Expand Down

0 comments on commit 4557117

Please sign in to comment.