From: Peter Dinda Date: Tue, 19 Jun 2012 21:28:09 +0000 (-0500) Subject: Prefaced output from V3_Print on linux module X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=ad00932be31579b80f80c1cc67677bd3c263fd89;hp=791ea2f3e21cfbc9c47341efbb98995c33d86fcb;p=palacios.git Prefaced output from V3_Print on linux module --- diff --git a/linux_module/palacios-stubs.c b/linux_module/palacios-stubs.c index a8f2923..de6dddd 100644 --- a/linux_module/palacios-stubs.c +++ b/linux_module/palacios-stubs.c @@ -40,16 +40,48 @@ extern int cpu_list[NR_CPUS]; extern int cpu_list_len; + + /** * Prints a message to the console. */ static void palacios_print(const char * fmt, ...) { + +#if V3_PRINTK_OLD_STYLE_OUTPUT + va_list ap; + va_start(ap, fmt); vprintk(fmt, ap); va_end(ap); - + + return + +#else + + va_list ap; + char *buf; + + // Allocate space atomically, in case we are called + // with a lock held + buf = kmalloc(V3_PRINTK_BUF_SIZE, GFP_ATOMIC); + if (!buf) { + printk("palacios: output skipped - unable to allocate\n"); + return; + } + + va_start(ap, fmt); + vsnprintf(buf,V3_PRINTK_BUF_SIZE, fmt, ap); + va_end(ap); + + printk(KERN_INFO "palacios: %s",buf); + + kfree(buf); + return; + +#endif + } diff --git a/linux_module/palacios.h b/linux_module/palacios.h index 7b48adb..6bb7271 100644 --- a/linux_module/palacios.h +++ b/linux_module/palacios.h @@ -47,11 +47,16 @@ // KERN_DEBUG "<7>" /* debug-level messages */ // All 'printk's should be changed to one of these macros, for easier control -#define ERROR(fmt, args...) printk((KERN_ERR fmt), ##args) -#define WARNING(fmt, args...) printk((KERN_WARNING fmt), ##args) -#define NOTICE(fmt, args...) printk((KERN_NOTICE fmt), ##args) -#define INFO(fmt, args...) printk((KERN_INFO fmt), ##args) -#define DEBUG(fmt, args...) printk((KERN_DEBUG fmt), ##args) +#define ERROR(fmt, args...) printk((KERN_ERR "palacios: " fmt), ##args) +#define WARNING(fmt, args...) printk((KERN_WARNING "palacios: " fmt), ##args) +#define NOTICE(fmt, args...) printk((KERN_NOTICE "palacios: " fmt), ##args) +#define INFO(fmt, args...) printk((KERN_INFO "palacios: " fmt), ##args) +#define DEBUG(fmt, args...) printk((KERN_DEBUG "palacios: " fmt), ##args) + +// Turn this on for unprefaced output +#define V3_PRINTK_OLD_STYLE_OUTPUT 0 +// Maximum length output from printk +#define V3_PRINTK_BUF_SIZE 1024 struct v3_guest_img { unsigned long long size;