mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
Rename virXXXXMacAddr to virMacAddrXXX
Rename virFormatMacAddr, virGenerateMacAddr and virParseMacAddr to virMacAddrFormat, virMacAddrGenerate and virMacAddrParse respectively
This commit is contained in:
parent
54a38915d8
commit
4ce98dadcc
@ -848,7 +848,7 @@ extern void
|
||||
virCapabilitiesGenerateMac(virCapsPtr caps,
|
||||
unsigned char *mac)
|
||||
{
|
||||
virGenerateMacAddr(caps->macPrefix, mac);
|
||||
virMacAddrGenerate(caps->macPrefix, mac);
|
||||
}
|
||||
|
||||
extern void
|
||||
|
@ -161,9 +161,9 @@ virDomainAuditNet(virDomainObjPtr vm,
|
||||
|
||||
virUUIDFormat(vm->def->uuid, uuidstr);
|
||||
if (oldDef)
|
||||
virFormatMacAddr(oldDef->mac, oldMacstr);
|
||||
virMacAddrFormat(oldDef->mac, oldMacstr);
|
||||
if (newDef)
|
||||
virFormatMacAddr(newDef->mac, newMacstr);
|
||||
virMacAddrFormat(newDef->mac, newMacstr);
|
||||
if (!(vmname = virAuditEncode("vm", vm->def->name))) {
|
||||
VIR_WARN("OOM while encoding audit message");
|
||||
return;
|
||||
@ -207,7 +207,7 @@ virDomainAuditNetDevice(virDomainDefPtr vmDef, virDomainNetDefPtr netDef,
|
||||
const char *virt;
|
||||
|
||||
virUUIDFormat(vmDef->uuid, uuidstr);
|
||||
virFormatMacAddr(netDef->mac, macstr);
|
||||
virMacAddrFormat(netDef->mac, macstr);
|
||||
rdev = virDomainAuditGetRdev(device);
|
||||
|
||||
if (!(vmname = virAuditEncode("vm", vmDef->name)) ||
|
||||
|
@ -3810,7 +3810,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
|
||||
}
|
||||
|
||||
if (macaddr) {
|
||||
if (virParseMacAddr((const char *)macaddr, def->mac) < 0) {
|
||||
if (virMacAddrParse((const char *)macaddr, def->mac) < 0) {
|
||||
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unable to parse mac address '%s'"),
|
||||
(const char *)macaddr);
|
||||
@ -13904,7 +13904,7 @@ virDomainNetFind(virDomainDefPtr def, const char *device)
|
||||
unsigned char mac[VIR_MAC_BUFLEN];
|
||||
int i;
|
||||
|
||||
if (virParseMacAddr(device, mac) == 0)
|
||||
if (virMacAddrParse(device, mac) == 0)
|
||||
isMac = true;
|
||||
|
||||
if (isMac) {
|
||||
|
@ -425,7 +425,7 @@ virNetworkDHCPRangeDefParseXML(const char *networkName,
|
||||
|
||||
mac = virXMLPropString(cur, "mac");
|
||||
if ((mac != NULL) &&
|
||||
(virParseMacAddr(mac, &addr[0]) != 0)) {
|
||||
(virMacAddrParse(mac, &addr[0]) != 0)) {
|
||||
virNetworkReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Cannot parse MAC address '%s' in network '%s'"),
|
||||
mac, networkName);
|
||||
@ -989,7 +989,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
|
||||
|
||||
tmp = virXPathString("string(./mac[1]/@address)", ctxt);
|
||||
if (tmp) {
|
||||
if (virParseMacAddr(tmp, def->mac) < 0) {
|
||||
if (virMacAddrParse(tmp, def->mac) < 0) {
|
||||
virNetworkReportError(VIR_ERR_XML_ERROR,
|
||||
_("Invalid bridge mac address '%s' in network '%s'"),
|
||||
tmp, def->name);
|
||||
@ -1513,7 +1513,7 @@ char *virNetworkDefFormat(const virNetworkDefPtr def, unsigned int flags)
|
||||
|
||||
if (def->mac_specified) {
|
||||
char macaddr[VIR_MAC_STRING_BUFLEN];
|
||||
virFormatMacAddr(def->mac, macaddr);
|
||||
virMacAddrFormat(def->mac, macaddr);
|
||||
virBufferAsprintf(&buf, " <mac address='%s'/>\n", macaddr);
|
||||
}
|
||||
|
||||
@ -1840,7 +1840,7 @@ void virNetworkSetBridgeMacAddr(virNetworkDefPtr def)
|
||||
/* if the bridge doesn't have a mac address explicitly defined,
|
||||
* autogenerate a random one.
|
||||
*/
|
||||
virGenerateMacAddr((unsigned char[]){ 0x52, 0x54, 0 },
|
||||
virMacAddrGenerate((unsigned char[]){ 0x52, 0x54, 0 },
|
||||
def->mac);
|
||||
def->mac_specified = true;
|
||||
}
|
||||
|
@ -1670,7 +1670,7 @@ static int
|
||||
virNWMACAddressParser(const char *input,
|
||||
nwMACAddressPtr output)
|
||||
{
|
||||
return virParseMacAddr(input, &output->addr[0]);
|
||||
return virMacAddrParse(input, &output->addr[0]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1110,8 +1110,6 @@ virFileUnlock;
|
||||
virFileWaitForDevices;
|
||||
virFileWriteStr;
|
||||
virFindFileInPath;
|
||||
virFormatMacAddr;
|
||||
virGenerateMacAddr;
|
||||
virGetGroupID;
|
||||
virGetGroupName;
|
||||
virGetHostname;
|
||||
@ -1123,7 +1121,9 @@ virIndexToDiskName;
|
||||
virIsDevMapperDevice;
|
||||
virKillProcess;
|
||||
virMacAddrCompare;
|
||||
virParseMacAddr;
|
||||
virMacAddrFormat;
|
||||
virMacAddrGenerate;
|
||||
virMacAddrParse;
|
||||
virParseNumber;
|
||||
virParseVersionString;
|
||||
virPipeReadUntilEOF;
|
||||
|
@ -303,7 +303,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
|
||||
return -1;
|
||||
}
|
||||
|
||||
virFormatMacAddr(item->u.macaddr.addr, buf);
|
||||
virMacAddrFormat(item->u.macaddr.addr, buf);
|
||||
break;
|
||||
|
||||
case DATATYPE_IPV6MASK:
|
||||
@ -3129,7 +3129,7 @@ ebtablesApplyBasicRules(const char *ifname,
|
||||
return -1;
|
||||
}
|
||||
|
||||
virFormatMacAddr(macaddr, macaddr_str);
|
||||
virMacAddrFormat(macaddr, macaddr_str);
|
||||
|
||||
ebiptablesAllTeardown(ifname);
|
||||
|
||||
@ -3234,7 +3234,7 @@ ebtablesApplyDHCPOnlyRules(const char *ifname,
|
||||
srcIPParam = virBufferContentAndReset(&buf);
|
||||
}
|
||||
|
||||
virFormatMacAddr(macaddr, macaddr_str);
|
||||
virMacAddrFormat(macaddr, macaddr_str);
|
||||
|
||||
ebiptablesAllTeardown(ifname);
|
||||
|
||||
|
@ -831,7 +831,7 @@ __virNWFilterInstantiateFilter(const unsigned char *vmuuid,
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
virFormatMacAddr(macaddr, vmmacaddr);
|
||||
virMacAddrFormat(macaddr, vmmacaddr);
|
||||
str_macaddr = strdup(vmmacaddr);
|
||||
if (!str_macaddr) {
|
||||
virReportOOMError();
|
||||
|
@ -511,7 +511,7 @@ learnIPAddressThread(void *arg)
|
||||
goto done;
|
||||
}
|
||||
|
||||
virFormatMacAddr(req->macaddr, macaddr);
|
||||
virMacAddrFormat(req->macaddr, macaddr);
|
||||
|
||||
switch (req->howDetect) {
|
||||
case DETECT_DHCP:
|
||||
|
@ -295,7 +295,7 @@ openvzReadNetworkConf(virDomainDefPtr def,
|
||||
_("MAC address %s too long for destination"), p);
|
||||
goto error;
|
||||
}
|
||||
if (virParseMacAddr(cpy_temp, net->mac) < 0) {
|
||||
if (virMacAddrParse(cpy_temp, net->mac) < 0) {
|
||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Wrong MAC address"));
|
||||
goto error;
|
||||
|
@ -763,9 +763,9 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
|
||||
ADD_ARG_LIT(vpsid);
|
||||
}
|
||||
|
||||
virFormatMacAddr(net->mac, macaddr);
|
||||
virMacAddrFormat(net->mac, macaddr);
|
||||
virCapabilitiesGenerateMac(driver->caps, host_mac);
|
||||
virFormatMacAddr(host_mac, host_macaddr);
|
||||
virMacAddrFormat(host_mac, host_macaddr);
|
||||
|
||||
if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
|
||||
(net->type == VIR_DOMAIN_NET_TYPE_ETHERNET &&
|
||||
|
@ -6479,7 +6479,7 @@ qemuParseCommandLineNet(virCapsPtr caps,
|
||||
for (i = 0 ; i < nkeywords ; i++) {
|
||||
if (STREQ(keywords[i], "macaddr")) {
|
||||
genmac = 0;
|
||||
if (virParseMacAddr(values[i], def->mac) < 0) {
|
||||
if (virMacAddrParse(values[i], def->mac) < 0) {
|
||||
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unable to parse mac address '%s'"),
|
||||
values[i]);
|
||||
|
@ -5361,7 +5361,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
||||
net = dev->data.net;
|
||||
if (virDomainNetIndexByMac(vmdef, net->mac) >= 0) {
|
||||
char macbuf[VIR_MAC_STRING_BUFLEN];
|
||||
virFormatMacAddr(net->mac, macbuf);
|
||||
virMacAddrFormat(net->mac, macbuf);
|
||||
qemuReportError(VIR_ERR_INVALID_ARG,
|
||||
_("mac %s already exists"), macbuf);
|
||||
return -1;
|
||||
@ -5422,7 +5422,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
|
||||
if (virDomainNetRemoveByMac(vmdef, net->mac)) {
|
||||
char macbuf[VIR_MAC_STRING_BUFLEN];
|
||||
|
||||
virFormatMacAddr(net->mac, macbuf);
|
||||
virMacAddrFormat(net->mac, macbuf);
|
||||
qemuReportError(VIR_ERR_INVALID_ARG,
|
||||
_("no nic of mac %s"), macbuf);
|
||||
return -1;
|
||||
@ -5496,7 +5496,7 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
|
||||
net = dev->data.net;
|
||||
if ((pos = virDomainNetIndexByMac(vmdef, net->mac)) < 0) {
|
||||
char macbuf[VIR_MAC_STRING_BUFLEN];
|
||||
virFormatMacAddr(net->mac, macbuf);
|
||||
virMacAddrFormat(net->mac, macbuf);
|
||||
qemuReportError(VIR_ERR_INVALID_ARG,
|
||||
_("mac %s doesn't exist"), macbuf);
|
||||
return -1;
|
||||
|
@ -1794,7 +1794,7 @@ virMacAddrCompare (const char *p, const char *q)
|
||||
}
|
||||
|
||||
/**
|
||||
* virParseMacAddr:
|
||||
* virMacAddrParse:
|
||||
* @str: string representation of MAC address, e.g., "0:1E:FC:E:3a:CB"
|
||||
* @addr: 6-byte MAC address
|
||||
*
|
||||
@ -1803,7 +1803,7 @@ virMacAddrCompare (const char *p, const char *q)
|
||||
* Return 0 upon success, or -1 in case of error.
|
||||
*/
|
||||
int
|
||||
virParseMacAddr(const char* str, unsigned char *addr)
|
||||
virMacAddrParse(const char* str, unsigned char *addr)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -1838,7 +1838,7 @@ virParseMacAddr(const char* str, unsigned char *addr)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void virFormatMacAddr(const unsigned char *addr,
|
||||
void virMacAddrFormat(const unsigned char *addr,
|
||||
char *str)
|
||||
{
|
||||
snprintf(str, VIR_MAC_STRING_BUFLEN,
|
||||
@ -1848,7 +1848,7 @@ void virFormatMacAddr(const unsigned char *addr,
|
||||
str[VIR_MAC_STRING_BUFLEN-1] = '\0';
|
||||
}
|
||||
|
||||
void virGenerateMacAddr(const unsigned char *prefix,
|
||||
void virMacAddrGenerate(const unsigned char *prefix,
|
||||
unsigned char *addr)
|
||||
{
|
||||
addr[0] = prefix[0];
|
||||
|
@ -182,11 +182,11 @@ char *virStrcpy(char *dest, const char *src, size_t destbytes)
|
||||
# define VIR_MAC_PREFIX_BUFLEN 3
|
||||
# define VIR_MAC_STRING_BUFLEN VIR_MAC_BUFLEN * 3
|
||||
|
||||
int virParseMacAddr(const char* str,
|
||||
int virMacAddrParse(const char* str,
|
||||
unsigned char *addr) ATTRIBUTE_RETURN_CHECK;
|
||||
void virFormatMacAddr(const unsigned char *addr,
|
||||
void virMacAddrFormat(const unsigned char *addr,
|
||||
char *str);
|
||||
void virGenerateMacAddr(const unsigned char *prefix,
|
||||
void virMacAddrGenerate(const unsigned char *prefix,
|
||||
unsigned char *addr);
|
||||
|
||||
int virDiskNameToIndex(const char* str);
|
||||
|
@ -264,7 +264,7 @@ virNetDevReplaceMacAddress(const char *linkdev,
|
||||
virReportOOMError();
|
||||
return -1;
|
||||
}
|
||||
virFormatMacAddr(oldmac, macstr);
|
||||
virMacAddrFormat(oldmac, macstr);
|
||||
if (virFileWriteStr(path, macstr, O_CREAT|O_TRUNC|O_WRONLY) < 0) {
|
||||
virReportSystemError(errno, _("Unable to preserve mac for %s"),
|
||||
linkdev);
|
||||
@ -305,7 +305,7 @@ virNetDevRestoreMacAddress(const char *linkdev,
|
||||
if (virFileReadAll(path, VIR_MAC_STRING_BUFLEN, &macstr) < 0)
|
||||
return -1;
|
||||
|
||||
if (virParseMacAddr(macstr, &oldmac[0]) != 0) {
|
||||
if (virMacAddrParse(macstr, &oldmac[0]) != 0) {
|
||||
virNetDevError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Cannot parse MAC address from '%s'"),
|
||||
oldmacname);
|
||||
|
@ -3000,7 +3000,7 @@ sharedFoldersCleanup:
|
||||
MACAddress[8], MACAddress[9], MACAddress[10], MACAddress[11]);
|
||||
|
||||
/* XXX some real error handling here some day ... */
|
||||
if (virParseMacAddr(macaddr, def->nets[netAdpIncCnt]->mac) < 0)
|
||||
if (virMacAddrParse(macaddr, def->nets[netAdpIncCnt]->mac) < 0)
|
||||
{}
|
||||
|
||||
netAdpIncCnt++;
|
||||
@ -4349,7 +4349,7 @@ vboxAttachNetwork(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
|
||||
char macaddr[VIR_MAC_STRING_BUFLEN] = {0};
|
||||
char macaddrvbox[VIR_MAC_STRING_BUFLEN - 5] = {0};
|
||||
|
||||
virFormatMacAddr(def->nets[i]->mac, macaddr);
|
||||
virMacAddrFormat(def->nets[i]->mac, macaddr);
|
||||
snprintf(macaddrvbox, VIR_MAC_STRING_BUFLEN - 5,
|
||||
"%02X%02X%02X%02X%02X%02X",
|
||||
def->nets[i]->mac[0],
|
||||
|
@ -2365,7 +2365,7 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
|
||||
if (addressType == NULL || STRCASEEQ(addressType, "generated") ||
|
||||
STRCASEEQ(addressType, "vpx")) {
|
||||
if (generatedAddress != NULL) {
|
||||
if (virParseMacAddr(generatedAddress, (*def)->mac) < 0) {
|
||||
if (virMacAddrParse(generatedAddress, (*def)->mac) < 0) {
|
||||
VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Expecting VMX entry '%s' to be MAC address but "
|
||||
"found '%s'"), generatedAddress_name,
|
||||
@ -2375,7 +2375,7 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
|
||||
}
|
||||
} else if (STRCASEEQ(addressType, "static")) {
|
||||
if (address != NULL) {
|
||||
if (virParseMacAddr(address, (*def)->mac) < 0) {
|
||||
if (virMacAddrParse(address, (*def)->mac) < 0) {
|
||||
VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Expecting VMX entry '%s' to be MAC address but "
|
||||
"found '%s'"), address_name, address);
|
||||
@ -3557,7 +3557,7 @@ virVMXFormatEthernet(virDomainNetDefPtr def, int controller,
|
||||
}
|
||||
|
||||
/* def:mac -> vmx:addressType, vmx:(generated)Address, vmx:checkMACAddress */
|
||||
virFormatMacAddr(def->mac, mac_string);
|
||||
virMacAddrFormat(def->mac, mac_string);
|
||||
|
||||
prefix = (def->mac[0] << 16) | (def->mac[1] << 8) | def->mac[2];
|
||||
suffix = (def->mac[3] << 16) | (def->mac[4] << 8) | def->mac[5];
|
||||
|
@ -2713,7 +2713,7 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml,
|
||||
goto cleanup;
|
||||
|
||||
char macStr[VIR_MAC_STRING_BUFLEN];
|
||||
virFormatMacAddr(dev->data.net->mac, macStr);
|
||||
virMacAddrFormat(dev->data.net->mac, macStr);
|
||||
|
||||
if (!(target = strdup(macStr))) {
|
||||
virReportOOMError();
|
||||
|
@ -1513,7 +1513,7 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
|
||||
}
|
||||
xen_vif_get_record(session, &vif_rec, vif);
|
||||
if (vif_rec != NULL) {
|
||||
if (virParseMacAddr((const char *)vif_rec->mac,defPtr->nets[i]->mac) < 0)
|
||||
if (virMacAddrParse((const char *)vif_rec->mac,defPtr->nets[i]->mac) < 0)
|
||||
xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unable to parse given mac address"));
|
||||
xen_vif_record_free(vif_rec);
|
||||
|
@ -562,7 +562,7 @@ createVMRecordFromXml (virConnectPtr conn, virDomainDefPtr def,
|
||||
goto error_cleanup;
|
||||
if (def->nets[i]->mac) {
|
||||
char macStr[VIR_MAC_STRING_BUFLEN];
|
||||
virFormatMacAddr(def->nets[i]->mac, macStr);
|
||||
virMacAddrFormat(def->nets[i]->mac, macStr);
|
||||
if (!(mac = strdup(macStr))) {
|
||||
VIR_FREE(bridge);
|
||||
goto error_cleanup;
|
||||
|
@ -580,7 +580,7 @@ xenParseSxprNets(virDomainDefPtr def,
|
||||
|
||||
tmp = sexpr_node(node, "device/vif/mac");
|
||||
if (tmp) {
|
||||
if (virParseMacAddr(tmp, net->mac) < 0) {
|
||||
if (virMacAddrParse(tmp, net->mac) < 0) {
|
||||
XENXS_ERROR(VIR_ERR_INTERNAL_ERROR,
|
||||
_("malformed mac address '%s'"), tmp);
|
||||
goto cleanup;
|
||||
|
@ -690,7 +690,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
|
||||
goto no_memory;
|
||||
|
||||
if (mac[0]) {
|
||||
if (virParseMacAddr(mac, net->mac) < 0) {
|
||||
if (virMacAddrParse(mac, net->mac) < 0) {
|
||||
XENXS_ERROR(VIR_ERR_INTERNAL_ERROR,
|
||||
_("malformed mac address '%s'"), mac);
|
||||
goto cleanup;
|
||||
|
@ -1408,7 +1408,7 @@ cmdDomIfSetLink (vshControl *ctl, const vshCmd *cmd)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virParseMacAddr(iface, macaddr) == 0) {
|
||||
if (virMacAddrParse(iface, macaddr) == 0) {
|
||||
element = "mac";
|
||||
attr = "address";
|
||||
} else {
|
||||
@ -1566,7 +1566,7 @@ cmdDomIfGetLink (vshControl *ctl, const vshCmd *cmd)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virParseMacAddr(iface, macaddr) == 0) {
|
||||
if (virMacAddrParse(iface, macaddr) == 0) {
|
||||
element = "mac";
|
||||
attr = "address";
|
||||
} else {
|
||||
@ -13473,7 +13473,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
|
||||
if (cur->type == XML_ELEMENT_NODE &&
|
||||
xmlStrEqual(cur->name, BAD_CAST "mac")) {
|
||||
char *tmp_mac = virXMLPropString(cur, "address");
|
||||
diff_mac = virMacAddrCompare (tmp_mac, mac);
|
||||
diff_mac = virMacAddrCompare(tmp_mac, mac);
|
||||
VIR_FREE(tmp_mac);
|
||||
if (!diff_mac) {
|
||||
goto hit;
|
||||
|
Loading…
Reference in New Issue
Block a user