Move networkMacMgrFileName into src/util/virmacmap.c and rename to
virMacMapFileName. We're about to move some more MacMgr processing
files into virnetworkobj and it doesn't make sense to have this helper
in the driver or in virnetworkobj.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
NB: From review - splitting patch 5 into 3 parts. This is just the
dealing with the file name patch.
src/libvirt_private.syms | 1 +
src/network/bridge_driver.c | 24 +++++++-----------------
src/util/virmacmap.c | 12 ++++++++++++
src/util/virmacmap.h | 4 ++++
4 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index d984176..6f4667f 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2057,6 +2057,7 @@ virMacAddrSetRaw;
# util/virmacmap.h
virMacMapAdd;
virMacMapDumpStr;
+virMacMapFileName;
virMacMapLookup;
virMacMapNew;
virMacMapRemove;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index fd0e6ca..de2e83c 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -322,18 +322,6 @@ networkRadvdConfigFileName(virNetworkDriverStatePtr driver,
}
-static char *
-networkMacMgrFileName(virNetworkDriverStatePtr driver,
- const char *bridge)
-{
- char *filename;
-
- ignore_value(virAsprintf(&filename, "%s/%s.macs",
- driver->dnsmasqStateDir, bridge));
- return filename;
-}
-
-
/* do needed cleanup steps and remove the network from the list */
static int
networkRemoveInactive(virNetworkDriverStatePtr driver,
@@ -375,7 +363,7 @@ networkRemoveInactive(virNetworkDriverStatePtr driver,
if (!(statusfile = virNetworkConfigFile(driver->stateDir, def->name)))
goto cleanup;
- if (!(macMapFile = networkMacMgrFileName(driver, def->bridge)))
+ if (!(macMapFile = virMacMapFileName(driver->dnsmasqStateDir, def->bridge)))
goto cleanup;
/* dnsmasq */
@@ -427,7 +415,7 @@ networkMacMgrAdd(virNetworkDriverStatePtr driver,
virMacAddrFormat(mac, macStr);
- if (!(file = networkMacMgrFileName(driver, obj->def->bridge)))
+ if (!(file = virMacMapFileName(driver->dnsmasqStateDir, obj->def->bridge)))
goto cleanup;
if (virMacMapAdd(obj->macmap, domain, macStr) < 0)
@@ -458,7 +446,7 @@ networkMacMgrDel(virNetworkDriverStatePtr driver,
virMacAddrFormat(mac, macStr);
- if (!(file = networkMacMgrFileName(driver, obj->def->bridge)))
+ if (!(file = virMacMapFileName(driver->dnsmasqStateDir, obj->def->bridge)))
goto cleanup;
if (virMacMapRemove(obj->macmap, domain, macStr) < 0)
@@ -523,7 +511,8 @@ networkUpdateState(virNetworkObjPtr obj,
if (!(obj->def->bridge && virNetDevExists(obj->def->bridge)
== 1))
obj->active = 0;
- if (!(macMapFile = networkMacMgrFileName(driver, obj->def->bridge)))
+ if (!(macMapFile = virMacMapFileName(driver->dnsmasqStateDir,
+ obj->def->bridge)))
goto cleanup;
if (!(obj->macmap = virMacMapNew(macMapFile)))
@@ -2380,7 +2369,8 @@ networkStartNetworkVirtual(virNetworkDriverStatePtr driver,
}
}
- if (!(macMapFile = networkMacMgrFileName(driver, obj->def->bridge)) ||
+ if (!(macMapFile = virMacMapFileName(driver->dnsmasqStateDir,
+ obj->def->bridge)) ||
!(obj->macmap = virMacMapNew(macMapFile)))
goto err1;
diff --git a/src/util/virmacmap.c b/src/util/virmacmap.c
index a9697e3..42890ba 100644
--- a/src/util/virmacmap.c
+++ b/src/util/virmacmap.c
@@ -294,6 +294,18 @@ virMacMapWriteFileLocked(virMacMapPtr mgr,
}
+char *
+virMacMapFileName(const char *dnsmasqStateDir,
+ const char *bridge)
+{
+ char *filename;
+
+ ignore_value(virAsprintf(&filename, "%s/%s.macs", dnsmasqStateDir,
bridge));
+
+ return filename;
+}
+
+
#define VIR_MAC_HASH_TABLE_SIZE 10
virMacMapPtr
diff --git a/src/util/virmacmap.h b/src/util/virmacmap.h
index 82da833..e6f754e 100644
--- a/src/util/virmacmap.h
+++ b/src/util/virmacmap.h
@@ -27,6 +27,10 @@
typedef struct virMacMap virMacMap;
typedef virMacMap *virMacMapPtr;
+char *
+virMacMapFileName(const char *dnsmasqStateDir,
+ const char *bridge);
+
virMacMapPtr virMacMapNew(const char *file);
int virMacMapAdd(virMacMapPtr mgr,
--
2.9.4