提交 070b6f7f 编写于 作者: J John Ferlan

network: Move and rename networkMacMgrFileName

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: NJohn Ferlan <jferlan@redhat.com>
上级 8e51b301
...@@ -2070,6 +2070,7 @@ virMacAddrSetRaw; ...@@ -2070,6 +2070,7 @@ virMacAddrSetRaw;
# util/virmacmap.h # util/virmacmap.h
virMacMapAdd; virMacMapAdd;
virMacMapDumpStr; virMacMapDumpStr;
virMacMapFileName;
virMacMapLookup; virMacMapLookup;
virMacMapNew; virMacMapNew;
virMacMapRemove; virMacMapRemove;
......
...@@ -322,18 +322,6 @@ networkRadvdConfigFileName(virNetworkDriverStatePtr driver, ...@@ -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 */ /* do needed cleanup steps and remove the network from the list */
static int static int
networkRemoveInactive(virNetworkDriverStatePtr driver, networkRemoveInactive(virNetworkDriverStatePtr driver,
...@@ -375,7 +363,7 @@ networkRemoveInactive(virNetworkDriverStatePtr driver, ...@@ -375,7 +363,7 @@ networkRemoveInactive(virNetworkDriverStatePtr driver,
if (!(statusfile = virNetworkConfigFile(driver->stateDir, def->name))) if (!(statusfile = virNetworkConfigFile(driver->stateDir, def->name)))
goto cleanup; goto cleanup;
if (!(macMapFile = networkMacMgrFileName(driver, def->bridge))) if (!(macMapFile = virMacMapFileName(driver->dnsmasqStateDir, def->bridge)))
goto cleanup; goto cleanup;
/* dnsmasq */ /* dnsmasq */
...@@ -427,7 +415,7 @@ networkMacMgrAdd(virNetworkDriverStatePtr driver, ...@@ -427,7 +415,7 @@ networkMacMgrAdd(virNetworkDriverStatePtr driver,
virMacAddrFormat(mac, macStr); virMacAddrFormat(mac, macStr);
if (!(file = networkMacMgrFileName(driver, obj->def->bridge))) if (!(file = virMacMapFileName(driver->dnsmasqStateDir, obj->def->bridge)))
goto cleanup; goto cleanup;
if (virMacMapAdd(obj->macmap, domain, macStr) < 0) if (virMacMapAdd(obj->macmap, domain, macStr) < 0)
...@@ -458,7 +446,7 @@ networkMacMgrDel(virNetworkDriverStatePtr driver, ...@@ -458,7 +446,7 @@ networkMacMgrDel(virNetworkDriverStatePtr driver,
virMacAddrFormat(mac, macStr); virMacAddrFormat(mac, macStr);
if (!(file = networkMacMgrFileName(driver, obj->def->bridge))) if (!(file = virMacMapFileName(driver->dnsmasqStateDir, obj->def->bridge)))
goto cleanup; goto cleanup;
if (virMacMapRemove(obj->macmap, domain, macStr) < 0) if (virMacMapRemove(obj->macmap, domain, macStr) < 0)
...@@ -523,7 +511,8 @@ networkUpdateState(virNetworkObjPtr obj, ...@@ -523,7 +511,8 @@ networkUpdateState(virNetworkObjPtr obj,
if (!(obj->def->bridge && virNetDevExists(obj->def->bridge) == 1)) if (!(obj->def->bridge && virNetDevExists(obj->def->bridge) == 1))
obj->active = 0; obj->active = 0;
if (!(macMapFile = networkMacMgrFileName(driver, obj->def->bridge))) if (!(macMapFile = virMacMapFileName(driver->dnsmasqStateDir,
obj->def->bridge)))
goto cleanup; goto cleanup;
if (!(obj->macmap = virMacMapNew(macMapFile))) if (!(obj->macmap = virMacMapNew(macMapFile)))
...@@ -2380,7 +2369,8 @@ networkStartNetworkVirtual(virNetworkDriverStatePtr driver, ...@@ -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))) !(obj->macmap = virMacMapNew(macMapFile)))
goto err1; goto err1;
......
...@@ -294,6 +294,18 @@ virMacMapWriteFileLocked(virMacMapPtr mgr, ...@@ -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 #define VIR_MAC_HASH_TABLE_SIZE 10
virMacMapPtr virMacMapPtr
......
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
typedef struct virMacMap virMacMap; typedef struct virMacMap virMacMap;
typedef virMacMap *virMacMapPtr; typedef virMacMap *virMacMapPtr;
char *
virMacMapFileName(const char *dnsmasqStateDir,
const char *bridge);
virMacMapPtr virMacMapNew(const char *file); virMacMapPtr virMacMapNew(const char *file);
int virMacMapAdd(virMacMapPtr mgr, int virMacMapAdd(virMacMapPtr mgr,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册