Instead of having multiple signals regarding to domain events,
like DomainStarted, DomainUndefined etc, we will have only one
called DomainEvents, and the specific event type will be specified in
the signals arguments.
The domain name argument in not needed in the signal since we can
fetch it from path.
The tests are adjusted to call correctly connect_to_signal method
on the new signal.
Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Connect.xml | 54 +++-----------------------------------------
src/events.c | 24 +++++++++-----------
test/test_connect.py | 10 ++++----
test/test_domain.py | 20 +++++++---------
4 files changed, 26 insertions(+), 82 deletions(-)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index f24dff4..1695100 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -44,59 +44,11 @@
<arg name="uuid" type="s" direction="in"/>
<arg name="domain" type="o" direction="out"/>
</method>
- <signal name="DomainCrashed">
+ <signal name="DomainEvent">
<annotation name="org.gtk.GDBus.DocString"
- value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#VIR_DOMAIN_EVENT_CRA...
- <arg name="reason" type="s"/>
- <arg name="domain" type="o"/>
- </signal>
- <signal name="DomainDefined">
- <annotation name="org.gtk.GDBus.DocString"
- value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#VIR_DOMAIN_EVENT_DEF...
- <arg name="reason" type="s"/>
- <arg name="domain" type="o"/>
- </signal>
- <signal name="DomainPMSuspended">
- <annotation name="org.gtk.GDBus.DocString"
- value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#VIR_DOMAIN_EVENT_SUS...
- <arg name="reason" type="s"/>
- <arg name="domain" type="o"/>
- </signal>
- <signal name="DomainResumed">
- <annotation name="org.gtk.GDBus.DocString"
- value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#VIR_DOMAIN_EVENT_RES...
- <arg name="reason" type="s"/>
- <arg name="domain" type="o"/>
- </signal>
- <signal name="DomainShutdown">
- <annotation name="org.gtk.GDBus.DocString"
- value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#VIR_DOMAIN_EVENT_SHU...
- <arg name="reason" type="s"/>
- <arg name="domain" type="o"/>
- </signal>
- <signal name="DomainStarted">
- <annotation name="org.gtk.GDBus.DocString"
- value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#VIR_DOMAIN_EVENT_STA...
- <arg name="reason" type="s"/>
- <arg name="domain" type="o"/>
- </signal>
- <signal name="DomainStopped">
- <annotation name="org.gtk.GDBus.DocString"
- value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#VIR_DOMAIN_EVENT_STO...
- <arg name="reason" type="s"/>
- <arg name="domain" type="o"/>
- </signal>
- <signal name="DomainSuspended">
- <annotation name="org.gtk.GDBus.DocString"
- value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#VIR_DOMAIN_EVENT_SUS...
- <arg name="reason" type="s"/>
- <arg name="domain" type="o"/>
- </signal>
- <signal name="DomainUndefined">
- <annotation name="org.gtk.GDBus.DocString"
- value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#VIR_DOMAIN_EVENT_UND...
- <arg name="reason" type="s"/>
+ value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEven...
<arg name="domain" type="o"/>
+ <arg name="event" type="s"/>
</signal>
</interface>
</node>
diff --git a/src/events.c b/src/events.c
index 1877115..9229063 100644
--- a/src/events.c
+++ b/src/events.c
@@ -7,15 +7,15 @@
VIRT_DBUS_ENUM_DECL(virtDBusEventsDomainEvent)
VIRT_DBUS_ENUM_IMPL(virtDBusEventsDomainEvent,
VIR_DOMAIN_EVENT_LAST,
- "DomainDefined",
- "DomainUndefined",
- "DomainStarted",
- "DomainSuspended",
- "DomainResumed",
- "DomainStopped",
- "DomainShutdown",
- "DomainPMSuspended",
- "DomainCrashed")
+ "Defined",
+ "Undefined",
+ "Started",
+ "Suspended",
+ "Resumed",
+ "Stopped",
+ "Shutdown",
+ "PMSuspended",
+ "Crashed")
static const gchar *
virtDBusEventsDomainEventToString(gint event)
@@ -32,18 +32,16 @@ virtDBusEventsDomainLifecycle(virConnectPtr connection
G_GNUC_UNUSED,
gpointer opaque)
{
virtDBusConnect *connect = opaque;
- const gchar *name;
g_autofree gchar *path = NULL;
- name = virDomainGetName(domain);
path = virtDBusUtilBusPathForVirDomain(domain, connect->domainPath);
g_dbus_connection_emit_signal(connect->bus,
NULL,
connect->connectPath,
VIRT_DBUS_CONNECT_INTERFACE,
- virtDBusEventsDomainEventToString(event),
- g_variant_new("(so)", name, path),
+ "DomainEvent",
+ g_variant_new("(os)", path,
virtDBusEventsDomainEventToString(event)),
This line is too long, but the change in the previous patch will
introduce temporary variable which will fix the long line.
Pavel