From nobody Thu May 2 02:51:39 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; 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 1525257298247777.9958650129773; Wed, 2 May 2018 03:34:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3FC17356CA; Wed, 2 May 2018 10:34:56 +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 0691C60F87; Wed, 2 May 2018 10:34:56 +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 8EB3A180BADA; Wed, 2 May 2018 10:34: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 w42AYpgX025632 for ; Wed, 2 May 2018 06:34:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3E9FE6F9D9; Wed, 2 May 2018 10:34:51 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6DA46F9D8 for ; Wed, 2 May 2018 10:34:50 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Wed, 2 May 2018 12:34:38 +0200 Message-Id: <20180502103446.9051-2-kkoukiou@redhat.com> In-Reply-To: <20180502103446.9051-1-kkoukiou@redhat.com> References: <20180502103446.9051-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 1/9] Implement NodeGetCPUStats method for Connect 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 02 May 2018 10:34:57 +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.Connect.xml | 7 +++++++ src/connect.c | 41 +++++++++++++++++++++++++++++++++++++++++ tests/test_connect.py | 4 ++++ 3 files changed, 52 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index ee7bfdc..e5c18bd 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -166,6 +166,13 @@ + + + + + + diff --git a/src/connect.c b/src/connect.c index 5e577e4..6d0243f 100644 --- a/src/connect.c +++ b/src/connect.c @@ -842,6 +842,46 @@ virtDBusConnectNetworkLookupByUUID(GVariant *inArgs, *outArgs =3D g_variant_new("(o)", path); } =20 +static void +virtDBusConnectNodeGetCPUStats(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + gint cpuNum; + guint flags; + g_autofree virNodeCPUStatsPtr stats =3D NULL; + gint count =3D 0; + gint ret; + GVariant *gret; + GVariantBuilder builder; + + g_variant_get(inArgs, "(iu)", &cpuNum, &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + ret =3D virNodeGetCPUStats(connect->connection, cpuNum, NULL, &count, = flags); + if (ret =3D=3D 0 && count !=3D 0) { + stats =3D g_new0(virNodeCPUStats, count); + if (virNodeGetCPUStats(connect->connection, cpuNum, stats, + &count, flags) < 0) { + return virtDBusUtilSetLastVirtError(error); + } + } + + g_variant_builder_init(&builder, G_VARIANT_TYPE("a{st}")); + for (gint i =3D 0; i < count; i++) + g_variant_builder_add(&builder, "{st}", stats[i].field, stats[i].v= alue); + gret =3D g_variant_builder_end(&builder); + + *outArgs =3D g_variant_new_tuple(&gret, 1); +} + static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] =3D { { "Encrypted", virtDBusConnectGetEncrypted, NULL }, { "Hostname", virtDBusConnectGetHostname, NULL }, @@ -873,6 +913,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTa= ble[] =3D { { "NetworkDefineXML", virtDBusConnectNetworkDefineXML }, { "NetworkLookupByName", virtDBusConnectNetworkLookupByName }, { "NetworkLookupByUUID", virtDBusConnectNetworkLookupByUUID }, + { "NodeGetCPUStats", virtDBusConnectNodeGetCPUStats }, { 0 } }; =20 diff --git a/tests/test_connect.py b/tests/test_connect.py index 57f0658..1383cc0 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -156,6 +156,10 @@ class TestConnect(libvirttest.BaseTestClass): path =3D getattr(self.connect, lookup_method_name)(prop) assert original_path =3D=3D path =20 + def test_connect_node_get_cpu_stats(self): + stats =3D self.connect.NodeGetCPUStats(0, 0) + assert isinstance(stats, dbus.Dictionary) + =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 Thu May 2 02:51:39 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; 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 1525257297946216.54264535679533; Wed, 2 May 2018 03:34:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 475A483F46; Wed, 2 May 2018 10:34:56 +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 13BFB2A175; Wed, 2 May 2018 10:34:56 +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 A1471180BADB; Wed, 2 May 2018 10:34: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 w42AYpnE025638 for ; Wed, 2 May 2018 06:34:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id D6BB36F9D9; Wed, 2 May 2018 10:34:51 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A91C6353E for ; Wed, 2 May 2018 10:34:51 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Wed, 2 May 2018 12:34:39 +0200 Message-Id: <20180502103446.9051-3-kkoukiou@redhat.com> In-Reply-To: <20180502103446.9051-1-kkoukiou@redhat.com> References: <20180502103446.9051-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 2/9] Implement NodeGetFreeMemory method for Connect 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 02 May 2018 10:34:56 +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.Connect.xml | 5 +++++ src/connect.c | 24 ++++++++++++++++++++++++ tests/test_connect.py | 4 ++++ 3 files changed, 33 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index e5c18bd..c642aff 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -173,6 +173,11 @@ + + + + diff --git a/src/connect.c b/src/connect.c index 6d0243f..b161925 100644 --- a/src/connect.c +++ b/src/connect.c @@ -882,6 +882,29 @@ virtDBusConnectNodeGetCPUStats(GVariant *inArgs, *outArgs =3D g_variant_new_tuple(&gret, 1); } =20 +static void +virtDBusConnectNodeGetFreeMemory(GVariant *inArgs G_GNUC_UNUSED, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) + +{ + virtDBusConnect *connect =3D userData; + guint64 freemem; + + if (!virtDBusConnectOpen(connect, error)) + return; + + freemem =3D virNodeGetFreeMemory(connect->connection); + if (freemem =3D=3D 0) + return virtDBusUtilSetLastVirtError(error); + + *outArgs =3D g_variant_new("(t)", freemem); +} + static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] =3D { { "Encrypted", virtDBusConnectGetEncrypted, NULL }, { "Hostname", virtDBusConnectGetHostname, NULL }, @@ -914,6 +937,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTa= ble[] =3D { { "NetworkLookupByName", virtDBusConnectNetworkLookupByName }, { "NetworkLookupByUUID", virtDBusConnectNetworkLookupByUUID }, { "NodeGetCPUStats", virtDBusConnectNodeGetCPUStats }, + { "NodeGetFreeMemory", virtDBusConnectNodeGetFreeMemory }, { 0 } }; =20 diff --git a/tests/test_connect.py b/tests/test_connect.py index 1383cc0..7b9ad0d 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -160,6 +160,10 @@ class TestConnect(libvirttest.BaseTestClass): stats =3D self.connect.NodeGetCPUStats(0, 0) assert isinstance(stats, dbus.Dictionary) =20 + def test_connect_node_get_free_memory(self): + free_mem =3D self.connect.NodeGetFreeMemory() + assert isinstance(free_mem, dbus.UInt64) + =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 Thu May 2 02:51:39 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; 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 1525257308667573.2406265819793; Wed, 2 May 2018 03:35:08 -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 6D79385A02; Wed, 2 May 2018 10:35:05 +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 32A8817D23; Wed, 2 May 2018 10:35:05 +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 CBEEE180BAE7; Wed, 2 May 2018 10:35:04 +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 w42AYq4T025648 for ; Wed, 2 May 2018 06:34:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7A8746353E; Wed, 2 May 2018 10:34:52 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E2687C2A for ; Wed, 2 May 2018 10:34:51 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Wed, 2 May 2018 12:34:40 +0200 Message-Id: <20180502103446.9051-4-kkoukiou@redhat.com> In-Reply-To: <20180502103446.9051-1-kkoukiou@redhat.com> References: <20180502103446.9051-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 3/9] Implement NodeGetInfo method for Connect 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.26]); Wed, 02 May 2018 10:35:08 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou --- data/org.libvirt.Connect.xml | 5 +++++ src/connect.c | 25 +++++++++++++++++++++++++ tests/test_connect.py | 4 ++++ 3 files changed, 34 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index c642aff..6b6758f 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -178,6 +178,11 @@ value=3D"See https://libvirt.org/html/libvirt-libvirt-host.html#vi= rNodeGetFreeMemory"/> + + + + diff --git a/src/connect.c b/src/connect.c index b161925..367d5ae 100644 --- a/src/connect.c +++ b/src/connect.c @@ -905,6 +905,30 @@ virtDBusConnectNodeGetFreeMemory(GVariant *inArgs G_GN= UC_UNUSED, *outArgs =3D g_variant_new("(t)", freemem); } =20 +static void +virtDBusConnectNodeGetInfo(GVariant *inArgs G_GNUC_UNUSED, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) + +{ + virtDBusConnect *connect =3D userData; + virNodeInfo info; + + if (!virtDBusConnectOpen(connect, error)) + return; + + if (virNodeGetInfo(connect->connection, &info) < 0) + return virtDBusUtilSetLastVirtError(error); + + *outArgs =3D g_variant_new("((stuuuuuu))", info.model, info.memory, + info.cpus, info.mhz, info.nodes, info.sockets, + info.cores, info.threads); +} + static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] =3D { { "Encrypted", virtDBusConnectGetEncrypted, NULL }, { "Hostname", virtDBusConnectGetHostname, NULL }, @@ -938,6 +962,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTa= ble[] =3D { { "NetworkLookupByUUID", virtDBusConnectNetworkLookupByUUID }, { "NodeGetCPUStats", virtDBusConnectNodeGetCPUStats }, { "NodeGetFreeMemory", virtDBusConnectNodeGetFreeMemory }, + { "NodeGetInfo", virtDBusConnectNodeGetInfo }, { 0 } }; =20 diff --git a/tests/test_connect.py b/tests/test_connect.py index 7b9ad0d..f0f68b1 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -164,6 +164,10 @@ class TestConnect(libvirttest.BaseTestClass): free_mem =3D self.connect.NodeGetFreeMemory() assert isinstance(free_mem, dbus.UInt64) =20 + def test_connect_node_get_info(self): + info =3D self.connect.NodeGetInfo() + assert isinstance(info, dbus.Struct) + =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 Thu May 2 02:51:39 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; 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 15252573066034.262602793121232; Wed, 2 May 2018 03:35:06 -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 B70CB30BEA42; Wed, 2 May 2018 10:35:02 +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 7B22817D09; Wed, 2 May 2018 10:35:02 +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 0570A180BAE5; Wed, 2 May 2018 10:35:02 +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 w42AYrS3025653 for ; Wed, 2 May 2018 06:34:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1DFC46353E; Wed, 2 May 2018 10:34:53 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5DBD6353F for ; Wed, 2 May 2018 10:34:52 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Wed, 2 May 2018 12:34:41 +0200 Message-Id: <20180502103446.9051-5-kkoukiou@redhat.com> In-Reply-To: <20180502103446.9051-1-kkoukiou@redhat.com> References: <20180502103446.9051-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 4/9] Implement NodeGetMemoryParameters method in Connect 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.45]); Wed, 02 May 2018 10:35:05 +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.Connect.xml | 6 ++++++ src/connect.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 6b6758f..c62d107 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -183,6 +183,12 @@ value=3D"See https://libvirt.org/html/libvirt-libvirt-host.html#vi= rNodeGetInfo"/> + + + + + diff --git a/src/connect.c b/src/connect.c index 367d5ae..f2c6d45 100644 --- a/src/connect.c +++ b/src/connect.c @@ -929,6 +929,43 @@ virtDBusConnectNodeGetInfo(GVariant *inArgs G_GNUC_UNU= SED, info.cores, info.threads); } =20 +static void +virtDBusConnectNodeGetMemoryParameters(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUS= ED, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_auto(virtDBusUtilTypedParams) params =3D { 0 }; + guint flags; + gint ret; + GVariant *grecords; + + g_variant_get(inArgs, "(u)", &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + ret =3D virNodeGetMemoryParameters(connect->connection, NULL, + ¶ms.nparams, flags); + if (ret < 0) + return virtDBusUtilSetLastVirtError(error); + if (params.nparams !=3D 0) { + params.params =3D g_new0(virTypedParameter, params.nparams); + if (virNodeGetMemoryParameters(connect->connection, params.params, + ¶ms.nparams, flags) < 0) { + return virtDBusUtilSetLastVirtError(error); + } + } + + grecords =3D virtDBusUtilTypedParamsToGVariant(params.params, params.n= params); + + *outArgs =3D g_variant_new_tuple(&grecords, 1); +} + static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] =3D { { "Encrypted", virtDBusConnectGetEncrypted, NULL }, { "Hostname", virtDBusConnectGetHostname, NULL }, @@ -963,6 +1000,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodT= able[] =3D { { "NodeGetCPUStats", virtDBusConnectNodeGetCPUStats }, { "NodeGetFreeMemory", virtDBusConnectNodeGetFreeMemory }, { "NodeGetInfo", virtDBusConnectNodeGetInfo }, + { "NodeGetMemoryParameters", virtDBusConnectNodeGetMemoryParameters }, { 0 } }; =20 --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:39 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; 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 1525257305828828.9669231625204; Wed, 2 May 2018 03:35:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B22F881F01; Wed, 2 May 2018 10:35:02 +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 647D062664; Wed, 2 May 2018 10:35:02 +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 EF9344CAA9; Wed, 2 May 2018 10:35:01 +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 w42AYrM9025666 for ; Wed, 2 May 2018 06:34:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id B53E06353F; Wed, 2 May 2018 10:34:53 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 59B3B7C2A for ; Wed, 2 May 2018 10:34:53 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Wed, 2 May 2018 12:34:42 +0200 Message-Id: <20180502103446.9051-6-kkoukiou@redhat.com> In-Reply-To: <20180502103446.9051-1-kkoukiou@redhat.com> References: <20180502103446.9051-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] Implement NodeGetMemoryStats method for Connect 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 02 May 2018 10:35:05 +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.Connect.xml | 6 ++++++ src/connect.c | 44 ++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 50 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index c62d107..4a1ee4a 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -189,6 +189,12 @@ + + + + + diff --git a/src/connect.c b/src/connect.c index f2c6d45..0ecb333 100644 --- a/src/connect.c +++ b/src/connect.c @@ -966,6 +966,49 @@ virtDBusConnectNodeGetMemoryParameters(GVariant *inArg= s, *outArgs =3D g_variant_new_tuple(&grecords, 1); } =20 +static void +virtDBusConnectNodeGetMemoryStats(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autofree virNodeMemoryStatsPtr params =3D NULL; + gint nparams =3D 0; + gint cellNum =3D VIR_NODE_MEMORY_STATS_ALL_CELLS; + guint flags; + gint ret; + GVariantBuilder builder; + GVariant *res; + + g_variant_get(inArgs, "(u)", &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + ret =3D virNodeGetMemoryStats(connect->connection, cellNum, NULL, + &nparams, flags); + if (ret < 0) + return virtDBusUtilSetLastVirtError(error); + if (nparams !=3D 0) { + params =3D g_new0(virNodeMemoryStats, nparams); + if (virNodeGetMemoryStats(connect->connection, cellNum, params, + &nparams, flags) < 0) { + return virtDBusUtilSetLastVirtError(error); + } + } + + g_variant_builder_init(&builder, G_VARIANT_TYPE("a{st}")); + for (gint i =3D 0; i < nparams; i++) + g_variant_builder_add(&builder, "{st}", params[i].field, params[i]= .value); + res =3D g_variant_builder_end(&builder); + + *outArgs =3D g_variant_new_tuple(&res, 1); +} + static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] =3D { { "Encrypted", virtDBusConnectGetEncrypted, NULL }, { "Hostname", virtDBusConnectGetHostname, NULL }, @@ -1001,6 +1044,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethod= Table[] =3D { { "NodeGetFreeMemory", virtDBusConnectNodeGetFreeMemory }, { "NodeGetInfo", virtDBusConnectNodeGetInfo }, { "NodeGetMemoryParameters", virtDBusConnectNodeGetMemoryParameters }, + { "NodeGetMemoryStats", virtDBusConnectNodeGetMemoryStats }, { 0 } }; =20 --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:39 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; 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 1525257311516197.42450824628168; Wed, 2 May 2018 03:35:11 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1D718C003659; Wed, 2 May 2018 10:35:09 +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 D91902A17C; Wed, 2 May 2018 10:35:08 +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 79C064CAAB; Wed, 2 May 2018 10:35:08 +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 w42AYs8v025673 for ; Wed, 2 May 2018 06:34:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 580F47C2A; Wed, 2 May 2018 10:34:54 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0C406F9D9 for ; Wed, 2 May 2018 10:34:53 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Wed, 2 May 2018 12:34:43 +0200 Message-Id: <20180502103446.9051-7-kkoukiou@redhat.com> In-Reply-To: <20180502103446.9051-1-kkoukiou@redhat.com> References: <20180502103446.9051-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 6/9] Implement NodeGetSecurityModel 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 02 May 2018 10:35:10 +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.Connect.xml | 5 +++++ src/connect.c | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 4a1ee4a..610dda7 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -195,6 +195,11 @@ + + + + diff --git a/src/connect.c b/src/connect.c index 0ecb333..7495017 100644 --- a/src/connect.c +++ b/src/connect.c @@ -1009,6 +1009,28 @@ virtDBusConnectNodeGetMemoryStats(GVariant *inArgs, *outArgs =3D g_variant_new_tuple(&res, 1); } =20 +static void +virtDBusConnectNodeGetSecurityModel(GVariant *inArgs G_GNUC_UNUSED, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) + +{ + virtDBusConnect *connect =3D userData; + virSecurityModel secmodel; + + if (!virtDBusConnectOpen(connect, error)) + return; + + if (virNodeGetSecurityModel(connect->connection, &secmodel) < 0) + return virtDBusUtilSetLastVirtError(error); + + *outArgs =3D g_variant_new("((ss))", secmodel.model, secmodel.doi); +} + static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] =3D { { "Encrypted", virtDBusConnectGetEncrypted, NULL }, { "Hostname", virtDBusConnectGetHostname, NULL }, @@ -1045,6 +1067,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethod= Table[] =3D { { "NodeGetInfo", virtDBusConnectNodeGetInfo }, { "NodeGetMemoryParameters", virtDBusConnectNodeGetMemoryParameters }, { "NodeGetMemoryStats", virtDBusConnectNodeGetMemoryStats }, + { "NodeGetSecurityModel", virtDBusConnectNodeGetSecurityModel }, { 0 } }; =20 --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:39 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; 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 1525257313431599.5912907869; Wed, 2 May 2018 03:35:13 -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 14E6E81DE5; Wed, 2 May 2018 10:35:11 +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 D1CE51726C; Wed, 2 May 2018 10:35: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 85335180BADC; Wed, 2 May 2018 10:35:10 +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 w42AYt5i025681 for ; Wed, 2 May 2018 06:34:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id EF2AE7C2A; Wed, 2 May 2018 10:34:54 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 939296353E for ; Wed, 2 May 2018 10:34:54 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Wed, 2 May 2018 12:34:44 +0200 Message-Id: <20180502103446.9051-8-kkoukiou@redhat.com> In-Reply-To: <20180502103446.9051-1-kkoukiou@redhat.com> References: <20180502103446.9051-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 7/9] Implement NodeSetMemoryParameters method for Connect 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.25]); Wed, 02 May 2018 10:35: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.Connect.xml | 6 ++++++ src/connect.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 610dda7..e46d28d 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -200,6 +200,12 @@ value=3D"See https://libvirt.org/html/libvirt-libvirt-host.html#vi= rNodeGetSecurityModel"/> + + + + + diff --git a/src/connect.c b/src/connect.c index 7495017..cea64cb 100644 --- a/src/connect.c +++ b/src/connect.c @@ -1031,6 +1031,36 @@ virtDBusConnectNodeGetSecurityModel(GVariant *inArgs= G_GNUC_UNUSED, *outArgs =3D g_variant_new("((ss))", secmodel.model, secmodel.doi); } =20 +static void +virtDBusConnectNodeSetMemoryParameters(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUS= ED, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(GVariantIter) iter =3D NULL; + g_auto(virtDBusUtilTypedParams) params =3D { 0 }; + guint flags; + + g_variant_get(inArgs, "(a{sv}u)", &iter, &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + if (!virtDBusUtilGVariantToTypedParams(iter, ¶ms.params, + ¶ms.nparams, error)) { + return; + } + + if (virNodeSetMemoryParameters(connect->connection, params.params, + params.nparams, flags) < 0) { + virtDBusUtilSetLastVirtError(error); + } +} + static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] =3D { { "Encrypted", virtDBusConnectGetEncrypted, NULL }, { "Hostname", virtDBusConnectGetHostname, NULL }, @@ -1068,6 +1098,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethod= Table[] =3D { { "NodeGetMemoryParameters", virtDBusConnectNodeGetMemoryParameters }, { "NodeGetMemoryStats", virtDBusConnectNodeGetMemoryStats }, { "NodeGetSecurityModel", virtDBusConnectNodeGetSecurityModel }, + { "NodeSetMemoryParameters", virtDBusConnectNodeSetMemoryParameters }, { 0 } }; =20 --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:39 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; 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 1525257315429389.17810882144204; Wed, 2 May 2018 03:35:15 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 48C0531343A0; Wed, 2 May 2018 10:35:14 +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 0B7B030012A8; Wed, 2 May 2018 10:35:14 +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 B71F84CAAD; Wed, 2 May 2018 10:35:13 +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 w42AYtut025696 for ; Wed, 2 May 2018 06:34:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9226C7C2A; Wed, 2 May 2018 10:34:55 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 368A36353F for ; Wed, 2 May 2018 10:34:55 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Wed, 2 May 2018 12:34:45 +0200 Message-Id: <20180502103446.9051-9-kkoukiou@redhat.com> In-Reply-To: <20180502103446.9051-1-kkoukiou@redhat.com> References: <20180502103446.9051-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 8/9] Implement NodeSuspendForDuration method for Connect 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.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 02 May 2018 10:35:14 +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.Connect.xml | 8 ++++++++ src/connect.c | 42 ++++++++++++++++++++++++++++++++++++++++= ++ 2 files changed, 50 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index e46d28d..eb4990e 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -206,6 +206,14 @@ + + + + + + diff --git a/src/connect.c b/src/connect.c index cea64cb..4035853 100644 --- a/src/connect.c +++ b/src/connect.c @@ -13,6 +13,13 @@ VIRT_DBUS_ENUM_IMPL(virtDBusConnectCPUCompareResult, "identical", "superset") =20 +VIRT_DBUS_ENUM_DECL(virtDBusConnectNodeSuspendTarget) +VIRT_DBUS_ENUM_IMPL(virtDBusConnectNodeSuspendTarget, + VIR_NODE_SUSPEND_TARGET_LAST, + "mem", + "disk", + "hybrid") + static gint virtDBusConnectCredType[] =3D { VIR_CRED_AUTHNAME, VIR_CRED_ECHOPROMPT, @@ -1061,6 +1068,40 @@ virtDBusConnectNodeSetMemoryParameters(GVariant *inA= rgs, } } =20 +static void +virtDBusConnectNodeSuspendForDuration(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSE= D, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + const gchar *targetStr; + gint target; + guint64 duration; + guint flags; + + g_variant_get(inArgs, "(&stu)", &targetStr, &duration, &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + target =3D virtDBusConnectNodeSuspendTargetTypeFromString(targetStr); + if (target < 0) { + g_set_error(error, VIRT_DBUS_ERROR, VIRT_DBUS_ERROR_LIBVIRT, + "Can't get valid virNodeSuspendTarget from string '%s'= .", + targetStr); + return; + } + + if (virNodeSuspendForDuration(connect->connection, target, + duration, flags) < 0) { + virtDBusUtilSetLastVirtError(error); + } +} + static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] =3D { { "Encrypted", virtDBusConnectGetEncrypted, NULL }, { "Hostname", virtDBusConnectGetHostname, NULL }, @@ -1099,6 +1140,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethod= Table[] =3D { { "NodeGetMemoryStats", virtDBusConnectNodeGetMemoryStats }, { "NodeGetSecurityModel", virtDBusConnectNodeGetSecurityModel }, { "NodeSetMemoryParameters", virtDBusConnectNodeSetMemoryParameters }, + { "NodeSuspendForDuration", virtDBusConnectNodeSuspendForDuration }, { 0 } }; =20 --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:39 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; 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 1525257318093903.4384791091079; Wed, 2 May 2018 03:35:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0BED430F8D95; Wed, 2 May 2018 10:35:17 +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 C73155BD65; Wed, 2 May 2018 10:35:16 +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 734A8180BAEB; Wed, 2 May 2018 10:35:16 +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 w42AYuLY025708 for ; Wed, 2 May 2018 06:34:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 356F27C2A; Wed, 2 May 2018 10:34:56 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDF0F6353E for ; Wed, 2 May 2018 10:34:55 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Wed, 2 May 2018 12:34:46 +0200 Message-Id: <20180502103446.9051-10-kkoukiou@redhat.com> In-Reply-To: <20180502103446.9051-1-kkoukiou@redhat.com> References: <20180502103446.9051-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 9/9] Implement NodeGetCPUMap method for Connect 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 02 May 2018 10:35:17 +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.Connect.xml | 6 ++++++ src/connect.c | 35 +++++++++++++++++++++++++++++++++++ tests/test_connect.py | 4 ++++ 3 files changed, 45 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index eb4990e..b84753b 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -166,6 +166,12 @@ + + + + + diff --git a/src/connect.c b/src/connect.c index 4035853..7558b70 100644 --- a/src/connect.c +++ b/src/connect.c @@ -849,6 +849,40 @@ virtDBusConnectNetworkLookupByUUID(GVariant *inArgs, *outArgs =3D g_variant_new("(o)", path); } =20 +static void +virtDBusConnectNodeGetCPUMap(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autofree guchar *cpumap =3D NULL; + guint online =3D 0; + guint flags; + gint ret; + GVariant *gret; + GVariantBuilder builder; + + g_variant_get(inArgs, "(u)", &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + ret =3D virNodeGetCPUMap(connect->connection, &cpumap, &online, flags); + if (ret < 0) + return virtDBusUtilSetLastVirtError(error); + + g_variant_builder_init(&builder, G_VARIANT_TYPE("ab")); + for (gint i =3D 0; i < ret; i++) + g_variant_builder_add(&builder, "b", VIR_CPU_USED(cpumap, i)); + gret =3D g_variant_builder_end(&builder); + + *outArgs =3D g_variant_new_tuple(&gret, 1); +} + static void virtDBusConnectNodeGetCPUStats(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1133,6 +1167,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethod= Table[] =3D { { "NetworkDefineXML", virtDBusConnectNetworkDefineXML }, { "NetworkLookupByName", virtDBusConnectNetworkLookupByName }, { "NetworkLookupByUUID", virtDBusConnectNetworkLookupByUUID }, + { "NodeGetCPUMap", virtDBusConnectNodeGetCPUMap }, { "NodeGetCPUStats", virtDBusConnectNodeGetCPUStats }, { "NodeGetFreeMemory", virtDBusConnectNodeGetFreeMemory }, { "NodeGetInfo", virtDBusConnectNodeGetInfo }, diff --git a/tests/test_connect.py b/tests/test_connect.py index f0f68b1..4ddcb52 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -168,6 +168,10 @@ class TestConnect(libvirttest.BaseTestClass): info =3D self.connect.NodeGetInfo() assert isinstance(info, dbus.Struct) =20 + def test_connect_node_get_cpumap(self): + info =3D self.connect.NodeGetCPUMap(0) + assert isinstance(info, dbus.Array) + =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