[v3 19/32] Created virDomainEventBalloonChange

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

 



---
 src/conf/domain_event.c | 56 +++++++++++++++++++++++++++++++++++--------------
 1 file changed, 40 insertions(+), 16 deletions(-)

diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index 47b183a..589ffea 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -93,6 +93,7 @@ static virClassPtr virDomainEventGraphicsClass;
 static virClassPtr virDomainEventBlockJobClass;
 static virClassPtr virDomainEventDiskChangeClass;
 static virClassPtr virDomainEventTrayChangeClass;
+static virClassPtr virDomainEventBalloonChangeClass;
 
 static void virObjectEventDispose(void *obj);
 static void virDomainEventDispose(void *obj);
@@ -104,6 +105,7 @@ static void virDomainEventGraphicsDispose(void *obj);
 static void virDomainEventBlockJobDispose(void *obj);
 static void virDomainEventDiskChangeDispose(void *obj);
 static void virDomainEventTrayChangeDispose(void *obj);
+static void virDomainEventBalloonChangeDispose(void *obj);
 
 struct _virObjectEvent {
     virObject parent;
@@ -117,10 +119,6 @@ struct _virDomainEvent {
 
     union {
         struct {
-            /* In unit of 1024 bytes */
-            unsigned long long actual;
-        } balloonChange;
-        struct {
             char *devAlias;
         } deviceRemoved;
     } data;
@@ -204,6 +202,15 @@ struct _virDomainEventTrayChange {
 typedef struct _virDomainEventTrayChange virDomainEventTrayChange;
 typedef virDomainEventTrayChange *virDomainEventTrayChangePtr;
 
+struct _virDomainEventBalloonChange {
+    virDomainEvent parent;
+
+    /* In unit of 1024 bytes */
+    unsigned long long actual;
+};
+typedef struct _virDomainEventBalloonChange virDomainEventBalloonChange;
+typedef virDomainEventBalloonChange *virDomainEventBalloonChangePtr;
+
 
 static int virObjectEventOnceInit(void)
 {
@@ -265,6 +272,12 @@ static int virObjectEventOnceInit(void)
                                              sizeof(virDomainEventTrayChange),
                                              virDomainEventTrayChangeDispose)))
         return -1;
+    if (!(virDomainEventBalloonChangeClass = virClassNew(
+                                             virDomainEventClass,
+                                             "virDomainEventBalloonChange",
+                                             sizeof(virDomainEventBalloonChange),
+                                             virDomainEventBalloonChangeDispose)))
+        return -1;
     return 0;
 }
 
@@ -385,6 +398,12 @@ static void virDomainEventTrayChangeDispose(void *obj)
     VIR_FREE(event->devAlias);
 }
 
+static void virDomainEventBalloonChangeDispose(void *obj)
+{
+    virDomainEventBalloonChangePtr event = obj;
+    VIR_DEBUG("obj=%p", event);
+}
+
 /**
  * virObjectEventCallbackListFree:
  * @list: event callback list head
@@ -1484,36 +1503,36 @@ virDomainEventPMSuspendDiskNewFromDom(virDomainPtr dom)
 virDomainEventPtr virDomainEventBalloonChangeNewFromDom(virDomainPtr dom,
                                                         unsigned long long actual)
 {
-    virDomainEventPtr ev;
+    virDomainEventBalloonChangePtr ev;
 
     if (virObjectEventInitialize() < 0)
         return NULL;
 
-    if (!(ev = virDomainEventNew(virDomainEventClass,
+    if (!(ev = virDomainEventNew(virDomainEventBalloonChangeClass,
                                  VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE,
                                  dom->id, dom->name, dom->uuid)))
         return NULL;
 
-    ev->data.balloonChange.actual = actual;
+    ev->actual = actual;
 
-    return ev;
+    return (virDomainEventPtr)ev;
 }
 virDomainEventPtr virDomainEventBalloonChangeNewFromObj(virDomainObjPtr obj,
                                                         unsigned long long actual)
 {
-    virDomainEventPtr ev;
+    virDomainEventBalloonChangePtr ev;
 
     if (virObjectEventInitialize() < 0)
         return NULL;
 
-    if (!(ev = virDomainEventNew(virDomainEventClass,
+    if (!(ev = virDomainEventNew(virDomainEventBalloonChangeClass,
                                  VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE,
                                  obj->def->id, obj->def->name, obj->def->uuid)))
         return NULL;
 
-    ev->data.balloonChange.actual = actual;
+    ev->actual = actual;
 
-    return ev;
+    return (virDomainEventPtr)ev;
 }
 
 static virDomainEventPtr
@@ -1741,10 +1760,15 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn,
         goto cleanup;
 
     case VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE:
-        ((virConnectDomainEventBalloonChangeCallback)cb)(conn, dom,
-                                                         event->data.balloonChange.actual,
-                                                         cbopaque);
-        goto cleanup;
+        {
+            virDomainEventBalloonChangePtr balloonChangeEvent;
+
+            balloonChangeEvent = (virDomainEventBalloonChangePtr)event;
+            ((virConnectDomainEventBalloonChangeCallback)cb)(conn, dom,
+                                                             balloonChangeEvent->actual,
+                                                             cbopaque);
+            goto cleanup;
+        }
 
     case VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK:
         ((virConnectDomainEventPMSuspendDiskCallback)cb)(conn, dom, 0, cbopaque);
-- 
1.8.4.4

--
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]