[libvirt] [dbus PATCH 09/10] Implement Undefine method for Network Interface

Katerina Koukiou kkoukiou at redhat.com
Thu Apr 5 13:29:33 UTC 2018


Signed-off-by: Katerina Koukiou <kkoukiou at redhat.com>
---
 data/org.libvirt.Network.xml |  4 ++++
 src/network.c                | 21 +++++++++++++++++++++
 test/test_network.py         | 13 +++++++++++++
 3 files changed, 38 insertions(+)

diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml
index c143f08..8a8eef7 100644
--- a/data/org.libvirt.Network.xml
+++ b/data/org.libvirt.Network.xml
@@ -23,5 +23,9 @@
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-network.html#virDomainDestroy"/>
     </method>
+    <method name="Undefine">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkUndefine"/>
+    </method>
   </interface>
 </node>
diff --git a/src/network.c b/src/network.c
index d46e327..c911880 100644
--- a/src/network.c
+++ b/src/network.c
@@ -127,6 +127,26 @@ virtDBusNetworkDestroy(GVariant *inArgs G_GNUC_UNUSED,
         virtDBusUtilSetLastVirtError(error);
 }
 
+static void
+virtDBusNetworkUndefine(GVariant *inArgs G_GNUC_UNUSED,
+                        GUnixFDList *inFDs G_GNUC_UNUSED,
+                        const gchar *objectPath,
+                        gpointer userData,
+                        GVariant **outArgs G_GNUC_UNUSED,
+                        GUnixFDList **outFDs G_GNUC_UNUSED,
+                        GError **error)
+{
+    virtDBusConnect *connect = userData;
+    g_autoptr(virNetwork) network = NULL;
+
+    network = virtDBusNetworkGetVirNetwork(connect, objectPath, error);
+    if (!network)
+        return;
+
+    if (virNetworkUndefine(network) < 0)
+        virtDBusUtilSetLastVirtError(error);
+}
+
 static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] = {
     { "Autostart", virtDBusNetworkGetAutostart, NULL },
     { "BridgeName", virtDBusNetworkGetBridgeName, NULL },
@@ -137,6 +157,7 @@ static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] = {
 
 static virtDBusGDBusMethodTable virtDBusNetworkMethodTable[] = {
     { "Destroy", virtDBusNetworkDestroy },
+    { "Undefine", virtDBusNetworkUndefine },
     { 0 }
 };
 
diff --git a/test/test_network.py b/test/test_network.py
index 825b52f..f61e73d 100755
--- a/test/test_network.py
+++ b/test/test_network.py
@@ -30,6 +30,19 @@ class TestNetwork(libvirttest.BaseTestClass):
 
         self.main_loop()
 
+    def test_network_undefine(self):
+        def domain_undefined(path, _event):
+            assert isinstance(path, dbus.ObjectPath)
+            self.loop.quit()
+
+        self.connect.connect_to_signal('NetworkEvent', domain_undefined, arg1='Undefined')
+
+        _,test_network = self.test_network()
+        interface_obj = dbus.Interface(test_network, 'org.libvirt.Network')
+        interface_obj.Destroy()
+        interface_obj.Undefine()
+
+        self.main_loop()
 
 if __name__ == '__main__':
     libvirttest.run()
-- 
2.15.0




More information about the libvir-list mailing list