1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

Do not crash on gluster snapshots with no host name

virStorageFileBackendGlusterInit did not check nhosts.

https://bugzilla.redhat.com/show_bug.cgi?id=1162974
(cherry picked from commit b66288faaba68e22a2876029872ddadf1794bda8)
This commit is contained in:
Ján Tomko 2014-11-12 09:34:28 +01:00 committed by Cole Robinson
parent 1aeac2af00
commit 40f8708e9a

View File

@ -571,9 +571,17 @@ virStorageFileBackendGlusterInit(virStorageSourcePtr src)
{ {
virStorageFileBackendGlusterPrivPtr priv = NULL; virStorageFileBackendGlusterPrivPtr priv = NULL;
virStorageNetHostDefPtr host = &(src->hosts[0]); virStorageNetHostDefPtr host = &(src->hosts[0]);
const char *hostname = host->name; const char *hostname;
int port = 0; int port = 0;
if (src->nhosts != 1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Expected exactly 1 host for the gluster volume"));
return -1;
}
hostname = host->name;
VIR_DEBUG("initializing gluster storage file %p (gluster://%s:%s/%s%s)", VIR_DEBUG("initializing gluster storage file %p (gluster://%s:%s/%s%s)",
src, hostname, host->port ? host->port : "0", src, hostname, host->port ? host->port : "0",
NULLSTR(src->volume), src->path); NULLSTR(src->volume), src->path);