Re: [libvirt] [dbus PATCH 06/15] Implement Path property for StorageVol Interface

2018-06-14 Thread Ján Tomko

On Tue, Jun 12, 2018 at 11:00:19AM +0200, Katerina Koukiou wrote:

Signed-off-by: Katerina Koukiou 
---
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="See 
https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolGetKey"/>
  

+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolGetPath"/>
+  
+
  

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 = g_variant_new("s", key);
}

+static void
+virtDBusStorageVolGetPath(const gchar *objectPath,
+  gpointer userData,
+  GVariant **value,
+  GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStorageVol) storageVol = NULL;
+const gchar *key;
+


g_autofree gchar *path;

virStorageVolGetPath returns a strdup'd string, unlike
virStorageVolGetKey

Jano


+storageVol = virtDBusStorageVolGetVirStorageVol(connect, objectPath,
+error);
+if (!storageVol)
+return;
+
+key = virStorageVolGetPath(storageVol);
+if (!key)
+return virtDBusUtilSetLastVirtError(error);
+
+*value = g_variant_new("s", key);
+}


signature.asc
Description: Digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [dbus PATCH 06/15] Implement Path property for StorageVol Interface

2018-06-14 Thread Ján Tomko

On Tue, Jun 12, 2018 at 11:00:19AM +0200, Katerina Koukiou wrote:

Signed-off-by: Katerina Koukiou 
---
data/org.libvirt.StorageVol.xml |  5 +
src/storagevol.c| 23 +++
tests/test_storage.py   |  1 +
3 files changed, 29 insertions(+)



Reviewed-by: Ján Tomko 

Jano


signature.asc
Description: Digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [dbus PATCH 06/15] Implement Path property for StorageVol Interface

2018-06-12 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 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="See 
https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolGetKey"/>
   
 
+
+  https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolGetPath"/>
+  
+
   
 
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 = g_variant_new("s", key);
 }
 
+static void
+virtDBusStorageVolGetPath(const gchar *objectPath,
+  gpointer userData,
+  GVariant **value,
+  GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virStorageVol) storageVol = NULL;
+const gchar *key;
+
+storageVol = virtDBusStorageVolGetVirStorageVol(connect, objectPath,
+error);
+if (!storageVol)
+return;
+
+key = virStorageVolGetPath(storageVol);
+if (!key)
+return virtDBusUtilSetLastVirtError(error);
+
+*value = g_variant_new("s", key);
+}
+
 static virtDBusGDBusPropertyTable virtDBusStorageVolPropertyTable[] = {
 { "Name", virtDBusStorageVolGetName, NULL },
 { "Key", virtDBusStorageVolGetKey, NULL },
+{ "Path", virtDBusStorageVolGetPath, NULL },
 { 0 }
 };
 
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=dbus.PROPERTIES_IFACE)
 assert isinstance(props['Key'], dbus.String)
 assert isinstance(props['Name'], dbus.String)
+assert isinstance(props['Path'], dbus.String)
 
 
 if __name__ == '__main__':
-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list