[libvirt] parsing url with percent sign when user want to use iso disk via http

I found a strange thing, when i specify url for iso in libvirt xml like: qemu gets invalid url in cmdline i think that problem is qemu/qemu_command.c:3430: ret = virURIFormat(uri); test string looks like https://alukardd.org/data/test?t=1 qemu gets url with percent urlencoded %3F , in this case http server get not test with param t=1 but filename test%3Ft=1 so this is not right. why libvirt try to fix contructed url ? does it safe to delete this line ? -- Vasiliy Tolstov, e-mail: v.tolstov@selfip.ru

On 19.01.2016 13:15, Vasiliy Tolstov wrote:
I found a strange thing, when i specify url for iso in libvirt xml like:
qemu gets invalid url in cmdline i think that problem is qemu/qemu_command.c:3430: ret = virURIFormat(uri);
test string looks like https://alukardd.org/data/test?t=1 qemu gets url with percent urlencoded %3F , in this case http server get not test with param t=1 but filename test%3Ft=1 so this is not right.
why libvirt try to fix contructed url ? does it safe to delete this line ?
No it's not safe. Othewise you won't get any source string for your disk. The line we are talking about is in qemuBuildNetworkDriveURI(). Now, it's virURIFormat that formats the URI and it uses libxml2 for that. In our tests it seems like we should be discarding escape sequences in Format(). Take a look at tests/viruritest.c and you'll see. So maybe a bug in libxml2? Michal

On Fri, Jan 22, 2016 at 09:59:53AM +0100, Michal Privoznik wrote:
On 19.01.2016 13:15, Vasiliy Tolstov wrote:
I found a strange thing, when i specify url for iso in libvirt xml like:
What does the XML look like? AFAIK libvirt does not support specifying the whole disk URL, just separate parts of it.
qemu gets invalid url in cmdline i think that problem is qemu/qemu_command.c:3430: ret = virURIFormat(uri);
test string looks like https://alukardd.org/data/test?t=1 qemu gets url with percent urlencoded %3F , in this case http server get not test with param t=1 but filename test%3Ft=1 so this is not right.
why libvirt try to fix contructed url ? does it safe to delete this line ?
No it's not safe. Othewise you won't get any source string for your disk. The line we are talking about is in qemuBuildNetworkDriveURI(). Now, it's virURIFormat that formats the URI and it uses libxml2 for that. In our tests it seems like we should be discarding escape sequences in Format(). Take a look at tests/viruritest.c and you'll see. So maybe a bug in libxml2?
libxml2 does the right thing here. We treat the <source name=''/> attribute as the 'path' part of the URI, not 'path?query'. If the query is important, a separate XML attribute would be neater than overloading 'name' to do both. Jan
participants (3)
-
Ján Tomko
-
Michal Privoznik
-
Vasiliy Tolstov