Пример #1
0
        private XenClientGuestWCFService(Udbus.Core.Logging.ILog log)
        {
            this.log = log;

            // Initialize the uuid field from XenStore.
            XenStoreLib.XenStoreWrapper xenStoreWrapper = new XenStoreLib.XenStoreWrapper();
            string vm       = xenStoreWrapper.ReadString("vm");
            string uuidPath = string.Format("{0}/uuid", vm);

            this.uuid_ = xenStoreWrapper.ReadString(uuidPath);

            // Work out the install directory.
            this.installDir = System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("PROGRAMFILES") ?? "C:\\Program Files", "Citrix");
            this.installDir = System.IO.Path.Combine(installDir, "XenGuestPlugin");

            Microsoft.Win32.RegistryKey installKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(InstallRegkeyName);
            if (installKey != null)
            {
                string installVal = (string)installKey.GetValue(XcInstallDirName);
                if (!string.IsNullOrEmpty(installVal))
                {
                    this.installDir = installVal;
                }
            }
        }
Пример #2
0
        static public LogTraceSource ReplaceRoot(Udbus.Core.Logging.ILog logOld, string name, IEnumerable <System.Diagnostics.TraceSource> tracesources)
        {
            LogTraceSource create      = new LogTraceSource(tracesources);
            ILogNode       logNodeRoot = new LogNodeNameHierarchyRoot(name, create);

            Replace(logOld, create, logNodeRoot);
            return(create);
        }
Пример #3
0
 static public void RegisterForSignal(Udbus.Core.SignalEntry signalEntry, params Udbus.Core.IRegisterSignalHandlers[] registers)
 {
     Udbus.Core.Logging.ILog log = Udbus.Core.Logging.LogCreation.CreateRegisterSignalHandlerFunctionsLogger();
     log.Info("Registering signal: {0}", signalEntry.ToString());
     foreach (Udbus.Core.IRegisterSignalHandlers register in registers)
     {
         log.Info("Registering signal with {0}", register);
         register.AddSignalHandler(signalEntry);
     }
 }
Пример #4
0
        public static DDumpMessage CreateMessageDumper(Udbus.Core.Logging.ILog log)
        {
            DDumpMessage result = delegate(UdbusMessagePair messageData, string description)
            {
                if (!messageData.QuEmpty)
                {
                    log.Info("{0}. {1}", description, messageData.Data.ToString());
                }
                else
                {
                    log.Info("No message. {0}", description);
                }
            };

            return(result);
        }
        public XenClientGuestService()
        {
            // EventSource needs to be something for logging not to throw exception.
            bool bNoSource = string.IsNullOrEmpty(this.EventLog.Source);

            if (bNoSource) // If no source string setup
            {
                if (!string.IsNullOrEmpty(this.ServiceName))
                {
                    this.EventLog.Source = this.ServiceName;
                }
                else
                {
                    this.EventLog.Source = Logging.LogCreation.Service;
                }
            } // Ends if no source string setup

            log = Logging.LogCreation.CreateServiceLogger(this); // Log pre initialised service.
            Udbus.Core.Logging.ILog logRoot = Logging.LogCreation.CreateRootLogger(this); // Root logger pre initialised service.

            InitializeComponent();

            // Try to ammend event source name to something more meaningful.
            if (bNoSource && !string.IsNullOrEmpty(this.ServiceName)) // If no source string setup
            {
                this.EventLog.Source = this.ServiceName;
            } // Ends if no source string setup

            logRoot = Logging.LogCreation.ReplaceRootLogger(this, logRoot); // Root logger
            log     = Logging.LogCreation.ReplaceServiceLogger(this, log); // Log post initialised service.

            // Initialize fields.
            this.dbusHosts = new DbusHosts(this.EventLog);
            Udbus.Core.ServiceConnectionParams serviceConnectionParams;
            this.diagSignals = XcDiagRunner.CreateDbusDiag(out serviceConnectionParams, log, Log_Io_Debug);
            this.diagSignals.GatherRequest += this.OnGatherRequest;
            System.Threading.Thread xcdiagSignalsThread;
            this.diagsignalsThreadInfo = DbusHosts.RunSignalsAsync(out xcdiagSignalsThread, serviceConnectionParams);

            //We're gonna start doing our own thing logs wise...
            if (!EventLog.SourceExists("XenClientGuestService"))
            {
                EventLog.CreateEventSource("XenClientGuestService", "Application");
            }
            EventLog.WriteEntry("XenClientGuestService", "XenClientGuestService Logs Initialised");
        }
Пример #6
0
        internal static com.citrix.xenclient.xenmgr.diag.diagService CreateDbusDiag(out Udbus.Core.ServiceConnectionParams serviceConnectionParams,
                                                                                    Udbus.Core.Logging.ILog log, Udbus.Serialization.UdbusDelegates.D_io_debug io_debug)
        {
            // Create a V4V connection.
            Udbus.v4v.v4vConnection           connection;
            System.Threading.ManualResetEvent stop = new System.Threading.ManualResetEvent(false);
            DbusHosts.GetV4vConnection(out connection, out serviceConnectionParams,
                                       io_debug, stop,
                                       log
                                       );

            // Use dbus interface to xenmgr.diag.
            Udbus.Serialization.DbusConnectionParameters dbusConnectionParameters = com.citrix.xenclient.xenmgr.diag.diagService.DefaultConnectionParameters;
            dbusConnectionParameters.Destination = "com.citrix.xenclient.xenmgr";
            com.citrix.xenclient.xenmgr.diag.diagService diag = com.citrix.xenclient.xenmgr.diag.diagService.Create(serviceConnectionParams, dbusConnectionParameters);

            return(diag);
        }
        public XenClientGuestService()
        {
            // EventSource needs to be something for logging not to throw exception.
            bool bNoSource = string.IsNullOrEmpty(this.EventLog.Source);
            if (bNoSource) // If no source string setup
            {
                if (!string.IsNullOrEmpty(this.ServiceName))
                {
                    this.EventLog.Source = this.ServiceName;
                }
                else
                {
                    this.EventLog.Source = Logging.LogCreation.Service;
                }

            } // Ends if no source string setup

            log = Logging.LogCreation.CreateServiceLogger(this); // Log pre initialised service.
            Udbus.Core.Logging.ILog logRoot = Logging.LogCreation.CreateRootLogger(this); // Root logger pre initialised service.

            InitializeComponent();

            // Try to ammend event source name to something more meaningful.
            if (bNoSource && !string.IsNullOrEmpty(this.ServiceName)) // If no source string setup
            {
                this.EventLog.Source = this.ServiceName;

            } // Ends if no source string setup

            logRoot = Logging.LogCreation.ReplaceRootLogger(this, logRoot); // Root logger
            log = Logging.LogCreation.ReplaceServiceLogger(this, log); // Log post initialised service.

            // Initialize fields.
            this.dbusHosts = new DbusHosts(this.EventLog);
            Udbus.Core.ServiceConnectionParams serviceConnectionParams;
            this.diagSignals = XcDiagRunner.CreateDbusDiag(out serviceConnectionParams, log, Log_Io_Debug);
            this.diagSignals.GatherRequest += this.OnGatherRequest;
            System.Threading.Thread xcdiagSignalsThread;
            this.diagsignalsThreadInfo = DbusHosts.RunSignalsAsync(out xcdiagSignalsThread, serviceConnectionParams);

            //We're gonna start doing our own thing logs wise...
            if (!EventLog.SourceExists("XenClientGuestService")) EventLog.CreateEventSource("XenClientGuestService", "Application");
            EventLog.WriteEntry("XenClientGuestService", "XenClientGuestService Logs Initialised");
        }
Пример #8
0
        public static void GetV4vConnection(out Udbus.v4v.v4vConnection connection, out Udbus.Core.ServiceConnectionParams serviceConnectionParams,
                                            Udbus.Serialization.UdbusDelegates.D_io_debug io_debug, System.Threading.ManualResetEvent stop,
                                            Udbus.Core.Logging.ILog log)
        {
            connection = null;
            serviceConnectionParams = null;

            while (serviceConnectionParams == null)
            {
                using (Udbus.v4v.v4vConnection connectionTemp = KeepTryingToConnectToV4V(io_debug, stop, log))
                {
                    if (connectionTemp != null) // If got v4v connection
                    {
                        Udbus.v4v.v4vConnection connectionTemp2 = connectionTemp.Release();
                        try
                        {
                            Udbus.Core.ServiceConnectionParams serviceConnectionParamsTemp = TryServiceConnectionParams(connectionTemp2, log);

                            if (serviceConnectionParamsTemp == null) // If failed to create service connection
                            {
                                connectionTemp.Swap(connectionTemp2);
                            }    // Ends if failed to create service connection
                            else // Else created service connection
                            {
                                serviceConnectionParams = serviceConnectionParamsTemp;
                                connection = connectionTemp2;
                            } // Ends else created service connection
                        }
                        catch (Exception /*ex*/)
                        {
                            connectionTemp.Swap(connectionTemp2);
                            throw;
                        }
                    } // Ends if got v4v connection
                }     // Ends using v4vConnection

                if (serviceConnectionParams == null) // If failed to create connection
                {
                    // Wait a while.
                    System.Threading.Thread.Sleep(ConnectionWaitMilliseconds);
                } // Ends if failed to create connection
            }     // Ends while trying to setup service connection
        }
        private XenClientGuestWCFService(Udbus.Core.Logging.ILog log)
        {
            this.log = log;

            // Initialize the uuid field from XenStore.
            XenStoreLib.XenStoreWrapper xenStoreWrapper = new XenStoreLib.XenStoreWrapper();
            string vm = xenStoreWrapper.ReadString("vm");
            string uuidPath = string.Format("{0}/uuid", vm);
            this.uuid_ = xenStoreWrapper.ReadString(uuidPath);

            // Work out the install directory.
            this.installDir = System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("PROGRAMFILES") ?? "C:\\Program Files", "Citrix");
            this.installDir = System.IO.Path.Combine(installDir, "XenGuestPlugin");

            Microsoft.Win32.RegistryKey installKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(InstallRegkeyName);
            if (installKey != null)
            {
                string installVal = (string)installKey.GetValue(XcInstallDirName);
                if (!string.IsNullOrEmpty(installVal))
                {
                    this.installDir = installVal;
                }
            }
        }
Пример #10
0
        static private Udbus.v4v.v4vConnection TryV4VConnection(Udbus.Serialization.UdbusDelegates.D_io_debug io_debug, Udbus.Core.Logging.ILog log)
        {
            Udbus.v4v.v4vConnection result = null;

            try
            {
                Udbus.v4v.v4vConnection create = new Udbus.v4v.v4vConnection(io_debug);
                result = create;
            }
            catch (Udbus.Serialization.Exceptions.TransportFailureException transportEx)
            {
                log.Exception("Failed to create V4V transport. {0}", transportEx);
            }
            catch (Exception ex)
            {
                log.Exception("Error creating V4V transport. {0}", ex);
            }

            return(result);
        }
Пример #11
0
 public DbusHosts(System.Diagnostics.EventLog eventLog)
 {
     this.log        = Logging.LogCreation.CreateDbusHostsLogger(this, eventLog);
     this.logIoDebug = Logging.LogCreation.CreateIoDebugLogger(eventLog);
 }
Пример #12
0
        static private Udbus.v4v.v4vConnection KeepTryingToConnectToV4V(Udbus.Serialization.UdbusDelegates.D_io_debug io_debug, System.Threading.ManualResetEvent stop, Udbus.Core.Logging.ILog log)
        {
            Udbus.v4v.v4vConnection connection = TryV4VConnection(io_debug, log);

            while (connection == null && stop.WaitOne(0) == false)
            {
                System.Threading.Thread.Sleep(ConnectionWaitMilliseconds);
                connection = TryV4VConnection(io_debug, log);
            } // Ends while failed to connect to V4V

            return(connection);
        }
Пример #13
0
 public DbusHosts()
 {
     this.log = Logging.LogCreation.CreateDbusHostsLogger(this);
     this.logIoDebug = Logging.LogCreation.CreateIoDebugLogger();
 }
Пример #14
0
 public DbusHosts()
 {
     this.log        = Logging.LogCreation.CreateDbusHostsLogger(this);
     this.logIoDebug = Logging.LogCreation.CreateIoDebugLogger();
 }
Пример #15
0
 public DbusHosts(System.Diagnostics.EventLog eventLog)
 {
     this.log = Logging.LogCreation.CreateDbusHostsLogger(this, eventLog);
     this.logIoDebug = Logging.LogCreation.CreateIoDebugLogger(eventLog);
 }
Пример #16
0
        static private Udbus.Core.ServiceConnectionParams TryServiceConnectionParams(Udbus.v4v.v4vConnection connection, Udbus.Core.Logging.ILog log)
        {
            Udbus.Core.ServiceConnectionParams result = null;

            try
            {
                Udbus.Core.ServiceConnectionParams create = new Udbus.Core.ServiceConnectionParams(connection);
                result = create;
            }
            catch (Udbus.Serialization.Exceptions.UdbusAuthorisationException authex)
            {
                log.Exception("Authorisation Error creating ServiceConnectionParams. {0}", authex);
            }
            catch (Exception ex)
            {
                log.Exception("Error creating ServiceConnectionParams. {0}", ex);
            }
            return(result);
        }
Пример #17
0
 private XcDiagRunner(Udbus.Core.Logging.ILog log)
 {
     this.log = log;
 }
Пример #18
0
        static private bool SetRegistryValue(Microsoft.Win32.RegistryKey key, string name, string value, Udbus.Core.Logging.ILog log)
        {
            bool result = false;

            try
            {
                key.SetValue(name, value);
                result = true;
            }
            catch (System.ArgumentNullException argnullEx)
            {
                if (log != null)
                {
                    log.Exception("Failed to set registry key (argument null) \"{0}\\{1}\" to \"{2}\". {3}", key.Name, name, value, argnullEx);
                }
            }
            catch (System.ArgumentException argEx)
            {
                if (log != null)
                {
                    log.Exception("Failed to set registry key (argument exception) \"{0}\\{1}\" to \"{2}\". {3}", key.Name, name, value, argEx);
                }
            }
            catch (System.ObjectDisposedException objdispEx)
            {
                if (log != null)
                {
                    log.Exception("Failed to set registry key (object disposed) \"{0}\\{1}\" to \"{2}\". {3}", key.Name, name, value, objdispEx);
                }
            }
            catch (System.UnauthorizedAccessException unauthEx)
            {
                if (log != null)
                {
                    log.Exception("Failed to set registry key (unauthorised) \"{0}\\{1}\" to \"{2}\". {3}", key.Name, name, value, unauthEx);
                }
            }
            catch (System.Security.SecurityException secEx)
            {
                if (log != null)
                {
                    log.Exception("Failed to set registry key (security exception) \"{0}\\{1}\" to \"{2}\". {3}", key.Name, name, value, secEx);
                }
            }
            catch (System.IO.IOException ioEx)
            {
                if (log != null)
                {
                    log.Exception("Failed to set registry key (io exception) \"{0}\\{1}\" to \"{2}\". {3}", key.Name, name, value, ioEx);
                }
            }

            return(result);
        }
Пример #19
0
 public UdbusMessageVisitorDumpLog(Udbus.Core.Logging.ILog log)
     : base(CreateMessageDumper(log), CreateMessageDumper(log))
 {
 }
Пример #20
0
        } // Ends struct RunInThreadArgs
        #endregion // Internal structs/classes

        #region Constructors
        private XcDiagRunner(Udbus.Core.Logging.ILog log)
        {
            this.log = log;
        }
Пример #21
0
 internal static Udbus.Core.Logging.ILog ReplaceServiceLogger(System.ServiceProcess.ServiceBase service, Udbus.Core.Logging.ILog log)
 {
     return(Udbus.Core.Logging.LogCreation.ReplaceFormatLogger(log, defaultSourceLevel, assertServiceName(service.ServiceName), defaultFormat, MakeListenersForService(service)));
 }
Пример #22
0
 static public LogTraceSource ReplaceRoot(Udbus.Core.Logging.ILog logOld, string name, params System.Diagnostics.TraceSource[] tracesources)
 {
     return(ReplaceRoot(logOld, name, tracesources as IEnumerable <System.Diagnostics.TraceSource>));
 }
Пример #23
0
 /// <summary>
 /// Log debug output.
 /// </summary>
 /// <param name="logpriv">Reserved.</param>
 /// <param name="buf">String to log.</param>
 protected static void Service_io_debug(IntPtr logpriv, String buf)
 {
     Udbus.Core.Logging.ILog log = Udbus.Core.Logging.LogCreation.CreateDbusServiceLogger();
     log.Info(buf);
 }