From nobody Fri May 16 03:05:49 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 150108163786136.60085846987681; Wed, 26 Jul 2017 08:07:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DD20AC0B2C5E; Wed, 26 Jul 2017 15:07:10 +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 503F57AF4D; Wed, 26 Jul 2017 15:07:10 +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 50C9114B29; Wed, 26 Jul 2017 15:06:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6QF6dTw028665 for ; Wed, 26 Jul 2017 11:06:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 078626A32B; Wed, 26 Jul 2017 15:06:39 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-46.phx2.redhat.com [10.3.117.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0692A69524 for ; Wed, 26 Jul 2017 15:06:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DD20AC0B2C5E Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Wed, 26 Jul 2017 11:05:30 -0400 Message-Id: <20170726150537.4619-14-jferlan@redhat.com> In-Reply-To: <20170726150537.4619-1-jferlan@redhat.com> References: <20170726150537.4619-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 13/20] network: Introduce virNetworkObjIsPersistent 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 26 Jul 2017 15:07:11 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In preparation to privatize the virNetworkObj - create an accessor function to get the current @persistent value. Also change the value to a bool rath= er than an unsigned int (since that's how it's generated anyway). Signed-off-by: John Ferlan --- src/conf/virnetworkobj.c | 7 +++++++ src/conf/virnetworkobj.h | 5 ++++- src/libvirt_private.syms | 1 + src/network/bridge_driver.c | 9 +++++---- src/test/test_driver.c | 4 ++-- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index a195494..37b76e5 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -144,6 +144,13 @@ virNetworkObjSetActive(virNetworkObjPtr obj, } =20 =20 +bool +virNetworkObjIsPersistent(virNetworkObjPtr obj) +{ + return obj->persistent; +} + + int virNetworkObjGetAutostart(virNetworkObjPtr obj) { diff --git a/src/conf/virnetworkobj.h b/src/conf/virnetworkobj.h index 8b778c8..96f9eff 100644 --- a/src/conf/virnetworkobj.h +++ b/src/conf/virnetworkobj.h @@ -33,7 +33,7 @@ struct _virNetworkObj { pid_t radvdPid; bool active; int autostart; - unsigned int persistent : 1; + bool persistent; =20 virNetworkDefPtr def; /* The current definition */ virNetworkDefPtr newDef; /* New definition to activate at shutdown */ @@ -67,6 +67,9 @@ void virNetworkObjSetActive(virNetworkObjPtr obj, bool active); =20 +bool +virNetworkObjIsPersistent(virNetworkObjPtr obj); + int virNetworkObjGetAutostart(virNetworkObjPtr obj); =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8796258..2497af0 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -954,6 +954,7 @@ virNetworkObjGetNewDef; virNetworkObjGetPersistentDef; virNetworkObjGetRadvdPid; virNetworkObjIsActive; +virNetworkObjIsPersistent; virNetworkObjListExport; virNetworkObjListForEach; virNetworkObjListGetNames; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index f423c82..2433e4f 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -3099,7 +3099,7 @@ networkIsPersistent(virNetworkPtr net) if (virNetworkIsPersistentEnsureACL(net->conn, virNetworkObjGetDef(obj= )) < 0) goto cleanup; =20 - ret =3D obj->persistent; + ret =3D virNetworkObjIsPersistent(obj); =20 cleanup: virNetworkObjEndAPI(&obj); @@ -3597,7 +3597,7 @@ networkUndefine(virNetworkPtr net) if (virNetworkObjIsActive(obj)) active =3D true; =20 - if (!obj->persistent) { + if (!virNetworkObjIsPersistent(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("can't undefine transient network")); goto cleanup; @@ -3875,7 +3875,8 @@ networkDestroy(virNetworkPtr net) VIR_NETWORK_EVENT_STOPPED, 0); =20 - if (!obj->persistent && networkRemoveInactive(driver, obj) < 0) { + if (!virNetworkObjIsPersistent(obj) && + networkRemoveInactive(driver, obj) < 0) { ret =3D -1; goto cleanup; } @@ -3990,7 +3991,7 @@ networkSetAutostart(virNetworkPtr net, if (virNetworkSetAutostartEnsureACL(net->conn, def) < 0) goto cleanup; =20 - if (!obj->persistent) { + if (!virNetworkObjIsPersistent(obj)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("cannot set autostart for transient network= ")); goto cleanup; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 698488e..e306f1e 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -3377,7 +3377,7 @@ testNetworkIsPersistent(virNetworkPtr net) if (!(obj =3D testNetworkObjFindByUUID(privconn, net->uuid))) goto cleanup; =20 - ret =3D obj->persistent; + ret =3D virNetworkObjIsPersistent(obj); =20 cleanup: virNetworkObjEndAPI(&obj); @@ -3576,7 +3576,7 @@ testNetworkDestroy(virNetworkPtr net) event =3D virNetworkEventLifecycleNew(def->name, def->uuid, VIR_NETWORK_EVENT_STOPPED, 0); - if (!obj->persistent) + if (!virNetworkObjIsPersistent(obj)) virNetworkObjRemoveInactive(privconn->networks, obj); =20 ret =3D 0; --=20 2.9.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list