]> xenbits.xensource.com Git - libvirt.git/commitdiff
libvirt.c: Return error when remoteOnly is set but server is empty
authorMarcos Paulo de Souza <marcos.souza.org@gmail.com>
Tue, 10 Jul 2018 23:30:59 +0000 (20:30 -0300)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 11 Jul 2018 10:55:26 +0000 (12:55 +0200)
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 <marcos.souza.org@gmail.com>
src/libvirt.c

index 52f4dd280842aa28152f04cb08fb0a4f0e6ffe37..aeb8804714f8294b2b0f1e9b1612447f5f54474d 100644 (file)
@@ -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;