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(a)redhat.com>
---
docs/drvqemu.html.in | 2 ++
src/libvirt.c | 6 ++++++
2 files changed, 8 insertions(+)
diff --git a/docs/drvqemu.html.in b/docs/drvqemu.html.in
index 3cdd04aa1e..494dda56ef 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.
</p>
<pre>
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;
--
2.26.2