render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
43fe83
From 8f5480fdbf65d53aade99836156fad34f21d3803 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <8f5480fdbf65d53aade99836156fad34f21d3803.1377873636.git.jdenemar@redhat.com>
43fe83
From: Michal Privoznik <mprivozn@redhat.com>
43fe83
Date: Mon, 5 Aug 2013 11:30:17 +0200
43fe83
Subject: [PATCH] Introduce max_queued_clients
43fe83
43fe83
https://bugzilla.redhat.com/show_bug.cgi?id=981729
43fe83
43fe83
This configuration knob lets user to set the length of queue of
43fe83
connection requests waiting to be accept()-ed by the daemon. IOW, it
43fe83
just controls the @backlog passed to listen:
43fe83
43fe83
  int listen(int sockfd, int backlog);
43fe83
(cherry picked from commit 1199edb1d4e3ebbc691bd32d3519a3b662225420)
43fe83
---
43fe83
 daemon/libvirtd-config.c      | 1 +
43fe83
 daemon/libvirtd-config.h      | 1 +
43fe83
 daemon/libvirtd.aug           | 1 +
43fe83
 daemon/libvirtd.c             | 4 ++++
43fe83
 daemon/libvirtd.conf          | 6 ++++++
43fe83
 src/locking/lock_daemon.c     | 2 +-
43fe83
 src/lxc/lxc_controller.c      | 1 +
43fe83
 src/rpc/virnetserverservice.c | 6 ++++--
43fe83
 src/rpc/virnetserverservice.h | 2 ++
43fe83
 9 files changed, 21 insertions(+), 3 deletions(-)
43fe83
43fe83
diff --git a/daemon/libvirtd-config.c b/daemon/libvirtd-config.c
43fe83
index 107a9cf..c816fda 100644
43fe83
--- a/daemon/libvirtd-config.c
43fe83
+++ b/daemon/libvirtd-config.c
43fe83
@@ -414,6 +414,7 @@ daemonConfigLoadOptions(struct daemonConfig *data,
43fe83
     GET_CONF_INT(conf, filename, min_workers);
43fe83
     GET_CONF_INT(conf, filename, max_workers);
43fe83
     GET_CONF_INT(conf, filename, max_clients);
43fe83
+    GET_CONF_INT(conf, filename, max_queued_clients);
43fe83
 
43fe83
     GET_CONF_INT(conf, filename, prio_workers);
43fe83
 
43fe83
diff --git a/daemon/libvirtd-config.h b/daemon/libvirtd-config.h
43fe83
index 973e0ea..a24d5d2 100644
43fe83
--- a/daemon/libvirtd-config.h
43fe83
+++ b/daemon/libvirtd-config.h
43fe83
@@ -63,6 +63,7 @@ struct daemonConfig {
43fe83
     int min_workers;
43fe83
     int max_workers;
43fe83
     int max_clients;
43fe83
+    int max_queued_clients;
43fe83
 
43fe83
     int prio_workers;
43fe83
 
43fe83
diff --git a/daemon/libvirtd.aug b/daemon/libvirtd.aug
43fe83
index 7c56a41..70fce5c 100644
43fe83
--- a/daemon/libvirtd.aug
43fe83
+++ b/daemon/libvirtd.aug
43fe83
@@ -56,6 +56,7 @@ module Libvirtd =
43fe83
    let processing_entry = int_entry "min_workers"
43fe83
                         | int_entry "max_workers"
43fe83
                         | int_entry "max_clients"
43fe83
+                        | int_entry "max_queued_clients"
43fe83
                         | int_entry "max_requests"
43fe83
                         | int_entry "max_client_requests"
43fe83
                         | int_entry "prio_workers"
43fe83
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
43fe83
index 9f7fd8a..402b494 100644
43fe83
--- a/daemon/libvirtd.c
43fe83
+++ b/daemon/libvirtd.c
43fe83
@@ -485,6 +485,7 @@ static int daemonSetupNetworking(virNetServerPtr srv,
43fe83
                                            NULL,
43fe83
 #endif
43fe83
                                            false,
43fe83
+                                           config->max_queued_clients,
43fe83
                                            config->max_client_requests)))
43fe83
         goto error;
43fe83
     if (sock_path_ro) {
43fe83
@@ -497,6 +498,7 @@ static int daemonSetupNetworking(virNetServerPtr srv,
43fe83
                                                  NULL,
43fe83
 #endif
43fe83
                                                  true,
43fe83
+                                                 config->max_queued_clients,
43fe83
                                                  config->max_client_requests)))
43fe83
             goto error;
43fe83
     }
43fe83
@@ -522,6 +524,7 @@ static int daemonSetupNetworking(virNetServerPtr srv,
43fe83
                                                      NULL,
43fe83
 #endif
43fe83
                                                      false,
43fe83
+                                                     config->max_queued_clients,
43fe83
                                                      config->max_client_requests)))
43fe83
                 goto error;
43fe83
 
43fe83
@@ -562,6 +565,7 @@ static int daemonSetupNetworking(virNetServerPtr srv,
43fe83
                                             config->auth_tls,
43fe83
                                             ctxt,
43fe83
                                             false,
43fe83
+                                            config->max_queued_clients,
43fe83
                                             config->max_client_requests))) {
43fe83
                 virObjectUnref(ctxt);
43fe83
                 goto error;
43fe83
diff --git a/daemon/libvirtd.conf b/daemon/libvirtd.conf
43fe83
index af4493e..5353927 100644
43fe83
--- a/daemon/libvirtd.conf
43fe83
+++ b/daemon/libvirtd.conf
43fe83
@@ -257,6 +257,12 @@
43fe83
 # over all sockets combined.
43fe83
 #max_clients = 20
43fe83
 
43fe83
+# The maximum length of queue of connections waiting to be
43fe83
+# accepted by the daemon. Note, that some protocols supporting
43fe83
+# retransmission may obey this so that a later reattempt at
43fe83
+# connection succeeds.
43fe83
+#max_queued_clients = 1000
43fe83
+
43fe83
 
43fe83
 # The minimum limit sets the number of workers to start up
43fe83
 # initially. If the number of active clients exceeds this,
43fe83
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
43fe83
index c4c1727..c45f45c 100644
43fe83
--- a/src/locking/lock_daemon.c
43fe83
+++ b/src/locking/lock_daemon.c
43fe83
@@ -671,7 +671,7 @@ virLockDaemonSetupNetworkingNative(virNetServerPtr srv, const char *sock_path)
43fe83
 #if WITH_GNUTLS
43fe83
                                            NULL,
43fe83
 #endif
43fe83
-                                           false, 1)))
43fe83
+                                           false, 0, 1)))
43fe83
         return -1;
43fe83
 
43fe83
     if (virNetServerAddService(srv, svc, NULL) < 0) {
43fe83
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
43fe83
index 124ab19..ed73ab0 100644
43fe83
--- a/src/lxc/lxc_controller.c
43fe83
+++ b/src/lxc/lxc_controller.c
43fe83
@@ -745,6 +745,7 @@ static int virLXCControllerSetupServer(virLXCControllerPtr ctrl)
43fe83
                                            NULL,
43fe83
 #endif
43fe83
                                            false,
43fe83
+                                           0,
43fe83
                                            5)))
43fe83
         goto error;
43fe83
 
43fe83
diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c
43fe83
index 632f03d..4113ec9 100644
43fe83
--- a/src/rpc/virnetserverservice.c
43fe83
+++ b/src/rpc/virnetserverservice.c
43fe83
@@ -97,6 +97,7 @@ virNetServerServicePtr virNetServerServiceNewTCP(const char *nodename,
43fe83
                                                  virNetTLSContextPtr tls,
43fe83
 #endif
43fe83
                                                  bool readonly,
43fe83
+                                                 size_t max_queued_clients,
43fe83
                                                  size_t nrequests_client_max)
43fe83
 {
43fe83
     virNetServerServicePtr svc;
43fe83
@@ -122,7 +123,7 @@ virNetServerServicePtr virNetServerServiceNewTCP(const char *nodename,
43fe83
         goto error;
43fe83
 
43fe83
     for (i = 0; i < svc->nsocks; i++) {
43fe83
-        if (virNetSocketListen(svc->socks[i], 0) < 0)
43fe83
+        if (virNetSocketListen(svc->socks[i], max_queued_clients) < 0)
43fe83
             goto error;
43fe83
 
43fe83
         /* IO callback is initially disabled, until we're ready
43fe83
@@ -155,6 +156,7 @@ virNetServerServicePtr virNetServerServiceNewUNIX(const char *path,
43fe83
                                                   virNetTLSContextPtr tls,
43fe83
 #endif
43fe83
                                                   bool readonly,
43fe83
+                                                  size_t max_queued_clients,
43fe83
                                                   size_t nrequests_client_max)
43fe83
 {
43fe83
     virNetServerServicePtr svc;
43fe83
@@ -185,7 +187,7 @@ virNetServerServicePtr virNetServerServiceNewUNIX(const char *path,
43fe83
         goto error;
43fe83
 
43fe83
     for (i = 0; i < svc->nsocks; i++) {
43fe83
-        if (virNetSocketListen(svc->socks[i], 0) < 0)
43fe83
+        if (virNetSocketListen(svc->socks[i], max_queued_clients) < 0)
43fe83
             goto error;
43fe83
 
43fe83
         /* IO callback is initially disabled, until we're ready
43fe83
diff --git a/src/rpc/virnetserverservice.h b/src/rpc/virnetserverservice.h
43fe83
index 1ece503..eb31abf 100644
43fe83
--- a/src/rpc/virnetserverservice.h
43fe83
+++ b/src/rpc/virnetserverservice.h
43fe83
@@ -44,6 +44,7 @@ virNetServerServicePtr virNetServerServiceNewTCP(const char *nodename,
43fe83
                                                  virNetTLSContextPtr tls,
43fe83
 # endif
43fe83
                                                  bool readonly,
43fe83
+                                                 size_t max_queued_clients,
43fe83
                                                  size_t nrequests_client_max);
43fe83
 virNetServerServicePtr virNetServerServiceNewUNIX(const char *path,
43fe83
                                                   mode_t mask,
43fe83
@@ -53,6 +54,7 @@ virNetServerServicePtr virNetServerServiceNewUNIX(const char *path,
43fe83
                                                   virNetTLSContextPtr tls,
43fe83
 # endif
43fe83
                                                   bool readonly,
43fe83
+                                                  size_t max_queued_clients,
43fe83
                                                   size_t nrequests_client_max);
43fe83
 virNetServerServicePtr virNetServerServiceNewFD(int fd,
43fe83
                                                 int auth,
43fe83
-- 
43fe83
1.8.3.2
43fe83