remote: use a separate connection for secret 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 ad2b3fdd1c
commit 3a33a83602
3 changed files with 18 additions and 8 deletions

View File

@ -78,6 +78,7 @@ struct daemonClientPrivate {
virConnectPtr networkConn; virConnectPtr networkConn;
virConnectPtr nodedevConn; virConnectPtr nodedevConn;
virConnectPtr nwfilterConn; virConnectPtr nwfilterConn;
virConnectPtr secretConn;
daemonClientStreamPtr streams; daemonClientStreamPtr streams;
}; };

View File

@ -1713,7 +1713,7 @@ remoteClientFreePrivateCallbacks(struct daemonClientPrivate *priv)
DEREG_CB(priv->nodedevConn, priv->nodeDeviceEventCallbacks, DEREG_CB(priv->nodedevConn, priv->nodeDeviceEventCallbacks,
priv->nnodeDeviceEventCallbacks, priv->nnodeDeviceEventCallbacks,
virConnectNodeDeviceEventDeregisterAny, "node device"); virConnectNodeDeviceEventDeregisterAny, "node device");
DEREG_CB(priv->conn, priv->secretEventCallbacks, DEREG_CB(priv->secretConn, priv->secretEventCallbacks,
priv->nsecretEventCallbacks, priv->nsecretEventCallbacks,
virConnectSecretEventDeregisterAny, "secret"); virConnectSecretEventDeregisterAny, "secret");
DEREG_CB(priv->conn, priv->qemuEventCallbacks, DEREG_CB(priv->conn, priv->qemuEventCallbacks,
@ -1753,6 +1753,8 @@ void remoteClientFree(void *data)
virConnectClose(priv->nodedevConn); virConnectClose(priv->nodedevConn);
if (priv->nwfilterConn) if (priv->nwfilterConn)
virConnectClose(priv->nwfilterConn); virConnectClose(priv->nwfilterConn);
if (priv->secretConn)
virConnectClose(priv->secretConn);
VIR_FREE(priv); VIR_FREE(priv);
} }
@ -1829,6 +1831,7 @@ remoteDispatchConnectOpen(virNetServerPtr server ATTRIBUTE_UNUSED,
priv->networkConn = virObjectRef(priv->conn); priv->networkConn = virObjectRef(priv->conn);
priv->nodedevConn = virObjectRef(priv->conn); priv->nodedevConn = virObjectRef(priv->conn);
priv->nwfilterConn = virObjectRef(priv->conn); priv->nwfilterConn = virObjectRef(priv->conn);
priv->secretConn = virObjectRef(priv->conn);
/* force update the @readonly attribute which was inherited from the /* force update the @readonly attribute which was inherited from the
* virNetServerService object - this is important for sockets that are RW * virNetServerService object - this is important for sockets that are RW
@ -4050,12 +4053,12 @@ remoteDispatchSecretGetValue(virNetServerPtr server ATTRIBUTE_UNUSED,
struct daemonClientPrivate *priv = struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client); virNetServerClientGetPrivateData(client);
if (!priv->conn) { if (!priv->secretConn) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
goto cleanup; goto cleanup;
} }
if (!(secret = get_nonnull_secret(priv->conn, args->secret))) if (!(secret = get_nonnull_secret(priv->secretConn, args->secret)))
goto cleanup; goto cleanup;
if (!(value = virSecretGetValue(secret, &value_size, args->flags))) if (!(value = virSecretGetValue(secret, &value_size, args->flags)))
@ -6089,7 +6092,7 @@ remoteDispatchConnectSecretEventRegisterAny(virNetServerPtr server ATTRIBUTE_UNU
virNetServerClientGetPrivateData(client); virNetServerClientGetPrivateData(client);
virSecretPtr secret = NULL; virSecretPtr secret = NULL;
if (!priv->conn) { if (!priv->secretConn) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
goto cleanup; goto cleanup;
} }
@ -6097,7 +6100,7 @@ remoteDispatchConnectSecretEventRegisterAny(virNetServerPtr server ATTRIBUTE_UNU
virMutexLock(&priv->lock); virMutexLock(&priv->lock);
if (args->secret && if (args->secret &&
!(secret = get_nonnull_secret(priv->conn, *args->secret))) !(secret = get_nonnull_secret(priv->secretConn, *args->secret)))
goto cleanup; goto cleanup;
if (args->eventID >= VIR_SECRET_EVENT_ID_LAST || args->eventID < 0) { if (args->eventID >= VIR_SECRET_EVENT_ID_LAST || args->eventID < 0) {
@ -6123,7 +6126,7 @@ remoteDispatchConnectSecretEventRegisterAny(virNetServerPtr server ATTRIBUTE_UNU
callback) < 0) callback) < 0)
goto cleanup; goto cleanup;
if ((callbackID = virConnectSecretEventRegisterAny(priv->conn, if ((callbackID = virConnectSecretEventRegisterAny(priv->secretConn,
secret, secret,
args->eventID, args->eventID,
secretEventCallbacks[args->eventID], secretEventCallbacks[args->eventID],
@ -6161,7 +6164,7 @@ remoteDispatchConnectSecretEventDeregisterAny(virNetServerPtr server ATTRIBUTE_U
struct daemonClientPrivate *priv = struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client); virNetServerClientGetPrivateData(client);
if (!priv->conn) { if (!priv->secretConn) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
goto cleanup; goto cleanup;
} }
@ -6179,7 +6182,7 @@ remoteDispatchConnectSecretEventDeregisterAny(virNetServerPtr server ATTRIBUTE_U
goto cleanup; goto cleanup;
} }
if (virConnectSecretEventDeregisterAny(priv->conn, args->callbackID) < 0) if (virConnectSecretEventDeregisterAny(priv->secretConn, args->callbackID) < 0)
goto cleanup; goto cleanup;
VIR_DELETE_ELEMENT(priv->secretEventCallbacks, i, VIR_DELETE_ELEMENT(priv->secretEventCallbacks, i,

View File

@ -137,6 +137,9 @@ sub get_conn_arg {
if ($type =~ /remote_nonnull_nwfilter/) { if ($type =~ /remote_nonnull_nwfilter/) {
return "priv->nwfilterConn"; return "priv->nwfilterConn";
} }
if ($type =~ /remote_nonnull_secret/) {
return "priv->secretConn";
}
} }
# This is for the few virConnect APIs that # This is for the few virConnect APIs that
@ -154,6 +157,9 @@ sub get_conn_arg {
if ($proc =~ /Connect.*NWFilter/) { if ($proc =~ /Connect.*NWFilter/) {
return "priv->nwfilterConn"; return "priv->nwfilterConn";
} }
if ($proc =~ /Connect.*Secret/) {
return "priv->secretConn";
}
return "priv->conn"; return "priv->conn";
} }