From nobody Wed May 14 03:03:41 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 152899202010619.877338277568697; Thu, 14 Jun 2018 09:00:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B76A73150095; Thu, 14 Jun 2018 16:00:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 79971300174E; Thu, 14 Jun 2018 16:00:18 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E300118052EA; Thu, 14 Jun 2018 16:00:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5EG015p003764 for ; Thu, 14 Jun 2018 12:00:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8C0DD10FFE52; Thu, 14 Jun 2018 16:00:01 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C82C10FFE4D for ; Thu, 14 Jun 2018 16:00:01 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 14 Jun 2018 17:59:41 +0200 Message-Id: <20180614155953.30292-6-kkoukiou@redhat.com> In-Reply-To: <20180614155953.30292-1-kkoukiou@redhat.com> References: <20180614155953.30292-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH v2 05/17] Implement StorageVolCreateXML method for StoragePool Interface X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 14 Jun 2018 16:00:19 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.StoragePool.xml | 7 +++++++ src/storagepool.c | 34 ++++++++++++++++++++++++++++++++++ tests/libvirttest.py | 31 +++++++++++++++++++++++++++++++ tests/test_storage.py | 3 +++ tests/xmldata.py | 10 ++++++++++ 5 files changed, 85 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePoo= l.xml index 764c9c1..51d65ab 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -68,6 +68,13 @@ value=3D"See https://libvirt.org/html/libvirt-libvirt-storage.html= #virStoragePoolRefresh"/> + + + + + + diff --git a/src/storagepool.c b/src/storagepool.c index 4f83ee2..cde9ec3 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -367,6 +367,39 @@ virtDBusStoragePoolRefresh(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } =20 +static void +virtDBusStoragePoolStorageVolCreateXML(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virStoragePool) storagePool =3D NULL; + g_autoptr(virStorageVol) storageVol =3D NULL; + gchar *xml; + guint flags; + g_autofree gchar *path =3D NULL; + + g_variant_get(inArgs, "(&su)", &xml, &flags); + + storagePool =3D virtDBusStoragePoolGetVirStoragePool(connect, objectPa= th, + error); + if (!storagePool) + return; + + storageVol =3D virStorageVolCreateXML(storagePool, xml, flags); + if (!storageVol) + return virtDBusUtilSetLastVirtError(error); + + path =3D virtDBusUtilBusPathForVirStorageVol(storageVol, + connect->storageVolPath); + + *outArgs =3D g_variant_new("(o)", path); +} + static void virtDBusStoragePoolUndefine(GVariant *inArgs G_GNUC_UNUSED, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -407,6 +440,7 @@ static virtDBusGDBusMethodTable virtDBusStoragePoolMeth= odTable[] =3D { { "GetXMLDesc", virtDBusStoragePoolGetXMLDesc }, { "ListStorageVolumes", virtDBusStoragePoolListStorageVolumes }, { "Refresh", virtDBusStoragePoolRefresh }, + { "StorageVolCreateXML", virtDBusStoragePoolStorageVolCreateXML }, { "Undefine", virtDBusStoragePoolUndefine }, { 0 } }; diff --git a/tests/libvirttest.py b/tests/libvirttest.py index 23a597f..6d1a9d0 100644 --- a/tests/libvirttest.py +++ b/tests/libvirttest.py @@ -7,6 +7,7 @@ import pytest import subprocess import sys import time +import xmldata =20 =20 root =3D os.environ.get('abs_top_builddir', os.path.dirname(os.path.dirnam= e(__file__))) @@ -70,6 +71,20 @@ class BaseTestClass(): if self.timeout: raise TimeoutError() =20 + @pytest.fixture + def storage_volume_create(self): + """ Fixture to create dummy storage volume on the test driver + + This fixture should be used in the setup of every test manipulating + with test volume. + """ + _, test_storage_pool =3D self.get_test_storage_pool() + interface_obj =3D dbus.Interface(test_storage_pool, + 'org.libvirt.StoragePool') + path =3D interface_obj.StorageVolCreateXML(xmldata.minimal_storage= _vol_xml, 0) + yield path + + def get_test_domain(self): path =3D self.connect.ListDomains(0)[0] obj =3D self.bus.get_object('org.libvirt', path) @@ -100,6 +115,22 @@ class BaseTestClass(): obj =3D self.bus.get_object('org.libvirt', path) return path, obj =20 + def get_test_storage_volume(self): + """Fetch information for the test storage vol from test driver + + Returns: + (dbus.proxies.ProxyObject, dbus.proxies.ProxyObject): + Test StorageVol Object, Local proxy for the test StorageVol + Object. + + """ + _, test_storage_pool =3D self.get_test_storage_pool() + pool_iface =3D dbus.Interface(test_storage_pool, + 'org.libvirt.StoragePool') + path =3D pool_iface.ListStorageVolumes(0)[0] + obj =3D self.bus.get_object('org.libvirt', path) + return path, obj + =20 class DomainEvent(IntEnum): DEFINED =3D 0 diff --git a/tests/test_storage.py b/tests/test_storage.py index 10bcea3..2aefd74 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -126,6 +126,9 @@ class TestStoragePool(libvirttest.BaseTestClass): =20 self.main_loop() =20 + def test_storage_pool_volume_create(self, storage_volume_create): + assert isinstance(storage_volume_create, dbus.ObjectPath) + =20 if __name__ =3D=3D '__main__': libvirttest.run() diff --git a/tests/xmldata.py b/tests/xmldata.py index e42b6aa..926bd2c 100644 --- a/tests/xmldata.py +++ b/tests/xmldata.py @@ -35,3 +35,13 @@ minimal_storage_pool_xml =3D ''' ''' + +minimal_storage_vol_xml =3D ''' + + sparse.img + 2 + + /var/lib/virt/images/sparse.img + + +''' --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list