The virNetServerClient object had a hardcoded limit of 10 requests
per client. Extend constructor to allow it to be passed in as a
configurable variable. Wire this up to the 'max_client_requests'
config parameter in libvirtd
* daemon/libvirtd.c: Pass max_client_requests into services
* src/rpc/virnetserverservice.c, src/rpc/virnetserverservice.h: Pass
nrequests_client_max to clients
* src/rpc/virnetserverclient.c, src/rpc/virnetserverclient.h: Allow
configurable request limit
---
daemon/libvirtd.c | 4 ++++
src/rpc/virnetserverclient.c | 3 ++-
src/rpc/virnetserverclient.h | 1 +
src/rpc/virnetserverservice.c | 6 ++++++
src/rpc/virnetserverservice.h | 2 ++
5 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index d1f80e4..118aa92 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -486,6 +486,7 @@ static int daemonSetupNetworking(virNetServerPtr srv,
unix_sock_gid,
config->auth_unix_rw,
false,
+ config->max_client_requests,
NULL)))
goto error;
if (sock_path_ro &&
@@ -494,6 +495,7 @@ static int daemonSetupNetworking(virNetServerPtr srv,
unix_sock_gid,
config->auth_unix_ro,
true,
+ config->max_client_requests,
NULL)))
goto error;
@@ -509,6 +511,7 @@ static int daemonSetupNetworking(virNetServerPtr srv,
config->tcp_port,
config->auth_tcp,
false,
+ config->max_client_requests,
NULL)))
goto error;
@@ -543,6 +546,7 @@ static int daemonSetupNetworking(virNetServerPtr srv,
config->tls_port,
config->auth_tls,
false,
+ config->max_client_requests,
ctxt))) {
virNetTLSContextFree(ctxt);
goto error;
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index 57a3446..aac4c3c 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -282,6 +282,7 @@ virNetServerClientCheckAccess(virNetServerClientPtr client)
virNetServerClientPtr virNetServerClientNew(virNetSocketPtr sock,
int auth,
bool readonly,
+ size_t nrequests_max,
virNetTLSContextPtr tls)
{
virNetServerClientPtr client;
@@ -301,7 +302,7 @@ virNetServerClientPtr virNetServerClientNew(virNetSocketPtr sock,
client->auth = auth;
client->readonly = readonly;
client->tlsCtxt = tls;
- client->nrequests_max = 10; /* XXX */
+ client->nrequests_max = nrequests_max;
if (tls)
virNetTLSContextRef(tls);
diff --git a/src/rpc/virnetserverclient.h b/src/rpc/virnetserverclient.h
index 0994890..66510c3 100644
--- a/src/rpc/virnetserverclient.h
+++ b/src/rpc/virnetserverclient.h
@@ -41,6 +41,7 @@ typedef int (*virNetServerClientFilterFunc)(virNetServerClientPtr
client,
virNetServerClientPtr virNetServerClientNew(virNetSocketPtr sock,
int auth,
bool readonly,
+ size_t nrequests_max,
virNetTLSContextPtr tls);
int virNetServerClientAddFilter(virNetServerClientPtr client,
diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c
index e5a47b0..e84f72c 100644
--- a/src/rpc/virnetserverservice.c
+++ b/src/rpc/virnetserverservice.c
@@ -39,6 +39,7 @@ struct _virNetServerService {
int auth;
bool readonly;
+ size_t nrequests_client_max;
virNetTLSContextPtr tls;
@@ -65,6 +66,7 @@ static void virNetServerServiceAccept(virNetSocketPtr sock,
if (!(client = virNetServerClientNew(clientsock,
svc->auth,
svc->readonly,
+ svc->nrequests_client_max,
svc->tls)))
goto error;
@@ -88,6 +90,7 @@ virNetServerServicePtr virNetServerServiceNewTCP(const char *nodename,
const char *service,
int auth,
bool readonly,
+ size_t nrequests_client_max,
virNetTLSContextPtr tls)
{
virNetServerServicePtr svc;
@@ -99,6 +102,7 @@ virNetServerServicePtr virNetServerServiceNewTCP(const char *nodename,
svc->refs = 1;
svc->auth = auth;
svc->readonly = readonly;
+ svc->nrequests_client_max = nrequests_client_max;
svc->tls = tls;
if (tls)
virNetTLSContextRef(tls);
@@ -138,6 +142,7 @@ virNetServerServicePtr virNetServerServiceNewUNIX(const char *path,
gid_t grp,
int auth,
bool readonly,
+ size_t nrequests_client_max,
virNetTLSContextPtr tls)
{
virNetServerServicePtr svc;
@@ -149,6 +154,7 @@ virNetServerServicePtr virNetServerServiceNewUNIX(const char *path,
svc->refs = 1;
svc->auth = auth;
svc->readonly = readonly;
+ svc->nrequests_client_max = nrequests_client_max;
svc->tls = tls;
if (tls)
virNetTLSContextRef(tls);
diff --git a/src/rpc/virnetserverservice.h b/src/rpc/virnetserverservice.h
index 378fa0b..9357598 100644
--- a/src/rpc/virnetserverservice.h
+++ b/src/rpc/virnetserverservice.h
@@ -40,12 +40,14 @@ virNetServerServicePtr virNetServerServiceNewTCP(const char
*nodename,
const char *service,
int auth,
bool readonly,
+ size_t nrequests_client_max,
virNetTLSContextPtr tls);
virNetServerServicePtr virNetServerServiceNewUNIX(const char *path,
mode_t mask,
gid_t grp,
int auth,
bool readonly,
+ size_t nrequests_client_max,
virNetTLSContextPtr tls);
int virNetServerServiceGetPort(virNetServerServicePtr svc);
--
1.7.4.4