Signed-off-by: Anya Harter <aharter@xxxxxxxxxx> --- 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 @@ <node name="/org/libvirt/interface"> <interface name="org.libvirt.Interface"> + <property name="MAC" type="s" access="read"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetMACString"/> + <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/> + </property> <property name="Name" type="s" access="read"> <annotation name="org.gtk.GDBus.DocString" value="See 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@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list