From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49116) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDGky-00076c-M3 for qemu-devel@nongnu.org; Tue, 11 Feb 2014 12:04:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDGkq-0008Dw-5L for qemu-devel@nongnu.org; Tue, 11 Feb 2014 12:04:24 -0500 Received: from mail-qc0-x22d.google.com ([2607:f8b0:400d:c01::22d]:64936) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDGkp-0008DZ-Qg for qemu-devel@nongnu.org; Tue, 11 Feb 2014 12:04:15 -0500 Received: by mail-qc0-f173.google.com with SMTP id i8so13396123qcq.18 for ; Tue, 11 Feb 2014 09:04:15 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 11 Feb 2014 18:03:40 +0100 Message-Id: <1392138233-26407-8-git-send-email-pbonzini@redhat.com> In-Reply-To: <1392138233-26407-1-git-send-email-pbonzini@redhat.com> References: <1392138233-26407-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v2 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, famz@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