提交 7a9153a5 编写于 作者: M Martin Kletzander 提交者: Eric Blake

util: Prepare URI formatting for libxml2 >= 2.9.2

Since commit 8eb55d782a2b9afacc7938694891cc6fad7b42a5 libxml2 removes
two slashes from the URI when there is no server part.  This is fixed
with beb7281055dbf0ed4d041022a67c6c5cfd126f25, but only if the calling
application calls xmlSaveUri() on URI that xmlURIParse() parsed.  And
that is not the case in virURIFormat().  virURIFormat() accepts
virURIPtr that can be created without parsing it and we do that when we
format network storage paths for gluster for example.  Even though
virStorageSourceParseBackingURI() uses virURIParse(), it throws that data
structure right away.

Since we want to format URIs as URIs and not absolute URIs or opaque
URIs (see RFC 3986), we can specify that with a special hack thanks to
commit beb7281055dbf0ed4d041022a67c6c5cfd126f25, by setting port to -1.

This fixes qemuxml2argvtest test where the disk-drive-network-gluster
case was failing.
Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 8f17d0ea)
上级 f8c5522b
...@@ -258,6 +258,13 @@ virURIFormat(virURIPtr uri) ...@@ -258,6 +258,13 @@ virURIFormat(virURIPtr uri)
xmluri.server = tmpserver; xmluri.server = tmpserver;
} }
/*
* This helps libxml2 deal with the difference
* between uri:/absolute/path and uri:///absolute/path.
*/
if (!xmluri.server && !xmluri.port)
xmluri.port = -1;
ret = (char *)xmlSaveUri(&xmluri); ret = (char *)xmlSaveUri(&xmluri);
if (!ret) { if (!ret) {
virReportOOMError(); virReportOOMError();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册