From nobody Thu Dec 18 13:44:10 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522935063435284.99789352617245; Thu, 5 Apr 2018 06:31:03 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8E99826AC52; Thu, 5 Apr 2018 13:31:01 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 47BDD60927; Thu, 5 Apr 2018 13:31:01 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D725B18033EB; Thu, 5 Apr 2018 13:31:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w35DTlel009526 for ; Thu, 5 Apr 2018 09:29:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3AA5DAB3F5; Thu, 5 Apr 2018 13:29:47 +0000 (UTC) Received: from katerina.brq.redhat.com (ovpn-204-29.brq.redhat.com [10.40.204.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 782D09C073 for ; Thu, 5 Apr 2018 13:29:46 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 5 Apr 2018 15:29:32 +0200 Message-Id: <20180405132934.1420-9-kkoukiou@redhat.com> In-Reply-To: <20180405132934.1420-1-kkoukiou@redhat.com> References: <20180405132934.1420-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 08/10] Implement Destroy method for Network Interface. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 05 Apr 2018 13:31:02 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- 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 @@ + + + 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 =3D g_variant_new("s", uuid); } =20 +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 =3D userData; + g_autoptr(virNetwork) network =3D NULL; + + network =3D virtDBusNetworkGetVirNetwork(connect, objectPath, error); + if (!network) + return; + + if (virNetworkDestroy(network) < 0) + virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] =3D { { "Autostart", virtDBusNetworkGetAutostart, NULL }, { "BridgeName", virtDBusNetworkGetBridgeName, NULL }, @@ -116,6 +136,7 @@ static virtDBusGDBusPropertyTable virtDBusNetworkProper= tyTable[] =3D { }; =20 static virtDBusGDBusMethodTable virtDBusNetworkMethodTable[] =3D { + { "Destroy", virtDBusNetworkDestroy }, { 0 } }; =20 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) =20 + 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, ar= g1=3D'Stopped') + + _, test_network =3D self.test_network() + interface_obj =3D dbus.Interface(test_network, 'org.libvirt.Networ= k') + interface_obj.Destroy() + + self.main_loop() + =20 if __name__ =3D=3D '__main__': libvirttest.run() --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list