Re: [libvirt] [dbus PATCH v2 10/17] Implement MAC property for Interface Interface

2018-07-24 Thread Katerina Koukiou
On Fri, Jul 20, 2018 at 02:34:54PM -0400, Anya Harter wrote:
> Signed-off-by: Anya Harter 
> ---
>  data/org.libvirt.Interface.xml |  5 +
>  src/interface.c| 22 ++
>  tests/test_interface.py|  1 +
>  3 files changed, 28 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 10/17] Implement MAC 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|  1 +
 3 files changed, 28 insertions(+)

diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml
index c53c110..921e07f 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#virInterfaceGetMACString"/>
+  
+
 
   https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetName"/>
diff --git a/src/interface.c b/src/interface.c
index a597fe5..4caafcf 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -70,6 +70,27 @@ virtDBusInterfaceDestroy(GVariant *inArgs,
 virtDBusUtilSetLastVirtError(error);
 }
 
+static void
+virtDBusInterfaceGetMAC(const gchar *objectPath,
+gpointer userData,
+GVariant **value,
+GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virInterface) interface = NULL;
+const gchar *mac;
+
+interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error);
+if (!interface)
+return;
+
+mac = virInterfaceGetMACString(interface);
+if (!mac)
+return virtDBusUtilSetLastVirtError(error);
+
+*value = g_variant_new("s", mac);
+}
+
 static void
 virtDBusInterfaceGetName(const gchar *objectPath,
  gpointer userData,
@@ -139,6 +160,7 @@ virtDBusInterfaceUndefine(GVariant *inArgs G_GNUC_UNUSED,
 }
 
 static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = {
+{ "MAC", virtDBusInterfaceGetMAC, NULL },
 { "Name", virtDBusInterfaceGetName, NULL },
 { 0 }
 };
diff --git a/tests/test_interface.py b/tests/test_interface.py
index c11a9be..325f889 100755
--- a/tests/test_interface.py
+++ b/tests/test_interface.py
@@ -32,6 +32,7 @@ class TestInterface(libvirttest.BaseTestClass):
 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)
+assert isinstance(props['MAC'], 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