On Tue, Jul 23, 2019 at 05:03:14PM +0100, Daniel P. Berrangé wrote:
When the client has a connection to one of the hypervisor specific
daemons (eg virtqemud), the app may still expect to use the secondary
driver APIs (storage, network, etc). None of these will be registered in
the hypervisor daemon, so we must explicitly open a connection to each
of the daemons for the secondary drivers we need.
We don't want to open these secondary driver connections at the same
time as the primary connection is opened though. That would mean that
establishing a connection to virtqemud would immediately trigger
activation of virtnetworkd, virnwfilterd, etc despite that that these
drivers may never be used by the app.
Thus we only open the secondary driver connections at time of first use
by an API call.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/remote/remote_daemon.h | 13 +++
src/remote/remote_daemon_dispatch.c | 146 ++++++++++++++++++----------
2 files changed, 109 insertions(+), 50 deletions(-)
diff --git a/src/remote/remote_daemon_dispatch.c
b/src/remote/remote_daemon_dispatch.c
index b677bd44ee..f1304695bd 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -1954,18 +1954,35 @@ remoteGetHypervisorConn(virNetServerClientPtr client)
}
+static virConnectPtr
+remoteGetSecondaryConn(bool readonly, virConnectPtr *conn, const char *uri)
+{
+ if (!*conn) {
+ if (uri) {
+ VIR_DEBUG("Opening driver %s", uri);
+ if (readonly)
+ *conn = virConnectOpenReadOnly(uri);
+ else
+ *conn = virConnectOpen(uri);
+ if (!conn)
+ return NULL;
This needs to be !*conn
+ VIR_DEBUG("Opened driver %p", *conn);
+ } else {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection
not open"));
+ return NULL;
+ }
+ }
+
+ return *conn;
+}
Regards,
Daniel
--
|:
https://berrange.com -o-
https://www.flickr.com/photos/dberrange :|
|:
https://libvirt.org -o-
https://fstop138.berrange.com :|
|:
https://entangle-photo.org -o-
https://www.instagram.com/dberrange :|