summaryrefslogtreecommitdiffstats
path: root/block.c
diff options
context:
space:
mode:
authorChristoph Hellwig2010-06-23 12:25:17 +0200
committerKevin Wolf2010-07-02 13:18:01 +0200
commit39508e7adb0de3ef69caa1b494d823d8ac11d3f3 (patch)
treedfa21d828a7e8ea6c0b0af55a4c9013b4a120992 /block.c
parentqcow2: Fix error handling during metadata preallocation (diff)
downloadqemu-39508e7adb0de3ef69caa1b494d823d8ac11d3f3.tar.gz
qemu-39508e7adb0de3ef69caa1b494d823d8ac11d3f3.tar.xz
qemu-39508e7adb0de3ef69caa1b494d823d8ac11d3f3.zip
block: allow filenames with colons again for host devices
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 <hch@lst.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/block.c b/block.c
index e71a771e06..0aaec3bf35 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)