Received: from eggs.gnu.org ([2001:4830:134:3::10]:55625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFOV2-0000gy-0z for qemu-devel@nongnu.org; Mon, 17 Feb 2014 08:44:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFOUs-0000we-9Y for qemu-devel@nongnu.org; Mon, 17 Feb 2014 08:44:43 -0500 Received: from mail-qc0-x229.google.com ([2607:f8b0:400d:c01::229]:54311) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFOUs-0000vq-5C for qemu-devel@nongnu.org; Mon, 17 Feb 2014 08:44:34 -0500 Received: by mail-qc0-f169.google.com with SMTP id w7so23873797qcr.28 for ; Mon, 17 Feb 2014 05:44:33 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 17 Feb 2014 14:43:54 +0100 Message-Id: <1392644647-9897-8-git-send-email-pbonzini@redhat.com> In-Reply-To: <1392644647-9897-1-git-send-email-pbonzini@redhat.com> References: <1392644647-9897-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v3 07/20] gluster: default scheme to gluster:// and host to localhost. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, jcody@redhat.com, famz@redhat.com, stefanha@redhat.com Currently, "gluster:///volname/img" and (using file. options) "file.driver=gluster,file.filename=foo" will segfault. Also, "//host/volname/img" will be rejected, but it is a valid URL that should be accepted just fine with "file.driver=gluster". Accept all of these, by inferring missing transport and host as TCP and localhost respectively. Signed-off-by: Paolo Bonzini --- block/gluster.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/gluster.c b/block/gluster.c index a009b15..f9dd37f 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -127,7 +127,7 @@ static int qemu_gluster_parseuri(GlusterConf *gconf, const char *filename) } /* transport */ - if (!strcmp(uri->scheme, "gluster")) { + if (!uri->scheme || !strcmp(uri->scheme, "gluster")) { gconf->transport = g_strdup("tcp"); } else if (!strcmp(uri->scheme, "gluster+tcp")) { gconf->transport = g_strdup("tcp"); @@ -163,7 +163,7 @@ static int qemu_gluster_parseuri(GlusterConf *gconf, const char *filename) } gconf->server = g_strdup(qp->p[0].value); } else { - gconf->server = g_strdup(uri->server); + gconf->server = g_strdup(uri->server ? uri->server : "localhost"); gconf->port = uri->port; } -- 1.8.5.3