From nobody Fri May 3 16:32: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; 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 1525704377542903.7845891802943; Mon, 7 May 2018 07:46:17 -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 18F52C0C274A; Mon, 7 May 2018 14:46:16 +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 CF87B60BE0; Mon, 7 May 2018 14:46:15 +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 4DC685BBE4; Mon, 7 May 2018 14:46:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47Ef3ne032352 for ; Mon, 7 May 2018 10:41:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5CE702024CA2; Mon, 7 May 2018 14:41:03 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8E572024CA1 for ; Mon, 7 May 2018 14:41:02 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:42 +0200 Message-Id: <20180507144100.25045-2-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 01/19] Introduce StoragePool 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.32]); Mon, 07 May 2018 14:46:16 +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/Makefile.am | 3 +- data/org.libvirt.StoragePool.xml | 7 +++++ src/Makefile.am | 3 +- src/connect.c | 6 ++++ src/connect.h | 1 + src/storagepool.c | 65 ++++++++++++++++++++++++++++++++++++= ++++ src/storagepool.h | 9 ++++++ src/util.c | 33 ++++++++++++++++++++ src/util.h | 16 ++++++++++ 9 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 data/org.libvirt.StoragePool.xml create mode 100644 src/storagepool.c create mode 100644 src/storagepool.h diff --git a/data/Makefile.am b/data/Makefile.am index 61702df..4d2af45 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -21,7 +21,8 @@ polkit_DATA =3D $(polkit_files:.rules.in=3D.rules) interfaces_files =3D \ org.libvirt.Connect.xml \ org.libvirt.Domain.xml \ - org.libvirt.Network.xml + org.libvirt.Network.xml \ + org.libvirt.StoragePool.xml interfacesdir =3D $(DBUS_INTERFACES_DIR) interfaces_DATA =3D $(interfaces_files) =20 diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml new file mode 100644 index 0000000..504a166 --- /dev/null +++ b/data/org.libvirt.StoragePool.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/src/Makefile.am b/src/Makefile.am index 158398a..5e082da 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,7 +9,8 @@ DAEMON_SOURCES =3D \ domain.c domain.h \ events.c events.h \ gdbus.c gdbus.h \ - network.c network.h + network.c network.h \ + storagepool.c storagepool.h =20 EXTRA_DIST =3D \ $(DAEMON_SOURCES) diff --git a/src/connect.c b/src/connect.c index fd335e3..e838e98 100644 --- a/src/connect.c +++ b/src/connect.c @@ -2,6 +2,7 @@ #include "domain.h" #include "events.h" #include "network.h" +#include "storagepool.h" #include "util.h" =20 #include @@ -1105,6 +1106,7 @@ virtDBusConnectFree(virtDBusConnect *connect) =20 g_free(connect->domainPath); g_free(connect->networkPath); + g_free(connect->storagePoolPath); g_free(connect); } G_DEFINE_AUTOPTR_CLEANUP_FUNC(virtDBusConnect, virtDBusConnectFree); @@ -1154,6 +1156,10 @@ virtDBusConnectNew(virtDBusConnect **connectp, if (error && *error) return; =20 + virtDBusStoragePoolRegister(connect, error); + if (error && *error) + return; + *connectp =3D connect; connect =3D NULL; } diff --git a/src/connect.h b/src/connect.h index f89bc9d..d6c3830 100644 --- a/src/connect.h +++ b/src/connect.h @@ -14,6 +14,7 @@ struct virtDBusConnect { const gchar *connectPath; gchar *domainPath; gchar *networkPath; + gchar *storagePoolPath; virConnectPtr connection; GMutex lock; =20 diff --git a/src/storagepool.c b/src/storagepool.c new file mode 100644 index 0000000..f1421ef --- /dev/null +++ b/src/storagepool.c @@ -0,0 +1,65 @@ +#include "storagepool.h" +#include "util.h" + +#include + +static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] =3D { + { 0 } +}; + +static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] =3D { + { 0 } +}; + +static gchar ** +virtDBusStoragePoolEnumerate(gpointer userData) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virStoragePoolPtr) storagePools =3D NULL; + gint num =3D 0; + gchar **ret =3D NULL; + + if (!virtDBusConnectOpen(connect, NULL)) + return NULL; + + num =3D virConnectListAllStoragePools(connect->connection, &storagePoo= ls, 0); + if (num < 0) + return NULL; + + if (num =3D=3D 0) + return NULL; + + ret =3D g_new0(gchar *, num + 1); + + for (gint i =3D 0; i < num; i++) { + ret[i] =3D virtDBusUtilBusPathForVirStoragePool(storagePools[i], + connect->storagePool= Path); + } + + return ret; +} + +static GDBusInterfaceInfo *interfaceInfo; + +void +virtDBusStoragePoolRegister(virtDBusConnect *connect, + GError **error) +{ + connect->storagePoolPath =3D g_strdup_printf("%s/storagepool", + connect->connectPath); + + if (!interfaceInfo) { + interfaceInfo =3D virtDBusGDBusLoadIntrospectData(VIRT_DBUS_STORAG= EPOOL_INTERFACE, + error); + if (!interfaceInfo) + return; + } + + virtDBusGDBusRegisterSubtree(connect->bus, + connect->storagePoolPath, + interfaceInfo, + virtDBusStoragePoolEnumerate, + virtDBusStoragePoolMethodTable, + virtDBusStoragePoolPropertyTable, + connect); +} diff --git a/src/storagepool.h b/src/storagepool.h new file mode 100644 index 0000000..fb2bffb --- /dev/null +++ b/src/storagepool.h @@ -0,0 +1,9 @@ +#pragma once + +#include "connect.h" + +#define VIRT_DBUS_STORAGEPOOL_INTERFACE "org.libvirt.StoragePool" + +void +virtDBusStoragePoolRegister(virtDBusConnect *connect, + GError **error); diff --git a/src/util.c b/src/util.c index 548fac8..e90be3b 100644 --- a/src/util.c +++ b/src/util.c @@ -255,3 +255,36 @@ virtDBusUtilStringListFree(virtDBusCharArray *item) =20 g_free(item); } + +virStoragePoolPtr +virtDBusUtilVirStoragePoolFromBusPath(virConnectPtr connection, + const gchar *path, + const gchar *storagePoolPath) +{ + g_autofree gchar *name =3D NULL; + gsize prefixLen =3D strlen(storagePoolPath) + 1; + + name =3D virtDBusUtilDecodeUUID(path + prefixLen); + + return virStoragePoolLookupByUUIDString(connection, name); +} + +gchar * +virtDBusUtilBusPathForVirStoragePool(virStoragePoolPtr storagePool, + const gchar *storagePoolPath) +{ + gchar uuid[VIR_UUID_STRING_BUFLEN] =3D ""; + g_autofree gchar *newUuid =3D NULL; + virStoragePoolGetUUIDString(storagePool, uuid); + newUuid =3D virtDBusUtilEncodeUUID(uuid); + return g_strdup_printf("%s/%s", storagePoolPath, newUuid); +} + +void +virtDBusUtilVirStoragePoolListFree(virStoragePoolPtr *storagePools) +{ + for (gint i =3D 0; storagePools[i] !=3D NULL; i++) + virStoragePoolFree(storagePools[i]); + + g_free(storagePools); +} diff --git a/src/util.h b/src/util.h index 3309803..d932b66 100644 --- a/src/util.h +++ b/src/util.h @@ -78,3 +78,19 @@ void virtDBusUtilStringListFree(virtDBusCharArray *item); =20 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virtDBusCharArray, virtDBusUtilStringListFre= e); + +virStoragePoolPtr +virtDBusUtilVirStoragePoolFromBusPath(virConnectPtr connection, + const gchar *path, + const gchar *storagePoolPath); + +gchar * +virtDBusUtilBusPathForVirStoragePool(virStoragePoolPtr storagePool, + const gchar *storagePoolPath); + +void +virtDBusUtilVirStoragePoolListFree(virStoragePoolPtr *storagePools); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virStoragePool, virStoragePoolFree); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virStoragePoolPtr, + virtDBusUtilVirStoragePoolListFree); --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 16:32: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; 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 1525704073403175.30930694546214; Mon, 7 May 2018 07:41: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 45FDE81DE6; Mon, 7 May 2018 14:41: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 298AD5C293; Mon, 7 May 2018 14:41: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 826B01809547; Mon, 7 May 2018 14:41:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47Ef4BM032357 for ; Mon, 7 May 2018 10:41:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id F3C902024CA2; Mon, 7 May 2018 14:41:03 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 990AA2024CA1 for ; Mon, 7 May 2018 14:41:03 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:43 +0200 Message-Id: <20180507144100.25045-3-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 02/19] Implement ListStoragePools 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]); Mon, 07 May 2018 14:41: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 | 40 ++++++++++++++++++++++++++++++++++++++++ tests/test_connect.py | 12 ++++++++++++ 3 files changed, 58 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index a235872..9207295 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -145,6 +145,12 @@ + + + + + diff --git a/src/connect.c b/src/connect.c index e838e98..858db43 100644 --- a/src/connect.c +++ b/src/connect.c @@ -709,6 +709,45 @@ virtDBusConnectListNetworks(GVariant *inArgs, *outArgs =3D g_variant_new_tuple(&gnetworks, 1); } =20 +static void +virtDBusConnectListStoragePools(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_autoptr(virStoragePoolPtr) storagePools =3D NULL; + guint flags; + GVariantBuilder builder; + GVariant *gstoragePools; + + g_variant_get(inArgs, "(u)", &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + if (virConnectListAllStoragePools(connect->connection, &storagePools, + flags) < 0) { + return virtDBusUtilSetLastVirtError(error); + } + + g_variant_builder_init(&builder, G_VARIANT_TYPE("ao")); + + for (gint i =3D 0; storagePools[i]; i++) { + g_autofree gchar *path =3D NULL; + path =3D virtDBusUtilBusPathForVirStoragePool(storagePools[i], + connect->storagePoolPa= th); + + g_variant_builder_add(&builder, "o", path); + } + + gstoragePools =3D g_variant_builder_end(&builder); + *outArgs =3D g_variant_new_tuple(&gstoragePools, 1); +} + static void virtDBusConnectNetworkCreateXML(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1082,6 +1121,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethod= Table[] =3D { { "GetSysinfo", virtDBusConnectGetSysinfo }, { "ListDomains", virtDBusConnectListDomains }, { "ListNetworks", virtDBusConnectListNetworks }, + { "ListStoragePools", virtDBusConnectListStoragePools }, { "NetworkCreateXML", virtDBusConnectNetworkCreateXML }, { "NetworkDefineXML", virtDBusConnectNetworkDefineXML }, { "NetworkLookupByName", virtDBusConnectNetworkLookupByName }, diff --git a/tests/test_connect.py b/tests/test_connect.py index 3eeecb9..d8f05e8 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -126,6 +126,18 @@ class TestConnect(libvirttest.BaseTestClass): arch =3D "x86_64" assert isinstance(self.connect.GetCPUModelNames(arch, 0), dbus.Arr= ay) =20 + def test_connect_list_storage_pools(self): + storage_pools =3D self.connect.ListStoragePools(0) + assert isinstance(storage_pools, dbus.Array) + assert len(storage_pools) =3D=3D 1 + + for path in storage_pools: + assert isinstance(path, dbus.ObjectPath) + storage_pool =3D self.bus.get_object('org.libvirt', path) + + # ensure the path exists by calling Introspect on it + storage_pool.Introspect(dbus_interface=3Ddbus.INTROSPECTABLE_I= FACE) + def test_connect_network_create_xml(self): def network_started(path, event): if event !=3D libvirttest.NetworkEvent.STARTED: --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 16:32: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; 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 1525704384201425.15439136954535; Mon, 7 May 2018 07:46:24 -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 667EA80469; Mon, 7 May 2018 14:46:21 +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 2124930B4985; Mon, 7 May 2018 14:46:21 +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 AF0A7180BAE5; Mon, 7 May 2018 14:46:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47Ef4Pf032362 for ; Mon, 7 May 2018 10:41:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 96C492024CA2; Mon, 7 May 2018 14:41:04 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BCBB2024CA1 for ; Mon, 7 May 2018 14:41:04 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:44 +0200 Message-Id: <20180507144100.25045-4-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 03/19] Register StoragePool Lifecycle Events 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.28]); Mon, 07 May 2018 14:46:22 +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 | 13 +++++++++++++ src/connect.h | 1 + src/events.c | 43 ++++++++++++++++++++++++++++++++++++++++= +++ 4 files changed, 64 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 9207295..6b156d1 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -230,5 +230,12 @@ + + + + + + diff --git a/src/connect.c b/src/connect.c index 858db43..97c4857 100644 --- a/src/connect.c +++ b/src/connect.c @@ -60,6 +60,16 @@ virtDBusConnectClose(virtDBusConnect *connect, } } =20 + for (gint i =3D 0; i < VIR_STORAGE_POOL_EVENT_ID_LAST; i++) { + if (connect->storagePoolCallbackIds[i] >=3D 0) { + if (deregisterEvents) { + virConnectStoragePoolEventDeregisterAny(connect->connectio= n, + connect->storagePo= olCallbackIds[i]); + } + connect->storagePoolCallbackIds[i] =3D -1; + } + } + virConnectClose(connect->connection); connect->connection =3D NULL; } @@ -1177,6 +1187,9 @@ virtDBusConnectNew(virtDBusConnect **connectp, for (gint i =3D 0; i < VIR_NETWORK_EVENT_ID_LAST; i++) connect->networkCallbackIds[i] =3D -1; =20 + for (gint i =3D 0; i < VIR_STORAGE_POOL_EVENT_ID_LAST; i++) + connect->storagePoolCallbackIds[i] =3D -1; + connect->bus =3D bus; connect->uri =3D uri; connect->connectPath =3D connectPath; diff --git a/src/connect.h b/src/connect.h index d6c3830..b4df048 100644 --- a/src/connect.h +++ b/src/connect.h @@ -20,6 +20,7 @@ struct virtDBusConnect { =20 gint domainCallbackIds[VIR_DOMAIN_EVENT_ID_LAST]; gint networkCallbackIds[VIR_NETWORK_EVENT_ID_LAST]; + gint storagePoolCallbackIds[VIR_STORAGE_POOL_EVENT_ID_LAST]; }; typedef struct virtDBusConnect virtDBusConnect; =20 diff --git a/src/events.c b/src/events.c index ea55180..04967c2 100644 --- a/src/events.c +++ b/src/events.c @@ -143,6 +143,30 @@ virtDBusEventsNetworkLifecycle(virConnectPtr connectio= n G_GNUC_UNUSED, return 0; } =20 +static gint +virtDBusEventsStoragePoolLifecycle(virConnectPtr connection G_GNUC_UNUSED, + virStoragePoolPtr storagePool, + gint event, + gint detail, + gpointer opaque) +{ + virtDBusConnect *connect =3D opaque; + g_autofree gchar *path =3D NULL; + + path =3D virtDBusUtilBusPathForVirStoragePool(storagePool, + connect->storagePoolPath); + + g_dbus_connection_emit_signal(connect->bus, + NULL, + connect->connectPath, + VIRT_DBUS_CONNECT_INTERFACE, + "StoragePoolEvent", + g_variant_new("(ouu)", path, event, deta= il), + NULL); + + return 0; +} + static void virtDBusEventsRegisterDomainEvent(virtDBusConnect *connect, gint id, @@ -173,6 +197,21 @@ virtDBusEventsRegisterNetworkEvent(virtDBusConnect *co= nnect, NU= LL); } =20 +static void +virtDBusEventsRegisterStoragePoolEvent(virtDBusConnect *connect, + gint id, + virConnectStoragePoolEventGenericCa= llback callback) +{ + g_assert(connect->storagePoolCallbackIds[id] =3D=3D -1); + + connect->storagePoolCallbackIds[id] =3D virConnectStoragePoolEventRegi= sterAny(connect->connection, + = NULL, + = id, + = VIR_STORAGE_POOL_EVENT_CALLBACK(callback), + = connect, + = NULL); +} + void virtDBusEventsRegister(virtDBusConnect *connect) { @@ -199,4 +238,8 @@ virtDBusEventsRegister(virtDBusConnect *connect) virtDBusEventsRegisterNetworkEvent(connect, VIR_NETWORK_EVENT_ID_LIFECYCLE, VIR_NETWORK_EVENT_CALLBACK(virtDBus= EventsNetworkLifecycle)); + + virtDBusEventsRegisterStoragePoolEvent(connect, + VIR_STORAGE_POOL_EVENT_ID_LIFEC= YCLE, + VIR_STORAGE_POOL_EVENT_CALLBACK= (virtDBusEventsStoragePoolLifecycle)); } --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 16:32: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; 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 1525704208498620.9202520095552; Mon, 7 May 2018 07:43:28 -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 1C49F81DF1; Mon, 7 May 2018 14:43: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 0ADA819940; Mon, 7 May 2018 14:43:26 +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 B8936180BAE5; Mon, 7 May 2018 14:43:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47Ef5qf032373 for ; Mon, 7 May 2018 10:41:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 397152024CA2; Mon, 7 May 2018 14:41:05 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2A332024CA1 for ; Mon, 7 May 2018 14:41:04 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:45 +0200 Message-Id: <20180507144100.25045-5-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 04/19] Implement Destroy method for StoragePool 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.25]); Mon, 07 May 2018 14:43:27 +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.StoragePool.xml | 4 ++++ src/storagepool.c | 43 ++++++++++++++++++++++++++++++++++++= ++++ tests/libvirttest.py | 21 ++++++++++++++++++++ tests/test_storage.py | 26 ++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100755 tests/test_storage.py diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index 504a166..ac628d9 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -3,5 +3,9 @@ =20 + + + diff --git a/src/storagepool.c b/src/storagepool.c index f1421ef..5202f9e 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -3,11 +3,54 @@ =20 #include =20 +static virStoragePoolPtr +virtDBusStoragePoolGetVirStoragePool(virtDBusConnect *connect, + const gchar *objectPath, + GError **error) +{ + virStoragePoolPtr storagePool; + + if (virtDBusConnectOpen(connect, error) < 0) + return NULL; + + storagePool =3D virtDBusUtilVirStoragePoolFromBusPath(connect->connect= ion, + objectPath, + connect->storagePo= olPath); + if (!storagePool) { + virtDBusUtilSetLastVirtError(error); + return NULL; + } + + return storagePool; +} + +static void +virtDBusStoragePoolDestroy(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(virStoragePool) storagePool =3D NULL; + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + if (virStoragePoolDestroy(storagePool) < 0) + virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] =3D { { 0 } }; =20 static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] =3D { + { "Destroy", virtDBusStoragePoolDestroy }, { 0 } }; =20 diff --git a/tests/libvirttest.py b/tests/libvirttest.py index eee67a0..e88484f 100644 --- a/tests/libvirttest.py +++ b/tests/libvirttest.py @@ -87,6 +87,19 @@ class BaseTestClass(): obj =3D self.bus.get_object('org.libvirt', path) return path, obj =20 + def test_storage_pool(self): + """Fetch information for the test storage pool from test driver + + Returns: + (dbus.proxies.ProxyObject, dbus.proxies.ProxyObject): + Test StoragePool Object, Local proxy for the test StoragePool + Object. + + """ + path =3D self.connect.ListStoragePools(0)[0] + obj =3D self.bus.get_object('org.libvirt', path) + return path, obj + =20 class DomainEvent(IntEnum): DEFINED =3D 0 @@ -172,3 +185,11 @@ class NetworkEvent(IntEnum): UNDEFINED =3D 1 STARTED =3D 2 STOPPED =3D 3 + + +class StoragePoolEvent(IntEnum): + DEFINED =3D 0 + UNDEFINED =3D 1 + STARTED =3D 2 + STOPPED =3D 3 + LAST =3D 4 diff --git a/tests/test_storage.py b/tests/test_storage.py new file mode 100755 index 0000000..8c5d75f --- /dev/null +++ b/tests/test_storage.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import dbus +import libvirttest + +class TestStoragePool(libvirttest.BaseTestClass): + def test_storage_pool_destroy(self): + def storage_pool_destroyed(path, event, _detail): + if event !=3D libvirttest.StoragePoolEvent.STOPPED: + return + assert isinstance(path, dbus.ObjectPath) + self.loop.quit() + + self.connect.connect_to_signal('StoragePoolEvent', + storage_pool_destroyed) + + _, test_storage_pool =3D self.test_storage_pool() + interface_obj =3D dbus.Interface(test_storage_pool, + 'org.libvirt.StoragePool') + interface_obj.Destroy() + + 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 Fri May 3 16:32: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; 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 1525704214326741.8923428176255; Mon, 7 May 2018 07:43:34 -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 A6C94883AB; Mon, 7 May 2018 14:43:31 +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 5BEAF5C293; Mon, 7 May 2018 14:43:31 +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 11EE05BBE7; Mon, 7 May 2018 14:43:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47Ef5W1032382 for ; Mon, 7 May 2018 10:41:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id D10C32024CA2; Mon, 7 May 2018 14:41:05 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75AE12024CA1 for ; Mon, 7 May 2018 14:41:05 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:46 +0200 Message-Id: <20180507144100.25045-6-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 05/19] Implement Build method for StoragePool 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.26]); Mon, 07 May 2018 14:43:33 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" VIR_STORAGE_POOL_EVENT_CREATED event was added in 3.1. Test should be fixed later on to use signal handler. Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.StoragePool.xml | 5 +++++ src/storagepool.c | 25 +++++++++++++++++++++++++ tests/libvirttest.py | 8 ++++++++ tests/test_storage.py | 8 +++++++- 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index ac628d9..f96e676 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -3,6 +3,11 @@ =20 + + + + diff --git a/src/storagepool.c b/src/storagepool.c index 5202f9e..d23c847 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -24,6 +24,30 @@ virtDBusStoragePoolGetVirStoragePool(virtDBusConnect *co= nnect, return storagePool; } =20 +static void +virtDBusStoragePoolBuild(GVariant *inArgs, + 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(virStoragePool) storagePool =3D NULL; + guint flags; + + g_variant_get(inArgs, "(u)", &flags); + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + if (virStoragePoolBuild(storagePool, flags) < 0) + virtDBusUtilSetLastVirtError(error); +} + static void virtDBusStoragePoolDestroy(GVariant *inArgs G_GNUC_UNUSED, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -50,6 +74,7 @@ static virtDBusGDBusPropertyTable virtDBusStoragePoolProp= ertyTable[] =3D { }; =20 static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] =3D { + { "Build", virtDBusStoragePoolBuild }, { "Destroy", virtDBusStoragePoolDestroy }, { 0 } }; diff --git a/tests/libvirttest.py b/tests/libvirttest.py index e88484f..3cd02ef 100644 --- a/tests/libvirttest.py +++ b/tests/libvirttest.py @@ -187,6 +187,14 @@ class NetworkEvent(IntEnum): STOPPED =3D 3 =20 =20 +class StoragePoolBuildFlags(IntEnum): + NEW =3D 0 + REPAIR =3D 1 + RESIZE =3D 2 + NO_OVERWRITE =3D 4 + OVERWRITE =3D 8 + + class StoragePoolEvent(IntEnum): DEFINED =3D 0 UNDEFINED =3D 1 diff --git a/tests/test_storage.py b/tests/test_storage.py index 8c5d75f..cf13024 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -4,6 +4,13 @@ import dbus import libvirttest =20 class TestStoragePool(libvirttest.BaseTestClass): + def test_storage_pool_build(self): + _, test_storage_pool =3D self.test_storage_pool() + interface_obj =3D dbus.Interface(test_storage_pool, + 'org.libvirt.StoragePool') + interface_obj.Destroy() + interface_obj.Build(libvirttest.StoragePoolBuildFlags.NEW) + def test_storage_pool_destroy(self): def storage_pool_destroyed(path, event, _detail): if event !=3D libvirttest.StoragePoolEvent.STOPPED: @@ -13,7 +20,6 @@ class TestStoragePool(libvirttest.BaseTestClass): =20 self.connect.connect_to_signal('StoragePoolEvent', storage_pool_destroyed) - _, test_storage_pool =3D self.test_storage_pool() interface_obj =3D dbus.Interface(test_storage_pool, 'org.libvirt.StoragePool') --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 16:32: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; 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 1525704388582709.8464105450186; Mon, 7 May 2018 07:46:28 -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 37015C04AC51; Mon, 7 May 2018 14:46:26 +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 0202A5D75E; Mon, 7 May 2018 14:46:26 +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 9CDAB5BBE7; Mon, 7 May 2018 14:46:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47Ef6BY032387 for ; Mon, 7 May 2018 10:41:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 73CE92024CA2; Mon, 7 May 2018 14:41:06 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18DDE2024CA1 for ; Mon, 7 May 2018 14:41:05 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:47 +0200 Message-Id: <20180507144100.25045-7-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 06/19] Implement Create method for StoragePool 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.31]); Mon, 07 May 2018 14:46:27 +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.StoragePool.xml | 5 +++++ src/storagepool.c | 25 +++++++++++++++++++++++++ tests/test_storage.py | 17 +++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index f96e676..7e837c0 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -8,6 +8,11 @@ value=3D"See https://libvirt.org/html/libvirt-libvirt-storage.html= #virStoragePoolBuild"/> + + + + diff --git a/src/storagepool.c b/src/storagepool.c index d23c847..d4cd7a7 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -48,6 +48,30 @@ virtDBusStoragePoolBuild(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } =20 +static void +virtDBusStoragePoolCreate(GVariant *inArgs, + 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(virStoragePool) storagePool =3D NULL; + guint flags; + + g_variant_get(inArgs, "(u)", &flags); + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + if (virStoragePoolCreate(storagePool, flags) < 0) + virtDBusUtilSetLastVirtError(error); +} + static void virtDBusStoragePoolDestroy(GVariant *inArgs G_GNUC_UNUSED, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -75,6 +99,7 @@ static virtDBusGDBusPropertyTable virtDBusStoragePoolProp= ertyTable[] =3D { =20 static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] =3D { { "Build", virtDBusStoragePoolBuild }, + { "Create", virtDBusStoragePoolCreate }, { "Destroy", virtDBusStoragePoolDestroy }, { 0 } }; diff --git a/tests/test_storage.py b/tests/test_storage.py index cf13024..b1927cb 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -11,6 +11,23 @@ class TestStoragePool(libvirttest.BaseTestClass): interface_obj.Destroy() interface_obj.Build(libvirttest.StoragePoolBuildFlags.NEW) =20 + def test_storage_pool_create(self): + def storage_pool_started(path, event, _detail): + if event !=3D libvirttest.StoragePoolEvent.STARTED: + return + assert isinstance(path, dbus.ObjectPath) + self.loop.quit() + + self.connect.connect_to_signal('StoragePoolEvent', storage_pool_st= arted) + + _, test_storage_pool =3D self.test_storage_pool() + interface_obj =3D dbus.Interface(test_storage_pool, + 'org.libvirt.StoragePool') + interface_obj.Destroy() + interface_obj.Create(0) + + self.main_loop() + def test_storage_pool_destroy(self): def storage_pool_destroyed(path, event, _detail): if event !=3D libvirttest.StoragePoolEvent.STOPPED: --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 16:32: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; 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 1525704392393567.6136275487344; Mon, 7 May 2018 07:46:32 -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 824203150043; Mon, 7 May 2018 14:46:30 +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 3DE7031320A4; Mon, 7 May 2018 14:46:30 +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 DF58B180BAE8; Mon, 7 May 2018 14:46:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47Ef7uE032393 for ; Mon, 7 May 2018 10:41:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 16FCB2024CA2; Mon, 7 May 2018 14:41:07 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id B041B2024CA1 for ; Mon, 7 May 2018 14:41:06 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:48 +0200 Message-Id: <20180507144100.25045-8-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 07/19] Implement Delete method for StoragePool 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.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 07 May 2018 14:46:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" VIR_STORAGE_POOL_EVENT_DELETED event was added in 3.1. Test should be fixed later on to use signal handler. Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.StoragePool.xml | 5 +++++ src/storagepool.c | 25 +++++++++++++++++++++++++ tests/test_storage.py | 7 +++++++ 3 files changed, 37 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index 7e837c0..fb21e59 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -13,6 +13,11 @@ value=3D"See https://libvirt.org/html/libvirt-libvirt-storage.html= #virStoragePoolCreate"/> + + + + diff --git a/src/storagepool.c b/src/storagepool.c index d4cd7a7..bf1fd3f 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -72,6 +72,30 @@ virtDBusStoragePoolCreate(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } =20 +static void +virtDBusStoragePoolDelete(GVariant *inArgs, + 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(virStoragePool) storagePool =3D NULL; + guint flags; + + g_variant_get(inArgs, "(u)", &flags); + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + if (virStoragePoolDelete(storagePool, flags) < 0) + virtDBusUtilSetLastVirtError(error); +} + static void virtDBusStoragePoolDestroy(GVariant *inArgs G_GNUC_UNUSED, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -100,6 +124,7 @@ static virtDBusGDBusPropertyTable virtDBusStoragePoolPr= opertyTable[] =3D { static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] =3D { { "Build", virtDBusStoragePoolBuild }, { "Create", virtDBusStoragePoolCreate }, + { "Delete", virtDBusStoragePoolDelete }, { "Destroy", virtDBusStoragePoolDestroy }, { 0 } }; diff --git a/tests/test_storage.py b/tests/test_storage.py index b1927cb..c4c7cf1 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -28,6 +28,13 @@ class TestStoragePool(libvirttest.BaseTestClass): =20 self.main_loop() =20 + def test_storage_pool_delete(self): + _, test_storage_pool =3D self.test_storage_pool() + interface_obj =3D dbus.Interface(test_storage_pool, + 'org.libvirt.StoragePool') + interface_obj.Destroy() + interface_obj.Delete(0) + def test_storage_pool_destroy(self): def storage_pool_destroyed(path, event, _detail): if event !=3D libvirttest.StoragePoolEvent.STOPPED: --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 16:32: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; 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 1525704093205378.79200877631297; Mon, 7 May 2018 07:41:33 -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 2E739C0587C2; Mon, 7 May 2018 14:41:31 +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 D794231320A6; Mon, 7 May 2018 14:41:30 +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 4DE685BBE6; Mon, 7 May 2018 14:41:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47Ef7QL032401 for ; Mon, 7 May 2018 10:41:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id AE16A2024CA2; Mon, 7 May 2018 14:41:07 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52F2E2024CA1 for ; Mon, 7 May 2018 14:41:07 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:49 +0200 Message-Id: <20180507144100.25045-9-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 08/19] Implement getter for Autostart property for StoragePool 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.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 07 May 2018 14:41:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Most of the properties will not emit signals when changed, thus making the annotation EmitsChangedSignal->false global for this Interface. Properties with different behavior will overwrite it. Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.StoragePool.xml | 5 +++++ src/storagepool.c | 22 ++++++++++++++++++++++ tests/test_storage.py | 7 +++++++ 3 files changed, 34 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index fb21e59..ed03474 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -3,6 +3,11 @@ =20 + + + + diff --git a/src/storagepool.c b/src/storagepool.c index bf1fd3f..515b38c 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -24,6 +24,27 @@ virtDBusStoragePoolGetVirStoragePool(virtDBusConnect *co= nnect, return storagePool; } =20 +static void +virtDBusStoragePoolGetAutostart(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virStoragePool) storagePool =3D NULL; + gint autostart =3D 0; + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + if (virStoragePoolGetAutostart(storagePool, &autostart) < 0) + return virtDBusUtilSetLastVirtError(error); + + *value =3D g_variant_new("b", !!autostart); +} + static void virtDBusStoragePoolBuild(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -118,6 +139,7 @@ virtDBusStoragePoolDestroy(GVariant *inArgs G_GNUC_UNUS= ED, } =20 static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] =3D { + { "Autostart", virtDBusStoragePoolGetAutostart, NULL }, { 0 } }; =20 diff --git a/tests/test_storage.py b/tests/test_storage.py index c4c7cf1..0aa75e3 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -51,6 +51,13 @@ class TestStoragePool(libvirttest.BaseTestClass): =20 self.main_loop() =20 + def test_storage_pool_properties_type(self): + _, obj =3D self.test_storage_pool() + + props =3D obj.GetAll('org.libvirt.StoragePool', + dbus_interface=3Ddbus.PROPERTIES_IFACE) + assert isinstance(props['Autostart'], dbus.Boolean) + =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 Fri May 3 16:32: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; 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 1525704100174283.3695449049004; Mon, 7 May 2018 07:41:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 16BD85F798; Mon, 7 May 2018 14:41:38 +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 C60359ACA1; Mon, 7 May 2018 14:41:37 +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 709165BBE7; Mon, 7 May 2018 14:41:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47Ef8C9032411 for ; Mon, 7 May 2018 10:41:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 520D72024CA2; Mon, 7 May 2018 14:41:08 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id EAEEA2024CA1 for ; Mon, 7 May 2018 14:41:07 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:50 +0200 Message-Id: <20180507144100.25045-10-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 09/19] Implement GetInfo method for StoragePool 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.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 07 May 2018 14:41:38 +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.StoragePool.xml | 5 +++++ src/storagepool.c | 28 ++++++++++++++++++++++++++++ tests/test_storage.py | 7 +++++++ 3 files changed, 40 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index ed03474..29d501b 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -27,5 +27,10 @@ + + + + diff --git a/src/storagepool.c b/src/storagepool.c index 515b38c..a7bcc94 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -138,6 +138,33 @@ virtDBusStoragePoolDestroy(GVariant *inArgs G_GNUC_UNU= SED, virtDBusUtilSetLastVirtError(error); } =20 +static void +virtDBusStoragePoolGetInfo(GVariant *inArgs G_GNUC_UNUSED, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virStoragePool) storagePool =3D NULL; + g_autofree virStoragePoolInfoPtr info =3D NULL; + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + info =3D g_new0(virStoragePoolInfo, 1); + if (virStoragePoolGetInfo(storagePool, info) < 0) + return virtDBusUtilSetLastVirtError(error); + + *outArgs =3D g_variant_new("((uttt))", info->state, + info->capacity, info->allocation, + info->available); +} + static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] =3D { { "Autostart", virtDBusStoragePoolGetAutostart, NULL }, { 0 } @@ -148,6 +175,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMeth= odTable[] =3D { { "Create", virtDBusStoragePoolCreate }, { "Delete", virtDBusStoragePoolDelete }, { "Destroy", virtDBusStoragePoolDestroy }, + { "GetInfo", virtDBusStoragePoolGetInfo }, { 0 } }; =20 diff --git a/tests/test_storage.py b/tests/test_storage.py index 0aa75e3..116385b 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -51,6 +51,13 @@ class TestStoragePool(libvirttest.BaseTestClass): =20 self.main_loop() =20 + def test_storage_pool_get_info(self): + _, test_storage_pool =3D self.test_storage_pool() + interface_obj =3D dbus.Interface(test_storage_pool, + 'org.libvirt.StoragePool') + info =3D interface_obj.GetInfo() + assert isinstance(info, dbus.Struct) + def test_storage_pool_properties_type(self): _, obj =3D self.test_storage_pool() =20 --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 16:32: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; 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 1525704399247908.1796664422428; Mon, 7 May 2018 07:46:39 -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 97962804FC; Mon, 7 May 2018 14:46:37 +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 174F060BEC; Mon, 7 May 2018 14:46:37 +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 B13465BBE6; Mon, 7 May 2018 14:46:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47Ef9K7032426 for ; Mon, 7 May 2018 10:41:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id E85442024CA2; Mon, 7 May 2018 14:41:08 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DD482024CA1 for ; Mon, 7 May 2018 14:41:08 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:51 +0200 Message-Id: <20180507144100.25045-11-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 10/19] Implement Name property for StoragePool 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.27]); Mon, 07 May 2018 14:46:38 +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.StoragePool.xml | 4 ++++ src/storagepool.c | 23 +++++++++++++++++++++++ tests/test_storage.py | 1 + 3 files changed, 28 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index 29d501b..8bc90b7 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -8,6 +8,10 @@ + + + diff --git a/src/storagepool.c b/src/storagepool.c index a7bcc94..f81a670 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -45,6 +45,28 @@ virtDBusStoragePoolGetAutostart(const gchar *objectPath, *value =3D g_variant_new("b", !!autostart); } =20 +static void +virtDBusStoragePoolGetName(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virStoragePool) storagePool =3D NULL; + const gchar *name; + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + name =3D virStoragePoolGetName(storagePool); + if (!name) + return virtDBusUtilSetLastVirtError(error); + + *value =3D g_variant_new("s", name); +} + static void virtDBusStoragePoolBuild(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -167,6 +189,7 @@ virtDBusStoragePoolGetInfo(GVariant *inArgs G_GNUC_UNUS= ED, =20 static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] =3D { { "Autostart", virtDBusStoragePoolGetAutostart, NULL }, + { "Name", virtDBusStoragePoolGetName, NULL }, { 0 } }; =20 diff --git a/tests/test_storage.py b/tests/test_storage.py index 116385b..8e73228 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -64,6 +64,7 @@ class TestStoragePool(libvirttest.BaseTestClass): props =3D obj.GetAll('org.libvirt.StoragePool', dbus_interface=3Ddbus.PROPERTIES_IFACE) assert isinstance(props['Autostart'], dbus.Boolean) + assert isinstance(props['Name'], dbus.String) =20 =20 if __name__ =3D=3D '__main__': --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 16:32: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; 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 1525704218103995.9470964994039; Mon, 7 May 2018 07:43:38 -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 808AB3003A5C; Mon, 7 May 2018 14:43:36 +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 331A9611A9; Mon, 7 May 2018 14:43:36 +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 D7248180BAE7; Mon, 7 May 2018 14:43:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47Ef9OY032436 for ; Mon, 7 May 2018 10:41:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8A27E2024CA2; Mon, 7 May 2018 14:41:09 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2FCC32024CA1 for ; Mon, 7 May 2018 14:41:09 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:52 +0200 Message-Id: <20180507144100.25045-12-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 11/19] Implement UUID property for StoragePool 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 07 May 2018 14:43:37 +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.StoragePool.xml | 5 +++++ src/storagepool.c | 22 ++++++++++++++++++++++ tests/test_storage.py | 1 + 3 files changed, 28 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index 8bc90b7..a60ef84 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -12,6 +12,11 @@ + + + + diff --git a/src/storagepool.c b/src/storagepool.c index f81a670..43e8040 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -67,6 +67,27 @@ virtDBusStoragePoolGetName(const gchar *objectPath, *value =3D g_variant_new("s", name); } =20 +static void +virtDBusStoragePoolGetUUID(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virStoragePool) storagePool =3D NULL; + gchar uuid[VIR_UUID_STRING_BUFLEN] =3D ""; + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + if (virStoragePoolGetUUIDString(storagePool, uuid) < 0) + return virtDBusUtilSetLastVirtError(error); + + *value =3D g_variant_new("s", uuid); +} + static void virtDBusStoragePoolBuild(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -190,6 +211,7 @@ virtDBusStoragePoolGetInfo(GVariant *inArgs G_GNUC_UNUS= ED, static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] =3D { { "Autostart", virtDBusStoragePoolGetAutostart, NULL }, { "Name", virtDBusStoragePoolGetName, NULL }, + { "UUID", virtDBusStoragePoolGetUUID, NULL }, { 0 } }; =20 diff --git a/tests/test_storage.py b/tests/test_storage.py index 8e73228..3e67633 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -65,6 +65,7 @@ class TestStoragePool(libvirttest.BaseTestClass): dbus_interface=3Ddbus.PROPERTIES_IFACE) assert isinstance(props['Autostart'], dbus.Boolean) assert isinstance(props['Name'], dbus.String) + assert isinstance(props['UUID'], dbus.String) =20 =20 if __name__ =3D=3D '__main__': --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 16:32: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; 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 1525704108312211.0719475666641; Mon, 7 May 2018 07:41:48 -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 283AC80F9A; Mon, 7 May 2018 14:41:46 +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 CC9B368D97; Mon, 7 May 2018 14:41:45 +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 7EBFA180BAE7; Mon, 7 May 2018 14:41:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47EfA3k032448 for ; Mon, 7 May 2018 10:41:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2B6192024CA2; Mon, 7 May 2018 14:41:10 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id C54EB2024CA1 for ; Mon, 7 May 2018 14:41:09 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:53 +0200 Message-Id: <20180507144100.25045-13-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 12/19] Implement GetXMLDesc method for StoragePool 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.27]); Mon, 07 May 2018 14:41:47 +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.StoragePool.xml | 6 ++++++ src/storagepool.c | 29 +++++++++++++++++++++++++++++ tests/test_storage.py | 7 +++++++ 3 files changed, 42 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index a60ef84..50550ee 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -41,5 +41,11 @@ value=3D"See https://libvirt.org/html/libvirt-libvirt-storage.html= #virStoragePoolGetInfo"/> + + + + + diff --git a/src/storagepool.c b/src/storagepool.c index 43e8040..628ad17 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -208,6 +208,34 @@ virtDBusStoragePoolGetInfo(GVariant *inArgs G_GNUC_UNU= SED, info->available); } =20 +static void +virtDBusStoragePoolGetXMLDesc(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virStoragePool) storagePool =3D NULL; + g_autofree gchar *xml =3D NULL; + guint flags; + + g_variant_get(inArgs, "(u)", &flags); + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + xml =3D virStoragePoolGetXMLDesc(storagePool, flags); + if (!xml) + return virtDBusUtilSetLastVirtError(error); + + *outArgs =3D g_variant_new("(s)", xml); +} + static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] =3D { { "Autostart", virtDBusStoragePoolGetAutostart, NULL }, { "Name", virtDBusStoragePoolGetName, NULL }, @@ -221,6 +249,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMeth= odTable[] =3D { { "Delete", virtDBusStoragePoolDelete }, { "Destroy", virtDBusStoragePoolDestroy }, { "GetInfo", virtDBusStoragePoolGetInfo }, + { "GetXMLDesc", virtDBusStoragePoolGetXMLDesc }, { 0 } }; =20 diff --git a/tests/test_storage.py b/tests/test_storage.py index 3e67633..1afae2a 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -58,6 +58,13 @@ class TestStoragePool(libvirttest.BaseTestClass): info =3D interface_obj.GetInfo() assert isinstance(info, dbus.Struct) =20 + def test_storage_pool_get_xml_description(self): + _, test_storage_pool =3D self.test_storage_pool() + interface_obj =3D dbus.Interface(test_storage_pool, + 'org.libvirt.StoragePool') + info =3D interface_obj.GetXMLDesc(0) + assert isinstance(info, dbus.String) + def test_storage_pool_properties_type(self): _, obj =3D self.test_storage_pool() =20 --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 16:32: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; 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 1525704113746359.94681930352897; Mon, 7 May 2018 07:41:53 -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 27A8981DFA; Mon, 7 May 2018 14:41:52 +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 E435830B4982; Mon, 7 May 2018 14:41:51 +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 9B5875BBEE; Mon, 7 May 2018 14:41:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47EfA03032453 for ; Mon, 7 May 2018 10:41:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id C242A2024CA2; Mon, 7 May 2018 14:41:10 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67E272024CA1 for ; Mon, 7 May 2018 14:41:10 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:54 +0200 Message-Id: <20180507144100.25045-14-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 13/19] Implement Active property for StoragePool 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.25]); Mon, 07 May 2018 14:41:52 +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.StoragePool.xml | 4 ++++ src/storagepool.c | 23 +++++++++++++++++++++++ tests/test_storage.py | 1 + 3 files changed, 28 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index 50550ee..b739841 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -4,6 +4,10 @@ + + + diff --git a/src/storagepool.c b/src/storagepool.c index 628ad17..834e1c5 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -24,6 +24,28 @@ virtDBusStoragePoolGetVirStoragePool(virtDBusConnect *co= nnect, return storagePool; } =20 +static void +virtDBusStoragePoolGetActive(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virStoragePool) storagePool =3D NULL; + gint active; + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + active =3D virStoragePoolIsActive(storagePool); + if (active < 0) + return virtDBusUtilSetLastVirtError(error); + + *value =3D g_variant_new("b", !!active); +} + static void virtDBusStoragePoolGetAutostart(const gchar *objectPath, gpointer userData, @@ -237,6 +259,7 @@ virtDBusStoragePoolGetXMLDesc(GVariant *inArgs, } =20 static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] =3D { + { "Active", virtDBusStoragePoolGetActive, NULL }, { "Autostart", virtDBusStoragePoolGetAutostart, NULL }, { "Name", virtDBusStoragePoolGetName, NULL }, { "UUID", virtDBusStoragePoolGetUUID, NULL }, diff --git a/tests/test_storage.py b/tests/test_storage.py index 1afae2a..34838fc 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -70,6 +70,7 @@ class TestStoragePool(libvirttest.BaseTestClass): =20 props =3D obj.GetAll('org.libvirt.StoragePool', dbus_interface=3Ddbus.PROPERTIES_IFACE) + assert isinstance(props['Active'], dbus.Boolean) assert isinstance(props['Autostart'], dbus.Boolean) assert isinstance(props['Name'], dbus.String) assert isinstance(props['UUID'], dbus.String) --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 16:32: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; 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 1525704118126346.8097005427376; Mon, 7 May 2018 07:41:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 615825D678; Mon, 7 May 2018 14:41: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 312D22010CF0; Mon, 7 May 2018 14:41: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 D9696180BAE9; Mon, 7 May 2018 14:41:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47EfBJF032458 for ; Mon, 7 May 2018 10:41:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 64DFD2024CA2; Mon, 7 May 2018 14:41:11 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A1E62024CA1 for ; Mon, 7 May 2018 14:41:10 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:55 +0200 Message-Id: <20180507144100.25045-15-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 14/19] Implement Persistent property for StoragePool 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.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 07 May 2018 14:41: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.StoragePool.xml | 4 ++++ src/storagepool.c | 23 +++++++++++++++++++++++ tests/test_storage.py | 1 + 3 files changed, 28 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index b739841..31abd34 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -16,6 +16,10 @@ + + + diff --git a/src/storagepool.c b/src/storagepool.c index 834e1c5..c38e029 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -89,6 +89,28 @@ virtDBusStoragePoolGetName(const gchar *objectPath, *value =3D g_variant_new("s", name); } =20 +static void +virtDBusStoragePoolGetPersistent(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virStoragePool) storagePool =3D NULL; + gint persistent; + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + persistent =3D virStoragePoolIsPersistent(storagePool); + if (persistent < 0) + return virtDBusUtilSetLastVirtError(error); + + *value =3D g_variant_new("b", !!persistent); +} + static void virtDBusStoragePoolGetUUID(const gchar *objectPath, gpointer userData, @@ -262,6 +284,7 @@ static virtDBusGDBusPropertyTable virtDBusStoragePoolPr= opertyTable[] =3D { { "Active", virtDBusStoragePoolGetActive, NULL }, { "Autostart", virtDBusStoragePoolGetAutostart, NULL }, { "Name", virtDBusStoragePoolGetName, NULL }, + { "Persistent", virtDBusStoragePoolGetPersistent, NULL }, { "UUID", virtDBusStoragePoolGetUUID, NULL }, { 0 } }; diff --git a/tests/test_storage.py b/tests/test_storage.py index 34838fc..b872c3d 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -73,6 +73,7 @@ class TestStoragePool(libvirttest.BaseTestClass): assert isinstance(props['Active'], dbus.Boolean) assert isinstance(props['Autostart'], dbus.Boolean) assert isinstance(props['Name'], dbus.String) + assert isinstance(props['Persistent'], dbus.Boolean) assert isinstance(props['UUID'], dbus.String) =20 =20 --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 16:32: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; 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 1525704122494823.8931659943398; Mon, 7 May 2018 07:42:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B149D85542; Mon, 7 May 2018 14:42:00 +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 7A1461001F4F; Mon, 7 May 2018 14:42:00 +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 24998180BAED; Mon, 7 May 2018 14:42:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47EfCV6032466 for ; Mon, 7 May 2018 10:41:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 06C472024CA2; Mon, 7 May 2018 14:41:12 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id A08822024CA1 for ; Mon, 7 May 2018 14:41:11 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:56 +0200 Message-Id: <20180507144100.25045-16-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 15/19] Implement StoragePoolLookupByName 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 07 May 2018 14:42:01 +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 | 30 ++++++++++++++++++++++++++++++ tests/test_connect.py | 15 +++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 6b156d1..55c0883 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -217,6 +217,12 @@ + + + + + diff --git a/src/connect.c b/src/connect.c index 97c4857..fa4078f 100644 --- a/src/connect.c +++ b/src/connect.c @@ -1104,6 +1104,35 @@ virtDBusConnectNodeSetMemoryParameters(GVariant *inA= rgs, } } =20 +static void +virtDBusConnectStoragePoolLookupByName(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_autoptr(virStoragePool) storagePool =3D NULL; + g_autofree gchar *path =3D NULL; + const gchar *name; + + g_variant_get(inArgs, "(s)", &name); + + if (!virtDBusConnectOpen(connect, error)) + return; + + storagePool =3D virStoragePoolLookupByName(connect->connection, name); + if (!storagePool) + return virtDBusUtilSetLastVirtError(error); + + path =3D virtDBusUtilBusPathForVirStoragePool(storagePool, + connect->storagePoolPath); + + *outArgs =3D g_variant_new("(o)", path); +} + static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] =3D { { "Encrypted", virtDBusConnectGetEncrypted, NULL }, { "Hostname", virtDBusConnectGetHostname, NULL }, @@ -1143,6 +1172,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethod= Table[] =3D { { "NodeGetMemoryStats", virtDBusConnectNodeGetMemoryStats }, { "NodeGetSecurityModel", virtDBusConnectNodeGetSecurityModel }, { "NodeSetMemoryParameters", virtDBusConnectNodeSetMemoryParameters }, + { "StoragePoolLookupByName", virtDBusConnectStoragePoolLookupByName }, { 0 } }; =20 diff --git a/tests/test_connect.py b/tests/test_connect.py index d8f05e8..2e0cd7f 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -190,6 +190,21 @@ class TestConnect(libvirttest.BaseTestClass): info =3D self.connect.NodeGetCPUMap(0) assert isinstance(info, dbus.Array) =20 + @pytest.mark.parametrize("lookup_method_name,lookup_item", [ + ("StoragePoolLookupByName", 'Name'), + ]) + def test_connect_network_lookup_by_property( + self, + lookup_method_name, + lookup_item): + """Parameterized test for all StoragePoolLookupBy* API calls of Co= nnect interface + """ + original_path, obj =3D self.test_storage_pool() + prop =3D obj.Get('org.libvirt.StoragePool', lookup_item, + dbus_interface=3Ddbus.PROPERTIES_IFACE) + path =3D getattr(self.connect, lookup_method_name)(prop) + assert original_path =3D=3D path + =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 Fri May 3 16:32: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; 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 1525704128017267.2483077543053; Mon, 7 May 2018 07:42:08 -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 8E436C04AC43; Mon, 7 May 2018 14:42:06 +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 2FBA9608EE; Mon, 7 May 2018 14:42:06 +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 D12D55BBEB; Mon, 7 May 2018 14:42:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47EfCm0032481 for ; Mon, 7 May 2018 10:41:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9D0FC2024CA2; Mon, 7 May 2018 14:41:12 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 427C32024CA1 for ; Mon, 7 May 2018 14:41:12 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:57 +0200 Message-Id: <20180507144100.25045-17-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 16/19] Implement StoragePoolLookupByUUID 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 07 May 2018 14:42:07 +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 +++++++++++++++++++++++++++++++ tests/test_connect.py | 1 + 3 files changed, 38 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 55c0883..0c009cd 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -223,6 +223,12 @@ + + + + + diff --git a/src/connect.c b/src/connect.c index fa4078f..43013a2 100644 --- a/src/connect.c +++ b/src/connect.c @@ -1133,6 +1133,36 @@ virtDBusConnectStoragePoolLookupByName(GVariant *inA= rgs, *outArgs =3D g_variant_new("(o)", path); } =20 +static void +virtDBusConnectStoragePoolLookupByUUID(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_autoptr(virStoragePool) storagePool =3D NULL; + g_autofree gchar *path =3D NULL; + const gchar *uuidstr; + + g_variant_get(inArgs, "(s)", &uuidstr); + + if (!virtDBusConnectOpen(connect, error)) + return; + + storagePool =3D virStoragePoolLookupByUUIDString(connect->connection, + uuidstr); + if (!storagePool) + return virtDBusUtilSetLastVirtError(error); + + path =3D virtDBusUtilBusPathForVirStoragePool(storagePool, + connect->storagePoolPath); + + *outArgs =3D g_variant_new("(o)", path); +} + static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] =3D { { "Encrypted", virtDBusConnectGetEncrypted, NULL }, { "Hostname", virtDBusConnectGetHostname, NULL }, @@ -1173,6 +1203,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethod= Table[] =3D { { "NodeGetSecurityModel", virtDBusConnectNodeGetSecurityModel }, { "NodeSetMemoryParameters", virtDBusConnectNodeSetMemoryParameters }, { "StoragePoolLookupByName", virtDBusConnectStoragePoolLookupByName }, + { "StoragePoolLookupByUUID", virtDBusConnectStoragePoolLookupByUUID }, { 0 } }; =20 diff --git a/tests/test_connect.py b/tests/test_connect.py index 2e0cd7f..c0365ae 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -192,6 +192,7 @@ class TestConnect(libvirttest.BaseTestClass): =20 @pytest.mark.parametrize("lookup_method_name,lookup_item", [ ("StoragePoolLookupByName", 'Name'), + ("StoragePoolLookupByUUID", 'UUID'), ]) def test_connect_network_lookup_by_property( self, --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 16:32: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; 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 1525704404661584.4439695592295; Mon, 7 May 2018 07:46:44 -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 2A5673001FB9; Mon, 7 May 2018 14:46:43 +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 E32F65D9C7; Mon, 7 May 2018 14:46:42 +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 911335BBE5; Mon, 7 May 2018 14:46:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47EfDqK032491 for ; Mon, 7 May 2018 10:41:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3EFD22024CA2; Mon, 7 May 2018 14:41:13 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8F932024CA1 for ; Mon, 7 May 2018 14:41:12 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:58 +0200 Message-Id: <20180507144100.25045-18-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 17/19] Implement Refresh method for StoragePool 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.43]); Mon, 07 May 2018 14:46:43 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Test will should be added when VIR_STORAGE_POOL_EVENT_ID_REFRESH signal will be implemented. Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.StoragePool.xml | 5 +++++ src/storagepool.c | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index 31abd34..8ebab33 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -55,5 +55,10 @@ + + + + diff --git a/src/storagepool.c b/src/storagepool.c index c38e029..aa0e280 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -280,6 +280,30 @@ virtDBusStoragePoolGetXMLDesc(GVariant *inArgs, *outArgs =3D g_variant_new("(s)", xml); } =20 +static void +virtDBusStoragePoolRefresh(GVariant *inArgs, + 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(virStoragePool) storagePool =3D NULL; + guint flags; + + g_variant_get(inArgs, "(u)", &flags); + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + if (virStoragePoolRefresh(storagePool, flags) < 0) + virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] =3D { { "Active", virtDBusStoragePoolGetActive, NULL }, { "Autostart", virtDBusStoragePoolGetAutostart, NULL }, @@ -296,6 +320,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMeth= odTable[] =3D { { "Destroy", virtDBusStoragePoolDestroy }, { "GetInfo", virtDBusStoragePoolGetInfo }, { "GetXMLDesc", virtDBusStoragePoolGetXMLDesc }, + { "Refresh", virtDBusStoragePoolRefresh }, { 0 } }; =20 --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 16:32: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; 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 1525704225070744.7951259165625; Mon, 7 May 2018 07:43:45 -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 86BACC0587E9; Mon, 7 May 2018 14:43:43 +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 5696268D8F; Mon, 7 May 2018 14:43:43 +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 13E505BBEB; Mon, 7 May 2018 14:43:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47EfDhb032510 for ; Mon, 7 May 2018 10:41:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id D4F612024CA2; Mon, 7 May 2018 14:41:13 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A7102024CA1 for ; Mon, 7 May 2018 14:41:13 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:59 +0200 Message-Id: <20180507144100.25045-19-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 18/19] Implement setter for Autostart property for StoragePool 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.32]); Mon, 07 May 2018 14:43:44 +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.StoragePool.xml | 5 +++-- src/storagepool.c | 24 +++++++++++++++++++++++- tests/test_storage.py | 13 +++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index 8ebab33..9d59818 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -8,9 +8,10 @@ - + + value=3D"See https://libvirt.org/html/libvirt-libvirt-storage.ht= ml#virStoragePoolGetAutostart + https://libvirt.org/html/libvirt-libvirt-storage.html#vir= StoragePoolSetAutostart"/> Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152570440831437.912956434889566; Mon, 7 May 2018 07:46:48 -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 E262F31343C2; Mon, 7 May 2018 14:46:46 +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 B162F30B4998; Mon, 7 May 2018 14:46:46 +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 62467180BAE9; Mon, 7 May 2018 14:46:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47EfEtw032559 for ; Mon, 7 May 2018 10:41:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 76FA82024CA2; Mon, 7 May 2018 14:41:14 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C6B12024CA1 for ; Mon, 7 May 2018 14:41:13 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:41:00 +0200 Message-Id: <20180507144100.25045-20-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 19/19] Implement Undefine method for StoragePool 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]); Mon, 07 May 2018 14:46:47 +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.StoragePool.xml | 4 ++++ src/storagepool.c | 22 ++++++++++++++++++++++ tests/test_storage.py | 18 ++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index 9d59818..d7e19d0 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -61,5 +61,9 @@ value=3D"See https://libvirt.org/html/libvirt-libvirt-storage.html= #virStoragePoolRefresh"/> + + + diff --git a/src/storagepool.c b/src/storagepool.c index a40db14..c8b6467 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -325,6 +325,27 @@ virtDBusStoragePoolRefresh(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } =20 +static void +virtDBusStoragePoolUndefine(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(virStoragePool) storagePool =3D NULL; + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + if (virStoragePoolUndefine(storagePool) < 0) + virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] =3D { { "Active", virtDBusStoragePoolGetActive, NULL }, { "Autostart", virtDBusStoragePoolGetAutostart, @@ -343,6 +364,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMeth= odTable[] =3D { { "GetInfo", virtDBusStoragePoolGetInfo }, { "GetXMLDesc", virtDBusStoragePoolGetXMLDesc }, { "Refresh", virtDBusStoragePoolRefresh }, + { "Undefine", virtDBusStoragePoolUndefine }, { 0 } }; =20 diff --git a/tests/test_storage.py b/tests/test_storage.py index 2d87e08..d2cbbb5 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -89,6 +89,24 @@ class TestStoragePool(libvirttest.BaseTestClass): assert isinstance(props['Persistent'], dbus.Boolean) assert isinstance(props['UUID'], dbus.String) =20 + def test_storage_pool_undefine(self): + def storage_pool_undefined(path, event, _detail): + if event !=3D libvirttest.StoragePoolEvent.UNDEFINED: + return + assert isinstance(path, dbus.ObjectPath) + self.loop.quit() + + self.connect.connect_to_signal('StoragePoolEvent', + storage_pool_undefined) + + _, test_storage_pool =3D self.test_storage_pool() + interface_obj =3D dbus.Interface(test_storage_pool, + 'org.libvirt.StoragePool') + interface_obj.Destroy() + interface_obj.Undefine() + + 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