libvirt/src/network/bridge_driver_conf.h
Laine Stump b7b949d30c network: create separate config object for virNetworkDriverState
Similar to the other drivers, virNetworkDriverState now has a
virObject-derived object called virNetworkDriverConfig which is used
for config items.

As a starting point, the directory paths used by the network driver
are moved there (again, parallelling what is done for other drivers).

Using items in virNetworkDriverConfig is (yes, again) similar to using
items in the other drivers' config - anything in the config object is
immutable (once initialized), so the state object only needs to be
locked while getting a reference to the config object, and then the
members of the config object can be safely used until the config
object is unrefed.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-24 12:22:47 -04:00

83 lines
2.3 KiB
C

/*
* 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
* <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "internal.h"
#include "virthread.h"
#include "virdnsmasq.h"
#include "virnetworkobj.h"
#include "object_event.h"
typedef struct _virNetworkDriverConfig virNetworkDriverConfig;
struct _virNetworkDriverConfig {
virObject parent;
/* Immutable pointers, Immutable objects */
char *networkConfigDir;
char *networkAutostartDir;
char *stateDir;
char *pidDir;
char *dnsmasqStateDir;
};
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNetworkDriverConfig, virObjectUnref);
/* Main driver state */
typedef struct _virNetworkDriverState virNetworkDriverState;
struct _virNetworkDriverState {
virMutex lock;
/* Read-only */
bool privileged;
/* Require lock to get reference on 'config',
* then lockless thereafter */
virNetworkDriverConfig *config;
/* pid file FD, ensures two copies of the driver can't use the same root */
int lockFD;
/* Immutable pointer, self-locking APIs */
virNetworkObjList *networks;
/* Require lock to get a reference on the object,
* lockless access thereafter
*/
dnsmasqCaps *dnsmasqCaps;
/* Immutable pointer, self-locking APIs */
virObjectEventState *networkEventState;
virNetworkXMLOption *xmlopt;
};
virNetworkDriverConfig *
virNetworkDriverConfigNew(bool privileged);
virNetworkDriverConfig *
virNetworkDriverGetConfig(virNetworkDriverState *driver);
dnsmasqCaps *
networkGetDnsmasqCaps(virNetworkDriverState *driver);
int
networkDnsmasqCapsRefresh(virNetworkDriverState *driver);