[libvirt] [dbus PATCH 04/15] Implement Active property for Interface Interface

Anya Harter aharter at redhat.com
Fri Jul 6 21:36:44 UTC 2018


Signed-off-by: Anya Harter <aharter at redhat.com>
---
 data/org.libvirt.Interface.xml |  4 ++++
 src/interface.c                | 22 ++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml
index e6d9f2a..f50bc37 100644
--- a/data/org.libvirt.Interface.xml
+++ b/data/org.libvirt.Interface.xml
@@ -13,5 +13,9 @@
         value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetMACString"/>
       <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
     </property>
+    <property name="Active" type="b" access="read">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceIsActive"/>
+    </property>
   </interface>
 </node>
diff --git a/src/interface.c b/src/interface.c
index 2b62304..b73e116 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -66,7 +66,29 @@ virtDBusInterfaceGetMACString(const gchar *objectPath,
     *value = g_variant_new("s", mac);
 }
 
+static void
+virtDBusInterfaceGetActive(const gchar *objectPath,
+                           gpointer userData,
+                           GVariant **value,
+                           GError **error)
+{
+    virtDBusConnect *connect = userData;
+    g_autoptr(virInterface) interface = NULL;
+    gint active;
+
+    interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error);
+    if (!interface)
+        return;
+
+    active = virInterfaceIsActive(interface);
+    if (active < 0)
+        return virtDBusUtilSetLastVirtError(error);
+
+    *value = g_variant_new("b", !!active);
+}
+
 static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = {
+    { "Active", virtDBusInterfaceGetActive, NULL },
     { "MACString", virtDBusInterfaceGetMACString, NULL },
     { "Name", virtDBusInterfaceGetName, NULL },
     { 0 }
-- 
2.17.1




More information about the libvir-list mailing list