]> xenbits.xensource.com Git - people/pauldu/xeniface.git/commitdiff
Add log message if Windows Update requires a reboot
authorOwen Smith <owen.smith@citrix.com>
Fri, 3 Nov 2017 17:39:21 +0000 (17:39 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Fri, 3 Nov 2017 17:39:21 +0000 (17:39 +0000)
When Windows requires a reboot to install updates, the reboot and shutdown
operations can take a long time. The agent will have acknowledged the
request, but the operation may not complete in a suitable timeout period.
Add a log entry to help indicate an additional unknown amount of time
will be required for shutdown/reboot.

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

index 0b441864a93353666a589314703c0887243e2b01..e2a6c0301187bec8084aec8976df6670f7743134 100644 (file)
@@ -87,6 +87,10 @@ bool CXenIfaceCreator::Start(HANDLE svc)
 
 void CXenIfaceCreator::Stop()
 {
+    // Check if registry key is present, implies Windows Update
+    // require a reboot, which may spend time installing updates
+    LogIfRebootPending();
+
     m_devlist.Stop();
 }
 
@@ -280,6 +284,24 @@ bool CXenIfaceCreator::CheckSlateMode(std::string *mode)
     return true;
 }
 
+void CXenIfaceCreator::LogIfRebootPending()
+{
+    HKEY Key;
+    LONG lResult;
+
+    lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+                           "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Auto Update\\RebootRequired",
+                           0,
+                           KEY_READ,
+                           &Key);
+    if (lResult != ERROR_SUCCESS)
+        return; // key doesnt exist, dont log anything
+
+    RegCloseKey(Key);
+
+    CXenAgent::Log("RebootRequired detected\n");
+}
+
 void CXenIfaceCreator::StartShutdownWatch()
 {
     if (m_ctxt_shutdown)
index 60ecb16b26e187c2263677edd71b8a1140325637..e2e5e5c601a75ba851757ad9f7254ff623051bb6 100644 (file)
@@ -74,6 +74,7 @@ public:
     HANDLE  m_evt_slate_mode;
 
 private:
+    void LogIfRebootPending();
     void StartShutdownWatch();
     void StopShutdownWatch();
     void StartSlateModeWatch();