render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
910633
From f4d5340ba116befaa965e14537f42c2ead17d486 Mon Sep 17 00:00:00 2001
910633
Message-Id: <f4d5340ba116befaa965e14537f42c2ead17d486.1414680854.git.crobinso@redhat.com>
910633
From: Martin Kletzander <mkletzan@redhat.com>
910633
Date: Fri, 3 Oct 2014 18:27:01 +0200
910633
Subject: [PATCH] util: Prepare URI formatting for libxml2 >= 2.9.2
910633
910633
Since commit 8eb55d782a2b9afacc7938694891cc6fad7b42a5 libxml2 removes
910633
two slashes from the URI when there is no server part.  This is fixed
910633
with beb7281055dbf0ed4d041022a67c6c5cfd126f25, but only if the calling
910633
application calls xmlSaveUri() on URI that xmlURIParse() parsed.  And
910633
that is not the case in virURIFormat().  virURIFormat() accepts
910633
virURIPtr that can be created without parsing it and we do that when we
910633
format network storage paths for gluster for example.  Even though
910633
virStorageSourceParseBackingURI() uses virURIParse(), it throws that data
910633
structure right away.
910633
910633
Since we want to format URIs as URIs and not absolute URIs or opaque
910633
URIs (see RFC 3986), we can specify that with a special hack thanks to
910633
commit beb7281055dbf0ed4d041022a67c6c5cfd126f25, by setting port to -1.
910633
910633
This fixes qemuxml2argvtest test where the disk-drive-network-gluster
910633
case was failing.
910633
910633
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
910633
(cherry picked from commit 8f17d0eaae7ee2fa3e214b79b188fc14ed5aa1eb)
910633
---
910633
 src/util/viruri.c | 7 +++++++
910633
 1 file changed, 7 insertions(+)
910633
910633
diff --git a/src/util/viruri.c b/src/util/viruri.c
910633
index 69e7649..23d86c5 100644
910633
--- a/src/util/viruri.c
910633
+++ b/src/util/viruri.c
910633
@@ -254,6 +254,13 @@ virURIFormat(virURIPtr uri)
910633
         xmluri.server = tmpserver;
910633
     }
910633
 
910633
+    /*
910633
+     * This helps libxml2 deal with the difference
910633
+     * between uri:/absolute/path and uri:///absolute/path.
910633
+     */
910633
+    if (!xmluri.server && !xmluri.port)
910633
+        xmluri.port = -1;
910633
+
910633
     ret = (char *)xmlSaveUri(&xmluri);
910633
     if (!ret) {
910633
         virReportOOMError();
910633
-- 
910633
2.1.0
910633