Re: [libvirt] [dbus PATCH v2 09/17] Implement Name property for Interface Interface

2018-07-24 Thread Katerina Koukiou
On Fri, Jul 20, 2018 at 02:34:53PM -0400, Anya Harter wrote:
> Signed-off-by: Anya Harter 
> ---
>  data/org.libvirt.Interface.xml |  5 +
>  src/interface.c| 22 ++
>  tests/test_interface.py|  8 
>  3 files changed, 35 insertions(+)

Reviewed-by: Katerina Koukiou 


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

[libvirt] [dbus PATCH v2 09/17] Implement Name property for Interface Interface

2018-07-20 Thread Anya Harter
Signed-off-by: Anya Harter 
---
 data/org.libvirt.Interface.xml |  5 +
 src/interface.c| 22 ++
 tests/test_interface.py|  8 
 3 files changed, 35 insertions(+)

diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml
index dc03258..c53c110 100644
--- a/data/org.libvirt.Interface.xml
+++ b/data/org.libvirt.Interface.xml
@@ -3,6 +3,11 @@
 
 
   
+
+  https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetName"/>
+  
+
 
   https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceCreate"/>
diff --git a/src/interface.c b/src/interface.c
index fcec623..a597fe5 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -70,6 +70,27 @@ virtDBusInterfaceDestroy(GVariant *inArgs,
 virtDBusUtilSetLastVirtError(error);
 }
 
+static void
+virtDBusInterfaceGetName(const gchar *objectPath,
+ gpointer userData,
+ GVariant **value,
+ GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virInterface) interface = NULL;
+const gchar *name;
+
+interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error);
+if (!interface)
+return;
+
+name = virInterfaceGetName(interface);
+if (!name)
+return virtDBusUtilSetLastVirtError(error);
+
+*value = g_variant_new("s", name);
+}
+
 static void
 virtDBusInterfaceGetXMLDesc(GVariant *inArgs,
 GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -118,6 +139,7 @@ virtDBusInterfaceUndefine(GVariant *inArgs G_GNUC_UNUSED,
 }
 
 static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = {
+{ "Name", virtDBusInterfaceGetName, NULL },
 { 0 }
 };
 
diff --git a/tests/test_interface.py b/tests/test_interface.py
index 0b5a943..c11a9be 100755
--- a/tests/test_interface.py
+++ b/tests/test_interface.py
@@ -25,5 +25,13 @@ class TestInterface(libvirttest.BaseTestClass):
 _,interface_obj = self.interface_create()
 assert isinstance(interface_obj.GetXMLDesc(0), dbus.String)
 
+def test_interface_properties_type(self):
+""" Ensure correct return type for Interface properties
+"""
+test_interface_path,_ = self.interface_create()
+obj = self.bus.get_object('org.libvirt', test_interface_path)
+props = obj.GetAll('org.libvirt.Interface', 
dbus_interface=dbus.PROPERTIES_IFACE)
+assert isinstance(props['Name'], dbus.String)
+
 if __name__ == '__main__':
 libvirttest.run()
-- 
2.17.1

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