From: Marcos Paulo de Souza Date: Tue, 10 Jul 2018 23:30:59 +0000 (-0300) Subject: libvirt.c: Return error when remoteOnly is set but server is empty X-Git-Tag: v4.6.0-rc1~257 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4916297b46d61a6da2bd8d2ee0fb3876ca9b26c1;p=thirdparty%2Flibvirt.git libvirt.c: Return error when remoteOnly is set but server is empty Some drivers require a server in order to work, so this flag removes the burden of esach driver to check for an server by doing it in virConnectOpenInternal. Signed-off-by: Marcos Paulo de Souza --- diff --git a/src/libvirt.c b/src/libvirt.c index 52f4dd2808..aeb8804714 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1029,6 +1029,13 @@ virConnectOpenInternal(const char *name, VIR_DEBUG("Matching any URI scheme for '%s'", ret->uri ? ret->uri->scheme : ""); } + /* before starting the new connection, check if the driver only works + * with a server, and so return an error if the server is missing */ + if (virConnectDriverTab[i]->remoteOnly && ret->uri && !ret->uri->server) { + virReportError(VIR_ERR_INVALID_ARG, "%s", _("URI is missing the server part")); + goto failed; + } + ret->driver = virConnectDriverTab[i]->hypervisorDriver; ret->interfaceDriver = virConnectDriverTab[i]->interfaceDriver; ret->networkDriver = virConnectDriverTab[i]->networkDriver;