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 <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
Michal Privoznik 2021-02-25 16:29:22 +01:00
parent 7fe35dc802
commit b1fef73225
2 changed files with 8 additions and 0 deletions

View 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>

View 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;