From: Michal Privoznik
Date: Thu, 25 Feb 2021 15:29:22 +0000 (+0100)
Subject: virConnectOpen: Require root dir to be absolute path
X-Git-Tag: v7.2.0-rc1~138
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1fef732258ed9418f509ca1a4bf6cb31f55e2e9;p=thirdparty%2Flibvirt.git
virConnectOpen: Require root dir to be absolute path
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
Reviewed-by: Andrea Bolognani
---
diff --git a/docs/drvqemu.html.in b/docs/drvqemu.html.in
index 375c1b0352..fdf74979ad 100644
--- a/docs/drvqemu.html.in
+++ b/docs/drvqemu.html.in
@@ -73,6 +73,8 @@ qemu+ssh://root@example.com/system (remote access, SSH tunnelled)
registered & 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.
diff --git a/src/libvirt.c b/src/libvirt.c
index 5778b5daee..f2f0efa0cb 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -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;