[PATCH] daemon: libvirtd quit after timeout period without resources checking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Remove resources checking code for libvirtd to quit after timeout
period. The way we support this is the same as the libvirtd
signal handling, just set srv->quit to 1.
---
 daemon/libvirtd.c      |   16 +---------------
 daemon/libvirtd.pod.in |    5 +----
 src/rpc/virnetserver.c |   18 +++---------------
 src/rpc/virnetserver.h |    6 +-----
 4 files changed, 6 insertions(+), 39 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index ffbe067..d53f020 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -575,17 +575,6 @@ error:
     return -1;
 }
 
-
-static int daemonShutdownCheck(virNetServerPtr srv ATTRIBUTE_UNUSED,
-                               void *opaque ATTRIBUTE_UNUSED)
-{
-    if (virStateActive())
-        return 0;
-
-    return 1;
-}
-
-
 /*
  * Set up the logging environment
  * By default if daemonized all errors go to the logfile libvirtd.log,
@@ -1242,10 +1231,7 @@ int main(int argc, char **argv) {
 
     if (timeout != -1) {
         VIR_DEBUG("Registering shutdown timeout %d", timeout);
-        virNetServerAutoShutdown(srv,
-                                 timeout,
-                                 daemonShutdownCheck,
-                                 NULL);
+        virNetServerAutoShutdown(srv, timeout);
     }
 
     if ((daemonSetupSignals(srv)) < 0) {
diff --git a/daemon/libvirtd.pod.in b/daemon/libvirtd.pod.in
index 57a3b27..6b77f21 100644
--- a/daemon/libvirtd.pod.in
+++ b/daemon/libvirtd.pod.in
@@ -54,10 +54,7 @@ Use this name for the PID file, overriding the default value.
 
 =item B<-t, --timeout> I<SECONDS>
 
-Exit after timeout period (in seconds) elapse with no client connections
-or registered resources.  Be aware that resources such as autostart
-networks will result in never reaching the timeout, even when there are
-no client connections.
+Exit after timeout period (in seconds) elapse with no client connections.
 
 =item B<-v, --verbose>
 
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 248ad9f..515ad79 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -105,8 +105,6 @@ struct _virNetServer {
     virNetTLSContextPtr tls;
 
     unsigned int autoShutdownTimeout;
-    virNetServerAutoShutdownFunc autoShutdownFunc;
-    void *autoShutdownOpaque;
 
     virNetServerClientInitHook clientInitHook;
     void *clientInitOpaque;
@@ -433,16 +431,10 @@ bool virNetServerIsPrivileged(virNetServerPtr srv)
 
 
 void virNetServerAutoShutdown(virNetServerPtr srv,
-                              unsigned int timeout,
-                              virNetServerAutoShutdownFunc func,
-                              void *opaque)
+                              unsigned int timeout)
 {
     virNetServerLock(srv);
-
     srv->autoShutdownTimeout = timeout;
-    srv->autoShutdownFunc = func;
-    srv->autoShutdownOpaque = opaque;
-
     virNetServerUnlock(srv);
 }
 
@@ -663,12 +655,8 @@ static void virNetServerAutoShutdownTimer(int timerid ATTRIBUTE_UNUSED,
     virNetServerPtr srv = opaque;
 
     virNetServerLock(srv);
-
-    if (srv->autoShutdownFunc(srv, srv->autoShutdownOpaque)) {
-        VIR_DEBUG("Automatic shutdown triggered");
-        srv->quit = 1;
-    }
-
+    VIR_DEBUG("Automatic shutdown triggered");
+    srv->quit = 1;
     virNetServerUnlock(srv);
 }
 
diff --git a/src/rpc/virnetserver.h b/src/rpc/virnetserver.h
index 92f741a..d0231e5 100644
--- a/src/rpc/virnetserver.h
+++ b/src/rpc/virnetserver.h
@@ -46,16 +46,12 @@ virNetServerPtr virNetServerNew(size_t min_workers,
                                 virNetServerClientInitHook clientInitHook,
                                 void *opaque);
 
-typedef int (*virNetServerAutoShutdownFunc)(virNetServerPtr srv, void *opaque);
-
 void virNetServerRef(virNetServerPtr srv);
 
 bool virNetServerIsPrivileged(virNetServerPtr srv);
 
 void virNetServerAutoShutdown(virNetServerPtr srv,
-                              unsigned int timeout,
-                              virNetServerAutoShutdownFunc func,
-                              void *opaque);
+                              unsigned int timeout);
 
 typedef void (*virNetServerSignalFunc)(virNetServerPtr srv, siginfo_t *info, void *opaque);
 
-- 
1.7.7.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]