From patchwork Fri Jul 2 16:38:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 57673 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5BF0E1007DC for ; Sat, 3 Jul 2010 02:40:38 +1000 (EST) Received: from localhost ([127.0.0.1]:55554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OUjI3-0004Fv-81 for incoming@patchwork.ozlabs.org; Fri, 02 Jul 2010 12:40:35 -0400 Received: from [140.186.70.92] (port=40742 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OUjGL-00045w-HX for qemu-devel@nongnu.org; Fri, 02 Jul 2010 12:38:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OUjGI-0001U4-78 for qemu-devel@nongnu.org; Fri, 02 Jul 2010 12:38:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43103) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OUjGH-0001TM-WE for qemu-devel@nongnu.org; Fri, 02 Jul 2010 12:38:46 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o62Gchgr013652 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 2 Jul 2010 12:38:43 -0400 Received: from localhost.localdomain (vpn2-11-67.ams2.redhat.com [10.36.11.67]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o62GcbbA023884; Fri, 2 Jul 2010 12:38:42 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Fri, 2 Jul 2010 18:38:11 +0200 Message-Id: <1278088712-12302-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1278088712-12302-1-git-send-email-kwolf@redhat.com> References: <1278088712-12302-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 02/23] block: allow filenames with colons again for host devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Christoph Hellwig Before the raw/file split we used to allow filenames with colons for host device only. While this was more by accident than by design people rely on it, so we need to bring it back. So move the host device probing to be before the protocol detection again. Signed-off-by: Christoph Hellwig Signed-off-by: Kevin Wolf --- block.c | 29 ++++++++++++++++++----------- 1 files changed, 18 insertions(+), 11 deletions(-) diff --git a/block.c b/block.c index e71a771..0aaec3b 100644 --- a/block.c +++ b/block.c @@ -288,23 +288,30 @@ BlockDriver *bdrv_find_protocol(const char *filename) char protocol[128]; int len; const char *p; - int is_drive; /* TODO Drivers without bdrv_file_open must be specified explicitly */ + /* + * XXX(hch): we really should not let host device detection + * override an explicit protocol specification, but moving this + * later breaks access to device names with colons in them. + * Thanks to the brain-dead persistent naming schemes on udev- + * based Linux systems those actually are quite common. + */ + drv1 = find_hdev_driver(filename); + if (drv1) { + return drv1; + } + #ifdef _WIN32 - is_drive = is_windows_drive(filename) || - is_windows_drive_prefix(filename); -#else - is_drive = 0; + if (is_windows_drive(filename) || + is_windows_drive_prefix(filename)) + return bdrv_find_format("file"); #endif + p = strchr(filename, ':'); - if (!p || is_drive) { - drv1 = find_hdev_driver(filename); - if (!drv1) { - drv1 = bdrv_find_format("file"); - } - return drv1; + if (!p) { + return bdrv_find_format("file"); } len = p - filename; if (len > sizeof(protocol) - 1)