[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[win-pv-devel] [PATCH 1/2] Add log message if Windows Update requires a reboot



From: Owen Smith <owen.smith@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 src/xenagent/service.cpp | 22 ++++++++++++++++++++++
 src/xenagent/service.h   |  1 +
 2 files changed, 23 insertions(+)

diff --git a/src/xenagent/service.cpp b/src/xenagent/service.cpp
index 0b44186..e2a6c03 100644
--- a/src/xenagent/service.cpp
+++ b/src/xenagent/service.cpp
@@ -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)
diff --git a/src/xenagent/service.h b/src/xenagent/service.h
index 60ecb16..e2e5e5c 100644
--- a/src/xenagent/service.h
+++ b/src/xenagent/service.h
@@ -74,6 +74,7 @@ public:
     HANDLE  m_evt_slate_mode;
 
 private:
+    void LogIfRebootPending();
     void StartShutdownWatch();
     void StopShutdownWatch();
     void StartSlateModeWatch();
-- 
2.8.3


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.