[libvirt] [PATCH 0/3] Make util.[ch] a little bit smaller still

In keeping with the drive to stop src/util/util.[ch] being a general dumping ground, move some more functions out into their own dedicated files

From: "Daniel P. Berrange" <berrange@redhat.com> Rename virFormatMacAddr, virGenerateMacAddr and virParseMacAddr to virMacAddrFormat, virMacAddrGenerate and virMacAddrParse respectively --- src/conf/capabilities.c | 2 +- src/conf/domain_audit.c | 6 +++--- src/conf/domain_conf.c | 4 ++-- src/conf/network_conf.c | 8 ++++---- src/conf/nwfilter_conf.c | 2 +- src/libvirt_private.syms | 6 +++--- src/nwfilter/nwfilter_ebiptables_driver.c | 6 +++--- src/nwfilter/nwfilter_gentech_driver.c | 2 +- src/nwfilter/nwfilter_learnipaddr.c | 2 +- src/openvz/openvz_conf.c | 2 +- src/openvz/openvz_driver.c | 4 ++-- src/qemu/qemu_command.c | 2 +- src/qemu/qemu_driver.c | 6 +++--- src/util/util.c | 8 ++++---- src/util/util.h | 6 +++--- src/util/virnetdev.c | 4 ++-- src/vbox/vbox_tmpl.c | 4 ++-- src/vmx/vmx.c | 6 +++--- src/xen/xend_internal.c | 2 +- src/xenapi/xenapi_driver.c | 2 +- src/xenapi/xenapi_utils.c | 2 +- src/xenxs/xen_sxpr.c | 2 +- src/xenxs/xen_xm.c | 2 +- tools/virsh.c | 6 +++--- 24 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index ed0ae99..d44ce1b 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -848,7 +848,7 @@ extern void virCapabilitiesGenerateMac(virCapsPtr caps, unsigned char *mac) { - virGenerateMacAddr(caps->macPrefix, mac); + virMacAddrGenerate(caps->macPrefix, mac); } extern void diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index eb85ec7..7d766a2 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -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)) || diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 978e91c..6551a79 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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) { diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index c03ceaf..c65c75c 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -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; } diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index e2d8f23..5811592 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -1670,7 +1670,7 @@ static int virNWMACAddressParser(const char *input, nwMACAddressPtr output) { - return virParseMacAddr(input, &output->addr[0]); + return virMacAddrParse(input, &output->addr[0]); } diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index e1ee23f..4e50fa8 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -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; diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c index 8ddc2d5..b3b60b4 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -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); diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c index c35b749..fc71e7b 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -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(); diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c index 93f8f6e..140aea8 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -511,7 +511,7 @@ learnIPAddressThread(void *arg) goto done; } - virFormatMacAddr(req->macaddr, macaddr); + virMacAddrFormat(req->macaddr, macaddr); switch (req->howDetect) { case DETECT_DHCP: diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index c0517db..28f86ff 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -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; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index b848a88..833a98d 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -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 && diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7b9328f..9bfbada 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -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]); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ab69dca..196fd23 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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; diff --git a/src/util/util.c b/src/util/util.c index f1c3346..28b608d 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -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]; diff --git a/src/util/util.h b/src/util/util.h index 91cae47..3b31182 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -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); diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 06c825d..eafb47b 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -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); diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index d720432..b168c7d 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -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], diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 5ebd92a..1fdbd50 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -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]; diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index 1d8e035..b754eca 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -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(); diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index 68017bc..f877f67 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -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); diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c index 79fd946..ddc7736 100644 --- a/src/xenapi/xenapi_utils.c +++ b/src/xenapi/xenapi_utils.c @@ -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; diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c index 04ba5aa..7a53f94 100644 --- a/src/xenxs/xen_sxpr.c +++ b/src/xenxs/xen_sxpr.c @@ -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; diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 0aa04f3..a0d4806 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -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; diff --git a/tools/virsh.c b/tools/virsh.c index 74655c2..9b37dc0 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -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; -- 1.7.7.6

On 01/27/2012 10:37 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Rename virFormatMacAddr, virGenerateMacAddr and virParseMacAddr to virMacAddrFormat, virMacAddrGenerate and virMacAddrParse respectively ---
Quite mechanical, and fits in better with our conventions. ACK. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

From: "Daniel P. Berrange" <berrange@redhat.com> Move the virMacAddrXXX functions out of util.[ch] and into a new dedicate file virmacaddr.[ch] --- src/Makefile.am | 1 + src/conf/capabilities.h | 2 +- src/conf/network_conf.h | 2 +- src/libvirt_private.syms | 11 ++- src/util/util.c | 99 --------------------------------- src/util/util.h | 13 ---- src/util/virmacaddr.c | 128 +++++++++++++++++++++++++++++++++++++++++++ src/util/virmacaddr.h | 41 ++++++++++++++ src/util/virnetdev.c | 1 + src/util/virnetdevmacvlan.c | 2 +- 10 files changed, 181 insertions(+), 119 deletions(-) create mode 100644 src/util/virmacaddr.c create mode 100644 src/util/virmacaddr.h diff --git a/src/Makefile.am b/src/Makefile.am index 22fd58e..4a5d9f7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -93,6 +93,7 @@ UTIL_SOURCES = \ util/virhashcode.c util/virhashcode.h \ util/virkeycode.c util/virkeycode.h \ util/virkeymaps.h \ + util/virmacaddr.h util/virmacaddr.c \ util/virnetdev.h util/virnetdev.c \ util/virnetdevbandwidth.h util/virnetdevbandwidth.c \ util/virnetdevbridge.h util/virnetdevbridge.c \ diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 7f35c17..38d07c4 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -25,9 +25,9 @@ # define __VIR_CAPABILITIES_H # include "internal.h" -# include "util.h" # include "buf.h" # include "cpu_conf.h" +# include "virmacaddr.h" # include <libxml/xpath.h> diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h index 5cb396c..4339a69 100644 --- a/src/conf/network_conf.h +++ b/src/conf/network_conf.h @@ -35,7 +35,7 @@ # include "virsocketaddr.h" # include "virnetdevbandwidth.h" # include "virnetdevvportprofile.h" -# include "util.h" +# include "virmacaddr.h" enum virNetworkForwardType { VIR_NETWORK_FORWARD_NONE = 0, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4e50fa8..8a83f07 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1120,10 +1120,6 @@ virHexToBin; virIndexToDiskName; virIsDevMapperDevice; virKillProcess; -virMacAddrCompare; -virMacAddrFormat; -virMacAddrGenerate; -virMacAddrParse; virParseNumber; virParseVersionString; virPipeReadUntilEOF; @@ -1183,6 +1179,13 @@ virKeycodeValueFromString; virKeycodeValueTranslate; +# virmacaddr.h +virMacAddrCompare; +virMacAddrFormat; +virMacAddrGenerate; +virMacAddrParse; + + # virnetclient.h virNetClientHasPassFD; diff --git a/src/util/util.c b/src/util/util.c index 28b608d..baa0f12 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -77,7 +77,6 @@ #include "command.h" #include "nonblocking.h" #include "passfd.h" -#include "virrandom.h" #ifndef NSIG # define NSIG 32 @@ -1762,104 +1761,6 @@ virStrcpy(char *dest, const char *src, size_t destbytes) return virStrncpy(dest, src, strlen(src), destbytes); } -/* Compare two MAC addresses, ignoring differences in case, - * as well as leading zeros. - */ -int -virMacAddrCompare (const char *p, const char *q) -{ - unsigned char c, d; - do { - while (*p == '0' && c_isxdigit (p[1])) - ++p; - while (*q == '0' && c_isxdigit (q[1])) - ++q; - c = c_tolower (*p); - d = c_tolower (*q); - - if (c == 0 || d == 0) - break; - - ++p; - ++q; - } while (c == d); - - if (UCHAR_MAX <= INT_MAX) - return c - d; - - /* On machines where 'char' and 'int' are types of the same size, the - difference of two 'unsigned char' values - including the sign bit - - doesn't fit in an 'int'. */ - return (c > d ? 1 : c < d ? -1 : 0); -} - -/** - * virMacAddrParse: - * @str: string representation of MAC address, e.g., "0:1E:FC:E:3a:CB" - * @addr: 6-byte MAC address - * - * Parse a MAC address - * - * Return 0 upon success, or -1 in case of error. - */ -int -virMacAddrParse(const char* str, unsigned char *addr) -{ - int i; - - errno = 0; - for (i = 0; i < VIR_MAC_BUFLEN; i++) { - char *end_ptr; - unsigned long result; - - /* This is solely to avoid accepting the leading - * space or "+" that strtoul would otherwise accept. - */ - if (!c_isxdigit(*str)) - break; - - result = strtoul(str, &end_ptr, 16); - - if ((end_ptr - str) < 1 || 2 < (end_ptr - str) || - (errno != 0) || - (0xFF < result)) - break; - - addr[i] = (unsigned char) result; - - if ((i == 5) && (*end_ptr == '\0')) - return 0; - if (*end_ptr != ':') - break; - - str = end_ptr + 1; - } - - return -1; -} - -void virMacAddrFormat(const unsigned char *addr, - char *str) -{ - snprintf(str, VIR_MAC_STRING_BUFLEN, - "%02X:%02X:%02X:%02X:%02X:%02X", - addr[0], addr[1], addr[2], - addr[3], addr[4], addr[5]); - str[VIR_MAC_STRING_BUFLEN-1] = '\0'; -} - -void virMacAddrGenerate(const unsigned char *prefix, - unsigned char *addr) -{ - addr[0] = prefix[0]; - addr[1] = prefix[1]; - addr[2] = prefix[2]; - addr[3] = virRandomBits(8); - addr[4] = virRandomBits(8); - addr[5] = virRandomBits(8); -} - - int virEnumFromString(const char *const*types, unsigned int ntypes, const char *type) diff --git a/src/util/util.h b/src/util/util.h index 3b31182..96491e5 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -157,8 +157,6 @@ int virStrToDouble(char const *s, int virHexToBin(unsigned char c); -int virMacAddrCompare (const char *mac1, const char *mac2); - void virSkipSpaces(const char **str) ATTRIBUTE_NONNULL(1); void virSkipSpacesAndBackslash(const char **str) ATTRIBUTE_NONNULL(1); void virTrimSpaces(char *str, char **endp) ATTRIBUTE_NONNULL(1); @@ -178,17 +176,6 @@ char *virStrcpy(char *dest, const char *src, size_t destbytes) ATTRIBUTE_RETURN_CHECK; # define virStrcpyStatic(dest, src) virStrcpy((dest), (src), sizeof(dest)) -# define VIR_MAC_BUFLEN 6 -# define VIR_MAC_PREFIX_BUFLEN 3 -# define VIR_MAC_STRING_BUFLEN VIR_MAC_BUFLEN * 3 - -int virMacAddrParse(const char* str, - unsigned char *addr) ATTRIBUTE_RETURN_CHECK; -void virMacAddrFormat(const unsigned char *addr, - char *str); -void virMacAddrGenerate(const unsigned char *prefix, - unsigned char *addr); - int virDiskNameToIndex(const char* str); char *virIndexToDiskName(int idx, const char *prefix); diff --git a/src/util/virmacaddr.c b/src/util/virmacaddr.c new file mode 100644 index 0000000..2a11e78 --- /dev/null +++ b/src/util/virmacaddr.c @@ -0,0 +1,128 @@ +/* + * virmacaddr.c: MAC address handling + * + * Copyright (C) 2012 Red Hat, Inc. + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: + * Daniel P. Berrange <berrange@redhat.com> + */ + +#include <config.h> + +#include <stdlib.h> +#include <stdio.h> + +#include "c-ctype.h" +#include "virmacaddr.h" +#include "virrandom.h" + +/* Compare two MAC addresses, ignoring differences in case, + * as well as leading zeros. + */ +int +virMacAddrCompare (const char *p, const char *q) +{ + unsigned char c, d; + do { + while (*p == '0' && c_isxdigit (p[1])) + ++p; + while (*q == '0' && c_isxdigit (q[1])) + ++q; + c = c_tolower (*p); + d = c_tolower (*q); + + if (c == 0 || d == 0) + break; + + ++p; + ++q; + } while (c == d); + + if (UCHAR_MAX <= INT_MAX) + return c - d; + + /* On machines where 'char' and 'int' are types of the same size, the + difference of two 'unsigned char' values - including the sign bit - + doesn't fit in an 'int'. */ + return (c > d ? 1 : c < d ? -1 : 0); +} + +/** + * virMacAddrParse: + * @str: string representation of MAC address, e.g., "0:1E:FC:E:3a:CB" + * @addr: 6-byte MAC address + * + * Parse a MAC address + * + * Return 0 upon success, or -1 in case of error. + */ +int +virMacAddrParse(const char* str, unsigned char *addr) +{ + int i; + + errno = 0; + for (i = 0; i < VIR_MAC_BUFLEN; i++) { + char *end_ptr; + unsigned long result; + + /* This is solely to avoid accepting the leading + * space or "+" that strtoul would otherwise accept. + */ + if (!c_isxdigit(*str)) + break; + + result = strtoul(str, &end_ptr, 16); + + if ((end_ptr - str) < 1 || 2 < (end_ptr - str) || + (errno != 0) || + (0xFF < result)) + break; + + addr[i] = (unsigned char) result; + + if ((i == 5) && (*end_ptr == '\0')) + return 0; + if (*end_ptr != ':') + break; + + str = end_ptr + 1; + } + + return -1; +} + +void virMacAddrFormat(const unsigned char *addr, + char *str) +{ + snprintf(str, VIR_MAC_STRING_BUFLEN, + "%02X:%02X:%02X:%02X:%02X:%02X", + addr[0], addr[1], addr[2], + addr[3], addr[4], addr[5]); + str[VIR_MAC_STRING_BUFLEN-1] = '\0'; +} + +void virMacAddrGenerate(const unsigned char *prefix, + unsigned char *addr) +{ + addr[0] = prefix[0]; + addr[1] = prefix[1]; + addr[2] = prefix[2]; + addr[3] = virRandomBits(8); + addr[4] = virRandomBits(8); + addr[5] = virRandomBits(8); +} diff --git a/src/util/virmacaddr.h b/src/util/virmacaddr.h new file mode 100644 index 0000000..c14b5a0 --- /dev/null +++ b/src/util/virmacaddr.h @@ -0,0 +1,41 @@ +/* + * virmacaddr.h: MAC address handling + * + * Copyright (C) 2012 Red Hat, Inc. + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: + * Daniel P. Berrange <berrange@redhat.com> + */ + +#ifndef __VIR_MACADDR_H__ +# define __VIR_MACADDR_H__ + +# include "internal.h" + +# define VIR_MAC_BUFLEN 6 +# define VIR_MAC_PREFIX_BUFLEN 3 +# define VIR_MAC_STRING_BUFLEN VIR_MAC_BUFLEN * 3 + +int virMacAddrCompare(const char *mac1, const char *mac2); +void virMacAddrFormat(const unsigned char *addr, + char *str); +void virMacAddrGenerate(const unsigned char *prefix, + unsigned char *addr); +int virMacAddrParse(const char* str, + unsigned char *addr) ATTRIBUTE_RETURN_CHECK; + +#endif /* __VIR_MACADDR_H__ */ diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index eafb47b..9d76d47 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -23,6 +23,7 @@ #include <config.h> #include "virnetdev.h" +#include "virmacaddr.h" #include "virfile.h" #include "virterror_internal.h" #include "command.h" diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index 5e55b72..1d64b73 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -27,8 +27,8 @@ #include <config.h> - #include "virnetdevmacvlan.h" +#include "virmacaddr.h" #include "util.h" #include "virterror_internal.h" -- 1.7.7.6

On 01/27/2012 10:37 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Move the virMacAddrXXX functions out of util.[ch] and into a new dedicate file virmacaddr.[ch] --- src/Makefile.am | 1 + src/conf/capabilities.h | 2 +- src/conf/network_conf.h | 2 +- src/libvirt_private.syms | 11 ++- src/util/util.c | 99 --------------------------------- src/util/util.h | 13 ---- src/util/virmacaddr.c | 128 +++++++++++++++++++++++++++++++++++++++++++ src/util/virmacaddr.h | 41 ++++++++++++++ src/util/virnetdev.c | 1 + src/util/virnetdevmacvlan.c | 2 +- 10 files changed, 181 insertions(+), 119 deletions(-)
More insertions than deletions, but probably due to copyright headers :)
+++ b/src/util/virmacaddr.c @@ -0,0 +1,128 @@ +/* + * virmacaddr.c: MAC address handling + * + * Copyright (C) 2012 Red Hat, Inc.
When doing code motion, are we required to carry over the copyright years from the earlier location of the code?
+ +/* Compare two MAC addresses, ignoring differences in case, + * as well as leading zeros. + */ +int +virMacAddrCompare (const char *p, const char *q)
As long as you are moving things, would you like to fix spacing before '('?
+{ + unsigned char c, d; + do { + while (*p == '0' && c_isxdigit (p[1])) + ++p; + while (*q == '0' && c_isxdigit (q[1]))
and here too?
+ ++q; + c = c_tolower (*p); + d = c_tolower (*q);
and here
+ + result = strtoul(str, &end_ptr, 16); + + if ((end_ptr - str) < 1 || 2 < (end_ptr - str) || + (errno != 0) || + (0xFF < result))
That last check is impossible. Yes, I know it's just code motion, and the dead code was present in the original as well, but since we already did a length bound of at most two hex characters, we know that the result did not exceed 0xff. Why are we even bothering with strtoul for a two-character conversion? This seems like it is more efficient when open-coded. But in the interest of pure code motion, I'd do any cleanups as a separate patch. ACK. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Fri, Jan 27, 2012 at 10:52:08AM -0700, Eric Blake wrote:
On 01/27/2012 10:37 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Move the virMacAddrXXX functions out of util.[ch] and into a new dedicate file virmacaddr.[ch] --- src/Makefile.am | 1 + src/conf/capabilities.h | 2 +- src/conf/network_conf.h | 2 +- src/libvirt_private.syms | 11 ++- src/util/util.c | 99 --------------------------------- src/util/util.h | 13 ---- src/util/virmacaddr.c | 128 +++++++++++++++++++++++++++++++++++++++++++ src/util/virmacaddr.h | 41 ++++++++++++++ src/util/virnetdev.c | 1 + src/util/virnetdevmacvlan.c | 2 +- 10 files changed, 181 insertions(+), 119 deletions(-)
More insertions than deletions, but probably due to copyright headers :)
+++ b/src/util/virmacaddr.c @@ -0,0 +1,128 @@ +/* + * virmacaddr.c: MAC address handling + * + * Copyright (C) 2012 Red Hat, Inc.
When doing code motion, are we required to carry over the copyright years from the earlier location of the code?
Yeah actually I backdated it to 2006
+ +/* Compare two MAC addresses, ignoring differences in case, + * as well as leading zeros. + */ +int +virMacAddrCompare (const char *p, const char *q)
As long as you are moving things, would you like to fix spacing before '('?
+{ + unsigned char c, d; + do { + while (*p == '0' && c_isxdigit (p[1])) + ++p; + while (*q == '0' && c_isxdigit (q[1]))
and here too?
+ ++q; + c = c_tolower (*p); + d = c_tolower (*q);
and here
Have done
+ + result = strtoul(str, &end_ptr, 16); + + if ((end_ptr - str) < 1 || 2 < (end_ptr - str) || + (errno != 0) || + (0xFF < result))
That last check is impossible. Yes, I know it's just code motion, and the dead code was present in the original as well, but since we already did a length bound of at most two hex characters, we know that the result did not exceed 0xff.
Why are we even bothering with strtoul for a two-character conversion? This seems like it is more efficient when open-coded. But in the interest of pure code motion, I'd do any cleanups as a separate patch.
Interesting questions :-) Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

From: "Daniel P. Berrange" <berrange@redhat.com> The virEmitXMLWarning function should always have been in the xml.[hc] files, and should use virXML as its name prefix * src/util/util.c, src/util/util.h: Remove virEmitXMLWarning * src/util/xml.c, src/util/xml.h: Add virXMLEmitWarning --- src/util/util.c | 39 --------------------------------------- src/util/util.h | 4 ---- src/util/xml.c | 41 ++++++++++++++++++++++++++++++++++++++++- src/util/xml.h | 5 +++++ 4 files changed, 45 insertions(+), 44 deletions(-) diff --git a/src/util/util.c b/src/util/util.c index baa0f12..09062f6 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -2472,42 +2472,3 @@ bool virIsDevMapperDevice(const char *dev_name ATTRIBUTE_UNUSED) return false; } #endif - -int virEmitXMLWarning(int fd, - const char *name, - const char *cmd) { - size_t len; - const char *prologue = "<!--\n\ -WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE \n\ -OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:\n\ - virsh "; - const char *epilogue = "\n\ -or other application using the libvirt API.\n\ --->\n\n"; - - if (fd < 0 || !name || !cmd) { - errno = EINVAL; - return -1; - } - - len = strlen(prologue); - if (safewrite(fd, prologue, len) != len) - return -1; - - len = strlen(cmd); - if (safewrite(fd, cmd, len) != len) - return -1; - - if (safewrite(fd, " ", 1) != 1) - return -1; - - len = strlen(name); - if (safewrite(fd, name, len) != len) - return -1; - - len = strlen(epilogue); - if (safewrite(fd, epilogue, len) != len) - return -1; - - return 0; -} diff --git a/src/util/util.h b/src/util/util.h index 96491e5..f62cb42 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -238,8 +238,4 @@ int virBuildPathInternal(char **path, ...) ATTRIBUTE_SENTINEL; bool virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1); -int virEmitXMLWarning(int fd, - const char *name, - const char *cmd) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); - #endif /* __VIR_UTIL_H__ */ diff --git a/src/util/xml.c b/src/util/xml.c index 2909e85..b7fd06a 100644 --- a/src/util/xml.c +++ b/src/util/xml.c @@ -813,7 +813,7 @@ virXMLRewriteFile(int fd, void *opaque) struct virXMLRewritFileData *data = opaque; if (data->warnName && data->warnCommand) { - if (virEmitXMLWarning(fd, data->warnName, data->warnCommand) < 0) + if (virXMLEmitWarning(fd, data->warnName, data->warnCommand) < 0) return -1; } @@ -853,3 +853,42 @@ virXMLChildElementCount(xmlNodePtr node) } return ret; } + +int virXMLEmitWarning(int fd, + const char *name, + const char *cmd) { + size_t len; + const char *prologue = "<!--\n\ +WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE \n\ +OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:\n\ + virsh "; + const char *epilogue = "\n\ +or other application using the libvirt API.\n\ +-->\n\n"; + + if (fd < 0 || !name || !cmd) { + errno = EINVAL; + return -1; + } + + len = strlen(prologue); + if (safewrite(fd, prologue, len) != len) + return -1; + + len = strlen(cmd); + if (safewrite(fd, cmd, len) != len) + return -1; + + if (safewrite(fd, " ", 1) != 1) + return -1; + + len = strlen(name); + if (safewrite(fd, name, len) != len) + return -1; + + len = strlen(epilogue); + if (safewrite(fd, epilogue, len) != len) + return -1; + + return 0; +} diff --git a/src/util/xml.h b/src/util/xml.h index a3750fa..94a5cf4 100644 --- a/src/util/xml.h +++ b/src/util/xml.h @@ -144,4 +144,9 @@ int virXMLSaveFile(const char *path, const char *warnCommand, const char *xml); +int virXMLEmitWarning(int fd, + const char *name, + const char *cmd) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); + + #endif /* __VIR_XML_H__ */ -- 1.7.7.6

On 01/27/2012 10:37 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
The virEmitXMLWarning function should always have been in the xml.[hc] files, and should use virXML as its name prefix
* src/util/util.c, src/util/util.h: Remove virEmitXMLWarning * src/util/xml.c, src/util/xml.h: Add virXMLEmitWarning --- src/util/util.c | 39 --------------------------------------- src/util/util.h | 4 ---- src/util/xml.c | 41 ++++++++++++++++++++++++++++++++++++++++- src/util/xml.h | 5 +++++ 4 files changed, 45 insertions(+), 44 deletions(-)
Another mechanical move. ACK with the following changes. You forgot to also move the function declaration in libvirt_private.syms. And since no one outside of xml.c calls it, you might as well make it static and removing both the export in libvirt_private.syms, as well as:
+++ b/src/util/xml.c @@ -813,7 +813,7 @@ virXMLRewriteFile(int fd, void *opaque) struct virXMLRewritFileData *data = opaque;
if (data->warnName && data->warnCommand) { - if (virEmitXMLWarning(fd, data->warnName, data->warnCommand) < 0) + if (virXMLEmitWarning(fd, data->warnName, data->warnCommand) < 0) return -1; }
@@ -853,3 +853,42 @@ virXMLChildElementCount(xmlNodePtr node) } return ret; } + +int virXMLEmitWarning(int fd, + const char *name, + const char *cmd) {
either add a prototype or float this function to occur before its use when making it static, and
+++ b/src/util/xml.h @@ -144,4 +144,9 @@ int virXMLSaveFile(const char *path, const char *warnCommand, const char *xml);
+int virXMLEmitWarning(int fd, + const char *name, + const char *cmd) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); +
Drop this hunk, since no one else uses it. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Fri, Jan 27, 2012 at 10:56:27AM -0700, Eric Blake wrote:
On 01/27/2012 10:37 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
The virEmitXMLWarning function should always have been in the xml.[hc] files, and should use virXML as its name prefix
* src/util/util.c, src/util/util.h: Remove virEmitXMLWarning * src/util/xml.c, src/util/xml.h: Add virXMLEmitWarning --- src/util/util.c | 39 --------------------------------------- src/util/util.h | 4 ---- src/util/xml.c | 41 ++++++++++++++++++++++++++++++++++++++++- src/util/xml.h | 5 +++++ 4 files changed, 45 insertions(+), 44 deletions(-)
Another mechanical move. ACK with the following changes.
You forgot to also move the function declaration in libvirt_private.syms. And since no one outside of xml.c calls it, you might as well make it static and removing both the export in libvirt_private.syms, as well as:
Oh yes, good idea. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (2)
-
Daniel P. Berrange
-
Eric Blake