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 1522935071048994.3048324686251; Thu, 5 Apr 2018 06:31:11 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BE8753ADBB; Thu, 5 Apr 2018 13:31:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 820CC7D908; Thu, 5 Apr 2018 13:31:09 +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 447264CAA6; Thu, 5 Apr 2018 13:31:09 +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 w35DTn7c009549 for ; Thu, 5 Apr 2018 09:29:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 34B9FAB3F3; Thu, 5 Apr 2018 13:29:49 +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 8DD6C9C073 for ; Thu, 5 Apr 2018 13:29:48 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 5 Apr 2018 15:29:34 +0200 Message-Id: <20180405132934.1420-11-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 10/10] Implement Create 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 05 Apr 2018 13:31:10 +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 | 14 ++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml index 8a8eef7..0505e7a 100644 --- a/data/org.libvirt.Network.xml +++ b/data/org.libvirt.Network.xml @@ -19,6 +19,10 @@ + + + diff --git a/src/network.c b/src/network.c index c911880..1d749e4 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 +virtDBusNetworkCreate(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 (virNetworkCreate(network) < 0) + virtDBusUtilSetLastVirtError(error); +} + static void virtDBusNetworkDestroy(GVariant *inArgs G_GNUC_UNUSED, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -156,6 +176,7 @@ static virtDBusGDBusPropertyTable virtDBusNetworkProper= tyTable[] =3D { }; =20 static virtDBusGDBusMethodTable virtDBusNetworkMethodTable[] =3D { + { "Create", virtDBusNetworkCreate }, { "Destroy", virtDBusNetworkDestroy }, { "Undefine", virtDBusNetworkUndefine }, { 0 } diff --git a/test/test_network.py b/test/test_network.py index f61e73d..17d4555 100755 --- a/test/test_network.py +++ b/test/test_network.py @@ -17,6 +17,20 @@ class TestNetwork(libvirttest.BaseTestClass): assert isinstance(props['Name'], dbus.String) assert isinstance(props['UUID'], dbus.String) =20 + def test_network_create(self): + def domain_started(path, _event): + assert isinstance(path, dbus.ObjectPath) + self.loop.quit() + + self.connect.connect_to_signal('NetworkEvent', domain_started, arg= 1=3D'Started') + + _,test_network =3D self.test_network() + interface_obj =3D dbus.Interface(test_network, 'org.libvirt.Networ= k') + interface_obj.Destroy() + interface_obj.Create() + + self.main_loop() + def test_network_destroy(self): def network_stopped(path, _event): assert isinstance(path, dbus.ObjectPath) --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list