[dbus PATCH 07/14] Implement Name property for NodeDevice Interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
---
 data/org.libvirt.NodeDevice.xml |  5 +++++
 src/nodedev.c                   | 22 ++++++++++++++++++++++
 tests/test_nodedev.py           |  8 ++++++++
 3 files changed, 35 insertions(+)

diff --git a/data/org.libvirt.NodeDevice.xml b/data/org.libvirt.NodeDevice.xml
index ea9bd7c..b4caac3 100644
--- a/data/org.libvirt.NodeDevice.xml
+++ b/data/org.libvirt.NodeDevice.xml
@@ -3,6 +3,11 @@
 
 <node name="/org/libvirt/nodedev">
   <interface name="org.libvirt.NodeDevice">
+    <property name="Name" type="s" access="read">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceGetName"/>
+      <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 e8551b8..9647fb6 100644
--- a/src/nodedev.c
+++ b/src/nodedev.c
@@ -24,6 +24,27 @@ virtDBusNodeDeviceGetVirNodeDevice(virtDBusConnect *connect,
     return dev;
 }
 
+static void
+virtDBusNodeDeviceGetName(const gchar *objectPath,
+                          gpointer userData,
+                          GVariant **value,
+                          GError **error)
+{
+    virtDBusConnect *connect = userData;
+    g_autoptr(virNodeDevice) dev = NULL;
+    const gchar *name;
+
+    dev = virtDBusNodeDeviceGetVirNodeDevice(connect, objectPath, error);
+    if (!dev)
+        return;
+
+    name = virNodeDeviceGetName(dev);
+    if (!name)
+        return virtDBusUtilSetLastVirtError(error);
+
+    *value = g_variant_new("s", name);
+}
+
 static void
 virtDBusNodeDeviceDestroy(GVariant *inArgs G_GNUC_UNUSED,
                           GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -69,6 +90,7 @@ virtDBusNodeDeviceDetach(GVariant *inArgs,
 }
 
 static virtDBusGDBusPropertyTable virtDBusNodeDevicePropertyTable[] = {
+    { "Name", virtDBusNodeDeviceGetName, NULL },
     { 0 }
 };
 
diff --git a/tests/test_nodedev.py b/tests/test_nodedev.py
index 8ef8e32..cc7199a 100755
--- a/tests/test_nodedev.py
+++ b/tests/test_nodedev.py
@@ -26,6 +26,14 @@ class TestNodeDevice(libvirttest.BaseTestClass):
 
         self.main_loop()
 
+    def test_node_device_properties_type(self):
+        """ Ensure correct return type for NodeDevice properties
+        """
+        test_node_device_path = self.node_device_create()
+        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)
+
 
 if __name__ == '__main__':
     libvirttest.run()
-- 
2.15.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux