[PATCH] Add more debug logging for libvirtd startup

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

To facilitate future troubleshooting add a bunch more debugging
statements into important startup parts of libvirt
---
 daemon/libvirtd.c     |   40 +++++++++++++++++++++++++++++-----------
 src/libvirt.c         |   15 +++++++++------
 src/util/hooks.c      |    3 +++
 src/util/virnetlink.c |    1 +
 4 files changed, 42 insertions(+), 17 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index c1ee3f4..9c06344 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -461,6 +461,7 @@ static int daemonSetupNetworking(virNetServerPtr srv,
         goto error;
     }
 
+    VIR_DEBUG("Registering unix socket %s", sock_path);
     if (!(svc = virNetServerServiceNewUNIX(sock_path,
                                            unix_sock_rw_mask,
                                            unix_sock_gid,
@@ -469,15 +470,17 @@ static int daemonSetupNetworking(virNetServerPtr srv,
                                            config->max_client_requests,
                                            NULL)))
         goto error;
-    if (sock_path_ro &&
-        !(svcRO = virNetServerServiceNewUNIX(sock_path_ro,
-                                             unix_sock_ro_mask,
-                                             unix_sock_gid,
-                                             config->auth_unix_ro,
-                                             true,
-                                             config->max_client_requests,
-                                             NULL)))
-        goto error;
+    if (sock_path_ro) {
+        VIR_DEBUG("Registering unix socket %s", sock_path_ro);
+        if (!(svcRO = virNetServerServiceNewUNIX(sock_path_ro,
+                                                 unix_sock_ro_mask,
+                                                 unix_sock_gid,
+                                                 config->auth_unix_ro,
+                                                 true,
+                                                 config->max_client_requests,
+                                                 NULL)))
+            goto error;
+    }
 
     if (virNetServerAddService(srv, svc,
                                config->mdns_adv && !ipsock ?
@@ -491,6 +494,8 @@ static int daemonSetupNetworking(virNetServerPtr srv,
 
     if (ipsock) {
         if (config->listen_tcp) {
+            VIR_DEBUG("Registering TCP socket %s:%s",
+                      config->listen_addr, config->tcp_port);
             if (!(svcTCP = virNetServerServiceNewTCP(config->listen_addr,
                                                      config->tcp_port,
                                                      config->auth_tcp,
@@ -527,6 +532,8 @@ static int daemonSetupNetworking(virNetServerPtr srv,
                     goto error;
             }
 
+            VIR_DEBUG("Registering TLS socket %s:%s",
+                      config->listen_addr, config->tls_port);
             if (!(svcTLS =
                   virNetServerServiceNewTCP(config->listen_addr,
                                             config->tls_port,
@@ -1070,8 +1077,10 @@ int main(int argc, char **argv) {
     }
 
     if (!privileged &&
-        migrateProfile() < 0)
+        migrateProfile() < 0) {
+        VIR_ERROR(_("Exiting due to failure to migrate profile"));
         exit(EXIT_FAILURE);
+    }
 
     if (config->host_uuid &&
         virSetHostUUIDStr(config->host_uuid) < 0) {
@@ -1090,6 +1099,7 @@ int main(int argc, char **argv) {
         VIR_ERROR(_("Can't determine pid file path."));
         exit(EXIT_FAILURE);
     }
+    VIR_DEBUG("Decided on pid file path '%s'", NULLSTR(pid_file));
 
     if (daemonUnixSocketPaths(config,
                               privileged,
@@ -1098,6 +1108,8 @@ int main(int argc, char **argv) {
         VIR_ERROR(_("Can't determine socket paths"));
         exit(EXIT_FAILURE);
     }
+    VIR_DEBUG("Decided on socket paths '%s' and '%s'",
+              sock_file, NULLSTR(sock_file_ro));
 
     if (godaemon) {
         char ebuf[1024];
@@ -1135,6 +1147,7 @@ int main(int argc, char **argv) {
         old_umask = umask(022);
     else
         old_umask = umask(077);
+    VIR_DEBUG("Ensuring run dir '%s' exists", run_dir);
     if (virFileMakePath(run_dir) < 0) {
         char ebuf[1024];
         VIR_ERROR(_("unable to create rundir %s: %s"), run_dir,
@@ -1171,6 +1184,7 @@ int main(int argc, char **argv) {
     /* Beyond this point, nothing should rely on using
      * getuid/geteuid() == 0, for privilege level checks.
      */
+    VIR_DEBUG("Dropping privileges (if required)");
     if (daemonSetupPrivs() < 0) {
         ret = VIR_DAEMON_ERR_PRIVS;
         goto cleanup;
@@ -1207,11 +1221,13 @@ int main(int argc, char **argv) {
         goto cleanup;
     }
 
-    if (timeout != -1)
+    if (timeout != -1) {
+        VIR_DEBUG("Registering shutdown timeout %d", timeout);
         virNetServerAutoShutdown(srv,
                                  timeout,
                                  daemonShutdownCheck,
                                  NULL);
+    }
 
     if ((daemonSetupSignals(srv)) < 0) {
         ret = VIR_DAEMON_ERR_SIGNAL;
@@ -1219,11 +1235,13 @@ int main(int argc, char **argv) {
     }
 
     if (config->audit_level) {
+        VIR_DEBUG("Attempting to configure auditing subsystem");
         if (virAuditOpen() < 0) {
             if (config->audit_level > 1) {
                 ret = VIR_DAEMON_ERR_AUDIT;
                 goto cleanup;
             }
+            VIR_DEBUG("Proceeding without auditing");
         }
     }
     virAuditLog(config->audit_logging);
diff --git a/src/libvirt.c b/src/libvirt.c
index 16afd58..99e85e4 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -769,20 +769,23 @@ virRegisterStateDriver(virStateDriverPtr driver)
  * Returns 0 if all succeed, -1 upon any failure.
  */
 int virStateInitialize(int privileged) {
-    int i, ret = 0;
+    int i;
 
     if (virInitialize() < 0)
         return -1;
 
     for (i = 0 ; i < virStateDriverTabCount ; i++) {
-        if (virStateDriverTab[i]->initialize &&
-            virStateDriverTab[i]->initialize(privileged) < 0) {
-            VIR_ERROR(_("Initialization of %s state driver failed"),
+        if (virStateDriverTab[i]->initialize) {
+            VIR_DEBUG("Running global init for %s state driver",
                       virStateDriverTab[i]->name);
-            ret = -1;
+            if (virStateDriverTab[i]->initialize(privileged) < 0) {
+                VIR_ERROR(_("Initialization of %s state driver failed"),
+                          virStateDriverTab[i]->name);
+                return -1;
+            }
         }
     }
-    return ret;
+    return 0;
 }
 
 /**
diff --git a/src/util/hooks.c b/src/util/hooks.c
index f89a40f..e0d6bf0 100644
--- a/src/util/hooks.c
+++ b/src/util/hooks.c
@@ -271,6 +271,9 @@ virHookCall(int driver,
         return -1;
     }
 
+    VIR_DEBUG("Calling hook opstr=%s subopstr=%s extra=%s",
+              opstr, subopstr, extra);
+
     cmd = virCommandNewArgList(path, id, opstr, subopstr, extra, NULL);
 
     virCommandAddEnvPassCommon(cmd);
diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index 9539694..bb0dae9 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -130,6 +130,7 @@ virNetlinkStartup(void)
 {
     if (placeholder_nlhandle)
         return 0;
+    VIR_DEBUG("Running global netlink initialization");
     placeholder_nlhandle = virNetlinkAlloc();
     if (!placeholder_nlhandle) {
         virReportSystemError(errno, "%s",
-- 
1.7.10.2

--
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]