From: Daniel P. Berrange Date: Fri, 7 May 2010 12:42:11 +0000 (+0100) Subject: Add env variable for debugging gnutls usage X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=36a03bd2eed1a10b0c6e7aea108b037ae0a6ecae;p=libvirt.git Add env variable for debugging gnutls usage 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 --- diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 72cf2925c7..bd7d617ace 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -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) {