[dbus PATCH 08/10] Implement Destroy method 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         | 13 +++++++++++++
 3 files changed, 38 insertions(+)

diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml
index d144c5d..c143f08 100644
--- a/data/org.libvirt.Network.xml
+++ b/data/org.libvirt.Network.xml
@@ -19,5 +19,9 @@
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetUUIDString"/>
     </property>
+    <method name="Destroy">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-network.html#virDomainDestroy"/>
+    </method>
   </interface>
 </node>
diff --git a/src/network.c b/src/network.c
index 90c2d9c..d46e327 100644
--- a/src/network.c
+++ b/src/network.c
@@ -107,6 +107,26 @@ virtDBusNetworkGetUUID(const gchar *objectPath,
     *value = g_variant_new("s", uuid);
 }
 
+static void
+virtDBusNetworkDestroy(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 (virNetworkDestroy(network) < 0)
+        virtDBusUtilSetLastVirtError(error);
+}
+
 static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] = {
     { "Autostart", virtDBusNetworkGetAutostart, NULL },
     { "BridgeName", virtDBusNetworkGetBridgeName, NULL },
@@ -116,6 +136,7 @@ static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] = {
 };
 
 static virtDBusGDBusMethodTable virtDBusNetworkMethodTable[] = {
+    { "Destroy", virtDBusNetworkDestroy },
     { 0 }
 };
 
diff --git a/test/test_network.py b/test/test_network.py
index e753f7f..825b52f 100755
--- a/test/test_network.py
+++ b/test/test_network.py
@@ -17,6 +17,19 @@ class TestNetwork(libvirttest.BaseTestClass):
         assert isinstance(props['Name'], dbus.String)
         assert isinstance(props['UUID'], dbus.String)
 
+    def test_network_destroy(self):
+        def network_stopped(path, _event):
+            assert isinstance(path, dbus.ObjectPath)
+            self.loop.quit()
+
+        self.connect.connect_to_signal('NetworkEvent', network_stopped, arg1='Stopped')
+
+        _, test_network = self.test_network()
+        interface_obj = dbus.Interface(test_network, 'org.libvirt.Network')
+        interface_obj.Destroy()
+
+        self.main_loop()
+
 
 if __name__ == '__main__':
     libvirttest.run()
-- 
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