[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [PATCH 11/20] Add Setup/teardown of active device and logging to OnSuspend/OnShutdown
Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx> --- src/liteagent/LiteAgent.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++- src/liteagent/LiteAgent.h | 5 +++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/liteagent/LiteAgent.cpp b/src/liteagent/LiteAgent.cpp index a887925..bb17e91 100644 --- a/src/liteagent/LiteAgent.cpp +++ b/src/liteagent/LiteAgent.cpp @@ -149,7 +149,9 @@ static CLiteAgent s_service; return s_service.__ServiceControlHandlerEx(req, evt, data, ctxt); } -CLiteAgent::CLiteAgent() : m_handle(NULL), m_devs(GUID_INTERFACE_XENIFACE), m_dev(NULL) +CLiteAgent::CLiteAgent() : + m_handle(NULL), m_devs(GUID_INTERFACE_XENIFACE), m_dev(NULL), + m_ctxt_shutdown(NULL), m_ctxt_suspend(NULL), m_update(0) { m_status.dwServiceType = SERVICE_WIN32; m_status.dwCurrentState = SERVICE_START_PENDING; @@ -184,6 +186,18 @@ CLiteAgent::~CLiteAgent() m_dev = (CXenIfaceItf*)dev; // setting active device CLiteAgent::Log("Starting Active Device\n"); + + // register watch + m_dev->StoreAddWatch("control/shutdown", m_shutdown, &m_ctxt_shutdown); + // register suspend event + m_dev->SuspendRegister(m_suspend, &m_ctxt_suspend); + + // advertise + m_dev->StoreWrite("control/feature-shutdown", "1"); + // set xen time + SetXenTime(); + // kick xapi + KickXapi(); } } @@ -194,6 +208,18 @@ CLiteAgent::~CLiteAgent() m_dev = NULL; // active device removed CLiteAgent::Log("Active Device Removed\n"); + + // unadvertise + m_dev->StoreRemove("control/feature-shutdown"); + // kick xapi + KickXapi(); + + // unregister suspend event + m_dev->SuspendDeregister(m_ctxt_suspend); + m_ctxt_suspend = NULL; + // unregister watch + m_dev->StoreRemoveWatch(m_ctxt_shutdown); + m_ctxt_shutdown = NULL; } } @@ -241,6 +267,8 @@ void CLiteAgent::OnShutdown() if (m_dev == NULL) return; CLiteAgent::Log("OnShutdown(%ws)\n", m_dev->Path()); + + // check shutdown type and enact shutdown } void CLiteAgent::OnSuspend() @@ -248,6 +276,27 @@ void CLiteAgent::OnSuspend() if (m_dev == NULL) return; CLiteAgent::Log("OnSuspend(%ws)\n", m_dev->Path()); + + // advertise + m_dev->StoreWrite("control/feature-shutdown", "1"); + // set xen time + SetXenTime(); + // kick xapi + KickXapi(); +} + +void CLiteAgent::SetXenTime() +{ + CLiteAgent::Log("SetXenTime()\n"); +} + +void CLiteAgent::KickXapi() +{ + char value[32]; + _snprintf_s(value, sizeof(value), 31, "%I64d", m_update); + m_dev->StoreWrite("data/update_cnt", value); + m_dev->StoreWrite("data/updated", "1"); + ++m_update; } void CLiteAgent::SetServiceStatus(DWORD state, DWORD exit /*= 0*/, DWORD hint /*= 0*/) diff --git a/src/liteagent/LiteAgent.h b/src/liteagent/LiteAgent.h index b19d8e2..a95c394 100644 --- a/src/liteagent/LiteAgent.h +++ b/src/liteagent/LiteAgent.h @@ -70,6 +70,8 @@ private: // service events void OnShutdown(); void OnSuspend(); + void SetXenTime(); + void KickXapi(); private: // service support void SetServiceStatus(DWORD state, DWORD exit = 0, DWORD hint = 0); @@ -84,6 +86,9 @@ private: // service support CDeviceList m_devs; CXenIfaceItf* m_dev; + void* m_ctxt_shutdown; + void* m_ctxt_suspend; + int m_update; }; #endif -- 1.9.4.msysgit.1 _______________________________________________ win-pv-devel mailing list win-pv-devel@xxxxxxxxxxxxxxxxxxxx http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |