From db87bf359134fc7634f17d0882922f18423adc21 Mon Sep 17 00:00:00 2001 From: Paul Durrant Date: Fri, 29 Jul 2016 15:22:37 +0100 Subject: [PATCH] xenagent: use spec. compliant control/feature-XXX keys control/feature-shutdown is not documented in Xen's xenstore-paths documentation. The correct keys are feature-poweroff, feature-reboot, feature-s3 and feature-s4. Also the values that the toolstack should write control/shutdown are poweroff, reboot, s3 and s4 so the xenagent should only respond to these values. Signed-off-by: Paul Durrant Cc: Owen Smith --- src/xenagent/messages.mc | 4 ++-- src/xenagent/service.cpp | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/xenagent/messages.mc b/src/xenagent/messages.mc index 0289c44..6b60c8d 100644 --- a/src/xenagent/messages.mc +++ b/src/xenagent/messages.mc @@ -20,9 +20,9 @@ The tools requested that the local VM reboot. MessageId=0x0003 Facility=XenUser Severity=Informational -SymbolicName=EVENT_XENUSER_HIBERNATE +SymbolicName=EVENT_XENUSER_S4 Language=English -The tools requested that the local VM hibernate itself. +The tools requested that the local VM enter power state S4. . MessageId=0x0004 diff --git a/src/xenagent/service.cpp b/src/xenagent/service.cpp index 182752f..80aac11 100644 --- a/src/xenagent/service.cpp +++ b/src/xenagent/service.cpp @@ -220,7 +220,10 @@ CXenAgent::~CXenAgent() // shutdown m_device->StoreAddWatch("control/shutdown", m_evt_shutdown, &m_ctxt_shutdown); - m_device->StoreWrite("control/feature-shutdown", "1"); + m_device->StoreWrite("control/feature-poweroff", "1"); + m_device->StoreWrite("control/feature-reboot", "1"); + m_device->StoreWrite("control/feature-s3", "1"); + m_device->StoreWrite("control/feature-s4", "1"); // suspend m_device->SuspendRegister(m_evt_suspend, &m_ctxt_suspend); @@ -241,7 +244,10 @@ CXenAgent::~CXenAgent() m_ctxt_suspend = NULL; // shutdown - m_device->StoreRemove("control/feature-shutdown"); + m_device->StoreRemove("control/feature-poweroff"); + m_device->StoreRemove("control/feature-reboot"); + m_device->StoreRemove("control/feature-s3"); + m_device->StoreRemove("control/feature-s4"); if (m_ctxt_shutdown) m_device->StoreRemoveWatch(m_ctxt_shutdown); m_ctxt_shutdown = NULL; @@ -451,7 +457,7 @@ void CXenAgent::OnShutdown() CXenAgent::Log("OnShutdown(%ws) = %s\n", m_device->Path(), type.c_str()); - if (type == "poweroff" || type == "halt") { + if (type == "poweroff") { EventLog(EVENT_XENUSER_POWEROFF); m_device->StoreWrite("control/shutdown", ""); @@ -473,8 +479,8 @@ void CXenAgent::OnShutdown() SHTDN_REASON_FLAG_PLANNED)) { CXenAgent::Log("InitiateSystemShutdownEx failed %08x\n", GetLastError()); } - } else if (type == "hibernate") { - EventLog(EVENT_XENUSER_HIBERNATE); + } else if (type == "s4") { + EventLog(EVENT_XENUSER_S4); m_device->StoreWrite("control/shutdown", ""); AcquireShutdownPrivilege(); @@ -507,7 +513,11 @@ void CXenAgent::OnSuspend() m_ctxt_shutdown = NULL; m_device->StoreAddWatch("control/shutdown", m_evt_shutdown, &m_ctxt_shutdown); - m_device->StoreWrite("control/feature-shutdown", "1"); + m_device->StoreWrite("control/feature-poweroff", "1"); + m_device->StoreWrite("control/feature-reboot", "1"); + m_device->StoreWrite("control/feature-s3", "1"); + m_device->StoreWrite("control/feature-s4", "1"); + SetXenTime(); } -- 2.39.5