From nobody Wed May 14 09:45:54 2025 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525423136048903.6221673458521; Fri, 4 May 2018 01:38:56 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D05EF315008F; Fri, 4 May 2018 08:38:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9BFBC30012A0; Fri, 4 May 2018 08:38:54 +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 5D3A24CAAD; Fri, 4 May 2018 08:38:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w448ch01028973 for ; Fri, 4 May 2018 04:38:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 631A17C36; Fri, 4 May 2018 08:38:43 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0721783B8B for ; Fri, 4 May 2018 08:38:42 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Fri, 4 May 2018 10:38:31 +0200 Message-Id: <20180504083835.26984-6-kkoukiou@redhat.com> In-Reply-To: <20180504083835.26984-1-kkoukiou@redhat.com> References: <20180504083835.26984-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 5/9] Change NetworkEvent argument from string to unsigned int 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.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 04 May 2018 08:38:55 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Modify the relevant tests to comply with the new signal. Note: argument matching in connect_to_signal method is only usable with string and thus had to be refactored. Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.Connect.xml | 2 +- src/events.c | 14 +------------- tests/libvirttest.py | 7 +++++++ tests/test_connect.py | 12 ++++++++---- tests/test_network.py | 18 ++++++++++++------ 5 files changed, 29 insertions(+), 24 deletions(-) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 386a7bb..8272da6 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -176,7 +176,7 @@ - + diff --git a/src/events.c b/src/events.c index 601d898..1b584f7 100644 --- a/src/events.c +++ b/src/events.c @@ -146,14 +146,6 @@ virtDBusEventsDomainDiskChange(virConnectPtr connectio= n G_GNUC_UNUSED, return 0; } =20 -VIRT_DBUS_ENUM_DECL(virtDBusEventsNetworkEvent) -VIRT_DBUS_ENUM_IMPL(virtDBusEventsNetworkEvent, - VIR_NETWORK_EVENT_LAST, - "Defined", - "Undefined", - "Started", - "Stopped") - static gint virtDBusEventsNetworkLifecycle(virConnectPtr connection G_GNUC_UNUSED, virNetworkPtr network, @@ -163,10 +155,6 @@ virtDBusEventsNetworkLifecycle(virConnectPtr connectio= n G_GNUC_UNUSED, { virtDBusConnect *connect =3D opaque; g_autofree gchar *path =3D NULL; - const gchar *eventStr =3D virtDBusEventsNetworkEventTypeToString(event= ); - - if (!eventStr) - return 0; =20 path =3D virtDBusUtilBusPathForVirNetwork(network, connect->networkPat= h); =20 @@ -175,7 +163,7 @@ virtDBusEventsNetworkLifecycle(virConnectPtr connection= G_GNUC_UNUSED, connect->connectPath, VIRT_DBUS_CONNECT_INTERFACE, "NetworkEvent", - g_variant_new("(os)", path, eventStr), + g_variant_new("(ou)", path, event), NULL); =20 return 0; diff --git a/tests/libvirttest.py b/tests/libvirttest.py index f7f48ed..0e84a94 100644 --- a/tests/libvirttest.py +++ b/tests/libvirttest.py @@ -98,3 +98,10 @@ class DomainEvent(IntEnum): SHUTDOWN =3D 6 PMSUSPENDED =3D 7 CRASHED =3D 8 + + +class NetworkEvent(IntEnum): + DEFINED =3D 0 + UNDEFINED =3D 1 + STARTED =3D 2 + STOPPED =3D 3 diff --git a/tests/test_connect.py b/tests/test_connect.py index 41cc134..7748822 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -125,11 +125,13 @@ class TestConnect(libvirttest.BaseTestClass): assert isinstance(self.connect.GetCPUModelNames(arch, 0), dbus.Arr= ay) =20 def test_connect_network_create_xml(self): - def network_started(path, _event): + def network_started(path, event): + if event !=3D libvirttest.NetworkEvent.STARTED: + return assert isinstance(path, dbus.ObjectPath) self.loop.quit() =20 - self.connect.connect_to_signal('NetworkEvent', network_started, ar= g1=3D'Started') + self.connect.connect_to_signal('NetworkEvent', network_started) =20 path =3D self.connect.NetworkCreateXML(self.minimal_network_xml) assert isinstance(path, dbus.ObjectPath) @@ -137,11 +139,13 @@ class TestConnect(libvirttest.BaseTestClass): self.main_loop() =20 def test_connect_network_define_xml(self): - def network_defined(path, _event): + def network_defined(path, event): + if event !=3D libvirttest.NetworkEvent.DEFINED: + return assert isinstance(path, dbus.ObjectPath) self.loop.quit() =20 - self.connect.connect_to_signal('NetworkEvent', network_defined, ar= g1=3D'Defined') + self.connect.connect_to_signal('NetworkEvent', network_defined) =20 path =3D self.connect.NetworkDefineXML(self.minimal_network_xml) assert isinstance(path, dbus.ObjectPath) diff --git a/tests/test_network.py b/tests/test_network.py index 1340d95..f34c081 100755 --- a/tests/test_network.py +++ b/tests/test_network.py @@ -34,11 +34,13 @@ class TestNetwork(libvirttest.BaseTestClass): assert autostart_current =3D=3D dbus.Boolean(autostart_expected) =20 def test_network_create(self): - def domain_started(path, _event): + def domain_started(path, event): + if event !=3D libvirttest.NetworkEvent.STARTED: + return assert isinstance(path, dbus.ObjectPath) self.loop.quit() =20 - self.connect.connect_to_signal('NetworkEvent', domain_started, arg= 1=3D'Started') + self.connect.connect_to_signal('NetworkEvent', domain_started) =20 _,test_network =3D self.test_network() interface_obj =3D dbus.Interface(test_network, 'org.libvirt.Networ= k') @@ -48,11 +50,13 @@ class TestNetwork(libvirttest.BaseTestClass): self.main_loop() =20 def test_network_destroy(self): - def network_stopped(path, _event): + def network_stopped(path, event): + if event !=3D libvirttest.NetworkEvent.STOPPED: + return assert isinstance(path, dbus.ObjectPath) self.loop.quit() =20 - self.connect.connect_to_signal('NetworkEvent', network_stopped, ar= g1=3D'Stopped') + self.connect.connect_to_signal('NetworkEvent', network_stopped) =20 _, test_network =3D self.test_network() interface_obj =3D dbus.Interface(test_network, 'org.libvirt.Networ= k') @@ -66,11 +70,13 @@ class TestNetwork(libvirttest.BaseTestClass): assert isinstance(interface_obj.GetXMLDesc(0), dbus.String) =20 def test_network_undefine(self): - def domain_undefined(path, _event): + def domain_undefined(path, event): + if event !=3D libvirttest.NetworkEvent.UNDEFINED: + return assert isinstance(path, dbus.ObjectPath) self.loop.quit() =20 - self.connect.connect_to_signal('NetworkEvent', domain_undefined, a= rg1=3D'Undefined') + self.connect.connect_to_signal('NetworkEvent', domain_undefined) =20 _,test_network =3D self.test_network() interface_obj =3D dbus.Interface(test_network, 'org.libvirt.Networ= k') --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list