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

[Libvir] PATCH: Fix libvirtd to not shutdown at startup



Changes to the daemon to make it called qemudShutdown() broke the network
driver when run in --daemon mode. This is because the main daemon forks
into the background, and the original PID then exits destroying any active
networks & removing the iptables rules.

 # /usr/sbin/libvirtd --daemon
Shutting down network 'default'iptables: No chain/target/match by that name
iptables: Bad rule (does a matching rule exist in that chain?)
iptables: Bad rule (does a matching rule exist in that chain?)
iptables: Bad rule (does a matching rule exist in that chain?)
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: Bad rule (does a matching rule exist in that chain?)
iptables: Bad rule (does a matching rule exist in that chain?)
iptables: Bad rule (does a matching rule exist in that chain?)
iptables: Bad rule (does a matching rule exist in that chain?)
Failed to bring down bridge 'virbr0' : No such device
Failed to delete bridge 'virbr0' : No such device or address

The core issue is that when forking into daemon mode the original process
should immediately exit & not do invoke cleanup functions. This patch
makes it do that

Dan.

Index: qemud/qemud.c
===================================================================
RCS file: /data/cvs/libvirt/qemud/qemud.c,v
retrieving revision 1.89
diff -u -r1.89 qemud.c
--- qemud/qemud.c	3 Mar 2008 18:10:19 -0000	1.89
+++ qemud/qemud.c	9 Mar 2008 20:56:27 -0000
@@ -393,7 +393,7 @@
             case -1:
                 return -1;
             default:
-                return nextpid;
+                _exit(0);
             }
 
         cleanup:
@@ -418,8 +418,7 @@
                 status != 0) {
                 return -1;
             }
-
-            return pid;
+            _exit(0);
         }
     }
 }
@@ -2116,16 +2115,12 @@
         goto error1;
 
     if (godaemon) {
-        int pid;
         openlog("libvirtd", 0, 0);
-        pid = qemudGoDaemon();
-        if (pid < 0) {
+        if (qemudGoDaemon() < 0) {
             qemudLog(QEMUD_ERR, _("Failed to fork as daemon: %s"),
                      strerror(errno));
             goto error1;
         }
-        if (pid > 0)
-            goto out;
 
         /* Choose the name of the PID file. */
         if (!pid_file) {
@@ -2172,7 +2167,6 @@
     if (godaemon)
         closelog();
 
- out:
     ret = 0;
 
  error2:


-- 
|: Red Hat, Engineering, Boston   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


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