[Libguestfs] [PATCH v3] lib: libvirt: Convert all drive socket parameters to an absolute path (RHBZ#1588451).

Richard W.M. Jones rjones at redhat.com
Thu Jun 21 10:01:50 UTC 2018


---
 lib/launch-libvirt.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lib/launch-libvirt.c b/lib/launch-libvirt.c
index b279aa6b9..48404ef93 100644
--- a/lib/launch-libvirt.c
+++ b/lib/launch-libvirt.c
@@ -23,6 +23,7 @@
 #include <stdarg.h>
 #include <stdbool.h>
 #include <unistd.h>
+#include <limits.h>
 #include <fcntl.h>
 #include <grp.h>
 #include <errno.h>
@@ -1698,8 +1699,20 @@ construct_libvirt_xml_disk_source_hosts (guestfs_h *g,
       }
 
       case drive_transport_unix: {
+        /* libvirt requires sockets to be specified as an absolute path
+         * (RHBZ#1588451).
+         */
+        const char *socket = src->servers[i].u.socket;
+        CLEANUP_FREE char *abs_socket = realpath (socket, NULL);
+
+        if (abs_socket == NULL) {
+          perrorf (g, _("realpath: could not convert ‘%s’ to absolute path"),
+                   socket);
+          return -1;
+        }
+
         attribute ("transport", "unix");
-        attribute ("socket", src->servers[i].u.socket);
+        attribute ("socket", abs_socket);
         break;
       }
       }
-- 
2.16.2




More information about the Libguestfs mailing list