Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Network.xml | 6 ++++++
src/network.c | 28 ++++++++++++++++++++++++++++
test/test_network.py | 5 +++++
3 files changed, 39 insertions(+)
diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml
index 46198fe..456217a 100644
--- a/data/org.libvirt.Network.xml
+++ b/data/org.libvirt.Network.xml
@@ -27,6 +27,12 @@
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkDestroy&q...
</method>
+ <method name="GetXMLDesc">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetXMLDes...
+ <arg name="flags" type="u" direction="in"/>
+ <arg name="xml" type="s" direction="out"/>
+ </method>
<method name="Undefine">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkUndefine&...
diff --git a/src/network.c b/src/network.c
index bb385d3..bd9e86a 100644
--- a/src/network.c
+++ b/src/network.c
@@ -147,6 +147,33 @@ virtDBusNetworkDestroy(GVariant *inArgs G_GNUC_UNUSED,
virtDBusUtilSetLastVirtError(error);
}
+static void
+virtDBusNetworkGetXMLDesc(GVariant *inArgs,
+ GUnixFDList *inFDs G_GNUC_UNUSED,
+ const gchar *objectPath,
+ gpointer userData,
+ GVariant **outArgs,
+ GUnixFDList **outFDs G_GNUC_UNUSED,
+ GError **error)
+{
+ virtDBusConnect *connect = userData;
+ g_autoptr(virNetwork) network = NULL;
+ g_autofree gchar *xml = NULL;
+ guint flags;
+
+ g_variant_get(inArgs, "(u)", &flags);
+
+ network = virtDBusNetworkGetVirNetwork(connect, objectPath, error);
+ if (!network)
+ return;
+
+ xml = virNetworkGetXMLDesc(network, flags);
+ if (!xml)
+ return virtDBusUtilSetLastVirtError(error);
+
+ *outArgs = g_variant_new("(s)", xml);
+}
+
static void
virtDBusNetworkUndefine(GVariant *inArgs G_GNUC_UNUSED,
GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -178,6 +205,7 @@ static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] = {
static virtDBusGDBusMethodTable virtDBusNetworkMethodTable[] = {
{ "Create", virtDBusNetworkCreate },
{ "Destroy", virtDBusNetworkDestroy },
+ { "GetXMLDesc", virtDBusNetworkGetXMLDesc },
{ "Undefine", virtDBusNetworkUndefine },
{ 0 }
};
diff --git a/test/test_network.py b/test/test_network.py
index 8ec54ad..397fc0c 100755
--- a/test/test_network.py
+++ b/test/test_network.py
@@ -44,6 +44,11 @@ class TestNetwork(libvirttest.BaseTestClass):
self.main_loop()
+ def test_network_get_xml_description(self):
+ _,test_network = self.test_network()
+ interface_obj = dbus.Interface(test_network, 'org.libvirt.Network')
+ assert isinstance(interface_obj.GetXMLDesc(0), dbus.String)
+
def test_network_undefine(self):
def domain_undefined(path, _event):
assert isinstance(path, dbus.ObjectPath)
--
2.15.0