mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
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: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
8e51b30148
commit
070b6f7f55
@ -2070,6 +2070,7 @@ virMacAddrSetRaw;
|
||||
# util/virmacmap.h
|
||||
virMacMapAdd;
|
||||
virMacMapDumpStr;
|
||||
virMacMapFileName;
|
||||
virMacMapLookup;
|
||||
virMacMapNew;
|
||||
virMacMapRemove;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user