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

Richard W.M. Jones rjones at redhat.com
Mon Mar 10 11:47:57 UTC 2008


On Sun, Mar 09, 2008 at 08:59:24PM +0000, Daniel P. Berrange wrote:
> 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.
[...]
> 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:

+1 to this patch.

There's another problem I've noticed.  If you start the daemon and TLS
is enabled in the config and there is no /etc/pki directory, then the
daemon exits with an error but doesn't clean up the bridge, meaning
that next time you start the daemon the default network cannot be
created.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top




More information about the libvir-list mailing list