From nobody Thu Sep 19 01:52:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1715968799117315.4643772569673; Fri, 17 May 2024 10:59:59 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1AAB6175A; Fri, 17 May 2024 13:59:58 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 3C8771B53; Fri, 17 May 2024 13:31:49 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id EE52E1ABD; Fri, 17 May 2024 13:30:20 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 32DAD1A05 for ; Fri, 17 May 2024 13:30:13 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-427-2iiV1l28OyCRKb1WCMz6qA-1; Fri, 17 May 2024 13:30:11 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 067041C05153 for ; Fri, 17 May 2024 17:30:11 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.16.223]) by smtp.corp.redhat.com (Postfix) with ESMTP id E431340C6EB7 for ; Fri, 17 May 2024 17:30:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715967012; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z1CzP5EAS9lgc9kCJfHTLwFFZjuDxm4jfb5jcg8vGDk=; b=Fti7DWfHSbtYrf0yYiAR60k16srnPcNV6t0yVh0XMOdV+Wd1xYGHAvtVKBBBHP3I9SFByA EzM2BK1dUWhQdDSF/Ozoi2fMkXquKayuQt3THYiZ3MfevYCOexxg5zn/ep51WBjaKnqVqW LL8PGHebA2yXziezSuuy+MlFkV1aVpY= X-MC-Unique: 2iiV1l28OyCRKb1WCMz6qA-1 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH v5 22/30] network: save network status when firewall rules are reloaded Date: Fri, 17 May 2024 13:29:59 -0400 Message-ID: <20240517173007.8125-23-laine@redhat.com> In-Reply-To: <20240517173007.8125-1-laine@redhat.com> References: <20240517173007.8125-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: W2YFH4W6HV25QM57VLHPEFPAD63DZRUO X-Message-ID-Hash: W2YFH4W6HV25QM57VLHPEFPAD63DZRUO X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1715968801009100001 Content-Type: text/plain; charset="utf-8" In the case that a new version of libvirt is started that uses different rules to build the network firewall, we need to re-save the status so that when the network is destroyed (or the *next* time libvirt is restarted and wants to remove/re-add the firewall), it will have the proper information to perform the firewall removal. Signed-off-by: Laine Stump Reviewed-by: Daniel P. Berrang=C3=A9 --- src/conf/virnetworkobj.c | 1 + src/network/bridge_driver.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index f5db4c5804..19305798cb 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -834,6 +834,7 @@ virNetworkObjSaveStatus(const char *statusDir, int flags =3D 0; g_autofree char *xml =3D NULL; =20 + VIR_DEBUG("Writing network status to disk"); if (!(xml =3D virNetworkObjFormat(obj, xmlopt, flags))) return -1; =20 diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 1b4c5aedf2..53a896feb9 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -1686,6 +1686,7 @@ networkReloadFirewallRulesHelper(virNetworkObj *obj, VIR_LOCK_GUARD lock =3D virObjectLockGuard(obj); virNetworkDef *def =3D virNetworkObjGetDef(obj); virFirewall *fwRemoval =3D NULL; + bool saveStatus =3D false; =20 if (virNetworkObjIsActive(obj)) { switch ((virNetworkForwardType) def->forward.type) { @@ -1700,6 +1701,7 @@ networkReloadFirewallRulesHelper(virNetworkObj *obj, networkRemoveFirewallRules(obj); ignore_value(networkAddFirewallRules(def, cfg->firewallBackend= , &fwRemoval)); virNetworkObjSetFwRemoval(obj, fwRemoval); + saveStatus =3D true; break; =20 case VIR_NETWORK_FORWARD_OPEN: @@ -1717,6 +1719,11 @@ networkReloadFirewallRulesHelper(virNetworkObj *obj, } } =20 + if (saveStatus) { + ignore_value(virNetworkObjSaveStatus(cfg->stateDir, obj, + network_driver->xmlopt)); + } + return 0; } =20 @@ -2366,7 +2373,6 @@ networkStartNetwork(virNetworkDriverState *driver, /* Persist the live configuration now that anything autogenerated * is setup. */ - VIR_DEBUG("Writing network status to disk"); if (virNetworkObjSaveStatus(cfg->stateDir, obj, network_driver->xmlopt) < 0) goto cleanup; --=20 2.45.0