From nobody Sat Apr 27 08:46:41 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 1528794045232529.0229839393478; Tue, 12 Jun 2018 02:00:45 -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 85D813086258; Tue, 12 Jun 2018 09:00:41 +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 411FB308332B; Tue, 12 Jun 2018 09: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 BC5924CA80; Tue, 12 Jun 2018 09:00:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C90VM2006293 for ; Tue, 12 Jun 2018 05:00:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id B36532022DF7; Tue, 12 Jun 2018 09:00:31 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A5912022DF5 for ; Tue, 12 Jun 2018 09:00:31 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 11:00:14 +0200 Message-Id: <20180612090028.2800-2-kkoukiou@redhat.com> In-Reply-To: <20180612090028.2800-1-kkoukiou@redhat.com> References: <20180612090028.2800-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 01/15] 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.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.49]); Tue, 12 Jun 2018 09:00:44 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou --- data/Makefile.am | 3 +- data/org.libvirt.StorageVol.xml | 7 +++ src/Makefile.am | 3 +- src/connect.c | 6 +++ src/connect.h | 1 + src/storagevol.c | 96 +++++++++++++++++++++++++++++++++++++= ++++ src/storagevol.h | 9 ++++ src/util.c | 35 +++++++++++++++ src/util.h | 16 +++++++ 9 files changed, 174 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..5688cab 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -24,7 +24,8 @@ 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 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..539e722 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,7 +12,8 @@ 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 =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..dad7d11 --- /dev/null +++ b/src/storagevol.c @@ -0,0 +1,96 @@ +#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; + gint numVols =3D 0; + gint numVolsTotal =3D 0; + gint offset =3D 0; + gchar **ret =3D NULL; + + if (!virtDBusConnectOpen(connect, NULL)) + return NULL; + + numPools =3D virConnectListAllStoragePools(connect->connection, + &storagePools, 0); + if (numPools < 0) + return NULL; + + if (numPools =3D=3D 0) + return NULL; + + for (gint i =3D 0; i < numPools; i++) { + g_autoptr(virStorageVolPtr) storageVols =3D NULL; + + numVols =3D virStoragePoolListAllVolumes(storagePools[i], + &storageVols, 0); + if (numVols < 0) + return NULL; + + if (numVols =3D=3D 0) + return NULL; + + numVolsTotal +=3D numVols; + } + + ret =3D g_new0(gchar *, numVolsTotal + 1); + + for (gint i =3D 0; i < numPools; i++) { + g_autoptr(virStorageVolPtr) storageVols =3D NULL; + + numVols =3D virStoragePoolListAllVolumes(storagePools[i], + &storageVols, 0); + if (numVols < 0) + return NULL; + + if (numVols =3D=3D 0) + return NULL; + + for (gint j =3D 0; j < numVols; j++) { + ret[offset] =3D virtDBusUtilBusPathForVirStorageVol(storageVol= s[j], + connect->sto= rageVolPath); + offset++; + } + } + + return ret; +} + +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..1d11ce6 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); + + key =3D virtDBusUtilDecodeStr(path + prefixLen + 1); + + 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 Sat Apr 27 08:46:41 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 1528794040193351.7866393016543; Tue, 12 Jun 2018 02:00:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E32183078AAB; Tue, 12 Jun 2018 09: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 972888E1AB; Tue, 12 Jun 2018 09: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 007844CA80; Tue, 12 Jun 2018 09:00:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C90W5V006298 for ; Tue, 12 Jun 2018 05:00:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5698B2022DF7; Tue, 12 Jun 2018 09:00:32 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF66C2022DF5 for ; Tue, 12 Jun 2018 09:00:31 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 11:00:15 +0200 Message-Id: <20180612090028.2800-3-kkoukiou@redhat.com> In-Reply-To: <20180612090028.2800-1-kkoukiou@redhat.com> References: <20180612090028.2800-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 02/15] 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 12 Jun 2018 09:00:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: J=EF=BF=BDn Tomko --- data/org.libvirt.StoragePool.xml | 6 ++++++ src/storagepool.c | 44 ++++++++++++++++++++++++++++++++++++= ++++ tests/test_storage.py | 8 ++++++++ 3 files changed, 58 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..11e356c 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -301,6 +301,49 @@ virtDBusStoragePoolGetXMLDesc(GVariant *inArgs, *outArgs =3D g_variant_new("(s)", xml); } =20 +static void +virtDBusStoragePoolListAllVolumes(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; + g_autofree gchar *xml =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 +406,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMeth= odTable[] =3D { { "Destroy", virtDBusStoragePoolDestroy }, { "GetInfo", virtDBusStoragePoolGetInfo }, { "GetXMLDesc", virtDBusStoragePoolGetXMLDesc }, + { "ListStorageVolumes", virtDBusStoragePoolListAllVolumes }, { "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 Sat Apr 27 08:46:41 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 1528794039389329.79402469553463; Tue, 12 Jun 2018 02:00:39 -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 81D6F307C81E; Tue, 12 Jun 2018 09:00:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 219E7308332D; Tue, 12 Jun 2018 09: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 A3F121800532; Tue, 12 Jun 2018 09:00:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C90Xcc006306 for ; Tue, 12 Jun 2018 05:00:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id ED8D92022DF7; Tue, 12 Jun 2018 09:00:32 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 923412022DF5 for ; Tue, 12 Jun 2018 09:00:32 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 11:00:16 +0200 Message-Id: <20180612090028.2800-4-kkoukiou@redhat.com> In-Reply-To: <20180612090028.2800-1-kkoukiou@redhat.com> References: <20180612090028.2800-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 03/15] 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.40]); Tue, 12 Jun 2018 09:00:38 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: J=EF=BF=BDn Tomko --- data/org.libvirt.StoragePool.xml | 7 +++++++ src/storagepool.c | 34 ++++++++++++++++++++++++++++++++++ tests/libvirttest.py | 17 +++++++++++++++++ tests/test_storage.py | 4 ++++ 4 files changed, 62 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 11e356c..c3fd0bf 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -368,6 +368,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, @@ -408,6 +441,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMeth= odTable[] =3D { { "GetXMLDesc", virtDBusStoragePoolGetXMLDesc }, { "ListStorageVolumes", virtDBusStoragePoolListAllVolumes }, { "Refresh", virtDBusStoragePoolRefresh }, + { "StorageVolCreateXML", virtDBusStoragePoolStorageVolCreateXML }, { "Undefine", virtDBusStoragePoolUndefine }, { 0 } }; diff --git a/tests/libvirttest.py b/tests/libvirttest.py index 3cd02ef..f65251a 100644 --- a/tests/libvirttest.py +++ b/tests/libvirttest.py @@ -100,6 +100,23 @@ class BaseTestClass(): obj =3D self.bus.get_object('org.libvirt', path) return path, obj =20 + def test_storage_vol(self): + minimal_storage_vol_xml =3D ''' + + sparse.img + 2 + + /var/lib/virt/images/sparse.img + + + ''' + _, test_storage_pool =3D self.test_storage_pool() + interface_obj =3D dbus.Interface(test_storage_pool, + 'org.libvirt.StoragePool') + path =3D interface_obj.StorageVolCreateXML(minimal_storage_vol_xml= , 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 79e0c16..1cd1249 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -126,6 +126,10 @@ class TestStoragePool(libvirttest.BaseTestClass): =20 self.main_loop() =20 + def test_storage_pool_volume_create(self): + path, _ =3D self.test_storage_vol() + assert isinstance(path, dbus.ObjectPath) + =20 if __name__ =3D=3D '__main__': libvirttest.run() --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 08:46:41 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 1528794052538215.44434032620347; Tue, 12 Jun 2018 02:00:52 -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 CFFE280F6C; Tue, 12 Jun 2018 09:00:49 +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 76A6D2010D5E; Tue, 12 Jun 2018 09:00:49 +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 944364CA82; Tue, 12 Jun 2018 09:00:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C90XF8006316 for ; Tue, 12 Jun 2018 05:00:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 90E2B2022DF7; Tue, 12 Jun 2018 09:00:33 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 359C22022DF5 for ; Tue, 12 Jun 2018 09:00:33 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 11:00:17 +0200 Message-Id: <20180612090028.2800-5-kkoukiou@redhat.com> In-Reply-To: <20180612090028.2800-1-kkoukiou@redhat.com> References: <20180612090028.2800-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 04/15] 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 12 Jun 2018 09:00:51 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: J=EF=BF=BDn Tomko --- data/org.libvirt.StorageVol.xml | 5 +++++ src/storagevol.c | 44 +++++++++++++++++++++++++++++++++++++= ++++ tests/test_storage.py | 9 +++++++++ 3 files changed, 58 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 dad7d11..70bc2bc 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 1cd1249..bfdd084 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -131,5 +131,14 @@ class TestStoragePool(libvirttest.BaseTestClass): assert isinstance(path, dbus.ObjectPath) =20 =20 +class TestStorageVolume(libvirttest.BaseTestClass): + def test_storage_vol_properties_type(self): + _, obj =3D self.test_storage_vol() + + 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 Sat Apr 27 08:46:41 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 152879404688364.40253036441754; Tue, 12 Jun 2018 02:00:46 -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 76E278110F; Tue, 12 Jun 2018 09:00:44 +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 441FB3001934; Tue, 12 Jun 2018 09:00:44 +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 BC1531800532; Tue, 12 Jun 2018 09:00:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C90YCT006323 for ; Tue, 12 Jun 2018 05:00:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 33BC62022DF7; Tue, 12 Jun 2018 09:00:34 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCAFB2022DF5 for ; Tue, 12 Jun 2018 09:00:33 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 11:00:18 +0200 Message-Id: <20180612090028.2800-6-kkoukiou@redhat.com> In-Reply-To: <20180612090028.2800-1-kkoukiou@redhat.com> References: <20180612090028.2800-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 05/15] 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: , 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.28]); Tue, 12 Jun 2018 09:00:45 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: J=EF=BF=BDn 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 70bc2bc..82d81ab 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 bfdd084..7aa887d 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -137,6 +137,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 Sat Apr 27 08:46:41 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 1528794055770193.0127376354818; Tue, 12 Jun 2018 02:00:55 -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 D0E923084054; Tue, 12 Jun 2018 09:00:53 +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 881D810694CD; Tue, 12 Jun 2018 09:00:53 +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 A57171800534; Tue, 12 Jun 2018 09:00:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C90YYk006329 for ; Tue, 12 Jun 2018 05:00:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id CB13F2022DF7; Tue, 12 Jun 2018 09:00:34 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FE782022DF5 for ; Tue, 12 Jun 2018 09:00:34 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 11:00:19 +0200 Message-Id: <20180612090028.2800-7-kkoukiou@redhat.com> In-Reply-To: <20180612090028.2800-1-kkoukiou@redhat.com> References: <20180612090028.2800-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 06/15] 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: , 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.40]); Tue, 12 Jun 2018 09:00:55 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: J=EF=BF=BDn 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 82d81ab..c65e11a 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; + const gchar *key; + + storageVol =3D virtDBusStorageVolGetVirStorageVol(connect, objectPath, + error); + if (!storageVol) + return; + + key =3D virStorageVolGetPath(storageVol); + if (!key) + return virtDBusUtilSetLastVirtError(error); + + *value =3D g_variant_new("s", key); +} + 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 7aa887d..a430808 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -139,6 +139,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 Sat Apr 27 08:46:41 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 1528794066334775.2239340952891; Tue, 12 Jun 2018 02:01:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CCA13C0587EF; Tue, 12 Jun 2018 09:01:04 +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 2944017F37; Tue, 12 Jun 2018 09:01: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 1129118037EC; Tue, 12 Jun 2018 09:01:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C90ZaZ006338 for ; Tue, 12 Jun 2018 05:00:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6E7F22022DF7; Tue, 12 Jun 2018 09:00:35 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12C042022DF5 for ; Tue, 12 Jun 2018 09:00:34 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 11:00:20 +0200 Message-Id: <20180612090028.2800-8-kkoukiou@redhat.com> In-Reply-To: <20180612090028.2800-1-kkoukiou@redhat.com> References: <20180612090028.2800-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 07/15] 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 12 Jun 2018 09:01: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: J=EF=BF=BDn 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 c65e11a..efe88d3 100644 --- a/src/storagevol.c +++ b/src/storagevol.c @@ -90,6 +90,34 @@ virtDBusStorageVolGetPath(const gchar *objectPath, *value =3D g_variant_new("s", key); } =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 a430808..1d0afe0 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -141,6 +141,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.test_storage_vol() + 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 Sat Apr 27 08:46:41 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 1528794076640287.77931821181016; Tue, 12 Jun 2018 02:01:16 -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 52D2230C110F; Tue, 12 Jun 2018 09:01:15 +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 D7660600C0; Tue, 12 Jun 2018 09:01:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 625EC4CA83; Tue, 12 Jun 2018 09:01:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C90atm006346 for ; Tue, 12 Jun 2018 05:00:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 11E352022DF7; Tue, 12 Jun 2018 09:00:36 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id AACC52022DF5 for ; Tue, 12 Jun 2018 09:00:35 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 11:00:21 +0200 Message-Id: <20180612090028.2800-9-kkoukiou@redhat.com> In-Reply-To: <20180612090028.2800-1-kkoukiou@redhat.com> References: <20180612090028.2800-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 08/15] 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: , 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.46]); Tue, 12 Jun 2018 09:01:16 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: J=EF=BF=BDn Tomko --- data/org.libvirt.Connect.xml | 6 ++++++ src/connect.c | 30 ++++++++++++++++++++++++++++++ tests/test_connect.py | 14 ++++++++++++++ 3 files changed, 50 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..c526808 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 da146a4..fc4ca78 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -245,6 +245,20 @@ class TestConnect(libvirttest.BaseTestClass): path =3D getattr(self.connect, lookup_method_name)(prop) assert original_path =3D=3D path =20 + @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.test_storage_vol() + 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 Sat Apr 27 08:46:41 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 1528794086944353.9847970186066; Tue, 12 Jun 2018 02:01:26 -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 7F3A13082A4C; Tue, 12 Jun 2018 09:01: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 0AA2410694C7; Tue, 12 Jun 2018 09:01: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 5716D4BB78; Tue, 12 Jun 2018 09:01:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C90aGt006353 for ; Tue, 12 Jun 2018 05:00:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id A8EEA2022DF7; Tue, 12 Jun 2018 09:00:36 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DF282022DF5 for ; Tue, 12 Jun 2018 09:00:36 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 11:00:22 +0200 Message-Id: <20180612090028.2800-10-kkoukiou@redhat.com> In-Reply-To: <20180612090028.2800-1-kkoukiou@redhat.com> References: <20180612090028.2800-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 09/15] 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: , 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.45]); Tue, 12 Jun 2018 09:01: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: J=EF=BF=BDn 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 c3fd0bf..55077ed 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -401,6 +401,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 G_GNUC_U= NUSED, + 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, @@ -442,6 +475,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMeth= odTable[] =3D { { "ListStorageVolumes", virtDBusStoragePoolListAllVolumes }, { "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 Sat Apr 27 08:46:41 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 1528794099161534.1937549297143; Tue, 12 Jun 2018 02:01:39 -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 451DE3D955; Tue, 12 Jun 2018 09:01:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B50FB10694C7; Tue, 12 Jun 2018 09:01: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 179D44CA82; Tue, 12 Jun 2018 09:01:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C90bsI006361 for ; Tue, 12 Jun 2018 05:00:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4BF5C2022DF7; Tue, 12 Jun 2018 09:00:37 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4BAE2022DF5 for ; Tue, 12 Jun 2018 09:00:36 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 11:00:23 +0200 Message-Id: <20180612090028.2800-11-kkoukiou@redhat.com> In-Reply-To: <20180612090028.2800-1-kkoukiou@redhat.com> References: <20180612090028.2800-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 10/15] 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: , 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.30]); Tue, 12 Jun 2018 09:01:38 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: J=EF=BF=BDn Tomko --- data/org.libvirt.Connect.xml | 6 ++++++ src/connect.c | 29 +++++++++++++++++++++++++++++ tests/test_connect.py | 1 + 3 files changed, 36 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 c526808..157cdb3 100644 --- a/src/connect.c +++ b/src/connect.c @@ -1573,6 +1573,34 @@ 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; + g_autofree gchar *path =3D NULL; + + g_variant_get(inArgs, "(s)", &path); + + if (!virtDBusConnectOpen(connect, error)) + return; + + storageVol =3D virStorageVolLookupByPath(connect->connection, path); + 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 +1655,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 fc4ca78..80bb50b 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -247,6 +247,7 @@ class TestConnect(libvirttest.BaseTestClass): =20 @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 Sat Apr 27 08:46:41 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 1528794111713782.5312345196273; Tue, 12 Jun 2018 02:01:51 -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 1B35530014B0; Tue, 12 Jun 2018 09:01:50 +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 529BE10694C7; Tue, 12 Jun 2018 09:01:48 +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 420AF180BACA; Tue, 12 Jun 2018 09:01:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C90cPu006372 for ; Tue, 12 Jun 2018 05:00:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id E4C942022DF7; Tue, 12 Jun 2018 09:00:37 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 882C32022DF5 for ; Tue, 12 Jun 2018 09:00:37 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 11:00:24 +0200 Message-Id: <20180612090028.2800-12-kkoukiou@redhat.com> In-Reply-To: <20180612090028.2800-1-kkoukiou@redhat.com> References: <20180612090028.2800-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 11/15] 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: , 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.40]); Tue, 12 Jun 2018 09:01:51 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: J=EF=BF=BDn 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 efe88d3..66f7c86 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 Sat Apr 27 08:46:41 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 1528794061063960.4417739466686; Tue, 12 Jun 2018 02:01:01 -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 0EBF430820CA; Tue, 12 Jun 2018 09:00:59 +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 A7A3A60172; Tue, 12 Jun 2018 09:00:58 +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 EFC0A1800534; Tue, 12 Jun 2018 09:00:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C90ce2006382 for ; Tue, 12 Jun 2018 05:00:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 898F82022DF7; Tue, 12 Jun 2018 09:00:38 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CF5D2022DF5 for ; Tue, 12 Jun 2018 09:00:38 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 11:00:25 +0200 Message-Id: <20180612090028.2800-13-kkoukiou@redhat.com> In-Reply-To: <20180612090028.2800-1-kkoukiou@redhat.com> References: <20180612090028.2800-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 12/15] 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: , 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.47]); Tue, 12 Jun 2018 09:01:00 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: J=EF=BF=BDn 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 66f7c86..91d99e7 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 Sat Apr 27 08:46:41 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 15287940724771001.9997565140162; Tue, 12 Jun 2018 02:01:12 -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 8DF6C30C10EC; Tue, 12 Jun 2018 09:01:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 323C263156; Tue, 12 Jun 2018 09:01:10 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9A1874CA85; Tue, 12 Jun 2018 09:01:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C90du0006391 for ; Tue, 12 Jun 2018 05:00:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2DAD02022DF7; Tue, 12 Jun 2018 09:00:39 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id C65D92022DF5 for ; Tue, 12 Jun 2018 09:00:38 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 11:00:26 +0200 Message-Id: <20180612090028.2800-14-kkoukiou@redhat.com> In-Reply-To: <20180612090028.2800-1-kkoukiou@redhat.com> References: <20180612090028.2800-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 13/15] 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 12 Jun 2018 09:01:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: J=EF=BF=BDn 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 91d99e7..dc05dc4 100644 --- a/src/storagevol.c +++ b/src/storagevol.c @@ -90,6 +90,34 @@ virtDBusStorageVolGetPath(const gchar *objectPath, *value =3D g_variant_new("s", key); } =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 Sat Apr 27 08:46:41 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 1528794080739442.5962315849263; Tue, 12 Jun 2018 02:01:20 -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 37DA25F73A; Tue, 12 Jun 2018 09:01:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E1AC710694C7; Tue, 12 Jun 2018 09:01: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 10B5C18037EF; Tue, 12 Jun 2018 09:01:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C90dmS006400 for ; Tue, 12 Jun 2018 05:00:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id C43E42022DF7; Tue, 12 Jun 2018 09:00:39 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 695BD2022DF5 for ; Tue, 12 Jun 2018 09:00:39 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 11:00:27 +0200 Message-Id: <20180612090028.2800-15-kkoukiou@redhat.com> In-Reply-To: <20180612090028.2800-1-kkoukiou@redhat.com> References: <20180612090028.2800-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 14/15] 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: , 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]); Tue, 12 Jun 2018 09:01:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: J=EF=BF=BDn 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 dc05dc4..c574be9 100644 --- a/src/storagevol.c +++ b/src/storagevol.c @@ -90,6 +90,30 @@ virtDBusStorageVolGetPath(const gchar *objectPath, *value =3D g_variant_new("s", key); } =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 1d0afe0..f342e77 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -132,6 +132,12 @@ class TestStoragePool(libvirttest.BaseTestClass): =20 =20 class TestStorageVolume(libvirttest.BaseTestClass): + def test_storage_vol_delete(self): + test_storage_vol_path, test_storage_vol =3D self.test_storage_vol() + 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.test_storage_vol() =20 --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 08:46:41 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 1528794045813709.3160465636481; Tue, 12 Jun 2018 02:00:45 -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 0A88A3680B; Tue, 12 Jun 2018 09:00:44 +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 C37C9308332C; Tue, 12 Jun 2018 09:00:43 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1B0824CA80; Tue, 12 Jun 2018 09:00:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C90eHD006408 for ; Tue, 12 Jun 2018 05:00:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 66C702022DF7; Tue, 12 Jun 2018 09:00:40 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BE992022DF5 for ; Tue, 12 Jun 2018 09:00:39 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 11:00:28 +0200 Message-Id: <20180612090028.2800-16-kkoukiou@redhat.com> In-Reply-To: <20180612090028.2800-1-kkoukiou@redhat.com> References: <20180612090028.2800-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 15/15] 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: , 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.30]); Tue, 12 Jun 2018 09:00:44 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: J=EF=BF=BDn Tomko --- data/org.libvirt.StoragePool.xml | 9 +++++++++ src/storagepool.c | 41 ++++++++++++++++++++++++++++++++++++= ++++ tests/test_storage.py | 21 ++++++++++++++++++++ 3 files changed, 71 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 55077ed..854ca7d 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -401,6 +401,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; + gchar *key; + 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, @@ -475,6 +515,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMeth= odTable[] =3D { { "ListStorageVolumes", virtDBusStoragePoolListAllVolumes }, { "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 f342e77..8a0c4f6 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -130,6 +130,27 @@ class TestStoragePool(libvirttest.BaseTestClass): path, _ =3D self.test_storage_vol() assert isinstance(path, dbus.ObjectPath) =20 + def test_storage_pool_volume_create_xml_from(self): + minimal_storage_vol_clone_xml =3D ''' + + clone.img + 1 + + ''' + _, test_storage_vol =3D self.test_storage_vol() + 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.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 class TestStorageVolume(libvirttest.BaseTestClass): def test_storage_vol_delete(self): --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list