Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.Network.xml | 4 ++++ src/network.c | 23 +++++++++++++++++++++++ test/test_network.py | 1 + 3 files changed, 28 insertions(+) diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml index 1215ac3..83a6b9e 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="BridgeName" type="s" access="read"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetBridgeName"/> + </property> <property name="Name" type="s" access="read"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetName"/> diff --git a/src/network.c b/src/network.c index 56cbb41..fab017c 100644 --- a/src/network.c +++ b/src/network.c @@ -24,6 +24,28 @@ virtDBusNetworkGetVirNetwork(virtDBusConnect *connect, return network; } +static void +virtDBusNetworkGetBridgeName(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autoptr(virNetwork) network = NULL; + const gchar *bridge; + + network = virtDBusNetworkGetVirNetwork(connect, objectPath, error); + if (!network) + return; + + bridge = virNetworkGetBridgeName(network); + + if (!bridge) + return virtDBusUtilSetLastVirtError(error); + + *value = g_variant_new("s", bridge); +} + static void virtDBusNetworkGetName(const gchar *objectPath, gpointer userData, @@ -46,6 +68,7 @@ virtDBusNetworkGetName(const gchar *objectPath, } static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] = { + { "BridgeName", virtDBusNetworkGetBridgeName, NULL }, { "Name", virtDBusNetworkGetName, NULL }, { 0 } }; diff --git a/test/test_network.py b/test/test_network.py index 97ab0aa..9f15c2e 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['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