From nobody Sat Dec 21 13:57:43 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 1725374352849161.38083779709928; Tue, 3 Sep 2024 07:39:12 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C560612A0; Tue, 3 Sep 2024 10:39:11 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 96FA51472; Tue, 3 Sep 2024 10:36:55 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 37F33D8F; Tue, 3 Sep 2024 10:36:37 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 C38E2BD7 for ; Tue, 3 Sep 2024 10:36:36 -0400 (EDT) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-370-tOmVwBHwO5Gucjf_hQRu9A-1; Tue, 03 Sep 2024 10:36:35 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42bbe70c1c2so36996735e9.1 for ; Tue, 03 Sep 2024 07:36:34 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42bacaac810sm193253495e9.33.2024.09.03.07.36.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 07:36:32 -0700 (PDT) Received: from wheatley.brq.redhat.com (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 6ED071FC90C1 for ; Tue, 03 Sep 2024 16:36:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 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,T_SCC_BODY_TEXT_LINE 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=1725374196; 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=54FdrQkbmxI35/uwgmqhM3SeRSA5EmNSL49rhcT/lQk=; b=RSQs/WS2lLoEnp2Lby4h3iyXQLoeJbFx9PJi9dK98/Vis6rYGvl3Cpb8X270X24lXjdefQ YBVcQBtxnAs6a7JN0XFyVvDXD3SoXX1yxn229SXelW+8vTl4weZM4S2gFDeKOuc0Q73o6J wUIEAjdlGw/wlAoSCqZJh8PtZJH4/Dg= X-MC-Unique: tOmVwBHwO5Gucjf_hQRu9A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725374194; x=1725978994; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=54FdrQkbmxI35/uwgmqhM3SeRSA5EmNSL49rhcT/lQk=; b=fv0RCBb11WgfTSyIWfMgNKBXKoHUjsVvaXfnFaQXLzYiz1bF2C4cLfOk5kgF2PR4qq XE9jIbgxfrk+IVAh34SugUlzJlNPH14zBLPPrWcUwsg9cBhWGjqdI+rHPRYx2EaYsP1Q jBKqt9GXYx8gqQx/JrYwpqOTRdnIVDEK7cNWgYpkpl+pNKuO0bqzsMh2ptp0V4+MOj1g 2qKUv32kmZCunnbRwRVuiWaafx396T/o263afjKw2yj2Xf8sE65syR4quCQYCrzxFX3T Fd6ZwAB/SrhPbu3b6srb7wUzONzpqwq7uJuNe8h4oEodUQClEkY/gRR5TA/448zctCeS WHYg== X-Gm-Message-State: AOJu0Yw82DzTZj/a+ML0yXwLjQnlaG8vZf3nbhcw/vpVHA1Q9m+AEL1v BSXmEUuXQkNNEISMmtaUuneNYu9Dbew7QN9epsSo4FA0OdgyhJaaXRBQgG5UnBuMAQl8vpWwXLX kdBdhJ4LxWFjBFnN1/ZvWg6V8/dMulLu2cLY+Wtqp6B7h4CEoO2UrVqkjaYpWLpXBauDCwfTU0b KNS8LGvd8thgCIrrIoOXnyIoq5NsrD+deLQ2GslPo= X-Received: by 2002:a05:600c:3145:b0:426:593c:9361 with SMTP id 5b1f17b1804b1-42bb27a9c67mr120466165e9.26.1725374193803; Tue, 03 Sep 2024 07:36:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEe69DRNyNmPkfAnetTeFsZsYxKgw1MVpjvyPaQlxEK5qXaS3bGnXURsTpLQCMdR5FXhz6MSg== X-Received: by 2002:a05:600c:3145:b0:426:593c:9361 with SMTP id 5b1f17b1804b1-42bb27a9c67mr120465975e9.26.1725374193210; Tue, 03 Sep 2024 07:36:33 -0700 (PDT) From: Martin Kletzander To: devel@lists.libvirt.org Subject: [PATCH 8/8] network: Clean up after disappeared transient inactive networks Date: Tue, 3 Sep 2024 16:36:27 +0200 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: MPZHKMCKNXEGCQQWKQTZ5UOSVXLOXVGK X-Message-ID-Hash: MPZHKMCKNXEGCQQWKQTZ5UOSVXLOXVGK X-MailFrom: mkletzan@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: 1725374354497116600 Content-Type: text/plain; charset="utf-8"; x-default="true" If a network disappeared the daemon should not only remove it from the list of networks, but also do a proper cleanup. Signed-off-by: Martin Kletzander --- src/network/bridge_driver.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 0e8057e24aed..0ba62d986ff4 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -533,6 +533,23 @@ networkUpdateState(virNetworkObj *obj, } =20 =20 +static int +networkCleanupTransientInactive(virNetworkObj *obj, + void *opaque) +{ + virNetworkDriverState *driver =3D opaque; + + if (!virNetworkObjIsActive(obj) && + !virNetworkObjIsPersistent(obj)) { + /* We can only do a cleanup here so that this can be called from an + * iterator over the networks */ + networkCleanupInactive(driver, obj); + } + + return 0; +} + + static int networkAutostartConfig(virNetworkObj *obj, void *opaque) @@ -659,6 +676,11 @@ networkStateInitialize(bool privileged, virNetworkObjListForEach(network_driver->networks, networkUpdateState, network_driver); + /* Before removing inactive transient networks from the list make sure= we + * clean up after them as well */ + virNetworkObjListForEach(network_driver->networks, + networkCleanupTransientInactive, + network_driver); virNetworkObjListPrune(network_driver->networks, VIR_CONNECT_LIST_NETWORKS_INACTIVE | VIR_CONNECT_LIST_NETWORKS_TRANSIENT); --=20 2.46.0