]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add env variable for debugging gnutls usage
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 7 May 2010 12:42:11 +0000 (13:42 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 11 May 2010 14:54:38 +0000 (15:54 +0100)
Allow debugging of GNUTLS interactions by setting

  LIBVIRT_GNUTLS_DEBUG=10 LIBVIRT_DEBUG=1 virsh

* src/remote/remote_driver.c: Use LIBVIRT_GNUTLS_DEBUG to
  enable gnutls debugging

src/remote/remote_driver.c

index 72cf2925c7aea6c74450c0d0be23483ea78a035f..bd7d617ace2b7b979851a676fcde537f6c9d6158 100644 (file)
@@ -1138,16 +1138,29 @@ check_cert_file(const char *type, const char *file)
 }
 
 
+static void remote_debug_gnutls_log(int level, const char* str) {
+    DEBUG("%d %s", level, str);
+}
+
 static int
 initialize_gnutls(void)
 {
     static int initialized = 0;
     int err;
+    char *gnutlsdebug;
 
     if (initialized) return 0;
 
     gnutls_global_init ();
 
+    if ((gnutlsdebug = getenv("LIBVIRT_GNUTLS_DEBUG")) != NULL) {
+        int val;
+        if (virStrToLong_i(gnutlsdebug, NULL, 10, &val) < 0)
+            val = 10;
+        gnutls_global_set_log_level(val);
+        gnutls_global_set_log_function(remote_debug_gnutls_log);
+    }
+
     /* X509 stuff */
     err = gnutls_certificate_allocate_credentials (&x509_cred);
     if (err) {