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