Signed-off-by: Katerina Koukiou <kkouk...@redhat.com> --- data/org.libvirt.Network.xml | 4 ++++ src/network.c | 22 ++++++++++++++++++++++ test/test_network.py | 1 + 3 files changed, 27 insertions(+)
diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml index 456217a..cadf0a8 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="Active" type="b" access="read"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkIsActive"/> + </property> <property name="Autostart" type="b" access="read"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetAutostart"/> diff --git a/src/network.c b/src/network.c index bd9e86a..7f0091a 100644 --- a/src/network.c +++ b/src/network.c @@ -24,6 +24,27 @@ virtDBusNetworkGetVirNetwork(virtDBusConnect *connect, return network; } +static void +virtDBusNetworkGetActive(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autoptr(virNetwork) network = NULL; + gint active; + + network = virtDBusNetworkGetVirNetwork(connect, objectPath, error); + if (!network) + return; + + active = virNetworkIsActive(network); + if (active < 0) + return virtDBusUtilSetLastVirtError(error); + + *value = g_variant_new("b", !!active); +} + static void virtDBusNetworkGetAutostart(const gchar *objectPath, gpointer userData, @@ -195,6 +216,7 @@ virtDBusNetworkUndefine(GVariant *inArgs G_GNUC_UNUSED, } static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] = { + { "Active", virtDBusNetworkGetActive, NULL }, { "Autostart", virtDBusNetworkGetAutostart, NULL }, { "BridgeName", virtDBusNetworkGetBridgeName, NULL }, { "Name", virtDBusNetworkGetName, NULL }, diff --git a/test/test_network.py b/test/test_network.py index 397fc0c..4180cc8 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['Active'], dbus.Boolean) 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@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list