]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
network: move driver state struct into bridge_driver_conf.h
authorLaine Stump <laine@redhat.com>
Sun, 13 Mar 2022 18:21:02 +0000 (14:21 -0400)
committerLaine Stump <laine@redhat.com>
Wed, 24 Aug 2022 16:22:47 +0000 (12:22 -0400)
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 <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/network/bridge_driver.c
src/network/bridge_driver_conf.c [new file with mode: 0644]
src/network/bridge_driver_conf.h [new file with mode: 0644]
src/network/bridge_driver_platform.h
src/network/meson.build

index 733abaa7193298a3f6b6f8fb2cdeae83fb5d624f..3c36a66ec70eb2c53fd9ae9daffcfdec4eb7baa1 100644 (file)
@@ -95,31 +95,6 @@ networkGetDriver(void)
 }
 
 
-static dnsmasqCaps *
-networkGetDnsmasqCaps(virNetworkDriverState *driver)
-{
-    VIR_LOCK_GUARD lock = virLockGuardLock(&driver->lock);
-    return virObjectRef(driver->dnsmasqCaps);
-}
-
-
-static int
-networkDnsmasqCapsRefresh(virNetworkDriverState *driver)
-{
-    dnsmasqCaps *caps;
-
-    if (!(caps = dnsmasqCapsNewFromBinary()))
-        return -1;
-
-    VIR_WITH_MUTEX_LOCK_GUARD(&driver->lock) {
-        virObjectUnref(driver->dnsmasqCaps);
-        driver->dnsmasqCaps = caps;
-    }
-
-    return 0;
-}
-
-
 extern virXMLNamespace networkDnsmasqXMLNamespace;
 
 typedef struct _networkDnsmasqXmlNsDef networkDnsmasqXmlNsDef;
diff --git a/src/network/bridge_driver_conf.c b/src/network/bridge_driver_conf.c
new file mode 100644 (file)
index 0000000..b6c059e
--- /dev/null
@@ -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
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/* includes */
+#include <config.h>
+#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 = virLockGuardLock(&driver->lock);
+    return virObjectRef(driver->dnsmasqCaps);
+}
+
+
+int
+networkDnsmasqCapsRefresh(virNetworkDriverState *driver)
+{
+    dnsmasqCaps *caps;
+
+    if (!(caps = dnsmasqCapsNewFromBinary()))
+        return -1;
+
+    VIR_WITH_MUTEX_LOCK_GUARD(&driver->lock) {
+        virObjectUnref(driver->dnsmasqCaps);
+        driver->dnsmasqCaps = caps;
+    }
+
+    return 0;
+}
diff --git a/src/network/bridge_driver_conf.h b/src/network/bridge_driver_conf.h
new file mode 100644 (file)
index 0000000..f4307bb
--- /dev/null
@@ -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
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#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 root */
+    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);
index de7cbc1195e52c151264644420feb8abc55b7f6b..b720d343beb88cca1d9e56ef2ad2f6994b071afb 100644 (file)
 
 #pragma once
 
-#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"
 
-/* Main driver state */
-struct _virNetworkDriverState {
-    virMutex lock;
+void networkPreReloadFirewallRules(virNetworkDriverState *driver,
+                                   bool startup,
+                                   bool force);
 
-    /* Read-only */
-    bool privileged;
-
-    /* pid file FD, ensures two copies of the driver can't use the same root */
-    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 startup, bool force);
 void networkPostReloadFirewallRules(bool startup);
 
 int networkCheckRouteCollision(virNetworkDef *def);
index b5eff0c3ab6bcb9b47c0d5c713860f9823fe91d3..395074a0a0a6c43a30359b6853b95966957f9596 100644 (file)
@@ -1,5 +1,6 @@
 network_driver_sources = [
   'bridge_driver.c',
+  'bridge_driver_conf.c',
   'bridge_driver_platform.c',
 ]