From nobody Mon Feb 9 20:10:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661175136; cv=none; d=zohomail.com; s=zohoarc; b=bq1pOFImfJtMx8MLhDBBb9+HtFEAzEYsLLk19oVd0URrTuOTIvaKO5nB9U4bu96yonCjKGm3aElukKL6NaSoSdpuJ9N8SCcViePHpaviFiTS9FtNWi6tVBjXPzWyycNNuTbyTWVR6V5sOR/iJK75rVU1clyoi5u3AzZFiyLgRsI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661175136; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OTJBlkBv3HC1Q8X7srO+XF3EBl9eOJvS4z3LPKEWpXw=; b=eGiXO/+3FTQSWHP/JvkEgeSlYCmN3oR/A9bQhX+akPnUzygicmT3uracOut6lmn6p040SoHWXkVW+oE4veBcpy8LS9V6o//6jLho4ZbgDZfvBw/BZGFujgbYGuqBuLRrh4PkK8yihAgtQajdw+t2c6Gj341nJBETJfJdJdbOFF0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1661175136678241.93794278062228; Mon, 22 Aug 2022 06:32:16 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-356-RRJsfVqwO3SBChygciOoMg-1; Mon, 22 Aug 2022 09:32:14 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 55EC2803520; Mon, 22 Aug 2022 13:32:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FE41492CA4; Mon, 22 Aug 2022 13:32:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B7A001946A4B; Mon, 22 Aug 2022 13:32:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BFA111946A5F for ; Mon, 22 Aug 2022 13:31:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6507240CFD0D; Mon, 22 Aug 2022 13:31:52 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.2.16.254]) by smtp.corp.redhat.com (Postfix) with ESMTP id 500F140CFD0E for ; Mon, 22 Aug 2022 13:31:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661175135; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=OTJBlkBv3HC1Q8X7srO+XF3EBl9eOJvS4z3LPKEWpXw=; b=Mh6NY8N3a7l/hNXoP7TLufPbaGVMD2q3nt7vw9FBtkF3HrB6UQxOuPc9cnJuAJS2G0SnPa HUcPf3d2U8N8UE9LM9RVAGlc6m2cSkBaHTheh2nxIdLHYH3Qa9elV4FochFZMbrD/opC8a umDkHi2U3A+A+QEJVvgas3PHFcA7G78= X-MC-Unique: RRJsfVqwO3SBChygciOoMg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 11/16] network: move driver state struct into bridge_driver_conf.h Date: Mon, 22 Aug 2022 09:31:45 -0400 Message-Id: <20220822133150.1098794-12-laine@redhat.com> In-Reply-To: <20220822133150.1098794-1-laine@redhat.com> References: <20220822133150.1098794-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661175137632100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This is more similar to lxc and qemu drivers, where the driver state struct is defined along with a config struct in ${driver}_conf.h Signed-off-by: Laine Stump --- src/network/bridge_driver.c | 25 ----------- src/network/bridge_driver_conf.c | 56 +++++++++++++++++++++++ src/network/bridge_driver_conf.h | 67 ++++++++++++++++++++++++++++ src/network/bridge_driver_platform.h | 43 +++--------------- src/network/meson.build | 1 + 5 files changed, 129 insertions(+), 63 deletions(-) create mode 100644 src/network/bridge_driver_conf.c create mode 100644 src/network/bridge_driver_conf.h diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 733abaa719..3c36a66ec7 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -95,31 +95,6 @@ networkGetDriver(void) } =20 =20 -static dnsmasqCaps * -networkGetDnsmasqCaps(virNetworkDriverState *driver) -{ - VIR_LOCK_GUARD lock =3D virLockGuardLock(&driver->lock); - return virObjectRef(driver->dnsmasqCaps); -} - - -static int -networkDnsmasqCapsRefresh(virNetworkDriverState *driver) -{ - dnsmasqCaps *caps; - - if (!(caps =3D dnsmasqCapsNewFromBinary())) - return -1; - - VIR_WITH_MUTEX_LOCK_GUARD(&driver->lock) { - virObjectUnref(driver->dnsmasqCaps); - driver->dnsmasqCaps =3D caps; - } - - return 0; -} - - extern virXMLNamespace networkDnsmasqXMLNamespace; =20 typedef struct _networkDnsmasqXmlNsDef networkDnsmasqXmlNsDef; diff --git a/src/network/bridge_driver_conf.c b/src/network/bridge_driver_c= onf.c new file mode 100644 index 0000000000..b6c059e1e9 --- /dev/null +++ b/src/network/bridge_driver_conf.c @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2022 Red Hat, Inc. + * + * bridge_driver__conf.c: network.conf config file inspection + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + */ + +/* includes */ +#include +#include "virerror.h" +#include "datatypes.h" +#include "virlog.h" +#include "bridge_driver_conf.h" + +#define VIR_FROM_THIS VIR_FROM_NETWORK + +VIR_LOG_INIT("network.bridge_driver"); + + +dnsmasqCaps * +networkGetDnsmasqCaps(virNetworkDriverState *driver) +{ + VIR_LOCK_GUARD lock =3D virLockGuardLock(&driver->lock); + return virObjectRef(driver->dnsmasqCaps); +} + + +int +networkDnsmasqCapsRefresh(virNetworkDriverState *driver) +{ + dnsmasqCaps *caps; + + if (!(caps =3D dnsmasqCapsNewFromBinary())) + return -1; + + VIR_WITH_MUTEX_LOCK_GUARD(&driver->lock) { + virObjectUnref(driver->dnsmasqCaps); + driver->dnsmasqCaps =3D caps; + } + + return 0; +} diff --git a/src/network/bridge_driver_conf.h b/src/network/bridge_driver_c= onf.h new file mode 100644 index 0000000000..f4307bbdba --- /dev/null +++ b/src/network/bridge_driver_conf.h @@ -0,0 +1,67 @@ +/* + * bridge_driver_conf.h: network bridge driver state and config objects + * + * Copyright (C) 2006-2013 Red Hat, Inc. + * Copyright (C) 2006 Daniel P. Berrange + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#pragma once + +#include "internal.h" +#include "virthread.h" +#include "virdnsmasq.h" +#include "virnetworkobj.h" +#include "object_event.h" + +/* Main driver state */ +struct _virNetworkDriverState { + virMutex lock; + + /* Read-only */ + bool privileged; + + /* pid file FD, ensures two copies of the driver can't use the same ro= ot */ + int lockFD; + + /* Immutable pointer, self-locking APIs */ + virNetworkObjList *networks; + + /* Immutable pointers, Immutable objects */ + char *networkConfigDir; + char *networkAutostartDir; + char *stateDir; + char *pidDir; + char *dnsmasqStateDir; + + /* Require lock to get a reference on the object, + * lockless access thereafter + */ + dnsmasqCaps *dnsmasqCaps; + + /* Immutable pointer, self-locking APIs */ + virObjectEventState *networkEventState; + + virNetworkXMLOption *xmlopt; +}; + +typedef struct _virNetworkDriverState virNetworkDriverState; + +dnsmasqCaps * +networkGetDnsmasqCaps(virNetworkDriverState *driver); + +int +networkDnsmasqCapsRefresh(virNetworkDriverState *driver); diff --git a/src/network/bridge_driver_platform.h b/src/network/bridge_driv= er_platform.h index de7cbc1195..b720d343be 100644 --- a/src/network/bridge_driver_platform.h +++ b/src/network/bridge_driver_platform.h @@ -21,46 +21,13 @@ =20 #pragma once =20 -#include "internal.h" -#include "virthread.h" -#include "virdnsmasq.h" -#include "virnetworkobj.h" -#include "object_event.h" +#include "network_conf.h" +#include "bridge_driver_conf.h" =20 -/* Main driver state */ -struct _virNetworkDriverState { - virMutex lock; +void networkPreReloadFirewallRules(virNetworkDriverState *driver, + bool startup, + bool force); =20 - /* Read-only */ - bool privileged; - - /* pid file FD, ensures two copies of the driver can't use the same ro= ot */ - int lockFD; - - /* Immutable pointer, self-locking APIs */ - virNetworkObjList *networks; - - /* Immutable pointers, Immutable objects */ - char *networkConfigDir; - char *networkAutostartDir; - char *stateDir; - char *pidDir; - char *dnsmasqStateDir; - - /* Require lock to get a reference on the object, - * lockless access thereafter - */ - dnsmasqCaps *dnsmasqCaps; - - /* Immutable pointer, self-locking APIs */ - virObjectEventState *networkEventState; - - virNetworkXMLOption *xmlopt; -}; - -typedef struct _virNetworkDriverState virNetworkDriverState; - -void networkPreReloadFirewallRules(virNetworkDriverState *driver, bool sta= rtup, bool force); void networkPostReloadFirewallRules(bool startup); =20 int networkCheckRouteCollision(virNetworkDef *def); diff --git a/src/network/meson.build b/src/network/meson.build index b5eff0c3ab..395074a0a0 100644 --- a/src/network/meson.build +++ b/src/network/meson.build @@ -1,5 +1,6 @@ network_driver_sources =3D [ 'bridge_driver.c', + 'bridge_driver_conf.c', 'bridge_driver_platform.c', ] =20 --=20 2.37.1