From nobody Wed May 14 09:03:51 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525704208498620.9202520095552; Mon, 7 May 2018 07:43:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1C49F81DF1; Mon, 7 May 2018 14:43:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0ADA819940; Mon, 7 May 2018 14:43:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B8936180BAE5; Mon, 7 May 2018 14:43:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47Ef5qf032373 for ; Mon, 7 May 2018 10:41:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 397152024CA2; Mon, 7 May 2018 14:41:05 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2A332024CA1 for ; Mon, 7 May 2018 14:41:04 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:45 +0200 Message-Id: <20180507144100.25045-5-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 04/19] Implement Destroy method for StoragePool Interface X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 07 May 2018 14:43:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou --- data/org.libvirt.StoragePool.xml | 4 ++++ src/storagepool.c | 43 ++++++++++++++++++++++++++++++++++++= ++++ tests/libvirttest.py | 21 ++++++++++++++++++++ tests/test_storage.py | 26 ++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100755 tests/test_storage.py diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index 504a166..ac628d9 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -3,5 +3,9 @@ =20 + + + diff --git a/src/storagepool.c b/src/storagepool.c index f1421ef..5202f9e 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -3,11 +3,54 @@ =20 #include =20 +static virStoragePoolPtr +virtDBusStoragePoolGetVirStoragePool(virtDBusConnect *connect, + const gchar *objectPath, + GError **error) +{ + virStoragePoolPtr storagePool; + + if (virtDBusConnectOpen(connect, error) < 0) + return NULL; + + storagePool =3D virtDBusUtilVirStoragePoolFromBusPath(connect->connect= ion, + objectPath, + connect->storagePo= olPath); + if (!storagePool) { + virtDBusUtilSetLastVirtError(error); + return NULL; + } + + return storagePool; +} + +static void +virtDBusStoragePoolDestroy(GVariant *inArgs G_GNUC_UNUSED, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virStoragePool) storagePool =3D NULL; + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + if (virStoragePoolDestroy(storagePool) < 0) + virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusStoragePoolPropertyTable[] =3D { { 0 } }; =20 static virtDBusGDBusMethodTable virtDBusStoragePoolMethodTable[] =3D { + { "Destroy", virtDBusStoragePoolDestroy }, { 0 } }; =20 diff --git a/tests/libvirttest.py b/tests/libvirttest.py index eee67a0..e88484f 100644 --- a/tests/libvirttest.py +++ b/tests/libvirttest.py @@ -87,6 +87,19 @@ class BaseTestClass(): obj =3D self.bus.get_object('org.libvirt', path) return path, obj =20 + def test_storage_pool(self): + """Fetch information for the test storage pool from test driver + + Returns: + (dbus.proxies.ProxyObject, dbus.proxies.ProxyObject): + Test StoragePool Object, Local proxy for the test StoragePool + Object. + + """ + path =3D self.connect.ListStoragePools(0)[0] + obj =3D self.bus.get_object('org.libvirt', path) + return path, obj + =20 class DomainEvent(IntEnum): DEFINED =3D 0 @@ -172,3 +185,11 @@ class NetworkEvent(IntEnum): UNDEFINED =3D 1 STARTED =3D 2 STOPPED =3D 3 + + +class StoragePoolEvent(IntEnum): + DEFINED =3D 0 + UNDEFINED =3D 1 + STARTED =3D 2 + STOPPED =3D 3 + LAST =3D 4 diff --git a/tests/test_storage.py b/tests/test_storage.py new file mode 100755 index 0000000..8c5d75f --- /dev/null +++ b/tests/test_storage.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import dbus +import libvirttest + +class TestStoragePool(libvirttest.BaseTestClass): + def test_storage_pool_destroy(self): + def storage_pool_destroyed(path, event, _detail): + if event !=3D libvirttest.StoragePoolEvent.STOPPED: + return + assert isinstance(path, dbus.ObjectPath) + self.loop.quit() + + self.connect.connect_to_signal('StoragePoolEvent', + storage_pool_destroyed) + + _, test_storage_pool =3D self.test_storage_pool() + interface_obj =3D dbus.Interface(test_storage_pool, + 'org.libvirt.StoragePool') + interface_obj.Destroy() + + self.main_loop() + + +if __name__ =3D=3D '__main__': + libvirttest.run() --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list