mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
remote: use a separate connection for network APIs
Reviewed-by: John Ferlan <jferlan@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
cb712443b7
commit
ca88bbc618
@ -75,6 +75,7 @@ struct daemonClientPrivate {
|
||||
*/
|
||||
virConnectPtr conn;
|
||||
virConnectPtr interfaceConn;
|
||||
virConnectPtr networkConn;
|
||||
|
||||
daemonClientStreamPtr streams;
|
||||
};
|
||||
|
@ -1704,7 +1704,7 @@ remoteClientFreePrivateCallbacks(struct daemonClientPrivate *priv)
|
||||
DEREG_CB(priv->conn, priv->domainEventCallbacks,
|
||||
priv->ndomainEventCallbacks,
|
||||
virConnectDomainEventDeregisterAny, "domain");
|
||||
DEREG_CB(priv->conn, priv->networkEventCallbacks,
|
||||
DEREG_CB(priv->networkConn, priv->networkEventCallbacks,
|
||||
priv->nnetworkEventCallbacks,
|
||||
virConnectNetworkEventDeregisterAny, "network");
|
||||
DEREG_CB(priv->conn, priv->storageEventCallbacks,
|
||||
@ -1747,6 +1747,8 @@ void remoteClientFree(void *data)
|
||||
virConnectClose(priv->conn);
|
||||
if (priv->interfaceConn)
|
||||
virConnectClose(priv->interfaceConn);
|
||||
if (priv->networkConn)
|
||||
virConnectClose(priv->networkConn);
|
||||
|
||||
VIR_FREE(priv);
|
||||
}
|
||||
@ -1820,6 +1822,7 @@ remoteDispatchConnectOpen(virNetServerPtr server ATTRIBUTE_UNUSED,
|
||||
goto cleanup;
|
||||
|
||||
priv->interfaceConn = virObjectRef(priv->conn);
|
||||
priv->networkConn = virObjectRef(priv->conn);
|
||||
|
||||
/* force update the @readonly attribute which was inherited from the
|
||||
* virNetServerService object - this is important for sockets that are RW
|
||||
@ -5716,7 +5719,7 @@ remoteDispatchConnectNetworkEventRegisterAny(virNetServerPtr server ATTRIBUTE_UN
|
||||
virNetServerClientGetPrivateData(client);
|
||||
virNetworkPtr net = NULL;
|
||||
|
||||
if (!priv->conn) {
|
||||
if (!priv->networkConn) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -5724,7 +5727,7 @@ remoteDispatchConnectNetworkEventRegisterAny(virNetServerPtr server ATTRIBUTE_UN
|
||||
virMutexLock(&priv->lock);
|
||||
|
||||
if (args->net &&
|
||||
!(net = get_nonnull_network(priv->conn, *args->net)))
|
||||
!(net = get_nonnull_network(priv->networkConn, *args->net)))
|
||||
goto cleanup;
|
||||
|
||||
if (args->eventID >= VIR_NETWORK_EVENT_ID_LAST || args->eventID < 0) {
|
||||
@ -5750,7 +5753,7 @@ remoteDispatchConnectNetworkEventRegisterAny(virNetServerPtr server ATTRIBUTE_UN
|
||||
callback) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if ((callbackID = virConnectNetworkEventRegisterAny(priv->conn,
|
||||
if ((callbackID = virConnectNetworkEventRegisterAny(priv->networkConn,
|
||||
net,
|
||||
args->eventID,
|
||||
networkEventCallbacks[args->eventID],
|
||||
@ -5789,7 +5792,7 @@ remoteDispatchConnectNetworkEventDeregisterAny(virNetServerPtr server ATTRIBUTE_
|
||||
struct daemonClientPrivate *priv =
|
||||
virNetServerClientGetPrivateData(client);
|
||||
|
||||
if (!priv->conn) {
|
||||
if (!priv->networkConn) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -5807,7 +5810,7 @@ remoteDispatchConnectNetworkEventDeregisterAny(virNetServerPtr server ATTRIBUTE_
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virConnectNetworkEventDeregisterAny(priv->conn, args->callbackID) < 0)
|
||||
if (virConnectNetworkEventDeregisterAny(priv->networkConn, args->callbackID) < 0)
|
||||
goto cleanup;
|
||||
|
||||
VIR_DELETE_ELEMENT(priv->networkEventCallbacks, i,
|
||||
@ -6470,12 +6473,12 @@ remoteDispatchNetworkGetDHCPLeases(virNetServerPtr server ATTRIBUTE_UNUSED,
|
||||
virNetworkPtr net = NULL;
|
||||
int nleases = 0;
|
||||
|
||||
if (!priv->conn) {
|
||||
if (!priv->networkConn) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!(net = get_nonnull_network(priv->conn, args->net)))
|
||||
if (!(net = get_nonnull_network(priv->networkConn, args->net)))
|
||||
goto cleanup;
|
||||
|
||||
if ((nleases = virNetworkGetDHCPLeases(net,
|
||||
|
@ -128,6 +128,9 @@ sub get_conn_arg {
|
||||
if ($type =~ /remote_nonnull_interface/) {
|
||||
return "priv->interfaceConn";
|
||||
}
|
||||
if ($type =~ /remote_nonnull_network/) {
|
||||
return "priv->networkConn";
|
||||
}
|
||||
}
|
||||
|
||||
# This is for the few virConnect APIs that
|
||||
@ -136,6 +139,9 @@ sub get_conn_arg {
|
||||
if ($proc =~ /Connect.*Interface/ || $proc =~ /InterfaceChange/) {
|
||||
return "priv->interfaceConn";
|
||||
}
|
||||
if ($proc =~ /Connect.*Network/) {
|
||||
return "priv->networkConn";
|
||||
}
|
||||
|
||||
return "priv->conn";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user