]> xenbits.xensource.com Git - people/pauldu/xeniface.git/commitdiff
Log messages to dom0 log (if possible)
authorOwen Smith <owen.smith@citrix.com>
Wed, 20 Jul 2016 12:02:13 +0000 (13:02 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Fri, 22 Jul 2016 10:33:24 +0000 (11:33 +0100)
IoctlLog will strip any trailing newline and insert a single
newline to enforce log file consistancy

Signed-off-by: Owen Smith <owen.smith@citrix.com>
src/xenagent/service.cpp
src/xeniface/ioctls.c

index 55dc8cab9e6d655747be5f51ae8badabf811132d..182752f1a60beaf60d2175f224602c24fb937a03 100644 (file)
@@ -81,6 +81,12 @@ static CXenAgent s_service;
     va_end(args);
 
     OutputDebugString(message);
+
+    // if possible, send to xeniface to forward to logs
+    CCritSec crit(&s_service.m_crit);
+    if (s_service.m_device) {
+        s_service.m_device->Log(message);
+    }
 }
 
 /*static*/ int CXenAgent::ServiceInstall()
index ca946580526687c18321daa1bb794f4709163f1b..ca2cf1cc2970b4d378b0daa71b0cf565d6c74bdf 100644 (file)
@@ -113,6 +113,7 @@ IoctlLog(
     )
 {
     NTSTATUS    status;
+       PCHAR           ptr;
 
     status = STATUS_INVALID_BUFFER_SIZE;
     if (InLen == 0 || InLen > XENIFACE_LOG_MAX_LENGTH || OutLen != 0)
@@ -122,6 +123,11 @@ IoctlLog(
     if (!__IsValidStr(Buffer, InLen))
         goto fail2;
 
+       // remove newlines from end of buffer
+       for (ptr = Buffer + InLen - 1;
+                ptr != Buffer && *ptr != 0 && *ptr != '\n';
+                --ptr)
+                       *ptr = 0;
     XenIfaceDebugPrint(INFO, "USER: %s\n", Buffer);
     return STATUS_SUCCESS;