Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
Reviewed-by: Ján Tomko <jtomko(a)redhat.com>
---
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="See
https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolGetPat...
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal"
value="const"/>
</property>
+ <method name="Delete">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolDelete...
+ <arg name="flags" type="u" direction="in"/>
+ </method>
<method name="GetInfo">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolGetInf...
diff --git a/src/storagevol.c b/src/storagevol.c
index 022ce37..489749d 100644
--- a/src/storagevol.c
+++ b/src/storagevol.c
@@ -90,6 +90,30 @@ virtDBusStorageVolGetPath(const gchar *objectPath,
*value = g_variant_new("s", path);
}
+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 = userData;
+ g_autoptr(virStorageVol) storageVol = NULL;
+ guint flags;
+
+ g_variant_get(inArgs, "(u)", &flags);
+
+ storageVol = 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 virtDBusStorageVolPropertyTable[] =
{
};
static virtDBusGDBusMethodTable virtDBusStorageVolMethodTable[] = {
+ { "Delete", virtDBusStorageVolDelete },
{ "GetInfo", virtDBusStorageVolGetInfo },
{ "GetXMLDesc", virtDBusStorageVolGetXMLDesc },
{ "Resize", virtDBusStorageVolResize },
diff --git a/tests/test_storage.py b/tests/test_storage.py
index 3f15fe0..ae06007 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -133,6 +133,12 @@ class TestStoragePool(libvirttest.BaseTestClass):
@pytest.mark.usefixtures('storage_volume_create')
class TestStorageVolume(libvirttest.BaseTestClass):
+ def test_storage_vol_delete(self):
+ test_storage_vol_path, test_storage_vol = self.get_test_storage_volume()
+ interface_obj = dbus.Interface(test_storage_vol,
+ 'org.libvirt.StorageVol')
+ interface_obj.Delete(0)
+
def test_storage_vol_properties_type(self):
_, obj = self.get_test_storage_volume()
--
2.15.0