[dbus PATCH] Add detail argument to DomainEvent signal

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

 



Adjust all DomainEvent tests to do detail type checking.

Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
---
This commit is rebased on top of unmerged patches for removing enum<->string
translation.

 data/org.libvirt.Connect.xml |  1 +
 src/events.c                 |  4 ++--
 tests/libvirttest.py         | 55 ++++++++++++++++++++++++++++++++++++++++++++
 tests/test_connect.py        |  6 +++--
 tests/test_domain.py         | 15 ++++++++----
 5 files changed, 72 insertions(+), 9 deletions(-)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 8272da6..0f1456f 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -171,6 +171,7 @@
         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventCallback"/>
       <arg name="domain" type="o"/>
       <arg name="event" type="u"/>
+      <arg name="detail" type="u"/>
     </signal>
     <signal name="NetworkEvent">
       <annotation name="org.gtk.GDBus.DocString"
diff --git a/src/events.c b/src/events.c
index b432535..ea55180 100644
--- a/src/events.c
+++ b/src/events.c
@@ -8,7 +8,7 @@ static gint
 virtDBusEventsDomainLifecycle(virConnectPtr connection G_GNUC_UNUSED,
                               virDomainPtr domain,
                               gint event,
-                              gint detail G_GNUC_UNUSED,
+                              gint detail,
                               gpointer opaque)
 {
     virtDBusConnect *connect = opaque;
@@ -21,7 +21,7 @@ virtDBusEventsDomainLifecycle(virConnectPtr connection G_GNUC_UNUSED,
                                   connect->connectPath,
                                   VIRT_DBUS_CONNECT_INTERFACE,
                                   "DomainEvent",
-                                  g_variant_new("(ou)", path, event),
+                                  g_variant_new("(ouu)", path, event, detail),
                                   NULL);
 
     return 0;
diff --git a/tests/libvirttest.py b/tests/libvirttest.py
index 06ac0e4..eee67a0 100644
--- a/tests/libvirttest.py
+++ b/tests/libvirttest.py
@@ -100,6 +100,61 @@ class DomainEvent(IntEnum):
     CRASHED = 8
 
 
+class DomainEventDefinedDetailType(IntEnum):
+    ADDED = 0
+    UPDATED = 1
+    RENAMED = 2
+    FROM_SNAPSHOT = 3
+    LAST = 4
+
+
+class DomainEventResumedDetailType(IntEnum):
+    UNPAUSED = 0
+    MIGRATED = 1
+    FROM_SNAPSHOT = 2
+    POSTCOPY = 3
+    LAST = 4
+
+
+class DomainEventStartedDetailType(IntEnum):
+    BOOTED = 0
+    MIGRATED = 1
+    RESTORED = 2
+    FROM_SNAPSHOT = 3
+    WAKEUP = 4
+    LAST = 5
+
+
+class DomainEventStoppedDetailType(IntEnum):
+    SHUTDOWN = 0
+    DESTROYED = 1
+    CRASHED = 2
+    MIGRATED =	3
+    SAVED = 4
+    FAILED = 5
+    FROM_SNAPSHOT = 6
+    LAST = 7
+
+
+class DomainEventSuspendedDetailType(IntEnum):
+    PAUSED = 0
+    MIGRATED	= 1
+    IOERROR = 2
+    WATCHDOG	= 3
+    RESTORED = 4
+    FROM_SNAPSHOT = 5
+    API_ERROR = 6
+    POSTCOPY = 7
+    POSTCOPY_FAILED = 8
+    LAST = 9
+
+
+class DomainEventUndefinedDetailType(IntEnum):
+    REMOVED = 0
+    RENAMED = 1
+    LAST = 2
+
+
 class DomainState(IntEnum):
     NOSTATE = 0
     RUNNING = 1
diff --git a/tests/test_connect.py b/tests/test_connect.py
index 7748822..a2bd17f 100755
--- a/tests/test_connect.py
+++ b/tests/test_connect.py
@@ -31,9 +31,10 @@ class TestConnect(libvirttest.BaseTestClass):
     '''
 
     def test_connect_domain_create_xml(self):
-        def domain_started(path, event):
+        def domain_started(path, event, detail):
             if event != libvirttest.DomainEvent.STARTED:
                 return
+            assert detail == libvirttest.DomainEventStartedDetailType.BOOTED
             assert isinstance(path, dbus.ObjectPath)
             self.loop.quit()
 
@@ -45,9 +46,10 @@ class TestConnect(libvirttest.BaseTestClass):
         self.main_loop()
 
     def test_comnect_domain_define_xml(self):
-        def domain_defined(path, event):
+        def domain_defined(path, event, detail):
             if event != libvirttest.DomainEvent.DEFINED:
                 return
+            assert detail == libvirttest.DomainEventDefinedDetailType.ADDED
             assert isinstance(path, dbus.ObjectPath)
             self.loop.quit()
 
diff --git a/tests/test_domain.py b/tests/test_domain.py
index c7e09cd..dfa19ed 100755
--- a/tests/test_domain.py
+++ b/tests/test_domain.py
@@ -47,9 +47,10 @@ class TestDomain(libvirttest.BaseTestClass):
         assert autostart_current == dbus.Boolean(autostart_expected)
 
     def test_domain_managed_save(self):
-        def domain_stopped(path, event):
+        def domain_stopped(path, event, detail):
             if event != libvirttest.DomainEvent.STOPPED:
                 return
+            assert detail == libvirttest.DomainEventStoppedDetailType.SAVED
             assert isinstance(path, dbus.ObjectPath)
             self.loop.quit()
 
@@ -74,9 +75,10 @@ class TestDomain(libvirttest.BaseTestClass):
         assert description_expected == domain.GetMetadata(metadata_description, "", 0)
 
     def test_resume(self):
-        def domain_resumed(path, event):
+        def domain_resumed(path, event, detail):
             if event != libvirttest.DomainEvent.RESUMED:
                 return
+            assert detail == libvirttest.DomainEventResumedDetailType.UNPAUSED
             assert isinstance(path, dbus.ObjectPath)
             self.loop.quit()
 
@@ -92,9 +94,10 @@ class TestDomain(libvirttest.BaseTestClass):
         self.main_loop()
 
     def test_shutdown(self):
-        def domain_stopped(path, event):
+        def domain_stopped(path, event, detail):
             if event != libvirttest.DomainEvent.STOPPED:
                 return
+            assert detail == libvirttest.DomainEventStoppedDetailType.SHUTDOWN
             assert isinstance(path, dbus.ObjectPath)
             self.loop.quit()
 
@@ -109,9 +112,10 @@ class TestDomain(libvirttest.BaseTestClass):
         self.main_loop()
 
     def test_suspend(self):
-        def domain_suspended(path, event):
+        def domain_suspended(path, event, detail):
             if event != libvirttest.DomainEvent.SUSPENDED:
                 return
+            assert detail == libvirttest.DomainEventSuspendedDetailType.PAUSED
             assert isinstance(path, dbus.ObjectPath)
             self.loop.quit()
 
@@ -126,9 +130,10 @@ class TestDomain(libvirttest.BaseTestClass):
         self.main_loop()
 
     def test_undefine(self):
-        def domain_undefined(path, event):
+        def domain_undefined(path, event, detail):
             if event != libvirttest.DomainEvent.UNDEFINED:
                 return
+            assert detail == libvirttest.DomainEventUndefinedDetailType.REMOVED
             assert isinstance(path, dbus.ObjectPath)
             self.loop.quit()
 
-- 
2.15.0

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

  Powered by Linux