[PATCH 14/34] Created virDomainEventIOError

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

 



---
 src/conf/domain_event.c | 161 ++++++++++++++++++++++++++++--------------------
 src/conf/domain_event.h |  36 +++++------
 2 files changed, 112 insertions(+), 85 deletions(-)

diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index 8d08d2f..21494e5 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -83,11 +83,13 @@ static virClassPtr virDomainEventClass;
 static virClassPtr virDomainEventLifecycleClass;
 static virClassPtr virDomainEventRTCChangeClass;
 static virClassPtr virDomainEventWatchdogClass;
+static virClassPtr virDomainEventIOErrorClass;
 static void virObjectEventDispose(void *obj);
 static void virDomainEventDispose(void *obj);
 static void virDomainEventLifecycleDispose(void *obj);
 static void virDomainEventRTCChangeDispose(void *obj);
 static void virDomainEventWatchdogDispose(void *obj);
+static void virDomainEventIOErrorDispose(void *obj);
 
 struct _virObjectEvent {
     virObject parent;
@@ -101,12 +103,6 @@ struct _virDomainEvent {
 
     union {
         struct {
-            char *srcPath;
-            char *devAlias;
-            int action;
-            char *reason;
-        } ioError;
-        struct {
             int phase;
             virDomainEventGraphicsAddressPtr local;
             virDomainEventGraphicsAddressPtr remote;
@@ -163,6 +159,17 @@ struct _virDomainEventWatchdog {
 typedef struct _virDomainEventWatchdog virDomainEventWatchdog;
 typedef virDomainEventWatchdog *virDomainEventWatchdogPtr;
 
+struct _virDomainEventIOError {
+    virDomainEvent parent;
+
+    char *srcPath;
+    char *devAlias;
+    int action;
+    char *reason;
+};
+typedef struct _virDomainEventIOError virDomainEventIOError;
+typedef virDomainEventIOError *virDomainEventIOErrorPtr;
+
 static int virObjectEventOnceInit(void)
 {
     if (!(virObjectEventClass = virClassNew(virClassForObject(),
@@ -193,6 +200,12 @@ static int virObjectEventOnceInit(void)
                                              sizeof(virDomainEventWatchdog),
                                              virDomainEventWatchdogDispose)))
         return -1;
+    if (!(virDomainEventIOErrorClass = virClassNew(
+                                             virDomainEventClass,
+                                             "virDomainEventIOError",
+                                             sizeof(virDomainEventIOError),
+                                             virDomainEventIOErrorDispose)))
+        return -1;
     return 0;
 }
 
@@ -227,12 +240,6 @@ static void virDomainEventDispose(void *obj)
         return;
 
     switch (virObjectEventGetEventID(event)) {
-    case VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON:
-    case VIR_DOMAIN_EVENT_ID_IO_ERROR:
-        VIR_FREE(event->data.ioError.srcPath);
-        VIR_FREE(event->data.ioError.devAlias);
-        VIR_FREE(event->data.ioError.reason);
-        break;
 
     case VIR_DOMAIN_EVENT_ID_GRAPHICS:
         if (event->data.graphics.local) {
@@ -294,6 +301,16 @@ static void virDomainEventWatchdogDispose(void *obj)
     VIR_DEBUG("obj=%p", event);
 }
 
+static void virDomainEventIOErrorDispose(void *obj)
+{
+    virDomainEventIOErrorPtr event = obj;
+    VIR_DEBUG("obj=%p", event);
+
+    VIR_FREE(event->srcPath);
+    VIR_FREE(event->devAlias);
+    VIR_FREE(event->reason);
+}
+
 /**
  * virObjectEventCallbackListFree:
  * @list: event callback list head
@@ -961,26 +978,26 @@ void *virDomainEventWatchdogNewFromObj(virDomainObjPtr obj, int action)
     return ev;
 }
 
-static virDomainEventPtr virDomainEventIOErrorNewFromDomImpl(int event,
-                                                             virDomainPtr dom,
-                                                             const char *srcPath,
-                                                             const char *devAlias,
-                                                             int action,
-                                                             const char *reason)
+static void *virDomainEventIOErrorNewFromDomImpl(int event,
+                                                 virDomainPtr dom,
+                                                 const char *srcPath,
+                                                 const char *devAlias,
+                                                 int action,
+                                                 const char *reason)
 {
-    virDomainEventPtr ev;
+    virDomainEventIOErrorPtr ev;
 
     if (virObjectEventInitialize() < 0)
         return NULL;
 
-    if (!(ev = virDomainEventNew(virDomainEventClass, event,
+    if (!(ev = virDomainEventNew(virDomainEventIOErrorClass, event,
                                  dom->id, dom->name, dom->uuid)))
         return NULL;
 
-    ev->data.ioError.action = action;
-    if (VIR_STRDUP(ev->data.ioError.srcPath, srcPath) < 0 ||
-        VIR_STRDUP(ev->data.ioError.devAlias, devAlias) < 0 ||
-        VIR_STRDUP(ev->data.ioError.reason, reason) < 0) {
+    ev->action = action;
+    if (VIR_STRDUP(ev->srcPath, srcPath) < 0 ||
+        VIR_STRDUP(ev->devAlias, devAlias) < 0 ||
+        VIR_STRDUP(ev->reason, reason) < 0) {
         virObjectUnref(ev);
         ev = NULL;
     }
@@ -988,27 +1005,27 @@ static virDomainEventPtr virDomainEventIOErrorNewFromDomImpl(int event,
     return ev;
 }
 
-static virDomainEventPtr virDomainEventIOErrorNewFromObjImpl(int event,
-                                                             virDomainObjPtr obj,
-                                                             const char *srcPath,
-                                                             const char *devAlias,
-                                                             int action,
-                                                             const char *reason)
+static void *virDomainEventIOErrorNewFromObjImpl(int event,
+                                                 virDomainObjPtr obj,
+                                                 const char *srcPath,
+                                                 const char *devAlias,
+                                                 int action,
+                                                 const char *reason)
 {
-    virDomainEventPtr ev;
+    virDomainEventIOErrorPtr ev;
 
     if (virObjectEventInitialize() < 0)
         return NULL;
 
-    if (!(ev = virDomainEventNew(virDomainEventClass, event,
+    if (!(ev = virDomainEventNew(virDomainEventIOErrorClass, event,
                                  obj->def->id, obj->def->name,
                                  obj->def->uuid)))
         return NULL;
 
-    ev->data.ioError.action = action;
-    if (VIR_STRDUP(ev->data.ioError.srcPath, srcPath) < 0 ||
-        VIR_STRDUP(ev->data.ioError.devAlias, devAlias) < 0 ||
-        VIR_STRDUP(ev->data.ioError.reason, reason) < 0) {
+    ev->action = action;
+    if (VIR_STRDUP(ev->srcPath, srcPath) < 0 ||
+        VIR_STRDUP(ev->devAlias, devAlias) < 0 ||
+        VIR_STRDUP(ev->reason, reason) < 0) {
         virObjectUnref(ev);
         ev = NULL;
     }
@@ -1016,42 +1033,42 @@ static virDomainEventPtr virDomainEventIOErrorNewFromObjImpl(int event,
     return ev;
 }
 
-virDomainEventPtr virDomainEventIOErrorNewFromDom(virDomainPtr dom,
-                                                  const char *srcPath,
-                                                  const char *devAlias,
-                                                  int action)
+void *virDomainEventIOErrorNewFromDom(virDomainPtr dom,
+                                      const char *srcPath,
+                                      const char *devAlias,
+                                      int action)
 {
     return virDomainEventIOErrorNewFromDomImpl(VIR_DOMAIN_EVENT_ID_IO_ERROR,
                                                dom, srcPath, devAlias,
                                                action, NULL);
 }
 
-virDomainEventPtr virDomainEventIOErrorNewFromObj(virDomainObjPtr obj,
-                                                  const char *srcPath,
-                                                  const char *devAlias,
-                                                  int action)
+void *virDomainEventIOErrorNewFromObj(virDomainObjPtr obj,
+                                      const char *srcPath,
+                                      const char *devAlias,
+                                      int action)
 {
     return virDomainEventIOErrorNewFromObjImpl(VIR_DOMAIN_EVENT_ID_IO_ERROR,
                                                obj, srcPath, devAlias,
                                                action, NULL);
 }
 
-virDomainEventPtr virDomainEventIOErrorReasonNewFromDom(virDomainPtr dom,
-                                                        const char *srcPath,
-                                                        const char *devAlias,
-                                                        int action,
-                                                        const char *reason)
+void *virDomainEventIOErrorReasonNewFromDom(virDomainPtr dom,
+                                            const char *srcPath,
+                                            const char *devAlias,
+                                            int action,
+                                            const char *reason)
 {
     return virDomainEventIOErrorNewFromDomImpl(VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON,
                                                dom, srcPath, devAlias,
                                                action, reason);
 }
 
-virDomainEventPtr virDomainEventIOErrorReasonNewFromObj(virDomainObjPtr obj,
-                                                        const char *srcPath,
-                                                        const char *devAlias,
-                                                        int action,
-                                                        const char *reason)
+void *virDomainEventIOErrorReasonNewFromObj(virDomainObjPtr obj,
+                                            const char *srcPath,
+                                            const char *devAlias,
+                                            int action,
+                                            const char *reason)
 {
     return virDomainEventIOErrorNewFromObjImpl(VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON,
                                                obj, srcPath, devAlias,
@@ -1552,21 +1569,31 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn,
         }
 
     case VIR_DOMAIN_EVENT_ID_IO_ERROR:
-        ((virConnectDomainEventIOErrorCallback)cb)(conn, dom,
-                                                   event->data.ioError.srcPath,
-                                                   event->data.ioError.devAlias,
-                                                   event->data.ioError.action,
-                                                   cbopaque);
-        goto cleanup;
+        {
+            virDomainEventIOErrorPtr ioErrorEvent;
+
+            ioErrorEvent = (virDomainEventIOErrorPtr)event;
+            ((virConnectDomainEventIOErrorCallback)cb)(conn, dom,
+                                                       ioErrorEvent->srcPath,
+                                                       ioErrorEvent->devAlias,
+                                                       ioErrorEvent->action,
+                                                       cbopaque);
+            goto cleanup;
+        }
 
     case VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON:
-        ((virConnectDomainEventIOErrorReasonCallback)cb)(conn, dom,
-                                                         event->data.ioError.srcPath,
-                                                         event->data.ioError.devAlias,
-                                                         event->data.ioError.action,
-                                                         event->data.ioError.reason,
-                                                         cbopaque);
-        goto cleanup;
+        {
+            virDomainEventIOErrorPtr ioErrorEvent;
+
+            ioErrorEvent = (virDomainEventIOErrorPtr)event;
+            ((virConnectDomainEventIOErrorReasonCallback)cb)(conn, dom,
+                                                             ioErrorEvent->srcPath,
+                                                             ioErrorEvent->devAlias,
+                                                             ioErrorEvent->action,
+                                                             ioErrorEvent->reason,
+                                                             cbopaque);
+            goto cleanup;
+        }
 
     case VIR_DOMAIN_EVENT_ID_GRAPHICS:
         ((virConnectDomainEventGraphicsCallback)cb)(conn, dom,
diff --git a/src/conf/domain_event.h b/src/conf/domain_event.h
index b51ec97..45819dc 100644
--- a/src/conf/domain_event.h
+++ b/src/conf/domain_event.h
@@ -75,24 +75,24 @@ void *virDomainEventRTCChangeNewFromObj(virDomainObjPtr obj, long long offset);
 void *virDomainEventWatchdogNewFromDom(virDomainPtr dom, int action);
 void *virDomainEventWatchdogNewFromObj(virDomainObjPtr obj, int action);
 
-virDomainEventPtr virDomainEventIOErrorNewFromDom(virDomainPtr dom,
-                                                  const char *srcPath,
-                                                  const char *devAlias,
-                                                  int action);
-virDomainEventPtr virDomainEventIOErrorNewFromObj(virDomainObjPtr obj,
-                                                  const char *srcPath,
-                                                  const char *devAlias,
-                                                  int action);
-virDomainEventPtr virDomainEventIOErrorReasonNewFromDom(virDomainPtr dom,
-                                                        const char *srcPath,
-                                                        const char *devAlias,
-                                                        int action,
-                                                        const char *reason);
-virDomainEventPtr virDomainEventIOErrorReasonNewFromObj(virDomainObjPtr obj,
-                                                        const char *srcPath,
-                                                        const char *devAlias,
-                                                        int action,
-                                                        const char *reason);
+void *virDomainEventIOErrorNewFromDom(virDomainPtr dom,
+                                      const char *srcPath,
+                                      const char *devAlias,
+                                      int action);
+void *virDomainEventIOErrorNewFromObj(virDomainObjPtr obj,
+                                      const char *srcPath,
+                                      const char *devAlias,
+                                      int action);
+void *virDomainEventIOErrorReasonNewFromDom(virDomainPtr dom,
+                                            const char *srcPath,
+                                            const char *devAlias,
+                                            int action,
+                                            const char *reason);
+void *virDomainEventIOErrorReasonNewFromObj(virDomainObjPtr obj,
+                                            const char *srcPath,
+                                            const char *devAlias,
+                                            int action,
+                                            const char *reason);
 
 virDomainEventPtr virDomainEventGraphicsNewFromDom(virDomainPtr dom,
                                                    int phase,
-- 
1.8.4.2

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