Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.NodeDevice.xml | 5 +++++ src/nodedev.c | 22 ++++++++++++++++++++++ tests/test_nodedev.py | 1 + 3 files changed, 28 insertions(+) diff --git a/data/org.libvirt.NodeDevice.xml b/data/org.libvirt.NodeDevice.xml index b4caac3..c4b4075 100644 --- a/data/org.libvirt.NodeDevice.xml +++ b/data/org.libvirt.NodeDevice.xml @@ -8,6 +8,11 @@ value="See https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceGetName"/> <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/> </property> + <property name="Parent" type="s" access="read"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceGetParent"/> + <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/> + </property> <method name="Destroy"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceDestroy"/> diff --git a/src/nodedev.c b/src/nodedev.c index 9647fb6..c597411 100644 --- a/src/nodedev.c +++ b/src/nodedev.c @@ -45,6 +45,27 @@ virtDBusNodeDeviceGetName(const gchar *objectPath, *value = g_variant_new("s", name); } +static void +virtDBusNodeDeviceGetParent(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autoptr(virNodeDevice) dev = NULL; + const gchar *parent; + + dev = virtDBusNodeDeviceGetVirNodeDevice(connect, objectPath, error); + if (!dev) + return; + + parent = virNodeDeviceGetParent(dev); + if (!parent) + return virtDBusUtilSetLastVirtError(error); + + *value = g_variant_new("s", parent); +} + static void virtDBusNodeDeviceDestroy(GVariant *inArgs G_GNUC_UNUSED, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -91,6 +112,7 @@ virtDBusNodeDeviceDetach(GVariant *inArgs, static virtDBusGDBusPropertyTable virtDBusNodeDevicePropertyTable[] = { { "Name", virtDBusNodeDeviceGetName, NULL }, + { "Parent", virtDBusNodeDeviceGetParent, NULL }, { 0 } }; diff --git a/tests/test_nodedev.py b/tests/test_nodedev.py index cc7199a..39343ae 100755 --- a/tests/test_nodedev.py +++ b/tests/test_nodedev.py @@ -33,6 +33,7 @@ class TestNodeDevice(libvirttest.BaseTestClass): obj = self.bus.get_object('org.libvirt', test_node_device_path) props = obj.GetAll('org.libvirt.NodeDevice', dbus_interface=dbus.PROPERTIES_IFACE) assert isinstance(props['Name'], dbus.String) + assert isinstance(props['Parent'], dbus.String) if __name__ == '__main__': -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list