remote: use a separate connection for nodedev APIs

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2018-03-22 11:16:25 +00:00
parent ca88bbc618
commit 3ebf8f5b80
3 changed files with 18 additions and 8 deletions

View File

@ -76,6 +76,7 @@ struct daemonClientPrivate {
virConnectPtr conn;
virConnectPtr interfaceConn;
virConnectPtr networkConn;
virConnectPtr nodedevConn;
daemonClientStreamPtr streams;
};

View File

@ -1710,7 +1710,7 @@ remoteClientFreePrivateCallbacks(struct daemonClientPrivate *priv)
DEREG_CB(priv->conn, priv->storageEventCallbacks,
priv->nstorageEventCallbacks,
virConnectStoragePoolEventDeregisterAny, "storage");
DEREG_CB(priv->conn, priv->nodeDeviceEventCallbacks,
DEREG_CB(priv->nodedevConn, priv->nodeDeviceEventCallbacks,
priv->nnodeDeviceEventCallbacks,
virConnectNodeDeviceEventDeregisterAny, "node device");
DEREG_CB(priv->conn, priv->secretEventCallbacks,
@ -1749,6 +1749,8 @@ void remoteClientFree(void *data)
virConnectClose(priv->interfaceConn);
if (priv->networkConn)
virConnectClose(priv->networkConn);
if (priv->nodedevConn)
virConnectClose(priv->nodedevConn);
VIR_FREE(priv);
}
@ -1823,6 +1825,7 @@ remoteDispatchConnectOpen(virNetServerPtr server ATTRIBUTE_UNUSED,
priv->interfaceConn = virObjectRef(priv->conn);
priv->networkConn = virObjectRef(priv->conn);
priv->nodedevConn = virObjectRef(priv->conn);
/* force update the @readonly attribute which was inherited from the
* virNetServerService object - this is important for sockets that are RW
@ -3782,12 +3785,12 @@ remoteDispatchNodeDeviceGetParent(virNetServerPtr server ATTRIBUTE_UNUSED,
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
if (!priv->conn) {
if (!priv->nodedevConn) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
goto cleanup;
}
if (!(dev = virNodeDeviceLookupByName(priv->conn, args->name)))
if (!(dev = virNodeDeviceLookupByName(priv->nodedevConn, args->name)))
goto cleanup;
parent = virNodeDeviceGetParent(dev);
@ -5962,7 +5965,7 @@ remoteDispatchConnectNodeDeviceEventRegisterAny(virNetServerPtr server ATTRIBUTE
virNetServerClientGetPrivateData(client);
virNodeDevicePtr dev = NULL;
if (!priv->conn) {
if (!priv->nodedevConn) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
goto cleanup;
}
@ -5970,7 +5973,7 @@ remoteDispatchConnectNodeDeviceEventRegisterAny(virNetServerPtr server ATTRIBUTE
virMutexLock(&priv->lock);
if (args->dev &&
!(dev = get_nonnull_node_device(priv->conn, *args->dev)))
!(dev = get_nonnull_node_device(priv->nodedevConn, *args->dev)))
goto cleanup;
if (args->eventID >= VIR_NODE_DEVICE_EVENT_ID_LAST || args->eventID < 0) {
@ -5996,7 +5999,7 @@ remoteDispatchConnectNodeDeviceEventRegisterAny(virNetServerPtr server ATTRIBUTE
callback) < 0)
goto cleanup;
if ((callbackID = virConnectNodeDeviceEventRegisterAny(priv->conn,
if ((callbackID = virConnectNodeDeviceEventRegisterAny(priv->nodedevConn,
dev,
args->eventID,
nodeDeviceEventCallbacks[args->eventID],
@ -6034,7 +6037,7 @@ remoteDispatchConnectNodeDeviceEventDeregisterAny(virNetServerPtr server ATTRIBU
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
if (!priv->conn) {
if (!priv->nodedevConn) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
goto cleanup;
}
@ -6052,7 +6055,7 @@ remoteDispatchConnectNodeDeviceEventDeregisterAny(virNetServerPtr server ATTRIBU
goto cleanup;
}
if (virConnectNodeDeviceEventDeregisterAny(priv->conn, args->callbackID) < 0)
if (virConnectNodeDeviceEventDeregisterAny(priv->nodedevConn, args->callbackID) < 0)
goto cleanup;
VIR_DELETE_ELEMENT(priv->nodeDeviceEventCallbacks, i,

View File

@ -131,6 +131,9 @@ sub get_conn_arg {
if ($type =~ /remote_nonnull_network/) {
return "priv->networkConn";
}
if ($type =~ /remote_nonnull_node_device/) {
return "priv->nodedevConn";
}
}
# This is for the few virConnect APIs that
@ -142,6 +145,9 @@ sub get_conn_arg {
if ($proc =~ /Connect.*Network/) {
return "priv->networkConn";
}
if ($proc =~ /Node.*Device/) {
return "priv->nodedevConn";
}
return "priv->conn";
}