[PATCH 08/11] Add support for the suspend event

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

 



This patch introduces a new event type for the QMP event
SUSPEND:

    VIR_DOMAIN_EVENT_ID_PMSUSPEND

The event doesn't take any data, but considering there might
be reason for wakeup in future, the callback definition is:

typedef void
(*virConnectDomainEventSuspendCallback)(virConnectPtr conn,
                                        virDomainPtr dom,
                                        int reason,
                                        void *opaque);

"reason" is unused currently, always passes "0".
---
 daemon/remote.c                                    |   24 +++++++++-
 examples/domain-events/events-c/event-test.c       |   20 +++++++-
 examples/domain-events/events-python/event-test.py |    4 ++
 include/libvirt/libvirt.h.in                       |   19 +++++++
 python/libvirt-override-virConnect.py              |    9 ++++
 python/libvirt-override.c                          |   50 ++++++++++++++++++++
 src/conf/domain_event.c                            |   29 +++++++++++
 src/conf/domain_event.h                            |    2 +
 src/libvirt_private.syms                           |    2 +
 src/qemu/qemu_monitor.c                            |   10 ++++
 src/qemu/qemu_monitor.h                            |    3 +
 src/qemu/qemu_monitor_json.c                       |   11 ++++-
 src/qemu/qemu_process.c                            |   22 +++++++++
 src/remote/remote_driver.c                         |   31 ++++++++++++
 src/remote/remote_protocol.x                       |    7 ++-
 src/remote_protocol-structs                        |    4 ++
 16 files changed, 243 insertions(+), 4 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index db3b6bc..4fd676d 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -538,7 +538,6 @@ static int remoteRelayDomainEventTrayChange(virConnectPtr conn ATTRIBUTE_UNUSED,
     return 0;
 }
 
-
 static int remoteRelayDomainEventPMWakeup(virConnectPtr conn ATTRIBUTE_UNUSED,
                                           virDomainPtr dom,
                                           void *opaque) {
@@ -561,6 +560,28 @@ static int remoteRelayDomainEventPMWakeup(virConnectPtr conn ATTRIBUTE_UNUSED,
     return 0;
 }
 
+static int remoteRelayDomainEventPMSuspend(virConnectPtr conn ATTRIBUTE_UNUSED,
+                                           virDomainPtr dom,
+                                           void *opaque) {
+    virNetServerClientPtr client = opaque;
+    remote_domain_event_pmsuspend_msg data;
+
+    if (!client)
+        return -1;
+
+    VIR_DEBUG("Relaying domain %s %d system pmsuspend", dom->name, dom->id);
+
+    /* build return data */
+    memset(&data, 0, sizeof data);
+    make_nonnull_domain(&data.dom, dom);
+
+    remoteDispatchDomainEventSend(client, remoteProgram,
+                                  REMOTE_PROC_DOMAIN_EVENT_PMSUSPEND,
+                                  (xdrproc_t)xdr_remote_domain_event_pmsuspend_msg, &data);
+
+    return 0;
+}
+
 static virConnectDomainEventGenericCallback domainEventCallbacks[] = {
     VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventLifecycle),
     VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventReboot),
@@ -574,6 +595,7 @@ static virConnectDomainEventGenericCallback domainEventCallbacks[] = {
     VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventDiskChange),
     VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventTrayChange),
     VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventPMWakeup),
+    VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventPMSuspend),
 };
 
 verify(ARRAY_CARDINALITY(domainEventCallbacks) == VIR_DOMAIN_EVENT_ID_LAST);
diff --git a/examples/domain-events/events-c/event-test.c b/examples/domain-events/events-c/event-test.c
index 78cfa3b..9ffabd6 100644
--- a/examples/domain-events/events-c/event-test.c
+++ b/examples/domain-events/events-c/event-test.c
@@ -340,6 +340,16 @@ static int myDomainEventPMWakeupCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
     return 0;
 }
 
+static int myDomainEventPMSuspendCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
+                                          virDomainPtr dom,
+                                          int reason ATTRIBUTE_UNUSED,
+                                          void *opaque ATTRIBUTE_UNUSED)
+{
+    printf("%s EVENT: Domain %s(%d) system pmsuspend",
+           __func__, virDomainGetName(dom), virDomainGetID(dom));
+    return 0;
+}
+
 static void myFreeFunc(void *opaque)
 {
     char *str = opaque;
@@ -377,6 +387,7 @@ int main(int argc, char **argv)
     int callback9ret = -1;
     int callback10ret = -1;
     int callback11ret = -1;
+    int callback12ret = -1;
     struct sigaction action_stop;
 
     memset(&action_stop, 0, sizeof action_stop);
@@ -457,6 +468,11 @@ int main(int argc, char **argv)
                                                      VIR_DOMAIN_EVENT_ID_PMWAKEUP,
                                                      VIR_DOMAIN_EVENT_CALLBACK(myDomainEventPMWakeupCallback),
                                                      strdup("pmwakeup"), myFreeFunc);
+    callback12ret = virConnectDomainEventRegisterAny(dconn,
+                                                     NULL,
+                                                     VIR_DOMAIN_EVENT_ID_PMSUSPEND,
+                                                     VIR_DOMAIN_EVENT_CALLBACK(myDomainEventPMSuspendCallback),
+                                                     strdup("pmsuspend"), myFreeFunc);
     if ((callback1ret != -1) &&
         (callback2ret != -1) &&
         (callback3ret != -1) &&
@@ -466,7 +482,8 @@ int main(int argc, char **argv)
         (callback7ret != -1) &&
         (callback9ret != -1) &&
         (callback10ret != -1) &&
-        (callback11ret != -1)) {
+        (callback11ret != -1) &&
+        (callback12ret != -1)) {
         if (virConnectSetKeepAlive(dconn, 5, 3) < 0) {
             virErrorPtr err = virGetLastError();
             fprintf(stderr, "Failed to start keepalive protocol: %s\n",
@@ -493,6 +510,7 @@ int main(int argc, char **argv)
         virConnectDomainEventDeregisterAny(dconn, callback9ret);
         virConnectDomainEventDeregisterAny(dconn, callback10ret);
         virConnectDomainEventDeregisterAny(dconn, callback11ret);
+        virConnectDomainEventDeregisterAny(dconn, callback12ret);
         if (callback8ret != -1)
             virConnectDomainEventDeregisterAny(dconn, callback8ret);
     }
diff --git a/examples/domain-events/events-python/event-test.py b/examples/domain-events/events-python/event-test.py
index 249b590..78d36a3 100644
--- a/examples/domain-events/events-python/event-test.py
+++ b/examples/domain-events/events-python/event-test.py
@@ -480,6 +480,9 @@ def myDomainEventTrayChangeCallback(conn, dom, devAlias, reason, opaque):
 def myDomainEventWakeupCallback(conn, dom, reason, opaque):
     print "myDomainEventWakeupCallback: Domain %s(%s) system pmwakeup" % (
             dom.name(), dom.ID())
+def myDomainEventPMSuspendCallback(conn, dom, reason, opaque):
+    print "myDomainEventPMSuspendCallback: Domain %s(%s) system pmsuspend" % (
+            dom.name(), dom.ID())
 def usage(out=sys.stderr):
     print >>out, "usage: "+os.path.basename(sys.argv[0])+" [-hdl] [uri]"
     print >>out, "   uri will default to qemu:///system"
@@ -540,6 +543,7 @@ def main():
     vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_DISK_CHANGE, myDomainEventDiskChangeCallback, None)
     vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_TRAY_CHANGE, myDomainEventTrayChangeCallback, None)
     vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_PMWAKEUP, myDomainEventPMWakeupCallback, None)
+    vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_PMSUSPEND, myDomainEventPMSuspendCallback, None)
 
     vc.setKeepAlive(5, 3)
 
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index a9a15e1..caf5085 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -3719,6 +3719,24 @@ typedef void (*virConnectDomainEventPMWakeupCallback)(virConnectPtr conn,
                                                       void *opaque);
 
 /**
+ * virConnectDomainEventPMSuspendCallback:
+ * @conn: connection object
+ * @dom: domain on which the event occurred
+ * @reason: reason why the callback was called, unused currently,
+ *          always passes 0
+ * @opaque: application specified data
+ *
+ * This callback occurs when the guest is waken up.
+ *
+ * The callback signature to use when registering for an event of type
+ * VIR_DOMAIN_EVENT_ID_PMSuspend with virConnectDomainEventRegisterAny()
+ */
+typedef void (*virConnectDomainEventPMSuspendCallback)(virConnectPtr conn,
+                                                       virDomainPtr dom,
+                                                       int reason,
+                                                       void *opaque);
+
+/**
  * VIR_DOMAIN_EVENT_CALLBACK:
  *
  * Used to cast the event specific callback into the generic one
@@ -3740,6 +3758,7 @@ typedef enum {
     VIR_DOMAIN_EVENT_ID_DISK_CHANGE = 9,     /* virConnectDomainEventDiskChangeCallback */
     VIR_DOMAIN_EVENT_ID_TRAY_CHANGE = 10,    /* virConnectDomainEventTrayChangeCallback */
     VIR_DOMAIN_EVENT_ID_PMWAKEUP = 11,       /* virConnectDomainEventPMWakeupCallback */
+    VIR_DOMAIN_EVENT_ID_PMSUSPEND = 12,      /* virConnectDomainEventPMSuspendCallback */
 
 #ifdef VIR_ENUM_SENTINELS
     /*
diff --git a/python/libvirt-override-virConnect.py b/python/libvirt-override-virConnect.py
index 2d48828..811e16b 100644
--- a/python/libvirt-override-virConnect.py
+++ b/python/libvirt-override-virConnect.py
@@ -152,6 +152,15 @@
         cb(self, virDomain(self, _obj=dom), reason, opaque)
         return 0;
 
+    def _dispatchDomainEventPMSuspendCallback(self, dom, reason, cbData):
+        """Dispatches event to python user domain pmsuspend event callbacks
+        """
+        cb = cbData["cb"]
+        opaque = cbData["opaque"]
+
+        cb(self, virDomain(self, _obj=dom), reason, opaque)
+        return 0;
+
     def domainEventDeregisterAny(self, callbackID):
         """Removes a Domain Event Callback. De-registering for a
            domain callback will disable delivery of this event type """
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index f604a16..e6127c1 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -5021,6 +5021,53 @@ libvirt_virConnectDomainEventPMWakeupCallback(virConnectPtr conn ATTRIBUTE_UNUSE
     return ret;
 }
 
+static int
+libvirt_virConnectDomainEventPMSuspendCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
+                                               virDomainPtr dom,
+                                               int reason,
+                                               void *opaque)
+{
+    PyObject *pyobj_cbData = (PyObject*)opaque;
+    PyObject *pyobj_dom;
+    PyObject *pyobj_ret;
+    PyObject *pyobj_conn;
+    PyObject *dictKey;
+    int ret = -1;
+
+    LIBVIRT_ENSURE_THREAD_STATE;
+    /* Create a python instance of this virDomainPtr */
+    virDomainRef(dom);
+
+    pyobj_dom = libvirt_virDomainPtrWrap(dom);
+    Py_INCREF(pyobj_cbData);
+
+    dictKey = libvirt_constcharPtrWrap("conn");
+    pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
+    Py_DECREF(dictKey);
+
+    /* Call the Callback Dispatcher */
+    pyobj_ret = PyObject_CallMethod(pyobj_conn,
+                                    (char*)"_dispatchDomainEventPMSuspendCallback",
+                                    (char*)"OO",
+                                    pyobj_dom,
+                                    reason,
+                                    pyobj_cbData);
+
+    Py_DECREF(pyobj_cbData);
+    Py_DECREF(pyobj_dom);
+
+    if(!pyobj_ret) {
+        DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
+        PyErr_Print();
+    } else {
+        Py_DECREF(pyobj_ret);
+        ret = 0;
+    }
+
+    LIBVIRT_RELEASE_THREAD_STATE;
+    return ret;
+}
+
 static PyObject *
 libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject * self,
                                          PyObject * args)
@@ -5087,6 +5134,9 @@ libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject * self,
     case VIR_DOMAIN_EVENT_ID_PMWAKEUP:
         cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMWakeupCallback);
         break;
+    case VIR_DOMAIN_EVENT_ID_PMSUSPEND:
+        cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendCallback);
+        break;
     }
 
     if (!cb) {
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index 06a8e29..923c58d 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -1119,6 +1119,31 @@ virDomainEventPMWakeupNewFromDom(virDomainPtr dom)
     return virDomainEventPMWakeupNew(dom->id, dom->name, dom->uuid);
 }
 
+static virDomainEventPtr
+virDomainEventPMSuspendNew(int id, const char *name,
+                           unsigned char *uuid)
+{
+    virDomainEventPtr ev =
+        virDomainEventNewInternal(VIR_DOMAIN_EVENT_ID_PMSUSPEND,
+                                  id, name, uuid);
+
+    return ev;
+}
+
+virDomainEventPtr
+virDomainEventPMSuspendNewFromObj(virDomainObjPtr obj)
+{
+    return virDomainEventPMSuspendNew(obj->def->id,
+                                      obj->def->name,
+                                      obj->def->uuid);
+}
+
+virDomainEventPtr
+virDomainEventPMSuspendNewFromDom(virDomainPtr dom)
+{
+    return virDomainEventPMSuspendNew(dom->id, dom->name, dom->uuid);
+}
+
 /**
  * virDomainEventQueuePush:
  * @evtQueue: the dom event queue
@@ -1253,6 +1278,10 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn,
         ((virConnectDomainEventPMWakeupCallback)cb)(conn, dom, 0, cbopaque);
         break;
 
+    case VIR_DOMAIN_EVENT_ID_PMSUSPEND:
+        ((virConnectDomainEventPMSuspendCallback)cb)(conn, dom, 0, cbopaque);
+        break;
+
     default:
         VIR_WARN("Unexpected event ID %d", event->eventID);
         break;
diff --git a/src/conf/domain_event.h b/src/conf/domain_event.h
index 7d39201..f7776c7 100644
--- a/src/conf/domain_event.h
+++ b/src/conf/domain_event.h
@@ -122,6 +122,8 @@ virDomainEventPtr virDomainEventTrayChangeNewFromDom(virDomainPtr dom,
                                                      int reason);
 virDomainEventPtr virDomainEventPMWakeupNewFromObj(virDomainObjPtr obj);
 virDomainEventPtr virDomainEventPMWakeupNewFromDom(virDomainPtr dom);
+virDomainEventPtr virDomainEventPMSuspendNewFromObj(virDomainObjPtr obj);
+virDomainEventPtr virDomainEventPMSuspendNewFromDom(virDomainPtr dom);
 
 void virDomainEventFree(virDomainEventPtr event);
 
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index d591d04..678e89e 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -511,6 +511,8 @@ virDomainEventNew;
 virDomainEventNewFromDef;
 virDomainEventNewFromDom;
 virDomainEventNewFromObj;
+virDomainEventPMSuspendNewFromDom;
+virDomainEventPMSuspendNewFromObj;
 virDomainEventPMWakeupNewFromDom;
 virDomainEventPMWakeupNewFromObj;
 virDomainEventRTCChangeNewFromDom;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index adf3636..9372db6 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1063,6 +1063,16 @@ int qemuMonitorEmitPMWakeup(qemuMonitorPtr mon)
     return ret;
 }
 
+int qemuMonitorEmitPMSuspend(qemuMonitorPtr mon)
+{
+    int ret = -1;
+    VIR_DEBUG("mon=%p", mon);
+
+    QEMU_MONITOR_CALLBACK(mon, ret, domainPMSuspend, mon->vm);
+
+    return ret;
+}
+
 int qemuMonitorEmitBlockJob(qemuMonitorPtr mon,
                             const char *diskAlias,
                             int type,
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 6919a66..117e86c 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -130,6 +130,8 @@ struct _qemuMonitorCallbacks {
                             int reason);
     int (*domainPMWakeup)(qemuMonitorPtr mon,
                           virDomainObjPtr vm);
+    int (*domainPMSuspend)(qemuMonitorPtr mon,
+                           virDomainObjPtr vm);
 };
 
 char *qemuMonitorEscapeArg(const char *in);
@@ -200,6 +202,7 @@ int qemuMonitorEmitTrayChange(qemuMonitorPtr mon,
                               const char *devAlias,
                               int reason);
 int qemuMonitorEmitPMWakeup(qemuMonitorPtr mon);
+int qemuMonitorEmitPMSuspend(qemuMonitorPtr mon);
 int qemuMonitorEmitBlockJob(qemuMonitorPtr mon,
                             const char *diskAlias,
                             int type,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 7bb4410..c5cc59e 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -61,6 +61,7 @@ static void qemuMonitorJSONHandleVNCDisconnect(qemuMonitorPtr mon, virJSONValueP
 static void qemuMonitorJSONHandleBlockJob(qemuMonitorPtr mon, virJSONValuePtr data);
 static void qemuMonitorJSONHandleTrayChange(qemuMonitorPtr mon, virJSONValuePtr data);
 static void qemuMonitorJSONHandlePMWakeup(qemuMonitorPtr mon, virJSONValuePtr data);
+static void qemuMonitorJSONHandlePMSuspend(qemuMonitorPtr mon, virJSONValuePtr data);
 
 static struct {
     const char *type;
@@ -79,6 +80,7 @@ static struct {
     { "BLOCK_JOB_COMPLETED", qemuMonitorJSONHandleBlockJob, },
     { "DEVICE_TRAY_MOVED", qemuMonitorJSONHandleTrayChange, },
     { "WAKEUP", qemuMonitorJSONHandlePMWakeup, },
+    { "SUSPEND", qemuMonitorJSONHandlePMSuspend, },
 };
 
 
@@ -757,11 +759,18 @@ qemuMonitorJSONHandleTrayChange(qemuMonitorPtr mon,
 
 static void
 qemuMonitorJSONHandlePMWakeup(qemuMonitorPtr mon,
-                            virJSONValuePtr data ATTRIBUTE_UNUSED)
+                              virJSONValuePtr data ATTRIBUTE_UNUSED)
 {
     qemuMonitorEmitPMWakeup(mon);
 }
 
+static void
+qemuMonitorJSONHandlePMSuspend(qemuMonitorPtr mon,
+                               virJSONValuePtr data ATTRIBUTE_UNUSED)
+{
+    qemuMonitorEmitPMSuspend(mon);
+}
+
 int
 qemuMonitorJSONHumanCommandWithFd(qemuMonitorPtr mon,
                                   const char *cmd_str,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 7914a6a..d55c269 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1082,6 +1082,27 @@ qemuProcessHandlePMWakeup(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     return 0;
 }
 
+static int
+qemuProcessHandlePMSuspend(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
+                           virDomainObjPtr vm)
+{
+    struct qemud_driver *driver = qemu_driver;
+    virDomainEventPtr event = NULL;
+
+    virDomainObjLock(vm);
+    event = virDomainEventPMSuspendNewFromObj(vm);
+
+    virDomainObjUnlock(vm);
+
+    if (event) {
+        qemuDriverLock(driver);
+        qemuDomainEventQueue(driver, event);
+        qemuDriverUnlock(driver);
+    }
+
+    return 0;
+}
+
 static qemuMonitorCallbacks monitorCallbacks = {
     .destroy = qemuProcessHandleMonitorDestroy,
     .eofNotify = qemuProcessHandleMonitorEOF,
@@ -1097,6 +1118,7 @@ static qemuMonitorCallbacks monitorCallbacks = {
     .domainBlockJob = qemuProcessHandleBlockJob,
     .domainTrayChange = qemuProcessHandleTrayChange,
     .domainPMWakeup = qemuProcessHandlePMWakeup,
+    .domainPMSuspend = qemuProcessHandlePMSuspend,
 };
 
 static int
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 27eafa1..d0c71da 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -248,6 +248,11 @@ remoteDomainBuildEventPMWakeup(virNetClientProgramPtr prog,
                                virNetClientPtr client,
                                void *evdata, void *opaque);
 
+static void
+remoteDomainBuildEventPMSuspend(virNetClientProgramPtr prog,
+                                virNetClientPtr client,
+                                void *evdata, void *opaque);
+
 static virNetClientProgramEvent remoteDomainEvents[] = {
     { REMOTE_PROC_DOMAIN_EVENT_RTC_CHANGE,
       remoteDomainBuildEventRTCChange,
@@ -297,6 +302,10 @@ static virNetClientProgramEvent remoteDomainEvents[] = {
       remoteDomainBuildEventPMWakeup,
       sizeof(remote_domain_event_pmwakeup_msg),
       (xdrproc_t)xdr_remote_domain_event_pmwakeup_msg },
+    { REMOTE_PROC_DOMAIN_EVENT_PMSUSPEND,
+      remoteDomainBuildEventPMSuspend,
+      sizeof(remote_domain_event_pmsuspend_msg),
+      (xdrproc_t)xdr_remote_domain_event_pmsuspend_msg },
 };
 
 enum virDrvOpenRemoteFlags {
@@ -3709,6 +3718,28 @@ remoteDomainBuildEventPMWakeup(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
     remoteDomainEventQueue(priv, event);
 }
 
+static void
+remoteDomainBuildEventPMSuspend(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
+                                virNetClientPtr client ATTRIBUTE_UNUSED,
+                                void *evdata, void *opaque)
+{
+    virConnectPtr conn = opaque;
+    struct private_data *priv = conn->privateData;
+    remote_domain_event_pmsuspend_msg *msg = evdata;
+    virDomainPtr dom;
+    virDomainEventPtr event = NULL;
+
+    dom = get_nonnull_domain(conn, msg->dom);
+    if (!dom)
+        return;
+
+    event = virDomainEventPMSuspendNewFromDom(dom);
+
+    virDomainFree(dom);
+
+    remoteDomainEventQueue(priv, event);
+}
+
 static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
 remoteSecretOpen(virConnectPtr conn, virConnectAuthPtr auth,
                  unsigned int flags)
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index f462b20..2d57247 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -2188,6 +2188,10 @@ struct remote_domain_event_pmwakeup_msg {
     remote_nonnull_domain dom;
 };
 
+struct remote_domain_event_pmsuspend_msg {
+    remote_nonnull_domain dom;
+};
+
 struct remote_domain_managed_save_args {
     remote_nonnull_domain dom;
     unsigned int flags;
@@ -2777,7 +2781,8 @@ enum remote_procedure {
     REMOTE_PROC_DOMAIN_BLOCK_REBASE = 266, /* autogen autogen */
     REMOTE_PROC_DOMAIN_PM_WAKEUP = 267, /* autogen autogen */
     REMOTE_PROC_DOMAIN_EVENT_TRAY_CHANGE = 268, /* autogen autogen */
-    REMOTE_PROC_DOMAIN_EVENT_PMWAKEUP = 269 /* autogen autogen */
+    REMOTE_PROC_DOMAIN_EVENT_PMWAKEUP = 269, /* autogen autogen */
+    REMOTE_PROC_DOMAIN_EVENT_PMSUSPEND = 270 /* autogen autogen */
 
     /*
      * Notice how the entries are grouped in sets of 10 ?
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 5eb4df3..474e574 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -1658,6 +1658,9 @@ struct remote_domain_event_tray_change_msg {
 struct remote_domain_event_pmwakeup_msg {
         remote_nonnull_domain      dom;
 }
+struct remote_domain_event_pmsuspend_msg {
+        remote_nonnull_domain      dom;
+}
 struct remote_domain_managed_save_args {
         remote_nonnull_domain      dom;
         u_int                      flags;
@@ -2188,4 +2191,5 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_PM_WAKEUP = 267,
         REMOTE_PROC_DOMAIN_TRAY_CHANGE = 268,
         REMOTE_PROC_DOMAIN_PMWAKEUP = 269,
+        REMOTE_PROC_DOMAIN_PMSUSPEND = 270,
 };
-- 
1.7.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]