Index: /trunk/include/VBox/dbus-calls.h
===================================================================
--- /trunk/include/VBox/dbus-calls.h	(revision 55601)
+++ /trunk/include/VBox/dbus-calls.h	(revision 55602)
@@ -125,4 +125,6 @@
                   DBusHandleMessageFunction function, void *pvoid), \
                  (connection, function, pvoid)) \
+ RT_PROXY_STUB(dbus_connection_read_write, dbus_bool_t, \
+                 (DBusConnection *connection, int val), (connection, val)) \
  RT_PROXY_STUB(dbus_connection_read_write_dispatch, dbus_bool_t, \
                  (DBusConnection *connection, int val), (connection, val)) \
Index: /trunk/src/VBox/Main/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Main/Makefile.kmk	(revision 55601)
+++ /trunk/src/VBox/Main/Makefile.kmk	(revision 55602)
@@ -430,4 +430,5 @@
 	src-server/linux/HostHardwareLinux.cpp \
 	src-server/linux/HostDnsServiceLinux.cpp \
+	src-server/linux/HostPowerLinux.cpp \
 	src-server/HostDnsServiceResolvConf.cpp
 
Index: /trunk/src/VBox/Main/include/HostPower.h
===================================================================
--- /trunk/src/VBox/Main/include/HostPower.h	(revision 55601)
+++ /trunk/src/VBox/Main/include/HostPower.h	(revision 55602)
@@ -23,4 +23,8 @@
 
 #include <vector>
+
+#ifdef RT_OS_LINUX
+# include <VBox/dbus.h>
+#endif
 
 #ifdef RT_OS_DARWIN
@@ -60,4 +64,27 @@
     RTTHREAD    mThread;
 };
+#elif defined(RT_OS_LINUX)
+/**
+ * The Linux hosted Power Service.
+ */
+class HostPowerServiceLinux : public HostPowerService
+{
+public:
+
+    HostPowerServiceLinux(VirtualBox *aVirtualBox);
+    virtual ~HostPowerServiceLinux();
+
+private:
+
+    static DECLCALLBACK(int) powerChangeNotificationThread(RTTHREAD ThreadSelf, void *pInstance);
+
+    /* Private member vars */
+    /** Our message thread. */
+    RTTHREAD mThread;
+    /** Our (private) connection to the DBus.  Closing this will cause the
+     * message thread to exit. */
+    DBusConnection *mpConnection;
+};
+
 # elif defined(RT_OS_DARWIN) /* RT_OS_WINDOWS */
 /**
Index: /trunk/src/VBox/Main/src-server/HostImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/HostImpl.cpp	(revision 55601)
+++ /trunk/src/VBox/Main/src-server/HostImpl.cpp	(revision 55602)
@@ -304,4 +304,6 @@
 #if defined(RT_OS_WINDOWS)
     m->pHostPowerService = new HostPowerServiceWin(m->pParent);
+#elif defined(RT_OS_LINUX)
+    m->pHostPowerService = new HostPowerServiceLinux(m->pParent);
 #elif defined(RT_OS_DARWIN)
     m->pHostPowerService = new HostPowerServiceDarwin(m->pParent);
Index: /trunk/src/VBox/Main/src-server/linux/HostPowerLinux.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/linux/HostPowerLinux.cpp	(revision 55602)
+++ /trunk/src/VBox/Main/src-server/linux/HostPowerLinux.cpp	(revision 55602)
@@ -0,0 +1,142 @@
+/** @file
+ *
+ * VirtualBox interface to host's power notification service
+ */
+
+/*
+ * Copyright (C) 2015 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#include "HostPower.h"
+#include "Logging.h"
+
+#include <iprt/asm.h>
+#include <iprt/power.h>
+#include <iprt/time.h>
+
+static bool checkDBusError(DBusError *pError, DBusConnection *pConnection)
+{
+    if (dbus_error_is_set(pError))
+    {
+        LogRel(("HostPowerServiceLinux: DBus connection Error (%s)\n", pError->message));
+        dbus_error_free(pError);
+        /* Close the socket or whatever underlying the connection. */
+        dbus_connection_close(pConnection);
+        /* Free in-process resources used for the now-closed connection. */
+        dbus_connection_unref(pConnection);
+        return true;
+    }
+    return false;
+}
+
+HostPowerServiceLinux::HostPowerServiceLinux(VirtualBox *aVirtualBox)
+  : HostPowerService(aVirtualBox)
+  , mThread(NULL)
+  , mpConnection(NULL)
+{
+    DBusError error;
+    int rc;
+
+    rc = RTDBusLoadLib();
+    if (RT_FAILURE(rc))
+    {
+        LogRel(("HostPowerServiceLinux: DBus library not found.  Service not available.\n"));
+        return;
+    }
+    dbus_error_init(&error);
+    /* Connect to the DBus.  The connection will be not shared with any other
+     * in-process callers of dbus_bus_get().  This is considered wasteful (see
+     * API documentation) but simplifies our code, specifically shutting down.
+     * The session bus allows up to 100000 connections per user as it "is just
+     * running as the user anyway" (see session.conf.in in the DBus sources). */
+    mpConnection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
+    if (checkDBusError(&error, mpConnection))
+        return;
+    /* We do not want to exit(1) if the connection is broken. */
+    dbus_connection_set_exit_on_disconnect(mpConnection, FALSE);
+    /* Tell the bus to wait for the sleep signal(s). */
+    /* The current systemd-logind interface. */
+    dbus_bus_add_match(mpConnection, "type='signal',interface='org.freedesktop.login1.Manager'", &error);
+    /* The previous UPower interfaces (2010 - ca 2013). */
+    dbus_bus_add_match(mpConnection, "type='signal',interface='org.freedesktop.UPower'", &error);
+    dbus_connection_flush(mpConnection);
+    if (checkDBusError(&error, mpConnection))
+        return;
+    /* Create the new worker thread. */
+    rc = RTThreadCreate(&mThread, HostPowerServiceLinux::powerChangeNotificationThread, this, 0 /* cbStack */,
+                        RTTHREADTYPE_MSG_PUMP, RTTHREADFLAGS_WAITABLE, "MainPower");
+    if (RT_FAILURE(rc))
+        LogRel(("HostPowerServiceLinux: RTThreadCreate failed with %Rrc\n", rc));
+}
+
+
+HostPowerServiceLinux::~HostPowerServiceLinux()
+{
+    /* Closing the connection should cause the event loop to exit. */
+    LogFunc((": Stopping thread\n"));
+    dbus_connection_close(mpConnection);
+
+    RTThreadWait(mThread, 5000, NULL);
+    mThread = NIL_RTTHREAD;
+}
+
+
+DECLCALLBACK(int) HostPowerServiceLinux::powerChangeNotificationThread(RTTHREAD hThreadSelf, void *pInstance)
+{
+    HostPowerServiceLinux *pPowerObj = static_cast<HostPowerServiceLinux *>(pInstance);
+
+    Log(("HostPowerServiceLinux: Thread started\n"));
+    while (dbus_connection_read_write(pPowerObj->mpConnection, -1))
+    {
+        DBusMessage *pMessage = NULL;
+
+        do {
+            DBusMessageIter args;
+            dbus_bool_t fSuspend;
+
+            pMessage = dbus_connection_pop_message(pPowerObj->mpConnection);
+            if (pMessage == NULL)
+                continue;
+            /* The systemd-logind interface notification. */
+            if (   dbus_message_is_signal(pMessage, "org.freedesktop.login1.Manager", "PrepareForSleep")
+                && dbus_message_iter_init(pMessage, &args)
+                && dbus_message_iter_get_arg_type(&args) == DBUS_TYPE_BOOLEAN)
+            {
+                dbus_message_iter_get_basic(&args, &fSuspend);
+                /* Trinary operator does not work here as Reason_... is an
+                 * anonymous enum. */
+                if (fSuspend)
+                    pPowerObj->notify(Reason_HostSuspend);
+                else
+                    pPowerObj->notify(Reason_HostResume);            
+            }
+            /* The UPowerd interface notifications.  Sleeping is the older one,
+             * NotifySleep the newer.  This gives us one second grace before the
+             * suspend triggers. */
+            if (   dbus_message_is_signal(pMessage, "org.freedesktop.UPower", "Sleeping")
+                || dbus_message_is_signal(pMessage, "org.freedesktop.UPower", "NotifySleep"))
+                pPowerObj->notify(Reason_HostSuspend);
+            if (   dbus_message_is_signal(pMessage, "org.freedesktop.UPower", "Resuming")
+                || dbus_message_is_signal(pMessage, "org.freedesktop.UPower", "NotifyResume"))
+                pPowerObj->notify(Reason_HostResume);
+            /* Free local resources held for the message. */
+            dbus_message_unref(pMessage);
+        } while (pMessage != NULL);
+    }
+    /* Close the socket or whatever underlying the connection. */
+    dbus_connection_close(pPowerObj->mpConnection);
+    /* Free in-process resources used for the now-closed connection. */
+    dbus_connection_unref(pPowerObj->mpConnection);
+    pPowerObj->mpConnection = NULL;
+    Log(("HostPowerServiceLinux: Exiting thread\n"));
+    return VINF_SUCCESS;
+}
+
