From nobody Mon Feb 9 04:03:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522321709501474.2511870842552; Thu, 29 Mar 2018 04:08:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C6AB5C047B63; Thu, 29 Mar 2018 11:08:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A3981600C0; Thu, 29 Mar 2018 11:08:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6DEFD181BA06; Thu, 29 Mar 2018 11:08:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2TB84vI007257 for ; Thu, 29 Mar 2018 07:08:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id D7AEB1102E2D; Thu, 29 Mar 2018 11:08:04 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F1D61102E2C for ; Thu, 29 Mar 2018 11:08:04 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 29 Mar 2018 13:07:57 +0200 Message-Id: <20180329110758.9640-4-kkoukiou@redhat.com> In-Reply-To: <20180329110758.9640-1-kkoukiou@redhat.com> References: <20180329110758.9640-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 3/4] Merge all Domain lifecycle signals into one signal called Domain. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 29 Mar 2018 11:08:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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. The tests are adjusted to call correctly connect_to_signal method on the new signal. Signed-off-by: Katerina Koukiou --- 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/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index f24dff4..6810422 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -44,59 +44,11 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + value=3D"See https://libvirt.org/html/libvirt-libvirt-domain.html#= virConnectDomainEventCallback"/> + 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 =3D opaque; - const gchar *signal =3D NULL; - const gchar *name; + const gchar *event_type =3D NULL; g_autofree gchar *path =3D NULL; =20 switch (event) { case VIR_DOMAIN_EVENT_DEFINED: - signal =3D "DomainDefined"; + event_type =3D "DomainDefined"; break; case VIR_DOMAIN_EVENT_UNDEFINED: - signal =3D "DomainUndefined"; + event_type =3D "DomainUndefined"; break; case VIR_DOMAIN_EVENT_STARTED: - signal =3D "DomainStarted"; + event_type =3D "DomainStarted"; break; case VIR_DOMAIN_EVENT_SUSPENDED: - signal =3D "DomainSuspended"; + event_type =3D "DomainSuspended"; break; case VIR_DOMAIN_EVENT_RESUMED: - signal =3D "DomainResumed"; + event_type =3D "DomainResumed"; break; case VIR_DOMAIN_EVENT_STOPPED: - signal =3D "DomainStopped"; + event_type =3D "DomainStopped"; break; case VIR_DOMAIN_EVENT_SHUTDOWN: - signal =3D "DomainShutdown"; + event_type =3D "DomainShutdown"; break; case VIR_DOMAIN_EVENT_PMSUSPENDED: - signal =3D "DomainPMSuspended"; + event_type =3D "DomainPMSuspended"; break; case VIR_DOMAIN_EVENT_CRASHED: - signal =3D "DomainCrashed"; + event_type =3D "DomainCrashed"; break; default: return 0; } =20 - name =3D virDomainGetName(domain); path =3D virtDBusUtilBusPathForVirDomain(domain, connect->domainPath); =20 g_dbus_connection_emit_signal(connect->bus, NULL, connect->connectPath, VIRT_DBUS_CONNECT_INTERFACE, - signal, - g_variant_new("(so)", name, path), + "Domain", + g_variant_new("(os)", path, event_type), NULL); =20 return 0; diff --git a/test/test_connect.py b/test/test_connect.py index 48e25cb..c7830c5 100755 --- a/test/test_connect.py +++ b/test/test_connect.py @@ -29,12 +29,11 @@ class TestConnect(libvirttest.BaseTestClass): domain.Introspect(dbus_interface=3Ddbus.INTROSPECTABLE_IFACE) =20 def test_create(self): - def domain_started(name, path): - assert name =3D=3D 'foo' + def domain_started(path, _event): assert isinstance(path, dbus.ObjectPath) self.loop.quit() =20 - self.connect.connect_to_signal('DomainStarted', domain_started) + self.connect.connect_to_signal('Domain', domain_started, arg2=3D'D= omainStarted') =20 path =3D self.connect.CreateXML(self.minimal_xml, 0) assert isinstance(path, dbus.ObjectPath) @@ -42,12 +41,11 @@ class TestConnect(libvirttest.BaseTestClass): self.main_loop() =20 def test_define(self): - def domain_defined(name, path): - assert name =3D=3D 'foo' + def domain_defined(path, _event): assert isinstance(path, dbus.ObjectPath) self.loop.quit() =20 - self.connect.connect_to_signal('DomainDefined', domain_defined) + self.connect.connect_to_signal('Domain', domain_defined, arg2=3D'D= omainDefined') =20 path =3D self.connect.DefineXML(self.minimal_xml) assert isinstance(path, dbus.ObjectPath) diff --git a/test/test_domain.py b/test/test_domain.py index 1433ff5..7dbc971 100755 --- a/test/test_domain.py +++ b/test/test_domain.py @@ -38,12 +38,11 @@ class TestDomain(libvirttest.BaseTestClass): domain.Undefine(0) =20 def test_shutdown(self): - def domain_stopped(name, path): - assert name =3D=3D 'test' + def domain_stopped(path, _event): assert isinstance(path, dbus.ObjectPath) self.loop.quit() =20 - self.connect.connect_to_signal('DomainStopped', domain_stopped) + self.connect.connect_to_signal('Domain', domain_stopped, arg2=3D'D= omainStopped') =20 obj, domain =3D self.domain() domain.Shutdown(0) @@ -54,12 +53,11 @@ class TestDomain(libvirttest.BaseTestClass): self.main_loop() =20 def test_undefine(self): - def domain_undefined(name, path): - assert name =3D=3D 'test' + def domain_undefined(path, _event): assert isinstance(path, dbus.ObjectPath) self.loop.quit() =20 - self.connect.connect_to_signal('DomainUndefined', domain_undefined) + self.connect.connect_to_signal('Domain', domain_undefined, arg2=3D= 'DomainUndefined') =20 _, domain =3D self.domain() domain.Shutdown(0) @@ -68,12 +66,11 @@ class TestDomain(libvirttest.BaseTestClass): self.main_loop() =20 def test_suspend(self): - def domain_suspended(name, path): - assert name =3D=3D 'test' + def domain_suspended(path, _event): assert isinstance(path, dbus.ObjectPath) self.loop.quit() =20 - self.connect.connect_to_signal('DomainSuspended', domain_suspended) + self.connect.connect_to_signal('Domain', domain_suspended, arg2=3D= 'DomainSuspended') =20 obj, domain =3D self.domain() domain.Suspend() @@ -84,12 +81,11 @@ class TestDomain(libvirttest.BaseTestClass): self.main_loop() =20 def test_resume(self): - def domain_resumed(name, path): - assert name =3D=3D 'test' + def domain_resumed(path, _event): assert isinstance(path, dbus.ObjectPath) self.loop.quit() =20 - self.connect.connect_to_signal('DomainResumed', domain_resumed) + self.connect.connect_to_signal('Domain', domain_resumed, arg2=3D'D= omainResumed') =20 obj, domain =3D self.domain() domain.Suspend() --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list