From nobody Thu May 2 06:27: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 15289920068893.7143233198214602; Thu, 14 Jun 2018 09:00:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BF17330832F3; Thu, 14 Jun 2018 16:00:04 +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 5653D90800; Thu, 14 Jun 2018 16:00:04 +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 94CB14CA83; Thu, 14 Jun 2018 16:00:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5EFxx0Y003724 for ; Thu, 14 Jun 2018 11:59:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id E6FE210FFE52; Thu, 14 Jun 2018 15:59:58 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8914910FFE4D for ; Thu, 14 Jun 2018 15:59:58 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 14 Jun 2018 17:59:37 +0200 Message-Id: <20180614155953.30292-2-kkoukiou@redhat.com> In-Reply-To: <20180614155953.30292-1-kkoukiou@redhat.com> References: <20180614155953.30292-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 01/17] Introduce StorageVol 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 14 Jun 2018 16:00:05 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/Makefile.am | 4 ++- data/org.libvirt.StorageVol.xml | 7 ++++ src/Makefile.am | 4 ++- src/connect.c | 6 ++++ src/connect.h | 1 + src/storagevol.c | 77 +++++++++++++++++++++++++++++++++++++= ++++ src/storagevol.h | 9 +++++ src/util.c | 35 +++++++++++++++++++ src/util.h | 16 +++++++++ 9 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 data/org.libvirt.StorageVol.xml create mode 100644 src/storagevol.c create mode 100644 src/storagevol.h diff --git a/data/Makefile.am b/data/Makefile.am index fdec857..721b874 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -24,7 +24,9 @@ interfaces_files =3D \ org.libvirt.Network.xml \ org.libvirt.NWFilter.xml \ org.libvirt.Secret.xml \ - org.libvirt.StoragePool.xml + org.libvirt.StoragePool.xml \ + org.libvirt.StorageVol.xml \ + $(NULL) interfacesdir =3D $(DBUS_INTERFACES_DIR) interfaces_DATA =3D $(interfaces_files) =20 diff --git a/data/org.libvirt.StorageVol.xml b/data/org.libvirt.StorageVol.= xml new file mode 100644 index 0000000..c72c847 --- /dev/null +++ b/data/org.libvirt.StorageVol.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/src/Makefile.am b/src/Makefile.am index 22128c2..53d1a23 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,7 +12,9 @@ DAEMON_SOURCES =3D \ network.c network.h \ nwfilter.c nwfilter.h \ secret.c secret.h \ - storagepool.c storagepool.h + storagepool.c storagepool.h \ + storagevol.c storagevol.h \ + $(NULL) =20 EXTRA_DIST =3D \ $(DAEMON_SOURCES) diff --git a/src/connect.c b/src/connect.c index 75ae1cd..1090e3e 100644 --- a/src/connect.c +++ b/src/connect.c @@ -5,6 +5,7 @@ #include "nwfilter.h" #include "secret.h" #include "storagepool.h" +#include "storagevol.h" #include "util.h" =20 #include @@ -1612,6 +1613,7 @@ virtDBusConnectFree(virtDBusConnect *connect) g_free(connect->nwfilterPath); g_free(connect->secretPath); g_free(connect->storagePoolPath); + g_free(connect->storageVolPath); g_free(connect); } G_DEFINE_AUTOPTR_CLEANUP_FUNC(virtDBusConnect, virtDBusConnectFree); @@ -1679,6 +1681,10 @@ virtDBusConnectNew(virtDBusConnect **connectp, if (error && *error) return; =20 + virtDBusStorageVolRegister(connect, error); + if (error && *error) + return; + *connectp =3D connect; connect =3D NULL; } diff --git a/src/connect.h b/src/connect.h index fe672ed..341dfc4 100644 --- a/src/connect.h +++ b/src/connect.h @@ -17,6 +17,7 @@ struct virtDBusConnect { gchar *nwfilterPath; gchar *secretPath; gchar *storagePoolPath; + gchar *storageVolPath; virConnectPtr connection; GMutex lock; =20 diff --git a/src/storagevol.c b/src/storagevol.c new file mode 100644 index 0000000..0097a7f --- /dev/null +++ b/src/storagevol.c @@ -0,0 +1,77 @@ +#include "storagevol.h" +#include "util.h" + +#include + +static virtDBusGDBusPropertyTable virtDBusStorageVolPropertyTable[] =3D { + { 0 } +}; + +static virtDBusGDBusMethodTable virtDBusStorageVolMethodTable[] =3D { + { 0 } +}; + +static gchar ** +virtDBusStorageVolEnumerate(gpointer userData) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virStoragePoolPtr) storagePools =3D NULL; + gint numPools =3D 0; + GPtrArray *list =3D NULL; + + if (!virtDBusConnectOpen(connect, NULL)) + return NULL; + + numPools =3D virConnectListAllStoragePools(connect->connection, + &storagePools, 0); + if (numPools <=3D 0) + return NULL; + + list =3D g_ptr_array_new(); + + for (gint i =3D 0; i < numPools; i++) { + g_autoptr(virStorageVolPtr) storageVols =3D NULL; + gint numVols; + + numVols =3D virStoragePoolListAllVolumes(storagePools[i], + &storageVols, 0); + if (numVols <=3D 0) + continue; + + for (gint j =3D 0; j < numVols; j++) { + gchar *volPath =3D virtDBusUtilBusPathForVirStorageVol(storag= eVols[j], + connect-= >storageVolPath); + g_ptr_array_add(list, volPath); + } + } + + if (list->len > 0) + g_ptr_array_add(list, NULL); + + return (gchar **)g_ptr_array_free(list, FALSE); +} + +static GDBusInterfaceInfo *interfaceInfo; + +void +virtDBusStorageVolRegister(virtDBusConnect *connect, + GError **error) +{ + connect->storageVolPath =3D g_strdup_printf("%s/storagevol", + connect->connectPath); + + if (!interfaceInfo) { + interfaceInfo =3D virtDBusGDBusLoadIntrospectData(VIRT_DBUS_STORAG= EVOL_INTERFACE, + error); + if (!interfaceInfo) + return; + } + + virtDBusGDBusRegisterSubtree(connect->bus, + connect->storageVolPath, + interfaceInfo, + virtDBusStorageVolEnumerate, + virtDBusStorageVolMethodTable, + virtDBusStorageVolPropertyTable, + connect); +} diff --git a/src/storagevol.h b/src/storagevol.h new file mode 100644 index 0000000..e2a893b --- /dev/null +++ b/src/storagevol.h @@ -0,0 +1,9 @@ +#pragma once + +#include "connect.h" + +#define VIRT_DBUS_STORAGEVOL_INTERFACE "org.libvirt.StorageVol" + +void +virtDBusStorageVolRegister(virtDBusConnect *connect, + GError **error); diff --git a/src/util.c b/src/util.c index 1268736..ac6d11b 100644 --- a/src/util.c +++ b/src/util.c @@ -417,3 +417,38 @@ virtDBusUtilVirStoragePoolListFree(virStoragePoolPtr *= storagePools) =20 g_free(storagePools); } + +virStorageVolPtr +virtDBusUtilVirStorageVolFromBusPath(virConnectPtr connection, + const gchar *path, + const gchar *storageVolPath) +{ + g_autofree gchar *key =3D NULL; + gsize prefixLen =3D strlen(storageVolPath) + 1; + + key =3D virtDBusUtilDecodeStr(path + prefixLen); + + return virStorageVolLookupByKey(connection, key); +} + +gchar * +virtDBusUtilBusPathForVirStorageVol(virStorageVolPtr storageVol, + const gchar *storageVolPath) +{ + const gchar *key =3D NULL; + g_autofree const gchar *encodedKey =3D NULL; + + key =3D virStorageVolGetKey(storageVol); + encodedKey =3D virtDBusUtilEncodeStr(key); + + return g_strdup_printf("%s/%s", storageVolPath, encodedKey); +} + +void +virtDBusUtilVirStorageVolListFree(virStorageVolPtr *storageVols) +{ + for (gint i =3D 0; storageVols[i] !=3D NULL; i++) + virStorageVolFree(storageVols[i]); + + g_free(storageVols); +} diff --git a/src/util.h b/src/util.h index 56e0409..bf08d5d 100644 --- a/src/util.h +++ b/src/util.h @@ -133,3 +133,19 @@ virtDBusUtilVirStoragePoolListFree(virStoragePoolPtr *= storagePools); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virStoragePool, virStoragePoolFree); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virStoragePoolPtr, virtDBusUtilVirStoragePoolListFree); + +virStorageVolPtr +virtDBusUtilVirStorageVolFromBusPath(virConnectPtr connection, + const gchar *path, + const gchar *storageVolPath); + +gchar * +virtDBusUtilBusPathForVirStorageVol(virStorageVolPtr storageVol, + const gchar *storageVolPath); + +void +virtDBusUtilVirStorageVolListFree(virStorageVolPtr *storageVols); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virStorageVol, virStorageVolFree); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virStorageVolPtr, + virtDBusUtilVirStorageVolListFree); --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:27: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 1528992019870525.485758757314; Thu, 14 Jun 2018 09:00:19 -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 7967C883D1; Thu, 14 Jun 2018 16:00:18 +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 29ED610A4B35; Thu, 14 Jun 2018 16:00:18 +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 8DD71180053D; Thu, 14 Jun 2018 16:00:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5EFxxs7003733 for ; Thu, 14 Jun 2018 11:59:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8A77110FFE52; Thu, 14 Jun 2018 15:59:59 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E25810FFE4D for ; Thu, 14 Jun 2018 15:59:59 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 14 Jun 2018 17:59:38 +0200 Message-Id: <20180614155953.30292-3-kkoukiou@redhat.com> In-Reply-To: <20180614155953.30292-1-kkoukiou@redhat.com> References: <20180614155953.30292-1-kkoukiou@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 02/17] Implement ListStorageVolumes 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: , Content-Type: text/plain; charset="utf-8" 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.26]); Thu, 14 Jun 2018 16:00:19 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Katerina Koukiou Reviewed-by: J=C3=A1n Tomko --- data/org.libvirt.StoragePool.xml | 6 ++++++ src/storagepool.c | 43 ++++++++++++++++++++++++++++++++++++= ++++ tests/test_storage.py | 8 ++++++++ 3 files changed, 57 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index e9d6b0e..764c9c1 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -57,6 +57,12 @@ + + + + + diff --git a/src/storagepool.c b/src/storagepool.c index 0da732f..4f83ee2 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -301,6 +301,48 @@ virtDBusStoragePoolGetXMLDesc(GVariant *inArgs, *outArgs =3D g_variant_new("(s)", xml); } =20 +static void +virtDBusStoragePoolListStorageVolumes(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_autoptr(virStorageVolPtr) storageVols =3D NULL; + guint flags; + gint nVols; + GVariantBuilder builder; + GVariant *gstorageVols; + + g_variant_get(inArgs, "(u)", &flags); + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + nVols =3D virStoragePoolListAllVolumes(storagePool, &storageVols, flag= s); + if (nVols < 0) + return virtDBusUtilSetLastVirtError(error); + + g_variant_builder_init(&builder, G_VARIANT_TYPE("ao")); + + for (gint i =3D 0; i < nVols; i++) { + g_autofree gchar *path =3D NULL; + path =3D virtDBusUtilBusPathForVirStorageVol(storageVols[i], + connect->storageVolPath= ); + + g_variant_builder_add(&builder, "o", path); + } + + gstorageVols =3D g_variant_builder_end(&builder); + *outArgs =3D g_variant_new_tuple(&gstorageVols, 1); +} + static void virtDBusStoragePoolRefresh(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -363,6 +405,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMeth= odTable[] =3D { { "Destroy", virtDBusStoragePoolDestroy }, { "GetInfo", virtDBusStoragePoolGetInfo }, { "GetXMLDesc", virtDBusStoragePoolGetXMLDesc }, + { "ListStorageVolumes", virtDBusStoragePoolListStorageVolumes }, { "Refresh", virtDBusStoragePoolRefresh }, { "Undefine", virtDBusStoragePoolUndefine }, { 0 } diff --git a/tests/test_storage.py b/tests/test_storage.py index b9e7090..79e0c16 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -79,6 +79,14 @@ class TestStoragePool(libvirttest.BaseTestClass): info =3D interface_obj.GetXMLDesc(0) assert isinstance(info, dbus.String) =20 + def test_storage_pool_list_storage_volumes(self): + _, test_storage_pool =3D self.test_storage_pool() + interface_obj =3D dbus.Interface(test_storage_pool, + 'org.libvirt.StoragePool') + storage_vols =3D interface_obj.ListStorageVolumes(0) + assert isinstance(storage_vols, dbus.Array) + assert len(storage_vols) =3D=3D 0 + 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 Thu May 2 06:27: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 1528992027369469.0135749920511; Thu, 14 Jun 2018 09:00:27 -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 83620300306D; Thu, 14 Jun 2018 16:00:25 +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 5A7EC900C0; Thu, 14 Jun 2018 16:00:24 +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 CD5294CA8A; Thu, 14 Jun 2018 16:00:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5EG0069003743 for ; Thu, 14 Jun 2018 12:00:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 304A010FFE52; Thu, 14 Jun 2018 16:00:00 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id C5A3A10FFE4D for ; Thu, 14 Jun 2018 15:59:59 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 14 Jun 2018 17:59:39 +0200 Message-Id: <20180614155953.30292-4-kkoukiou@redhat.com> In-Reply-To: <20180614155953.30292-1-kkoukiou@redhat.com> References: <20180614155953.30292-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 03/17] test: move XML definition of entities to seperate file 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.46]); Thu, 14 Jun 2018 16:00:26 +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 --- tests/test_connect.py | 47 +++++++---------------------------------------- tests/xmldata.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 40 deletions(-) create mode 100644 tests/xmldata.py diff --git a/tests/test_connect.py b/tests/test_connect.py index da146a4..01b6bd1 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -3,43 +3,10 @@ import dbus import libvirttest import pytest +import xmldata =20 =20 class TestConnect(libvirttest.BaseTestClass): - minimal_domain_xml =3D ''' - - foo - 1024 - - hvm - - - ''' - - minimal_network_xml =3D ''' - - bar - 004b96e12d78c30f5aa5f03c87d21e69 - - - - - - - - - ''' - - minimal_storage_pool_xml =3D ''' - - foo - 35bb2ad9-388a-cdfe-461a-b8907f6e53fe - - /foo - - - ''' - def test_connect_domain_create_xml(self): def domain_started(path, event, detail): if event !=3D libvirttest.DomainEvent.STARTED: @@ -50,7 +17,7 @@ class TestConnect(libvirttest.BaseTestClass): =20 self.connect.connect_to_signal('DomainEvent', domain_started) =20 - path =3D self.connect.DomainCreateXML(self.minimal_domain_xml, 0) + path =3D self.connect.DomainCreateXML(xmldata.minimal_domain_xml, = 0) assert isinstance(path, dbus.ObjectPath) =20 self.main_loop() @@ -65,7 +32,7 @@ class TestConnect(libvirttest.BaseTestClass): =20 self.connect.connect_to_signal('DomainEvent', domain_defined) =20 - path =3D self.connect.DomainDefineXML(self.minimal_domain_xml) + path =3D self.connect.DomainDefineXML(xmldata.minimal_domain_xml) assert isinstance(path, dbus.ObjectPath) =20 self.main_loop() @@ -157,7 +124,7 @@ class TestConnect(libvirttest.BaseTestClass): =20 self.connect.connect_to_signal('NetworkEvent', network_started) =20 - path =3D self.connect.NetworkCreateXML(self.minimal_network_xml) + path =3D self.connect.NetworkCreateXML(xmldata.minimal_network_xml) assert isinstance(path, dbus.ObjectPath) =20 self.main_loop() @@ -171,7 +138,7 @@ class TestConnect(libvirttest.BaseTestClass): =20 self.connect.connect_to_signal('NetworkEvent', network_defined) =20 - path =3D self.connect.NetworkDefineXML(self.minimal_network_xml) + path =3D self.connect.NetworkDefineXML(xmldata.minimal_network_xml) assert isinstance(path, dbus.ObjectPath) =20 self.main_loop() @@ -210,7 +177,7 @@ class TestConnect(libvirttest.BaseTestClass): self.connect.connect_to_signal('StoragePoolEvent', storage_pool_st= arted) =20 path =3D self.connect.StoragePoolCreateXML( - self.minimal_storage_pool_xml, 0) + xmldata.minimal_storage_pool_xml, 0) assert isinstance(path, dbus.ObjectPath) =20 self.main_loop() @@ -225,7 +192,7 @@ class TestConnect(libvirttest.BaseTestClass): self.connect.connect_to_signal('StoragePoolEvent', storage_pool_de= fined) =20 path =3D self.connect.StoragePoolDefineXML( - self.minimal_storage_pool_xml, 0) + xmldata.minimal_storage_pool_xml, 0) assert isinstance(path, dbus.ObjectPath) =20 self.main_loop() diff --git a/tests/xmldata.py b/tests/xmldata.py new file mode 100644 index 0000000..e42b6aa --- /dev/null +++ b/tests/xmldata.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +"""Minimal libvirt XML definition of entities to be used in the test suite. +""" + +minimal_domain_xml =3D ''' + + foo + 1024 + + hvm + + +''' + +minimal_network_xml =3D ''' + + bar + 004b96e12d78c30f5aa5f03c87d21e69 + + + + + + + + +''' + +minimal_storage_pool_xml =3D ''' + + foo + 35bb2ad9-388a-cdfe-461a-b8907f6e53fe + + /foo + + +''' --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:27: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 1528992032354380.68565530211913; Thu, 14 Jun 2018 09:00:32 -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 AB0CA61D22; Thu, 14 Jun 2018 16:00: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 68E8B10A4B28; Thu, 14 Jun 2018 16:00: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 085DF18037F2; Thu, 14 Jun 2018 16:00:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5EG01PJ003750 for ; Thu, 14 Jun 2018 12:00:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id E65B610FFE52; Thu, 14 Jun 2018 16:00:00 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6AB3910FFE4D for ; Thu, 14 Jun 2018 16:00:00 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 14 Jun 2018 17:59:40 +0200 Message-Id: <20180614155953.30292-5-kkoukiou@redhat.com> In-Reply-To: <20180614155953.30292-1-kkoukiou@redhat.com> References: <20180614155953.30292-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 04/17] tests: rename test_* functions which are not tests 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.39]); Thu, 14 Jun 2018 16:00:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" pytest collects functions starting with test prefix to run them as tests by default. Rename functions that are not supposed to be run as tests, to avoid unexpected failures. Note: this commit also renames domain function to follow the naming convention for same purpose functions. Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- tests/libvirttest.py | 6 +++--- tests/test_connect.py | 6 +++--- tests/test_domain.py | 20 ++++++++++---------- tests/test_network.py | 14 +++++++------- tests/test_storage.py | 22 +++++++++++----------- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/tests/libvirttest.py b/tests/libvirttest.py index 3cd02ef..23a597f 100644 --- a/tests/libvirttest.py +++ b/tests/libvirttest.py @@ -70,12 +70,12 @@ class BaseTestClass(): if self.timeout: raise TimeoutError() =20 - def domain(self): + def get_test_domain(self): path =3D self.connect.ListDomains(0)[0] obj =3D self.bus.get_object('org.libvirt', path) return obj, dbus.Interface(obj, 'org.libvirt.Domain') =20 - def test_network(self): + def get_test_network(self): """Fetch information for the test network from test driver =20 Returns: @@ -87,7 +87,7 @@ class BaseTestClass(): obj =3D self.bus.get_object('org.libvirt', path) return path, obj =20 - def test_storage_pool(self): + def get_test_storage_pool(self): """Fetch information for the test storage pool from test driver =20 Returns: diff --git a/tests/test_connect.py b/tests/test_connect.py index 01b6bd1..ec3f551 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -46,7 +46,7 @@ class TestConnect(libvirttest.BaseTestClass): """Parameterized test for all DomainLookupBy* API calls of Connect= interface """ original_path =3D self.connect.ListDomains(0)[0] - obj, _ =3D self.domain() + obj, _ =3D self.get_test_domain() props =3D obj.GetAll('org.libvirt.Domain', dbus_interface=3Ddbus.P= ROPERTIES_IFACE) path =3D getattr(self.connect, lookup_method_name)(props[lookup_it= em]) assert original_path =3D=3D path @@ -150,7 +150,7 @@ class TestConnect(libvirttest.BaseTestClass): def test_connect_network_lookup_by_property(self, lookup_method_name, = lookup_item): """Parameterized test for all NetworkLookupBy* API calls of Connec= t interface """ - original_path, obj =3D self.test_network() + original_path, obj =3D self.get_test_network() prop =3D obj.Get('org.libvirt.Network', lookup_item, dbus_interfac= e=3Ddbus.PROPERTIES_IFACE) path =3D getattr(self.connect, lookup_method_name)(prop) assert original_path =3D=3D path @@ -206,7 +206,7 @@ class TestConnect(libvirttest.BaseTestClass): lookup_item): """Parameterized test for all StoragePoolLookupBy* API calls of Co= nnect interface """ - original_path, obj =3D self.test_storage_pool() + original_path, obj =3D self.get_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) diff --git a/tests/test_domain.py b/tests/test_domain.py index dbb1e3d..b9a6d33 100755 --- a/tests/test_domain.py +++ b/tests/test_domain.py @@ -7,7 +7,7 @@ DBUS_EXCEPTION_MISSING_FUNCTION =3D 'this function is not s= upported by the connect =20 class TestDomain(libvirttest.BaseTestClass): def test_api(self): - obj, domain =3D self.domain() + obj, domain =3D self.get_test_domain() =20 props =3D obj.GetAll('org.libvirt.Domain', dbus_interface=3Ddbus.P= ROPERTIES_IFACE) assert isinstance(props['Active'], dbus.Boolean) @@ -39,7 +39,7 @@ class TestDomain(libvirttest.BaseTestClass): domain.Undefine(0) =20 def test_domain_autostart(self): - _, domain =3D self.domain() + _, domain =3D self.get_test_domain() autostart_expected =3D True domain.Set('org.libvirt.Domain', 'Autostart', autostart_expected, = dbus_interface=3Ddbus.PROPERTIES_IFACE) autostart_current =3D domain.Get('org.libvirt.Domain', 'Autostart'= , dbus_interface=3Ddbus.PROPERTIES_IFACE) @@ -55,7 +55,7 @@ class TestDomain(libvirttest.BaseTestClass): =20 self.connect.connect_to_signal('DomainEvent', domain_stopped) =20 - obj, domain =3D self.domain() + obj, domain =3D self.get_test_domain() domain.ManagedSave(0) assert domain.HasManagedSaveImage(0) =3D=3D dbus.Boolean(True) state, _ =3D domain.GetState(0) @@ -67,7 +67,7 @@ class TestDomain(libvirttest.BaseTestClass): =20 def test_domain_metadata(self): metadata_description =3D 0 - obj, domain =3D self.domain() + obj, domain =3D self.get_test_domain() description_expected =3D "This is the Test domain" domain.SetMetadata(metadata_description, description_expected, "", "", 0) @@ -83,7 +83,7 @@ class TestDomain(libvirttest.BaseTestClass): =20 self.connect.connect_to_signal('DomainEvent', domain_resumed) =20 - obj, domain =3D self.domain() + obj, domain =3D self.get_test_domain() domain.Suspend() domain.Resume() =20 @@ -102,7 +102,7 @@ class TestDomain(libvirttest.BaseTestClass): =20 self.connect.connect_to_signal('DomainEvent', domain_stopped) =20 - obj, domain =3D self.domain() + obj, domain =3D self.get_test_domain() domain.Shutdown(0) =20 state, _ =3D domain.GetState(0) @@ -120,7 +120,7 @@ class TestDomain(libvirttest.BaseTestClass): =20 self.connect.connect_to_signal('DomainEvent', domain_suspended) =20 - obj, domain =3D self.domain() + obj, domain =3D self.get_test_domain() domain.Suspend() =20 state, _ =3D domain.GetState(0) @@ -138,20 +138,20 @@ class TestDomain(libvirttest.BaseTestClass): =20 self.connect.connect_to_signal('DomainEvent', domain_undefined) =20 - _, domain =3D self.domain() + _, domain =3D self.get_test_domain() domain.Shutdown(0) domain.Undefine(0) =20 self.main_loop() =20 def test_domain_vcpus(self): - obj, domain =3D self.domain() + obj, domain =3D self.get_test_domain() vcpus_expected =3D 2 domain.SetVcpus(vcpus_expected, 0) assert domain.GetVcpus(0) =3D=3D dbus.Int32(vcpus_expected) =20 def test_domain_vcpu_pin_info(self): - obj, domain =3D self.domain() + obj, domain =3D self.get_test_domain() pinInfo_expected =3D [ [ True, True, True, True, True, True, True, True ], [ True, True, True, True, True, True, True, True ] diff --git a/tests/test_network.py b/tests/test_network.py index 1a71536..11418cb 100755 --- a/tests/test_network.py +++ b/tests/test_network.py @@ -16,7 +16,7 @@ class TestNetwork(libvirttest.BaseTestClass): def test_network_properties_type(self): """ Ensure correct return type for Network properties """ - _, obj =3D self.test_network() + _, obj =3D self.get_test_network() props =3D obj.GetAll('org.libvirt.Network', dbus_interface=3Ddbus.= PROPERTIES_IFACE) assert isinstance(props['Active'], dbus.Boolean) assert isinstance(props['Autostart'], dbus.Boolean) @@ -25,7 +25,7 @@ class TestNetwork(libvirttest.BaseTestClass): assert isinstance(props['UUID'], dbus.String) =20 def test_network_autostart(self): - _,test_network =3D self.test_network() + _,test_network =3D self.get_test_network() interface_obj =3D dbus.Interface(test_network, 'org.libvirt.Networ= k') autostart_expected =3D True interface_obj.Set('org.libvirt.Network', 'Autostart', autostart_ex= pected, dbus_interface=3Ddbus.PROPERTIES_IFACE) @@ -41,7 +41,7 @@ class TestNetwork(libvirttest.BaseTestClass): =20 self.connect.connect_to_signal('NetworkEvent', domain_started) =20 - _,test_network =3D self.test_network() + _,test_network =3D self.get_test_network() interface_obj =3D dbus.Interface(test_network, 'org.libvirt.Networ= k') interface_obj.Destroy() interface_obj.Create() @@ -57,14 +57,14 @@ class TestNetwork(libvirttest.BaseTestClass): =20 self.connect.connect_to_signal('NetworkEvent', network_stopped) =20 - _, test_network =3D self.test_network() + _, test_network =3D self.get_test_network() interface_obj =3D dbus.Interface(test_network, 'org.libvirt.Networ= k') interface_obj.Destroy() =20 self.main_loop() =20 def test_network_get_xml_description(self): - _,test_network =3D self.test_network() + _,test_network =3D self.get_test_network() interface_obj =3D dbus.Interface(test_network, 'org.libvirt.Networ= k') assert isinstance(interface_obj.GetXMLDesc(0), dbus.String) =20 @@ -77,7 +77,7 @@ class TestNetwork(libvirttest.BaseTestClass): =20 self.connect.connect_to_signal('NetworkEvent', domain_undefined) =20 - _,test_network =3D self.test_network() + _,test_network =3D self.get_test_network() interface_obj =3D dbus.Interface(test_network, 'org.libvirt.Networ= k') interface_obj.Destroy() interface_obj.Undefine() @@ -88,7 +88,7 @@ class TestNetwork(libvirttest.BaseTestClass): ('4', '4', 0, ip_dhcp_host_xml, 0), # add-first, ip-dhcp-host ]) def test_network_update(self, command, section, parentIndex, xml_str, = flags): - _, test_network =3D self.test_network() + _, test_network =3D self.get_test_network() interface_obj =3D dbus.Interface(test_network, 'org.libvirt.Networ= k') interface_obj.Update(command, section, parentIndex, xml_str, flags) updated_netxml =3D interface_obj.GetXMLDesc(0) diff --git a/tests/test_storage.py b/tests/test_storage.py index 79e0c16..10bcea3 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -5,7 +5,7 @@ import libvirttest =20 class TestStoragePool(libvirttest.BaseTestClass): def test_storage_pool_autostart(self): - _, test_storage_pool =3D self.test_storage_pool() + _, test_storage_pool =3D self.get_test_storage_pool() interface_obj =3D dbus.Interface(test_storage_pool, 'org.libvirt.StoragePool') autostart_expected =3D True @@ -18,7 +18,7 @@ class TestStoragePool(libvirttest.BaseTestClass): assert autostart_current =3D=3D dbus.Boolean(autostart_expected) =20 def test_storage_pool_build(self): - _, test_storage_pool =3D self.test_storage_pool() + _, test_storage_pool =3D self.get_test_storage_pool() interface_obj =3D dbus.Interface(test_storage_pool, 'org.libvirt.StoragePool') interface_obj.Destroy() @@ -33,7 +33,7 @@ class TestStoragePool(libvirttest.BaseTestClass): =20 self.connect.connect_to_signal('StoragePoolEvent', storage_pool_st= arted) =20 - _, test_storage_pool =3D self.test_storage_pool() + _, test_storage_pool =3D self.get_test_storage_pool() interface_obj =3D dbus.Interface(test_storage_pool, 'org.libvirt.StoragePool') interface_obj.Destroy() @@ -42,7 +42,7 @@ class TestStoragePool(libvirttest.BaseTestClass): self.main_loop() =20 def test_storage_pool_delete(self): - _, test_storage_pool =3D self.test_storage_pool() + _, test_storage_pool =3D self.get_test_storage_pool() interface_obj =3D dbus.Interface(test_storage_pool, 'org.libvirt.StoragePool') interface_obj.Destroy() @@ -58,7 +58,7 @@ class TestStoragePool(libvirttest.BaseTestClass): self.connect.connect_to_signal('StoragePoolEvent', storage_pool_destroyed) =20 - _, test_storage_pool =3D self.test_storage_pool() + _, test_storage_pool =3D self.get_test_storage_pool() interface_obj =3D dbus.Interface(test_storage_pool, 'org.libvirt.StoragePool') interface_obj.Destroy() @@ -66,21 +66,21 @@ class TestStoragePool(libvirttest.BaseTestClass): self.main_loop() =20 def test_storage_pool_get_info(self): - _, test_storage_pool =3D self.test_storage_pool() + _, test_storage_pool =3D self.get_test_storage_pool() interface_obj =3D dbus.Interface(test_storage_pool, 'org.libvirt.StoragePool') 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() + _, test_storage_pool =3D self.get_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) =20 def test_storage_pool_list_storage_volumes(self): - _, test_storage_pool =3D self.test_storage_pool() + _, test_storage_pool =3D self.get_test_storage_pool() interface_obj =3D dbus.Interface(test_storage_pool, 'org.libvirt.StoragePool') storage_vols =3D interface_obj.ListStorageVolumes(0) @@ -88,7 +88,7 @@ class TestStoragePool(libvirttest.BaseTestClass): assert len(storage_vols) =3D=3D 0 =20 def test_storage_pool_properties_type(self): - _, obj =3D self.test_storage_pool() + _, obj =3D self.get_test_storage_pool() =20 props =3D obj.GetAll('org.libvirt.StoragePool', dbus_interface=3Ddbus.PROPERTIES_IFACE) @@ -108,7 +108,7 @@ class TestStoragePool(libvirttest.BaseTestClass): self.connect.connect_to_signal('StoragePoolEvent', storage_pool_undefined) =20 - _, test_storage_pool =3D self.test_storage_pool() + _, test_storage_pool =3D self.get_test_storage_pool() interface_obj =3D dbus.Interface(test_storage_pool, 'org.libvirt.StoragePool') interface_obj.Destroy() @@ -117,7 +117,7 @@ class TestStoragePool(libvirttest.BaseTestClass): self.main_loop() =20 def test_storage_pool_refresh(self): - _, test_storage_pool =3D self.test_storage_pool() + _, test_storage_pool =3D self.get_test_storage_pool() interface_obj =3D dbus.Interface(test_storage_pool, 'org.libvirt.StoragePool') interface_obj.connect_to_signal('Refresh', --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:27: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 152899202010619.877338277568697; Thu, 14 Jun 2018 09:00:20 -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 B76A73150095; Thu, 14 Jun 2018 16:00:18 +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 79971300174E; Thu, 14 Jun 2018 16:00:18 +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 E300118052EA; Thu, 14 Jun 2018 16:00:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5EG015p003764 for ; Thu, 14 Jun 2018 12:00:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8C0DD10FFE52; Thu, 14 Jun 2018 16:00:01 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C82C10FFE4D for ; Thu, 14 Jun 2018 16:00:01 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 14 Jun 2018 17:59:41 +0200 Message-Id: <20180614155953.30292-6-kkoukiou@redhat.com> In-Reply-To: <20180614155953.30292-1-kkoukiou@redhat.com> References: <20180614155953.30292-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 05/17] Implement StorageVolCreateXML 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.41]); Thu, 14 Jun 2018 16:00:19 +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 | 7 +++++++ src/storagepool.c | 34 ++++++++++++++++++++++++++++++++++ tests/libvirttest.py | 31 +++++++++++++++++++++++++++++++ tests/test_storage.py | 3 +++ tests/xmldata.py | 10 ++++++++++ 5 files changed, 85 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index 764c9c1..51d65ab 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -68,6 +68,13 @@ value=3D"See https://libvirt.org/html/libvirt-libvirt-storage.html= #virStoragePoolRefresh"/> + + + + + + diff --git a/src/storagepool.c b/src/storagepool.c index 4f83ee2..cde9ec3 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -367,6 +367,39 @@ virtDBusStoragePoolRefresh(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } =20 +static void +virtDBusStoragePoolStorageVolCreateXML(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_autoptr(virStorageVol) storageVol =3D NULL; + gchar *xml; + guint flags; + g_autofree gchar *path =3D NULL; + + g_variant_get(inArgs, "(&su)", &xml, &flags); + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + storageVol =3D virStorageVolCreateXML(storagePool, xml, flags); + if (!storageVol) + return virtDBusUtilSetLastVirtError(error); + + path =3D virtDBusUtilBusPathForVirStorageVol(storageVol, + connect->storageVolPath); + + *outArgs =3D g_variant_new("(o)", path); +} + static void virtDBusStoragePoolUndefine(GVariant *inArgs G_GNUC_UNUSED, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -407,6 +440,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMeth= odTable[] =3D { { "GetXMLDesc", virtDBusStoragePoolGetXMLDesc }, { "ListStorageVolumes", virtDBusStoragePoolListStorageVolumes }, { "Refresh", virtDBusStoragePoolRefresh }, + { "StorageVolCreateXML", virtDBusStoragePoolStorageVolCreateXML }, { "Undefine", virtDBusStoragePoolUndefine }, { 0 } }; diff --git a/tests/libvirttest.py b/tests/libvirttest.py index 23a597f..6d1a9d0 100644 --- a/tests/libvirttest.py +++ b/tests/libvirttest.py @@ -7,6 +7,7 @@ import pytest import subprocess import sys import time +import xmldata =20 =20 root =3D os.environ.get('abs_top_builddir', os.path.dirname(os.path.dirnam= e(__file__))) @@ -70,6 +71,20 @@ class BaseTestClass(): if self.timeout: raise TimeoutError() =20 + @pytest.fixture + def storage_volume_create(self): + """ Fixture to create dummy storage volume on the test driver + + This fixture should be used in the setup of every test manipulating + with test volume. + """ + _, test_storage_pool =3D self.get_test_storage_pool() + interface_obj =3D dbus.Interface(test_storage_pool, + 'org.libvirt.StoragePool') + path =3D interface_obj.StorageVolCreateXML(xmldata.minimal_storage= _vol_xml, 0) + yield path + + def get_test_domain(self): path =3D self.connect.ListDomains(0)[0] obj =3D self.bus.get_object('org.libvirt', path) @@ -100,6 +115,22 @@ class BaseTestClass(): obj =3D self.bus.get_object('org.libvirt', path) return path, obj =20 + def get_test_storage_volume(self): + """Fetch information for the test storage vol from test driver + + Returns: + (dbus.proxies.ProxyObject, dbus.proxies.ProxyObject): + Test StorageVol Object, Local proxy for the test StorageVol + Object. + + """ + _, test_storage_pool =3D self.get_test_storage_pool() + pool_iface =3D dbus.Interface(test_storage_pool, + 'org.libvirt.StoragePool') + path =3D pool_iface.ListStorageVolumes(0)[0] + obj =3D self.bus.get_object('org.libvirt', path) + return path, obj + =20 class DomainEvent(IntEnum): DEFINED =3D 0 diff --git a/tests/test_storage.py b/tests/test_storage.py index 10bcea3..2aefd74 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -126,6 +126,9 @@ class TestStoragePool(libvirttest.BaseTestClass): =20 self.main_loop() =20 + def test_storage_pool_volume_create(self, storage_volume_create): + assert isinstance(storage_volume_create, dbus.ObjectPath) + =20 if __name__ =3D=3D '__main__': libvirttest.run() diff --git a/tests/xmldata.py b/tests/xmldata.py index e42b6aa..926bd2c 100644 --- a/tests/xmldata.py +++ b/tests/xmldata.py @@ -35,3 +35,13 @@ minimal_storage_pool_xml =3D ''' ''' + +minimal_storage_vol_xml =3D ''' + + sparse.img + 2 + + /var/lib/virt/images/sparse.img + + +''' --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:27: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 1528992040133805.1790245100251; Thu, 14 Jun 2018 09:00:40 -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 4300A3082A4D; Thu, 14 Jun 2018 16:00: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 CB5A110A48B4; Thu, 14 Jun 2018 16:00: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 123454CA87; Thu, 14 Jun 2018 16:00:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5EG02Gx003772 for ; Thu, 14 Jun 2018 12:00:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 322E110FFE52; Thu, 14 Jun 2018 16:00:02 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6B5410FFE4D for ; Thu, 14 Jun 2018 16:00:01 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 14 Jun 2018 17:59:42 +0200 Message-Id: <20180614155953.30292-7-kkoukiou@redhat.com> In-Reply-To: <20180614155953.30292-1-kkoukiou@redhat.com> References: <20180614155953.30292-1-kkoukiou@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 06/17] Implement Name property for StorageVol 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: , Content-Type: text/plain; charset="utf-8" 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.45]); Thu, 14 Jun 2018 16:00:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Katerina Koukiou Reviewed-by: J=C3=A1n Tomko --- data/org.libvirt.StorageVol.xml | 5 +++++ src/storagevol.c | 44 +++++++++++++++++++++++++++++++++++++= ++++ tests/test_storage.py | 11 +++++++++++ 3 files changed, 60 insertions(+) diff --git a/data/org.libvirt.StorageVol.xml b/data/org.libvirt.StorageVol.= xml index c72c847..3110b4f 100644 --- a/data/org.libvirt.StorageVol.xml +++ b/data/org.libvirt.StorageVol.xml @@ -3,5 +3,10 @@ =20 + + + + diff --git a/src/storagevol.c b/src/storagevol.c index 0097a7f..12ebef1 100644 --- a/src/storagevol.c +++ b/src/storagevol.c @@ -3,7 +3,51 @@ =20 #include =20 +static virStorageVolPtr +virtDBusStorageVolGetVirStorageVol(virtDBusConnect *connect, + const gchar *objectPath, + GError **error) +{ + virStorageVolPtr storageVol; + + if (virtDBusConnectOpen(connect, error) < 0) + return NULL; + + storageVol =3D virtDBusUtilVirStorageVolFromBusPath(connect->connectio= n, + objectPath, + connect->storageVolP= ath); + if (!storageVol) { + virtDBusUtilSetLastVirtError(error); + return NULL; + } + + return storageVol; +} + +static void +virtDBusStorageVolGetName(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virStorageVol) storageVol =3D NULL; + const gchar *name; + + storageVol =3D virtDBusStorageVolGetVirStorageVol(connect, objectPath, + error); + if (!storageVol) + return; + + name =3D virStorageVolGetName(storageVol); + if (!name) + return virtDBusUtilSetLastVirtError(error); + + *value =3D g_variant_new("s", name); +} + static virtDBusGDBusPropertyTable virtDBusStorageVolPropertyTable[] =3D { + { "Name", virtDBusStorageVolGetName, NULL }, { 0 } }; =20 diff --git a/tests/test_storage.py b/tests/test_storage.py index 2aefd74..c93b800 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -2,6 +2,7 @@ =20 import dbus import libvirttest +import pytest =20 class TestStoragePool(libvirttest.BaseTestClass): def test_storage_pool_autostart(self): @@ -130,5 +131,15 @@ class TestStoragePool(libvirttest.BaseTestClass): assert isinstance(storage_volume_create, dbus.ObjectPath) =20 =20 +@pytest.mark.usefixtures('storage_volume_create') +class TestStorageVolume(libvirttest.BaseTestClass): + def test_storage_vol_properties_type(self): + _, obj =3D self.get_test_storage_volume() + + props =3D obj.GetAll('org.libvirt.StorageVol', + dbus_interface=3Ddbus.PROPERTIES_IFACE) + assert isinstance(props['Name'], dbus.String) + + if __name__ =3D=3D '__main__': libvirttest.run() --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:27: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 152899204923794.73558005561404; Thu, 14 Jun 2018 09:00:49 -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 C721E3078AAD; Thu, 14 Jun 2018 16:00:45 +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 6C15F308241B; Thu, 14 Jun 2018 16:00: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 F1DEE18037EC; Thu, 14 Jun 2018 16:00:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5EG04s0003788 for ; Thu, 14 Jun 2018 12:00:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3973D10FFE56; Thu, 14 Jun 2018 16:00:04 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1E6610FFE52 for ; Thu, 14 Jun 2018 16:00:02 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 14 Jun 2018 17:59:43 +0200 Message-Id: <20180614155953.30292-8-kkoukiou@redhat.com> In-Reply-To: <20180614155953.30292-1-kkoukiou@redhat.com> References: <20180614155953.30292-1-kkoukiou@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 07/17] Implement Key property for StorageVol 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: , Content-Type: text/plain; charset="utf-8" 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.48]); Thu, 14 Jun 2018 16:00:48 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Katerina Koukiou Reviewed-by: J=C3=A1n Tomko --- data/org.libvirt.StorageVol.xml | 5 +++++ src/storagevol.c | 23 +++++++++++++++++++++++ tests/test_storage.py | 1 + 3 files changed, 29 insertions(+) diff --git a/data/org.libvirt.StorageVol.xml b/data/org.libvirt.StorageVol.= xml index 3110b4f..3b36f3b 100644 --- a/data/org.libvirt.StorageVol.xml +++ b/data/org.libvirt.StorageVol.xml @@ -8,5 +8,10 @@ value=3D"See https://libvirt.org/html/libvirt-libvirt-storage.ht= ml#virStorageVolGetName"/> + + + + diff --git a/src/storagevol.c b/src/storagevol.c index 12ebef1..b979b82 100644 --- a/src/storagevol.c +++ b/src/storagevol.c @@ -46,8 +46,31 @@ virtDBusStorageVolGetName(const gchar *objectPath, *value =3D g_variant_new("s", name); } =20 +static void +virtDBusStorageVolGetKey(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virStorageVol) storageVol =3D NULL; + const gchar *key; + + storageVol =3D virtDBusStorageVolGetVirStorageVol(connect, objectPath, + error); + if (!storageVol) + return; + + key =3D virStorageVolGetKey(storageVol); + if (!key) + return virtDBusUtilSetLastVirtError(error); + + *value =3D g_variant_new("s", key); +} + static virtDBusGDBusPropertyTable virtDBusStorageVolPropertyTable[] =3D { { "Name", virtDBusStorageVolGetName, NULL }, + { "Key", virtDBusStorageVolGetKey, NULL }, { 0 } }; =20 diff --git a/tests/test_storage.py b/tests/test_storage.py index c93b800..91b2597 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -138,6 +138,7 @@ class TestStorageVolume(libvirttest.BaseTestClass): =20 props =3D obj.GetAll('org.libvirt.StorageVol', dbus_interface=3Ddbus.PROPERTIES_IFACE) + assert isinstance(props['Key'], dbus.String) assert isinstance(props['Name'], 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 Thu May 2 06:27: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 1528992020453579.7235628137015; Thu, 14 Jun 2018 09:00:20 -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 BE75181DE2; Thu, 14 Jun 2018 16:00:18 +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 73B2CA1624; Thu, 14 Jun 2018 16:00:18 +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 E74DC180053C; Thu, 14 Jun 2018 16:00:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5EG04Md003798 for ; Thu, 14 Jun 2018 12:00:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id CF8DF10FFE54; Thu, 14 Jun 2018 16:00:04 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73FC310FFE52 for ; Thu, 14 Jun 2018 16:00:04 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 14 Jun 2018 17:59:44 +0200 Message-Id: <20180614155953.30292-9-kkoukiou@redhat.com> In-Reply-To: <20180614155953.30292-1-kkoukiou@redhat.com> References: <20180614155953.30292-1-kkoukiou@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 08/17] Implement Path property for StorageVol 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: , Content-Type: text/plain; charset="utf-8" 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.25]); Thu, 14 Jun 2018 16:00:19 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Katerina Koukiou Reviewed-by: J=C3=A1n Tomko --- data/org.libvirt.StorageVol.xml | 5 +++++ src/storagevol.c | 23 +++++++++++++++++++++++ tests/test_storage.py | 1 + 3 files changed, 29 insertions(+) diff --git a/data/org.libvirt.StorageVol.xml b/data/org.libvirt.StorageVol.= xml index 3b36f3b..03c15c2 100644 --- a/data/org.libvirt.StorageVol.xml +++ b/data/org.libvirt.StorageVol.xml @@ -13,5 +13,10 @@ value=3D"See https://libvirt.org/html/libvirt-libvirt-storage.ht= ml#virStorageVolGetKey"/> + + + + diff --git a/src/storagevol.c b/src/storagevol.c index b979b82..7f33de8 100644 --- a/src/storagevol.c +++ b/src/storagevol.c @@ -68,9 +68,32 @@ virtDBusStorageVolGetKey(const gchar *objectPath, *value =3D g_variant_new("s", key); } =20 +static void +virtDBusStorageVolGetPath(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virStorageVol) storageVol =3D NULL; + g_autofree gchar *path =3D NULL; + + storageVol =3D virtDBusStorageVolGetVirStorageVol(connect, objectPath, + error); + if (!storageVol) + return; + + path =3D virStorageVolGetPath(storageVol); + if (!path) + return virtDBusUtilSetLastVirtError(error); + + *value =3D g_variant_new("s", path); +} + static virtDBusGDBusPropertyTable virtDBusStorageVolPropertyTable[] =3D { { "Name", virtDBusStorageVolGetName, NULL }, { "Key", virtDBusStorageVolGetKey, NULL }, + { "Path", virtDBusStorageVolGetPath, NULL }, { 0 } }; =20 diff --git a/tests/test_storage.py b/tests/test_storage.py index 91b2597..d3a8701 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -140,6 +140,7 @@ class TestStorageVolume(libvirttest.BaseTestClass): dbus_interface=3Ddbus.PROPERTIES_IFACE) assert isinstance(props['Key'], dbus.String) assert isinstance(props['Name'], dbus.String) + assert isinstance(props['Path'], 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 Thu May 2 06:27: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 1528992028532454.62447922283434; Thu, 14 Jun 2018 09:00:28 -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 1850381109; Thu, 14 Jun 2018 16:00:27 +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 BB69810A4B2F; Thu, 14 Jun 2018 16:00: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 366C04CA8B; Thu, 14 Jun 2018 16:00:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5EG05VE003805 for ; Thu, 14 Jun 2018 12:00:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 727B910FFE4D; Thu, 14 Jun 2018 16:00:05 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 165EE10FFE52 for ; Thu, 14 Jun 2018 16:00:04 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 14 Jun 2018 17:59:45 +0200 Message-Id: <20180614155953.30292-10-kkoukiou@redhat.com> In-Reply-To: <20180614155953.30292-1-kkoukiou@redhat.com> References: <20180614155953.30292-1-kkoukiou@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 09/17] Implement GetXMLDesc method for StorageVol 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: , Content-Type: text/plain; charset="utf-8" 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]); Thu, 14 Jun 2018 16:00:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Katerina Koukiou Reviewed-by: J=C3=A1n Tomko --- data/org.libvirt.StorageVol.xml | 6 ++++++ src/storagevol.c | 29 +++++++++++++++++++++++++++++ tests/test_storage.py | 7 +++++++ 3 files changed, 42 insertions(+) diff --git a/data/org.libvirt.StorageVol.xml b/data/org.libvirt.StorageVol.= xml index 03c15c2..c1fecf3 100644 --- a/data/org.libvirt.StorageVol.xml +++ b/data/org.libvirt.StorageVol.xml @@ -18,5 +18,11 @@ value=3D"See https://libvirt.org/html/libvirt-libvirt-storage.ht= ml#virStorageVolGetPath"/> + + + + + diff --git a/src/storagevol.c b/src/storagevol.c index 7f33de8..fb66dd0 100644 --- a/src/storagevol.c +++ b/src/storagevol.c @@ -90,6 +90,34 @@ virtDBusStorageVolGetPath(const gchar *objectPath, *value =3D g_variant_new("s", path); } =20 +static void +virtDBusStorageVolGetXMLDesc(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(virStorageVol) storageVol =3D NULL; + g_autofree gchar *xml =3D NULL; + guint flags; + + g_variant_get(inArgs, "(u)", &flags); + + storageVol =3D virtDBusStorageVolGetVirStorageVol(connect, objectPath, + error); + if (!storageVol) + return; + + xml =3D virStorageVolGetXMLDesc(storageVol, flags); + if (!xml) + return virtDBusUtilSetLastVirtError(error); + + *outArgs =3D g_variant_new("(s)", xml); +} + static virtDBusGDBusPropertyTable virtDBusStorageVolPropertyTable[] =3D { { "Name", virtDBusStorageVolGetName, NULL }, { "Key", virtDBusStorageVolGetKey, NULL }, @@ -98,6 +126,7 @@ static virtDBusGDBusPropertyTable virtDBusStorageVolProp= ertyTable[] =3D { }; =20 static virtDBusGDBusMethodTable virtDBusStorageVolMethodTable[] =3D { + { "GetXMLDesc", virtDBusStorageVolGetXMLDesc }, { 0 } }; =20 diff --git a/tests/test_storage.py b/tests/test_storage.py index d3a8701..3f15fe0 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -142,6 +142,13 @@ class TestStorageVolume(libvirttest.BaseTestClass): assert isinstance(props['Name'], dbus.String) assert isinstance(props['Path'], dbus.String) =20 + def test_storage_vol_get_xml_description(self): + _, test_storage_vol =3D self.get_test_storage_volume() + interface_obj =3D dbus.Interface(test_storage_vol, + 'org.libvirt.StorageVol') + xml =3D interface_obj.GetXMLDesc(0) + assert isinstance(xml, dbus.String) + =20 if __name__ =3D=3D '__main__': libvirttest.run() --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:27: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 1528992057183167.76284030472232; Thu, 14 Jun 2018 09:00:57 -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 D6F83811C0; Thu, 14 Jun 2018 16:00:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F6C62015669; Thu, 14 Jun 2018 16:00:54 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1073D4BB78; Thu, 14 Jun 2018 16:00:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5EG06oB003811 for ; Thu, 14 Jun 2018 12:00:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 65AE910FFE52; Thu, 14 Jun 2018 16:00:06 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 092A310FFE4D for ; Thu, 14 Jun 2018 16:00:05 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 14 Jun 2018 17:59:46 +0200 Message-Id: <20180614155953.30292-11-kkoukiou@redhat.com> In-Reply-To: <20180614155953.30292-1-kkoukiou@redhat.com> References: <20180614155953.30292-1-kkoukiou@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 10/17] Implement StorageVolLookupByKey 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: , Content-Type: text/plain; charset="utf-8" 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.27]); Thu, 14 Jun 2018 16:00:56 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Katerina Koukiou Reviewed-by: J=C3=A1n Tomko --- 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 f41acd2..d3871b3 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -308,6 +308,12 @@ + + + + + diff --git a/src/connect.c b/src/connect.c index 1090e3e..ff9d91a 100644 --- a/src/connect.c +++ b/src/connect.c @@ -1544,6 +1544,35 @@ virtDBusConnectStoragePoolLookupByUUID(GVariant *inA= rgs, *outArgs =3D g_variant_new("(o)", path); } =20 +static void +virtDBusConnectStorageVolLookupByKey(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(virStorageVol) storageVol =3D NULL; + g_autofree gchar *path =3D NULL; + const gchar *key; + + g_variant_get(inArgs, "(&s)", &key); + + if (!virtDBusConnectOpen(connect, error)) + return; + + storageVol =3D virStorageVolLookupByKey(connect->connection, key); + if (!storageVol) + return virtDBusUtilSetLastVirtError(error); + + path =3D virtDBusUtilBusPathForVirStorageVol(storageVol, + connect->storageVolPath); + + *outArgs =3D g_variant_new("(o)", path); +} + static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] =3D { { "Encrypted", virtDBusConnectGetEncrypted, NULL }, { "Hostname", virtDBusConnectGetHostname, NULL }, @@ -1597,6 +1626,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethod= Table[] =3D { { "StoragePoolDefineXML", virtDBusConnectStoragePoolDefineXML }, { "StoragePoolLookupByName", virtDBusConnectStoragePoolLookupByName }, { "StoragePoolLookupByUUID", virtDBusConnectStoragePoolLookupByUUID }, + { "StorageVolLookupByKey", virtDBusConnectStorageVolLookupByKey }, { 0 } }; =20 diff --git a/tests/test_connect.py b/tests/test_connect.py index ec3f551..5182769 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -212,6 +212,21 @@ class TestConnect(libvirttest.BaseTestClass): path =3D getattr(self.connect, lookup_method_name)(prop) assert original_path =3D=3D path =20 + @pytest.mark.usefixtures("storage_volume_create") + @pytest.mark.parametrize("lookup_method_name,lookup_item", [ + ("StorageVolLookupByKey", 'Key'), + ]) + def test_connect_storage_vol_lookup_by_property(self, + lookup_method_name, + lookup_item): + """Parameterized test for all StorageVolLookupBy* API calls of Con= nect interface + """ + original_path, obj =3D self.get_test_storage_volume() + prop =3D obj.Get('org.libvirt.StorageVol', 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 Thu May 2 06:27: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 1528992035759218.66861194064836; Thu, 14 Jun 2018 09:00:35 -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 27C4B3003063; Thu, 14 Jun 2018 16:00:34 +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 CAFD410A48A5; Thu, 14 Jun 2018 16:00:33 +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 4A7FA18037EF; Thu, 14 Jun 2018 16:00:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5EG07qj003818 for ; Thu, 14 Jun 2018 12:00:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 07B3B10FFE53; Thu, 14 Jun 2018 16:00:07 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id A052510FFE4D for ; Thu, 14 Jun 2018 16:00:06 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 14 Jun 2018 17:59:47 +0200 Message-Id: <20180614155953.30292-12-kkoukiou@redhat.com> In-Reply-To: <20180614155953.30292-1-kkoukiou@redhat.com> References: <20180614155953.30292-1-kkoukiou@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 11/17] Implement StorageVolLookupByName 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: , Content-Type: text/plain; charset="utf-8" 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.46]); Thu, 14 Jun 2018 16:00:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Katerina Koukiou Reviewed-by: J=C3=A1n Tomko --- data/org.libvirt.StoragePool.xml | 6 ++++++ src/storagepool.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index 51d65ab..161ade5 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -75,6 +75,12 @@ + + + + + diff --git a/src/storagepool.c b/src/storagepool.c index cde9ec3..ee2862b 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -400,6 +400,39 @@ virtDBusStoragePoolStorageVolCreateXML(GVariant *inArg= s, *outArgs =3D g_variant_new("(o)", path); } =20 +static void +virtDBusStoragePoolStorageVolLookupByName(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUS= ED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virStoragePool) storagePool =3D NULL; + g_autoptr(virStorageVol) storageVol =3D NULL; + g_autofree gchar *path =3D NULL; + const gchar *name; + + g_variant_get(inArgs, "(&s)", &name); + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + storageVol =3D virStorageVolLookupByName(storagePool, name); + + if (!storageVol) + return virtDBusUtilSetLastVirtError(error); + + path =3D virtDBusUtilBusPathForVirStorageVol(storageVol, + connect->storageVolPath); + + *outArgs =3D g_variant_new("(o)", path); +} + static void virtDBusStoragePoolUndefine(GVariant *inArgs G_GNUC_UNUSED, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -441,6 +474,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMeth= odTable[] =3D { { "ListStorageVolumes", virtDBusStoragePoolListStorageVolumes }, { "Refresh", virtDBusStoragePoolRefresh }, { "StorageVolCreateXML", virtDBusStoragePoolStorageVolCreateXML }, + { "StorageVolLookupByName", virtDBusStoragePoolStorageVolLookupByName = }, { "Undefine", virtDBusStoragePoolUndefine }, { 0 } }; --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:27: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 1528992027584424.27011845010486; Thu, 14 Jun 2018 09:00:27 -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 8D9E661D1A; Thu, 14 Jun 2018 16:00:25 +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 15B3F9D9B3; Thu, 14 Jun 2018 16:00:25 +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 EEAEC1800544; Thu, 14 Jun 2018 16:00:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5EG07k6003828 for ; Thu, 14 Jun 2018 12:00:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9F21E10FFE52; Thu, 14 Jun 2018 16:00:07 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42EF610FFE4D for ; Thu, 14 Jun 2018 16:00:07 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 14 Jun 2018 17:59:48 +0200 Message-Id: <20180614155953.30292-13-kkoukiou@redhat.com> In-Reply-To: <20180614155953.30292-1-kkoukiou@redhat.com> References: <20180614155953.30292-1-kkoukiou@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 12/17] Implement StorageVolLookupByPath 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: , Content-Type: text/plain; charset="utf-8" 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.39]); Thu, 14 Jun 2018 16:00:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Katerina Koukiou Reviewed-by: J=C3=A1n Tomko --- data/org.libvirt.Connect.xml | 6 ++++++ src/connect.c | 30 ++++++++++++++++++++++++++++++ tests/test_connect.py | 1 + 3 files changed, 37 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index d3871b3..37daed0 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -314,6 +314,12 @@ + + + + + diff --git a/src/connect.c b/src/connect.c index ff9d91a..4f2bdb6 100644 --- a/src/connect.c +++ b/src/connect.c @@ -1573,6 +1573,35 @@ virtDBusConnectStorageVolLookupByKey(GVariant *inArg= s, *outArgs =3D g_variant_new("(o)", path); } =20 +static void +virtDBusConnectStorageVolLookupByPath(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSE= D, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virStorageVol) storageVol =3D NULL; + const gchar *inPath; + g_autofree gchar *path =3D NULL; + + g_variant_get(inArgs, "(&s)", &inPath); + + if (!virtDBusConnectOpen(connect, error)) + return; + + storageVol =3D virStorageVolLookupByPath(connect->connection, inPath); + if (!storageVol) + return virtDBusUtilSetLastVirtError(error); + + path =3D virtDBusUtilBusPathForVirStorageVol(storageVol, + connect->storageVolPath); + + *outArgs =3D g_variant_new("(o)", path); +} + static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] =3D { { "Encrypted", virtDBusConnectGetEncrypted, NULL }, { "Hostname", virtDBusConnectGetHostname, NULL }, @@ -1627,6 +1656,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethod= Table[] =3D { { "StoragePoolLookupByName", virtDBusConnectStoragePoolLookupByName }, { "StoragePoolLookupByUUID", virtDBusConnectStoragePoolLookupByUUID }, { "StorageVolLookupByKey", virtDBusConnectStorageVolLookupByKey }, + { "StorageVolLookupByPath", virtDBusConnectStorageVolLookupByPath }, { 0 } }; =20 diff --git a/tests/test_connect.py b/tests/test_connect.py index 5182769..57b385e 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -215,6 +215,7 @@ class TestConnect(libvirttest.BaseTestClass): @pytest.mark.usefixtures("storage_volume_create") @pytest.mark.parametrize("lookup_method_name,lookup_item", [ ("StorageVolLookupByKey", 'Key'), + ("StorageVolLookupByPath", 'Path'), ]) def test_connect_storage_vol_lookup_by_property(self, lookup_method_name, --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:27: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 1528992046392551.2160853973072; Thu, 14 Jun 2018 09:00:46 -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 9C5C2D2ED6; Thu, 14 Jun 2018 16:00:41 +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 4639C3001936; Thu, 14 Jun 2018 16:00:41 +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 C07C0180053A; Thu, 14 Jun 2018 16:00:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5EG08r9003838 for ; Thu, 14 Jun 2018 12:00:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 409E110FFE52; Thu, 14 Jun 2018 16:00:08 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8F4110FFE4D for ; Thu, 14 Jun 2018 16:00:07 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 14 Jun 2018 17:59:49 +0200 Message-Id: <20180614155953.30292-14-kkoukiou@redhat.com> In-Reply-To: <20180614155953.30292-1-kkoukiou@redhat.com> References: <20180614155953.30292-1-kkoukiou@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 13/17] Implement Resize method for StorageVol 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: , Content-Type: text/plain; charset="utf-8" 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.38]); Thu, 14 Jun 2018 16:00:45 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Katerina Koukiou Reviewed-by: J=C3=A1n Tomko --- data/org.libvirt.StorageVol.xml | 6 ++++++ src/storagevol.c | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/data/org.libvirt.StorageVol.xml b/data/org.libvirt.StorageVol.= xml index c1fecf3..fdde430 100644 --- a/data/org.libvirt.StorageVol.xml +++ b/data/org.libvirt.StorageVol.xml @@ -24,5 +24,11 @@ + + + + + diff --git a/src/storagevol.c b/src/storagevol.c index fb66dd0..44965a9 100644 --- a/src/storagevol.c +++ b/src/storagevol.c @@ -118,6 +118,31 @@ virtDBusStorageVolGetXMLDesc(GVariant *inArgs, *outArgs =3D g_variant_new("(s)", xml); } =20 +static void +virtDBusStorageVolResize(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(virStorageVol) storageVol =3D NULL; + guint64 capacity; + guint flags; + + g_variant_get(inArgs, "(tu)", &capacity, &flags); + + storageVol =3D virtDBusStorageVolGetVirStorageVol(connect, objectPath, + error); + if (!storageVol) + return; + + if (virStorageVolResize(storageVol, capacity, flags) < 0) + virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusStorageVolPropertyTable[] =3D { { "Name", virtDBusStorageVolGetName, NULL }, { "Key", virtDBusStorageVolGetKey, NULL }, @@ -127,6 +152,7 @@ static virtDBusGDBusPropertyTable virtDBusStorageVolPro= pertyTable[] =3D { =20 static virtDBusGDBusMethodTable virtDBusStorageVolMethodTable[] =3D { { "GetXMLDesc", virtDBusStorageVolGetXMLDesc }, + { "Resize", virtDBusStorageVolResize }, { 0 } }; =20 --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:27: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 152899203191423.35281913495578; Thu, 14 Jun 2018 09:00:31 -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 05B28356F5; Thu, 14 Jun 2018 16:00: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 B119D900C0; Thu, 14 Jun 2018 16:00:29 +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 20F5B18037F0; Thu, 14 Jun 2018 16:00:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5EG08bs003845 for ; Thu, 14 Jun 2018 12:00:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id D6EE610FFE53; Thu, 14 Jun 2018 16:00:08 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BA4510FFE4D for ; Thu, 14 Jun 2018 16:00:08 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 14 Jun 2018 17:59:50 +0200 Message-Id: <20180614155953.30292-15-kkoukiou@redhat.com> In-Reply-To: <20180614155953.30292-1-kkoukiou@redhat.com> References: <20180614155953.30292-1-kkoukiou@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 14/17] Implement Wipe method for StorageVol 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 14 Jun 2018 16:00:30 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Katerina Koukiou Reviewed-by: J=C3=A1n Tomko --- data/org.libvirt.StorageVol.xml | 6 ++++++ src/storagevol.c | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/data/org.libvirt.StorageVol.xml b/data/org.libvirt.StorageVol.= xml index fdde430..aed3f7a 100644 --- a/data/org.libvirt.StorageVol.xml +++ b/data/org.libvirt.StorageVol.xml @@ -30,5 +30,11 @@ + + + + + diff --git a/src/storagevol.c b/src/storagevol.c index 44965a9..7bfe39e 100644 --- a/src/storagevol.c +++ b/src/storagevol.c @@ -143,6 +143,31 @@ virtDBusStorageVolResize(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } =20 +static void +virtDBusStorageVolWipe(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(virStorageVol) storageVol =3D NULL; + guint pattern; + guint flags; + + g_variant_get(inArgs, "(uu)", &pattern, &flags); + + storageVol =3D virtDBusStorageVolGetVirStorageVol(connect, objectPath, + error); + if (!storageVol) + return; + + if (virStorageVolWipePattern(storageVol, pattern, flags) < 0) + virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusStorageVolPropertyTable[] =3D { { "Name", virtDBusStorageVolGetName, NULL }, { "Key", virtDBusStorageVolGetKey, NULL }, @@ -153,6 +178,7 @@ static virtDBusGDBusPropertyTable virtDBusStorageVolPro= pertyTable[] =3D { static virtDBusGDBusMethodTable virtDBusStorageVolMethodTable[] =3D { { "GetXMLDesc", virtDBusStorageVolGetXMLDesc }, { "Resize", virtDBusStorageVolResize }, + { "Wipe", virtDBusStorageVolWipe }, { 0 } }; =20 --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:27: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 1528992068460884.6589803504928; Thu, 14 Jun 2018 09:01:08 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D6D8308213A; Thu, 14 Jun 2018 16:01:06 +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 17B5119E07; Thu, 14 Jun 2018 16:01: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 7D6B618037ED; Thu, 14 Jun 2018 16:01:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5EG09Jc003853 for ; Thu, 14 Jun 2018 12:00:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7997310FFE52; Thu, 14 Jun 2018 16:00:09 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DA8310FFE4D for ; Thu, 14 Jun 2018 16:00:08 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 14 Jun 2018 17:59:51 +0200 Message-Id: <20180614155953.30292-16-kkoukiou@redhat.com> In-Reply-To: <20180614155953.30292-1-kkoukiou@redhat.com> References: <20180614155953.30292-1-kkoukiou@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 15/17] Implement GetInfo method for StorageVol 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 14 Jun 2018 16:01:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Katerina Koukiou Reviewed-by: J=C3=A1n Tomko --- data/org.libvirt.StorageVol.xml | 6 ++++++ src/storagevol.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/data/org.libvirt.StorageVol.xml b/data/org.libvirt.StorageVol.= xml index aed3f7a..8a4eab2 100644 --- a/data/org.libvirt.StorageVol.xml +++ b/data/org.libvirt.StorageVol.xml @@ -18,6 +18,12 @@ value=3D"See https://libvirt.org/html/libvirt-libvirt-storage.ht= ml#virStorageVolGetPath"/> + + + + + diff --git a/src/storagevol.c b/src/storagevol.c index 7bfe39e..022ce37 100644 --- a/src/storagevol.c +++ b/src/storagevol.c @@ -90,6 +90,34 @@ virtDBusStorageVolGetPath(const gchar *objectPath, *value =3D g_variant_new("s", path); } =20 +static void +virtDBusStorageVolGetInfo(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(virStorageVol) storageVol =3D NULL; + virStorageVolInfo info; + guint flags; + + g_variant_get(inArgs, "(u)", &flags); + + storageVol =3D virtDBusStorageVolGetVirStorageVol(connect, objectPath, + error); + if (!storageVol) + return; + + if (virStorageVolGetInfoFlags(storageVol, &info, flags) < 0) + return virtDBusUtilSetLastVirtError(error); + + *outArgs =3D g_variant_new("((itt))", info.type, info.capacity, + info.allocation); +} + static void virtDBusStorageVolGetXMLDesc(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -176,6 +204,7 @@ static virtDBusGDBusPropertyTable virtDBusStorageVolPro= pertyTable[] =3D { }; =20 static virtDBusGDBusMethodTable virtDBusStorageVolMethodTable[] =3D { + { "GetInfo", virtDBusStorageVolGetInfo }, { "GetXMLDesc", virtDBusStorageVolGetXMLDesc }, { "Resize", virtDBusStorageVolResize }, { "Wipe", virtDBusStorageVolWipe }, --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:27: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 1528992077484679.4951181132317; Thu, 14 Jun 2018 09:01:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3067E3086254; Thu, 14 Jun 2018 16:01: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 AA6DE19CB7; Thu, 14 Jun 2018 16:01: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 188044CA84; Thu, 14 Jun 2018 16:01:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5EG0AQx003861 for ; Thu, 14 Jun 2018 12:00:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1CB4710FFE52; Thu, 14 Jun 2018 16:00:10 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4E0110FFE4D for ; Thu, 14 Jun 2018 16:00:09 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 14 Jun 2018 17:59:52 +0200 Message-Id: <20180614155953.30292-17-kkoukiou@redhat.com> In-Reply-To: <20180614155953.30292-1-kkoukiou@redhat.com> References: <20180614155953.30292-1-kkoukiou@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 16/17] Implement Delete method for StorageVol 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 14 Jun 2018 16:01:17 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Katerina Koukiou Reviewed-by: J=C3=A1n Tomko --- data/org.libvirt.StorageVol.xml | 5 +++++ src/storagevol.c | 25 +++++++++++++++++++++++++ tests/test_storage.py | 6 ++++++ 3 files changed, 36 insertions(+) diff --git a/data/org.libvirt.StorageVol.xml b/data/org.libvirt.StorageVol.= xml index 8a4eab2..7ad9459 100644 --- a/data/org.libvirt.StorageVol.xml +++ b/data/org.libvirt.StorageVol.xml @@ -18,6 +18,11 @@ value=3D"See https://libvirt.org/html/libvirt-libvirt-storage.ht= ml#virStorageVolGetPath"/> + + + + diff --git a/src/storagevol.c b/src/storagevol.c index 022ce37..489749d 100644 --- a/src/storagevol.c +++ b/src/storagevol.c @@ -90,6 +90,30 @@ virtDBusStorageVolGetPath(const gchar *objectPath, *value =3D g_variant_new("s", path); } =20 +static void +virtDBusStorageVolDelete(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(virStorageVol) storageVol =3D NULL; + guint flags; + + g_variant_get(inArgs, "(u)", &flags); + + storageVol =3D virtDBusStorageVolGetVirStorageVol(connect, objectPath, + error); + if (!storageVol) + return; + + if (virStorageVolDelete(storageVol, flags) < 0) + virtDBusUtilSetLastVirtError(error); +} + static void virtDBusStorageVolGetInfo(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -204,6 +228,7 @@ static virtDBusGDBusPropertyTable virtDBusStorageVolPro= pertyTable[] =3D { }; =20 static virtDBusGDBusMethodTable virtDBusStorageVolMethodTable[] =3D { + { "Delete", virtDBusStorageVolDelete }, { "GetInfo", virtDBusStorageVolGetInfo }, { "GetXMLDesc", virtDBusStorageVolGetXMLDesc }, { "Resize", virtDBusStorageVolResize }, diff --git a/tests/test_storage.py b/tests/test_storage.py index 3f15fe0..ae06007 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -133,6 +133,12 @@ class TestStoragePool(libvirttest.BaseTestClass): =20 @pytest.mark.usefixtures('storage_volume_create') class TestStorageVolume(libvirttest.BaseTestClass): + def test_storage_vol_delete(self): + test_storage_vol_path, test_storage_vol =3D self.get_test_storage_= volume() + interface_obj =3D dbus.Interface(test_storage_vol, + 'org.libvirt.StorageVol') + interface_obj.Delete(0) + def test_storage_vol_properties_type(self): _, obj =3D self.get_test_storage_volume() =20 --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:27: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 1528992047310985.1602477968092; Thu, 14 Jun 2018 09:00:47 -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 6F323D084B; Thu, 14 Jun 2018 16:00:36 +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 0698E2016A82; Thu, 14 Jun 2018 16:00: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 76BB84CA84; Thu, 14 Jun 2018 16:00:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5EG0AGj003868 for ; Thu, 14 Jun 2018 12:00:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id B359710FFE52; Thu, 14 Jun 2018 16:00:10 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57A3010FFE4D for ; Thu, 14 Jun 2018 16:00:10 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 14 Jun 2018 17:59:53 +0200 Message-Id: <20180614155953.30292-18-kkoukiou@redhat.com> In-Reply-To: <20180614155953.30292-1-kkoukiou@redhat.com> References: <20180614155953.30292-1-kkoukiou@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 17/17] Implement StorageVolCreateXMLFrom 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: , Content-Type: text/plain; charset="utf-8" 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.38]); Thu, 14 Jun 2018 16:00:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Katerina Koukiou Reviewed-by: J=C3=A1n Tomko --- data/org.libvirt.StoragePool.xml | 9 +++++++++ src/storagepool.c | 41 ++++++++++++++++++++++++++++++++++++= ++++ tests/test_storage.py | 22 +++++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index 161ade5..0a324e6 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -75,6 +75,15 @@ + + + + + + + diff --git a/src/storagepool.c b/src/storagepool.c index ee2862b..6eb6f27 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -400,6 +400,46 @@ virtDBusStoragePoolStorageVolCreateXML(GVariant *inArg= s, *outArgs =3D g_variant_new("(o)", path); } =20 +static void +virtDBusStoragePoolStorageVolCreateXMLFrom(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSE= D, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNU= SED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virStoragePool) storagePool =3D NULL; + g_autoptr(virStorageVol) storageVol =3D NULL; + g_autoptr(virStorageVol) storageVolOld =3D NULL; + const gchar *key; + const gchar *xml; + guint flags; + g_autofree gchar *path =3D NULL; + + g_variant_get(inArgs, "(&s&su)", &xml, &key, &flags); + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + storageVolOld =3D virStorageVolLookupByKey(connect->connection, key); + if (!storageVolOld) + return virtDBusUtilSetLastVirtError(error); + + storageVol =3D virStorageVolCreateXMLFrom(storagePool, xml, storageVol= Old, + flags); + if (!storageVol) + return virtDBusUtilSetLastVirtError(error); + + path =3D virtDBusUtilBusPathForVirStorageVol(storageVol, + connect->storageVolPath); + + *outArgs =3D g_variant_new("(o)", path); +} + static void virtDBusStoragePoolStorageVolLookupByName(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -474,6 +514,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMeth= odTable[] =3D { { "ListStorageVolumes", virtDBusStoragePoolListStorageVolumes }, { "Refresh", virtDBusStoragePoolRefresh }, { "StorageVolCreateXML", virtDBusStoragePoolStorageVolCreateXML }, + { "StorageVolCreateXMLFrom", virtDBusStoragePoolStorageVolCreateXMLFro= m }, { "StorageVolLookupByName", virtDBusStoragePoolStorageVolLookupByName = }, { "Undefine", virtDBusStoragePoolUndefine }, { 0 } diff --git a/tests/test_storage.py b/tests/test_storage.py index ae06007..63ecf91 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -130,6 +130,28 @@ class TestStoragePool(libvirttest.BaseTestClass): def test_storage_pool_volume_create(self, storage_volume_create): assert isinstance(storage_volume_create, dbus.ObjectPath) =20 + @pytest.mark.usefixtures('storage_volume_create') + def test_storage_pool_volume_create_xml_from(self): + minimal_storage_vol_clone_xml =3D ''' + + clone.img + 1 + + ''' + _, test_storage_vol =3D self.get_test_storage_volume() + props =3D test_storage_vol.GetAll('org.libvirt.StorageVol', + dbus_interface=3Ddbus.PROPERTIES_I= FACE) + test_storage_vol_key =3D str(props['Key']) + + _, test_storage_pool =3D self.get_test_storage_pool() + storage_pool_iface =3D dbus.Interface(test_storage_pool, + 'org.libvirt.StoragePool') + + new_vol_path =3D storage_pool_iface.StorageVolCreateXMLFrom(minima= l_storage_vol_clone_xml, + test_sto= rage_vol_key, + 0) + assert isinstance(new_vol_path, dbus.ObjectPath) + =20 @pytest.mark.usefixtures('storage_volume_create') class TestStorageVolume(libvirttest.BaseTestClass): --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list