Commit d42d6fa4 authored by Anya Harter's avatar Anya Harter Committed by Katerina Koukiou

Implement MAC property for Interface Interface

Signed-off-by: 's avatarAnya Harter <aharter@redhat.com>
Reviewed-by: 's avatarKaterina Koukiou <kkoukiou@redhat.com>
parent 282186a3
......@@ -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"/>
......
......@@ -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 }
};
......
......@@ -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()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment