]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: storage: Properly parse URIs with missing trailing slash
authorPeter Krempa <pkrempa@redhat.com>
Thu, 11 Oct 2018 10:22:21 +0000 (12:22 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 12 Oct 2018 14:41:48 +0000 (16:41 +0200)
commit6e7e965dcd3d885739129b1454ce19e819b54c25
tree39f2292ec563d37c7c8be0bfc383a0990d04a734
parent4471f7704c5425831a2933ae379bd87242961fb0
util: storage: Properly parse URIs with missing trailing slash

The URI parser used by libvirt does not populate uri->path if the
trailing slash is missing. The code virStorageSourceParseBackingURI
would then not populate src->path.

As only NBD network disks are allowed to have the 'name' field in the
XML defining the disk source omitted we'd generate an invalid XML which
we'd not parse again.

Fix it by populating src->path with an empty string if the uri is
lacking slash.

As pointed out above NBD is special in this case since we actually allow
it being NULL. The URI path is used as export name. Since an empty
export does not make sense the new approach clears the src->path if the
trailing slash is present but nothing else.

Add test cases now to cover all the various cases for NBD and non-NBD
uris as there was to time only 1 test abusing the quirk witout slash for
NBD and all other URIs contained the slash or in case of NBD also the
export name.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
src/util/virstoragefile.c
tests/qemublocktest.c
tests/virstoragetest.c