[libvirt] [dbus PATCH 3/4] Merge all Domain lifecycle signals into one signal called Domain.

Ján Tomko jtomko at redhat.com
Thu Mar 29 13:05:06 UTC 2018


On Thu, Mar 29, 2018 at 01:07:57PM +0200, Katerina Koukiou wrote:
>Instead of having multiple signals regarding to domain events,
>like DomainStarted, DomainUndefined etc, we will have only one
>called Domain, 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.
>

Any plans to add support for the 'detail' field of
virConnectDomainEventCallback?

>The tests are adjusted to call correctly connect_to_signal method
>on the new signal.
>
>Signed-off-by: Katerina Koukiou <kkoukiou at redhat.com>
>---
> data/org.libvirt.Connect.xml | 54 +++-----------------------------------------
> src/events.c                 | 26 ++++++++++-----------
> test/test_connect.py         | 10 ++++----
> test/test_domain.py          | 20 +++++++---------
> 4 files changed, 27 insertions(+), 83 deletions(-)
>

>diff --git a/src/events.c b/src/events.c
>index dada55f..62f3729 100644
>--- a/src/events.c
>+++ b/src/events.c
>@@ -12,51 +12,49 @@ virtDBusEventsDomainLifecycle(virConnectPtr connection G_GNUC_UNUSED,
>                               gpointer opaque)
> {
>     virtDBusConnect *connect = opaque;
>-    const gchar *signal = NULL;
>-    const gchar *name;
>+    const gchar *event_type = NULL;
>     g_autofree gchar *path = NULL;
>
>     switch (event) {
>     case VIR_DOMAIN_EVENT_DEFINED:
>-        signal = "DomainDefined";
>+        event_type = "DomainDefined";
>         break;
>     case VIR_DOMAIN_EVENT_UNDEFINED:
>-        signal = "DomainUndefined";
>+        event_type = "DomainUndefined";
>         break;
>     case VIR_DOMAIN_EVENT_STARTED:
>-        signal = "DomainStarted";
>+        event_type = "DomainStarted";
>         break;
>     case VIR_DOMAIN_EVENT_SUSPENDED:
>-        signal = "DomainSuspended";
>+        event_type = "DomainSuspended";
>         break;
>     case VIR_DOMAIN_EVENT_RESUMED:
>-        signal = "DomainResumed";
>+        event_type = "DomainResumed";
>         break;
>     case VIR_DOMAIN_EVENT_STOPPED:
>-        signal = "DomainStopped";
>+        event_type = "DomainStopped";
>         break;
>     case VIR_DOMAIN_EVENT_SHUTDOWN:
>-        signal = "DomainShutdown";
>+        event_type = "DomainShutdown";
>         break;
>     case VIR_DOMAIN_EVENT_PMSUSPENDED:
>-        signal = "DomainPMSuspended";
>+        event_type = "DomainPMSuspended";
>         break;
>     case VIR_DOMAIN_EVENT_CRASHED:
>-        signal = "DomainCrashed";
>+        event_type = "DomainCrashed";
>         break;
>     default:
>         return 0;

Converting this to an EnumToString call first would make the commit replacing
the char* variable name and the commit dropping the Domain prefix nicer.

Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180329/71c8950c/attachment-0001.sig>


More information about the libvir-list mailing list