]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virConnectOpen: Require root dir to be absolute path
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 25 Feb 2021 15:29:22 +0000 (16:29 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 12 Mar 2021 14:40:13 +0000 (15:40 +0100)
In theory, users might want to use a relative path as a root
directory for embed drivers. But in practice, nothing in driver
initialization (specifically QEMU driver since it's the only one
that supports embedding now), is prepared for that. Document and
enforce absolute paths.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1883725
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
docs/drvqemu.html.in
src/libvirt.c

index 375c1b03524c6da5684707bf859c33ce2b444582..fdf74979ad4117d422ad18d9a6bd00741c02a7a8 100644 (file)
@@ -73,6 +73,8 @@ qemu+ssh://root@example.com/system   (remote access, SSH tunnelled)
       registered &amp; be running an instance of the event loop. To open
       the driver in embedded mode the app use the new URI path and specify
       a virtual root directory under which the driver will create content.
+      The path to the root directory must be absolute. Passing a relative
+      path results in an error.
     </p>
 
     <pre>
index 5778b5daeefc0a309f87e44c9625479806ca54cb..f2f0efa0cb9bbedb596a90b601f6a10f2f197c62 100644 (file)
@@ -996,6 +996,12 @@ virConnectOpenInternal(const char *name,
             if (!root)
                 goto failed;
 
+            if (!g_path_is_absolute(root)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("root path must be absolute"));
+                goto failed;
+            }
+
             if (virEventRequireImpl() < 0)
                 goto failed;