[dbus PATCH 02/10] Implement Autostart property for Network Interface

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

 



Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
---
 data/org.libvirt.Network.xml |  4 ++++
 src/network.c                | 21 +++++++++++++++++++++
 test/test_network.py         |  1 +
 3 files changed, 26 insertions(+)

diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml
index 83a6b9e..30b352a 100644
--- a/data/org.libvirt.Network.xml
+++ b/data/org.libvirt.Network.xml
@@ -3,6 +3,10 @@
 
 <node name="/org/libvirt/network">
   <interface name="org.libvirt.Network">
+    <property name="Autostart" type="b" access="read">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetAutostart"/>
+    </property>
     <property name="BridgeName" type="s" access="read">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetBridgeName"/>
diff --git a/src/network.c b/src/network.c
index fab017c..5e48fa7 100644
--- a/src/network.c
+++ b/src/network.c
@@ -24,6 +24,26 @@ virtDBusNetworkGetVirNetwork(virtDBusConnect *connect,
     return network;
 }
 
+static void
+virtDBusNetworkGetAutostart(const gchar *objectPath,
+                            gpointer userData,
+                            GVariant **value,
+                            GError **error)
+{
+    virtDBusConnect *connect = userData;
+    g_autoptr(virNetwork) network = NULL;
+    gint autostart = 0;
+
+    network = virtDBusNetworkGetVirNetwork(connect, objectPath, error);
+    if (!network)
+        return;
+
+    if (virNetworkGetAutostart(network, &autostart) < 0)
+        return virtDBusUtilSetLastVirtError(error);
+
+    *value = g_variant_new("b", !!autostart);
+}
+
 static void
 virtDBusNetworkGetBridgeName(const gchar *objectPath,
                              gpointer userData,
@@ -68,6 +88,7 @@ virtDBusNetworkGetName(const gchar *objectPath,
 }
 
 static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] = {
+    { "Autostart", virtDBusNetworkGetAutostart, NULL },
     { "BridgeName", virtDBusNetworkGetBridgeName, NULL },
     { "Name", virtDBusNetworkGetName, NULL },
     { 0 }
diff --git a/test/test_network.py b/test/test_network.py
index 9f15c2e..1842944 100755
--- a/test/test_network.py
+++ b/test/test_network.py
@@ -12,6 +12,7 @@ class TestNetwork(libvirttest.BaseTestClass):
         """
         _, obj = self.test_network()
         props = obj.GetAll('org.libvirt.Network', dbus_interface=dbus.PROPERTIES_IFACE)
+        assert isinstance(props['Autostart'], dbus.Boolean)
         assert isinstance(props['BridgeName'], dbus.String)
         assert isinstance(props['Name'], dbus.String)
 
-- 
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