From 1db9a763c92eae49d05e5c7a4c9c5527cced2ad0 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 14 Jun 2018 11:19:49 +0100 Subject: [PATCH] lib: libvirt: Convert all socket parameters to an absolute path (RHBZ#1588451). (cherry picked from commit 70bc83f893e6e0daf20ca7c9b7bfe875ceaed594) --- 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 c709c4fe2..4df26825a 100644 --- a/lib/launch-libvirt.c +++ b/lib/launch-libvirt.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -1706,8 +1707,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.17.2