Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > media > main-src > by-pkgid > aadbe78a25743146bb784eee19f007c5 > files > 99

kvm-83-164.el5_5.9.src.rpm

From fdcb2f5621ae79feee9c180f088106da62ddbfd5 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost@redhat.com>
Date: Fri, 6 Mar 2009 18:28:30 -0300
Subject: [PATCH 02/16] Don't try to extract protocol from absolute filenames

https://bugzilla.redhat.com/show_bug.cgi?id=483751

Patch submitted upstream some time ago, but I've got no real feedback. I would
like this to be fixed more properly upstream (by making the code clearer and
defining precisely the semantics of ":" on filenames everywhere), but for RHEV
we need a simpler and safer solution.

Original commit message below:

  This patch fixes this issue:

    $ qemu-img create -f qcow2 /tmp/a:b 1G
    $ qemu-system-x86_64 -hda /tmp/a:b
    qemu: could not open disk image /tmp/a:b
    $

  Based on a suggestion by Daniel Berrange.

  However, this is still just a workaround. The semantics of filenames
  containing colon characters (and how this can be escaped, avoided,
  or worked around) are not very clear.

  Going further, what if we stop using "protocol:filename" strings
  internally, except where the user interface or external data really
  requires this format?

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-ID: <20090306212830.GL5077@blackpad>
Message-Id: <1240260965-2564-1-git-send-email-ehabkost@redhat.com>
Bugzilla: 501729
RH-Upstream-status: submitted(qemu-devel)
Acked-by: Kevin Wolf <kwolf@redhat.com>
Acked-by: john cooper <john.cooper@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
---
 qemu/block.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/qemu/block.c b/qemu/block.c
index c847088..c50b636 100644
--- a/qemu/block.c
+++ b/qemu/block.c
@@ -307,6 +307,14 @@ static BlockDriver *find_protocol(const char *filename)
         is_windows_drive_prefix(filename))
         return &bdrv_raw;
 #endif
+
+    /* Protocol name will never start with a slash.
+     * This allows the user to specify absolute filenames
+     * containing a ":" character.
+     */
+    if (*filename == '/')
+        return &bdrv_raw;
+
     p = strchr(filename, ':');
     if (!p)
         return &bdrv_raw;
-- 
1.6.3.rc4.29.g8146