From nobody Sat May 4 03:53:26 2024 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 1522744221837338.56537792697407; Tue, 3 Apr 2018 01:30:21 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EE1128046B; Tue, 3 Apr 2018 08:30:19 +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 B73CB8F6D9; Tue, 3 Apr 2018 08:30:19 +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 73FC01800CA5; Tue, 3 Apr 2018 08:30:19 +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 w338U6De008737 for ; Tue, 3 Apr 2018 04:30:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1CF5F7C24; Tue, 3 Apr 2018 08:30:06 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id B77457C28 for ; Tue, 3 Apr 2018 08:30:05 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 3 Apr 2018 10:29:56 +0200 Message-Id: <20180403083000.27851-2-kkoukiou@redhat.com> In-Reply-To: <20180403083000.27851-1-kkoukiou@redhat.com> References: <20180403083000.27851-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 v4 1/5] Implement Suspend method for Domain interface. 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 03 Apr 2018 08:30:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.Domain.xml | 4 ++++ src/domain.c | 21 +++++++++++++++++++++ test/test_domain.py | 15 +++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml index 39212ff..f31d078 100644 --- a/data/org.libvirt.Domain.xml +++ b/data/org.libvirt.Domain.xml @@ -84,6 +84,10 @@ value=3D"See https://libvirt.org/html/libvirt-libvirt-domain.html#= virDomainUndefineFlags"/> + + + diff --git a/src/domain.c b/src/domain.c index 4ff9f60..cb13b6b 100644 --- a/src/domain.c +++ b/src/domain.c @@ -450,6 +450,26 @@ virtDBusDomainUndefine(GVariant *inArgs G_GNUC_UNUSED, virtDBusUtilSetLastVirtError(error); } =20 +static void +virtDBusDomainSuspend(GVariant *inArgs G_GNUC_UNUSED, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virDomain) domain =3D NULL; + + domain =3D virtDBusDomainGetVirDomain(connect, objectPath, error); + if (!domain) + return; + + if (virDomainSuspend(domain) < 0) + virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusDomainPropertyTable[] =3D { { "Name", virtDBusDomainGetName, NULL }, { "UUID", virtDBusDomainGetUUID, NULL }, @@ -472,6 +492,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTab= le[] =3D { { "Reset", virtDBusDomainReset }, { "Create", virtDBusDomainCreate }, { "Undefine", virtDBusDomainUndefine }, + { "Suspend", virtDBusDomainSuspend }, { 0 } }; =20 diff --git a/test/test_domain.py b/test/test_domain.py index e617b1b..bb1b498 100755 --- a/test/test_domain.py +++ b/test/test_domain.py @@ -67,6 +67,21 @@ class TestDomain(libvirttest.BaseTestClass): =20 self.main_loop() =20 + def test_suspend(self): + def domain_suspended(name, path): + assert name =3D=3D 'test' + assert isinstance(path, dbus.ObjectPath) + self.loop.quit() + + self.connect.connect_to_signal('DomainSuspended', domain_suspended) + + obj, domain =3D self.domain() + domain.Suspend() + + state =3D obj.Get('org.libvirt.Domain', 'State', dbus_interface=3D= dbus.PROPERTIES_IFACE) + assert state =3D=3D 'paused' + + self.main_loop() =20 if __name__ =3D=3D '__main__': libvirttest.run() --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 03:53:26 2024 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 152274421404010.151631777853936; Tue, 3 Apr 2018 01:30:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0006D37E87; Tue, 3 Apr 2018 08:30:10 +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 C204F5E1C6; Tue, 3 Apr 2018 08:30:10 +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 E0BE14CA99; Tue, 3 Apr 2018 08:30:09 +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 w338U6l7008742 for ; Tue, 3 Apr 2018 04:30:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id CFC217C24; Tue, 3 Apr 2018 08:30:06 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7727E7C4F for ; Tue, 3 Apr 2018 08:30:06 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 3 Apr 2018 10:29:57 +0200 Message-Id: <20180403083000.27851-3-kkoukiou@redhat.com> In-Reply-To: <20180403083000.27851-1-kkoukiou@redhat.com> References: <20180403083000.27851-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 v4 2/5] Implement Resume method for Domain interface. 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 03 Apr 2018 08:30:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.Domain.xml | 4 ++++ src/domain.c | 21 +++++++++++++++++++++ test/test_domain.py | 17 +++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml index f31d078..7679018 100644 --- a/data/org.libvirt.Domain.xml +++ b/data/org.libvirt.Domain.xml @@ -88,6 +88,10 @@ + + + diff --git a/src/domain.c b/src/domain.c index cb13b6b..a530987 100644 --- a/src/domain.c +++ b/src/domain.c @@ -470,6 +470,26 @@ virtDBusDomainSuspend(GVariant *inArgs G_GNUC_UNUSED, virtDBusUtilSetLastVirtError(error); } =20 +static void +virtDBusDomainResume(GVariant *inArgs G_GNUC_UNUSED, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virDomain) domain =3D NULL; + + domain =3D virtDBusDomainGetVirDomain(connect, objectPath, error); + if (!domain) + return; + + if (virDomainResume(domain) < 0) + virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusDomainPropertyTable[] =3D { { "Name", virtDBusDomainGetName, NULL }, { "UUID", virtDBusDomainGetUUID, NULL }, @@ -493,6 +513,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTab= le[] =3D { { "Create", virtDBusDomainCreate }, { "Undefine", virtDBusDomainUndefine }, { "Suspend", virtDBusDomainSuspend }, + { "Resume", virtDBusDomainResume }, { 0 } }; =20 diff --git a/test/test_domain.py b/test/test_domain.py index bb1b498..1433ff5 100755 --- a/test/test_domain.py +++ b/test/test_domain.py @@ -83,5 +83,22 @@ class TestDomain(libvirttest.BaseTestClass): =20 self.main_loop() =20 + def test_resume(self): + def domain_resumed(name, path): + assert name =3D=3D 'test' + assert isinstance(path, dbus.ObjectPath) + self.loop.quit() + + self.connect.connect_to_signal('DomainResumed', domain_resumed) + + obj, domain =3D self.domain() + domain.Suspend() + domain.Resume() + + state =3D obj.Get('org.libvirt.Domain', 'State', dbus_interface=3D= dbus.PROPERTIES_IFACE) + assert state =3D=3D 'running' + + self.main_loop() + if __name__ =3D=3D '__main__': libvirttest.run() --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 03:53:26 2024 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 1522744213444134.85412522504032; Tue, 3 Apr 2018 01:30:13 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D984D28206; Tue, 3 Apr 2018 08:30:10 +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 85C1817A66; Tue, 3 Apr 2018 08:30:10 +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 EFF731800C9E; Tue, 3 Apr 2018 08:30:09 +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 w338U7hd008752 for ; Tue, 3 Apr 2018 04:30:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6DF267C28; Tue, 3 Apr 2018 08:30:07 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14FA57C45 for ; Tue, 3 Apr 2018 08:30:06 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 3 Apr 2018 10:29:58 +0200 Message-Id: <20180403083000.27851-4-kkoukiou@redhat.com> In-Reply-To: <20180403083000.27851-1-kkoukiou@redhat.com> References: <20180403083000.27851-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 v4 3/5] utils: Introduce functions and macros for translating ENUMs to strings 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 03 Apr 2018 08:30:11 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The functions were copied from src/util/virutil.* files from libvirt project Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- src/util.c | 27 +++++++++++++++++++++++++++ src/util.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/src/util.c b/src/util.c index d6c27f3..be65172 100644 --- a/src/util.c +++ b/src/util.c @@ -124,3 +124,30 @@ virtDBusUtilVirDomainListFree(virDomainPtr *domains) =20 g_free(domains); } + +const gchar * +virtDBusUtilEnumToString(const gchar *const *types, + guint ntypes, + gint type) +{ + if (type < 0 || (guint)type >=3D ntypes) + return NULL; + + return types[type]; +} + +gint +virtDBusUtilEnumFromString(const gchar *const *types, + guint ntypes, + const gchar *type) +{ + guint i; + if (!type) + return -1; + + for (i =3D 0; i < ntypes; i++) + if (g_str_equal(types[i], type) =3D=3D 0) + return i; + + return -1; +} diff --git a/src/util.h b/src/util.h index 4304bac..c9d9cfd 100644 --- a/src/util.h +++ b/src/util.h @@ -37,3 +37,31 @@ virtDBusUtilVirDomainListFree(virDomainPtr *domains); =20 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomain, virDomainFree); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainPtr, virtDBusUtilVirDomainListFree); + +gint +virtDBusUtilEnumFromString(const gchar *const *types, + guint ntypes, + const gchar *type) G_GNUC_PURE; + +const gchar * +virtDBusUtilEnumToString(const gchar *const *types, + guint ntypes, + gint type) G_GNUC_PURE; + +#define VIRT_DBUS_ENUM_IMPL(name, lastVal, ...) \ + static const gchar *const name ##TypeList[] =3D { __VA_ARGS__ }; \ + G_STATIC_ASSERT(G_N_ELEMENTS(name ##TypeList) =3D=3D lastVal); \ + const gchar *name ##TypeToString(gint type) { \ + return virtDBusUtilEnumToString(name ##TypeList, \ + G_N_ELEMENTS(name ##TypeList), \ + type); \ + } \ + gint name ##TypeFromString(const gchar *type) { \ + return virtDBusUtilEnumFromString(name ##TypeList, \ + G_N_ELEMENTS(name ##TypeList), \ + type); \ + } + +#define VIRT_DBUS_ENUM_DECL(name) \ + const gchar *name ##TypeToString(gint type) G_GNUC_PURE; \ + gint name ##TypeFromString(const gchar *type) G_GNUC_PURE; --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 03:53:26 2024 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 1522744221327917.6204401683904; Tue, 3 Apr 2018 01:30:21 -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 C6CA5C04AC5C; Tue, 3 Apr 2018 08:30:19 +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 A02C6600C8; Tue, 3 Apr 2018 08:30:19 +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 5E8834CAA0; Tue, 3 Apr 2018 08:30:19 +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 w338U8rx008757 for ; Tue, 3 Apr 2018 04:30:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0C1277C24; Tue, 3 Apr 2018 08:30:08 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id A719D7C4D for ; Tue, 3 Apr 2018 08:30:07 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 3 Apr 2018 10:29:59 +0200 Message-Id: <20180403083000.27851-5-kkoukiou@redhat.com> In-Reply-To: <20180403083000.27851-1-kkoukiou@redhat.com> References: <20180403083000.27851-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 v4 4/5] events: Introduce virtDBusEventsDomainEventToString function 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]); Tue, 03 Apr 2018 08:30:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This function replaces the manual translation of Event ENUMS. Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- src/events.c | 55 +++++++++++++++++++++---------------------------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/src/events.c b/src/events.c index dada55f..1877115 100644 --- a/src/events.c +++ b/src/events.c @@ -4,6 +4,26 @@ =20 #include =20 +VIRT_DBUS_ENUM_DECL(virtDBusEventsDomainEvent) +VIRT_DBUS_ENUM_IMPL(virtDBusEventsDomainEvent, + VIR_DOMAIN_EVENT_LAST, + "DomainDefined", + "DomainUndefined", + "DomainStarted", + "DomainSuspended", + "DomainResumed", + "DomainStopped", + "DomainShutdown", + "DomainPMSuspended", + "DomainCrashed") + +static const gchar * +virtDBusEventsDomainEventToString(gint event) +{ + const gchar *str =3D virtDBusEventsDomainEventTypeToString(event); + return str ? str : "unknown"; +} + static gint virtDBusEventsDomainLifecycle(virConnectPtr connection G_GNUC_UNUSED, virDomainPtr domain, @@ -12,42 +32,9 @@ virtDBusEventsDomainLifecycle(virConnectPtr connection G= _GNUC_UNUSED, gpointer opaque) { virtDBusConnect *connect =3D opaque; - const gchar *signal =3D NULL; const gchar *name; g_autofree gchar *path =3D NULL; =20 - switch (event) { - case VIR_DOMAIN_EVENT_DEFINED: - signal =3D "DomainDefined"; - break; - case VIR_DOMAIN_EVENT_UNDEFINED: - signal =3D "DomainUndefined"; - break; - case VIR_DOMAIN_EVENT_STARTED: - signal =3D "DomainStarted"; - break; - case VIR_DOMAIN_EVENT_SUSPENDED: - signal =3D "DomainSuspended"; - break; - case VIR_DOMAIN_EVENT_RESUMED: - signal =3D "DomainResumed"; - break; - case VIR_DOMAIN_EVENT_STOPPED: - signal =3D "DomainStopped"; - break; - case VIR_DOMAIN_EVENT_SHUTDOWN: - signal =3D "DomainShutdown"; - break; - case VIR_DOMAIN_EVENT_PMSUSPENDED: - signal =3D "DomainPMSuspended"; - break; - case VIR_DOMAIN_EVENT_CRASHED: - signal =3D "DomainCrashed"; - break; - default: - return 0; - } - name =3D virDomainGetName(domain); path =3D virtDBusUtilBusPathForVirDomain(domain, connect->domainPath); =20 @@ -55,7 +42,7 @@ virtDBusEventsDomainLifecycle(virConnectPtr connection G_= GNUC_UNUSED, NULL, connect->connectPath, VIRT_DBUS_CONNECT_INTERFACE, - signal, + virtDBusEventsDomainEventToString(event), g_variant_new("(so)", name, path), NULL); =20 --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 03:53:26 2024 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 1522744225551588.9829532435443; Tue, 3 Apr 2018 01:30:25 -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 B0E062821D; Tue, 3 Apr 2018 08:30:23 +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 81D26649AF; Tue, 3 Apr 2018 08:30:23 +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 409754CA9E; Tue, 3 Apr 2018 08:30:23 +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 w338U8fH008763 for ; Tue, 3 Apr 2018 04:30:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9F53D7C28; Tue, 3 Apr 2018 08:30:08 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45A847C45 for ; Tue, 3 Apr 2018 08:30:08 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 3 Apr 2018 10:30:00 +0200 Message-Id: <20180403083000.27851-6-kkoukiou@redhat.com> In-Reply-To: <20180403083000.27851-1-kkoukiou@redhat.com> References: <20180403083000.27851-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 v4 5/5] 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.30]); Tue, 03 Apr 2018 08:30:24 +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 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 Reviewed-by: Pavel Hrdina --- 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 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + value=3D"See https://libvirt.org/html/libvirt-libvirt-domain.html#= virConnectDomainEventCallback"/> + 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") =20 static const gchar * virtDBusEventsDomainEventToString(gint event) @@ -32,18 +32,16 @@ virtDBusEventsDomainLifecycle(virConnectPtr connection = G_GNUC_UNUSED, gpointer opaque) { virtDBusConnect *connect =3D opaque; - const gchar *name; g_autofree gchar *path =3D NULL; =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, - virtDBusEventsDomainEventToString(event), - g_variant_new("(so)", name, path), + "DomainEvent", + g_variant_new("(os)", path, virtDBusEven= tsDomainEventToString(event)), NULL); =20 return 0; diff --git a/test/test_connect.py b/test/test_connect.py index 48e25cb..5df7a5b 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('DomainEvent', domain_started, arg1= =3D'Started') =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('DomainEvent', domain_defined, arg1= =3D'Defined') =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..d36adf7 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('DomainEvent', domain_stopped, arg1= =3D'Stopped') =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('DomainEvent', domain_undefined, ar= g1=3D'Undefined') =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('DomainEvent', domain_suspended, ar= g1=3D'Suspended') =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('DomainEvent', domain_resumed, arg1= =3D'Resumed') =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