[PATCH v3] lib: libvirt: Convert all drive socket parameters to an absolute path (RHBZ#1588451).
https://bugzilla.redhat.com/show_bug.cgi?id=1588451 v2 was here: https://www.redhat.com/archives/libguestfs/2018-June/msg00067.html This is a greatly simplified version, which just changes the libvirt backend to make the path absolute. None of the tests need to be adjusted. Rich.
--- 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
participants (2)
-
Pino Toscano -
Richard W.M. Jones