mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 12:05:17 +00:00
remote: Pass 'mode' and 'socket' URI parameters to virt-ssh-helper
When handling virConnectOpen(), we parse given URI, specifically all those parameters we know, like ?mode, ?socket, ?name, etc. ignoring those we don't recognize yet. Then, we reconstruct the URI back, but ignoring all parameters we've parsed. In other words: qemu:///system?mode=legacy&foo=bar becomes: qemu:///system?foo=bar The reconstructed URI is then passed to the corresponding driver (QEMU in our example) with intent of it parsing parameters further (or just ignoring them). But for some transport modes, where virt-ssh-helper is ran on the remote host (libssh, libssh2, ssh) we need to pass ?mode and ?socket parameters, so that it can do the right thing, e.g. for 'mode=legacy' start the monolithic daemon, or for 'socket=' connect to the given socket. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/433 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
cdb1aa996a
commit
d133d73f54
@ -696,18 +696,31 @@ remoteConnectSupportsFeatureUnlocked(virConnectPtr conn,
|
|||||||
|
|
||||||
static char *
|
static char *
|
||||||
remoteConnectFormatURI(virURI *uri,
|
remoteConnectFormatURI(virURI *uri,
|
||||||
const char *driver_str)
|
const char *driver_str,
|
||||||
|
bool unmask)
|
||||||
{
|
{
|
||||||
|
const char *names[] = {"mode", "socket", NULL};
|
||||||
g_autofree char *query = NULL;
|
g_autofree char *query = NULL;
|
||||||
|
char *ret = NULL;
|
||||||
virURI tmpuri = {
|
virURI tmpuri = {
|
||||||
.scheme = (char *)driver_str,
|
.scheme = (char *)driver_str,
|
||||||
.path = uri->path,
|
.path = uri->path,
|
||||||
.fragment = uri->fragment,
|
.fragment = uri->fragment,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (unmask) {
|
||||||
|
virURIParamsSetIgnore(uri, false, names);
|
||||||
|
}
|
||||||
|
|
||||||
query = tmpuri.query = virURIFormatParams(uri);
|
query = tmpuri.query = virURIFormatParams(uri);
|
||||||
|
|
||||||
return virURIFormat(&tmpuri);
|
ret = virURIFormat(&tmpuri);
|
||||||
|
|
||||||
|
if (unmask) {
|
||||||
|
virURIParamsSetIgnore(uri, true, names);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -780,6 +793,7 @@ doRemoteOpen(virConnectPtr conn,
|
|||||||
g_autofree char *mode_str = NULL;
|
g_autofree char *mode_str = NULL;
|
||||||
g_autofree char *daemon_path = NULL;
|
g_autofree char *daemon_path = NULL;
|
||||||
g_autofree char *proxy_str = NULL;
|
g_autofree char *proxy_str = NULL;
|
||||||
|
g_autofree char *virtSshURI = NULL;
|
||||||
bool sanity = true;
|
bool sanity = true;
|
||||||
bool verify = true;
|
bool verify = true;
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
@ -851,7 +865,10 @@ doRemoteOpen(virConnectPtr conn,
|
|||||||
/* Allow remote serve to probe */
|
/* Allow remote serve to probe */
|
||||||
name = g_strdup("");
|
name = g_strdup("");
|
||||||
} else {
|
} else {
|
||||||
name = remoteConnectFormatURI(conn->uri, driver_str);
|
name = remoteConnectFormatURI(conn->uri, driver_str, false);
|
||||||
|
|
||||||
|
/* Preserve mode and socket parameters. */
|
||||||
|
virtSshURI = remoteConnectFormatURI(conn->uri, driver_str, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1006,7 +1023,7 @@ doRemoteOpen(virConnectPtr conn,
|
|||||||
proxy,
|
proxy,
|
||||||
netcat,
|
netcat,
|
||||||
sockname,
|
sockname,
|
||||||
name,
|
virtSshURI ? virtSshURI : name,
|
||||||
flags & REMOTE_DRIVER_OPEN_RO,
|
flags & REMOTE_DRIVER_OPEN_RO,
|
||||||
auth,
|
auth,
|
||||||
conn->uri);
|
conn->uri);
|
||||||
@ -1030,7 +1047,7 @@ doRemoteOpen(virConnectPtr conn,
|
|||||||
proxy,
|
proxy,
|
||||||
netcat,
|
netcat,
|
||||||
sockname,
|
sockname,
|
||||||
name,
|
virtSshURI ? virtSshURI : name,
|
||||||
flags & REMOTE_DRIVER_OPEN_RO,
|
flags & REMOTE_DRIVER_OPEN_RO,
|
||||||
auth,
|
auth,
|
||||||
conn->uri);
|
conn->uri);
|
||||||
@ -1063,7 +1080,7 @@ doRemoteOpen(virConnectPtr conn,
|
|||||||
proxy,
|
proxy,
|
||||||
netcat,
|
netcat,
|
||||||
sockname,
|
sockname,
|
||||||
name,
|
virtSshURI ? virtSshURI : name,
|
||||||
flags & REMOTE_DRIVER_OPEN_RO)))
|
flags & REMOTE_DRIVER_OPEN_RO)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user