[libvirt] [PATCH] storage: recognize gluster as networked file

A qcow2 file with a backing file of 'gluster://host/vol/file' should not try to look for a directory named './gluster:/' in the file system. * src/util/virstoragefile.c (virBackingStoreIsFile): Broaden check to include all protocols. Signed-off-by: Eric Blake <eblake@redhat.com> --- This one will be important to my work on gluster backing chains, but can be reviewed and applied independently now. src/util/virstoragefile.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 1b4d4cf..8f04b78 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -671,8 +671,13 @@ virStorageFileMatchesVersion(int format, static bool virBackingStoreIsFile(const char *backing) { - /* Backing store is a network block device or Rados block device */ - if (STRPREFIX(backing, "nbd:") || STRPREFIX(backing, "rbd:")) + char *colon = strchr(backing, ':'); + char *slash = strchr(backing, '/'); + + /* Reject anything that looks like a protocol (such as nbd: or + * rbd:); if someone really does want a relative file name that + * includes ':', they can always prefix './'. */ + if (colon && (!slash || colon < slash)) return false; return true; } -- 1.8.3.1

On Mon, Nov 04, 2013 at 02:30:50PM -0700, Eric Blake wrote:
A qcow2 file with a backing file of 'gluster://host/vol/file' should not try to look for a directory named './gluster:/' in the file system.
* src/util/virstoragefile.c (virBackingStoreIsFile): Broaden check to include all protocols.
Signed-off-by: Eric Blake <eblake@redhat.com> ---
This one will be important to my work on gluster backing chains, but can be reviewed and applied independently now.
src/util/virstoragefile.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 1b4d4cf..8f04b78 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -671,8 +671,13 @@ virStorageFileMatchesVersion(int format, static bool virBackingStoreIsFile(const char *backing) { - /* Backing store is a network block device or Rados block device */ - if (STRPREFIX(backing, "nbd:") || STRPREFIX(backing, "rbd:")) + char *colon = strchr(backing, ':'); + char *slash = strchr(backing, '/'); + + /* Reject anything that looks like a protocol (such as nbd: or + * rbd:); if someone really does want a relative file name that + * includes ':', they can always prefix './'. */
This makes complete sense, I just can't figure out how qemu treats this because when I tried it on upstream now, it ended up with a segfault :)
+ if (colon && (!slash || colon < slash)) return false; return true; }
Anyway, ACK. Martin

On 11/05/2013 01:13 AM, Martin Kletzander wrote:
On Mon, Nov 04, 2013 at 02:30:50PM -0700, Eric Blake wrote:
A qcow2 file with a backing file of 'gluster://host/vol/file' should not try to look for a directory named './gluster:/' in the file system.
* src/util/virstoragefile.c (virBackingStoreIsFile): Broaden check to include all protocols.
Signed-off-by: Eric Blake <eblake@redhat.com> ---
+ /* Reject anything that looks like a protocol (such as nbd: or + * rbd:); if someone really does want a relative file name that + * includes ':', they can always prefix './'. */
This makes complete sense, I just can't figure out how qemu treats this because when I tried it on upstream now, it ended up with a segfault :)
A qemu segfault? Can you post the reproduction recipe?
+ if (colon && (!slash || colon < slash)) return false; return true; }
Anyway, ACK.
Thanks; pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Tue, Nov 05, 2013 at 08:42:08AM -0700, Eric Blake wrote:
On 11/05/2013 01:13 AM, Martin Kletzander wrote:
On Mon, Nov 04, 2013 at 02:30:50PM -0700, Eric Blake wrote:
A qcow2 file with a backing file of 'gluster://host/vol/file' should not try to look for a directory named './gluster:/' in the file system.
* src/util/virstoragefile.c (virBackingStoreIsFile): Broaden check to include all protocols.
Signed-off-by: Eric Blake <eblake@redhat.com> ---
+ /* Reject anything that looks like a protocol (such as nbd: or + * rbd:); if someone really does want a relative file name that + * includes ':', they can always prefix './'. */
This makes complete sense, I just can't figure out how qemu treats this because when I tried it on upstream now, it ended up with a segfault :)
A qemu segfault? Can you post the reproduction recipe?
I tried my first thing and it crashed. This is enough: qemu-img create -f qcow2 -o backing_file=gluster://test1.qcow2,backing_fmt=qcow2 test.qcow2 1M qemu-img convert -f qcow2 -O raw test.qcow2 output.img I just haven't had the time to check why and where it segfaults... Martin
participants (2)
-
Eric Blake
-
Martin Kletzander