The global functions virNetDevReplaceMacAddress(),
virNetDevReplaceNetConfig(), virNetDevRestoreMacAddress(), and
virNetDevRestoreNetConfig() are no longer used, as their functionality
has been replaced by virNetDev(Save|Read|Set)NetConfig().
The static functions virNetDevReplaceVfConfig() and
virNetDevRestoreVfConfig() were only used by the above-named global
functions that were removed.
---
src/libvirt_private.syms | 4 -
src/util/virnetdev.c | 332 -----------------------------------------------
src/util/virnetdev.h | 9 --
3 files changed, 345 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 7e9334a..69f38c7 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2012,10 +2012,6 @@ virNetDevIfStateTypeToString;
virNetDevIsVirtualFunction;
virNetDevPFGetVF;
virNetDevReadNetConfig;
-virNetDevReplaceMacAddress;
-virNetDevReplaceNetConfig;
-virNetDevRestoreMacAddress;
-virNetDevRestoreNetConfig;
virNetDevRunEthernetScript;
virNetDevRxFilterFree;
virNetDevRxFilterModeTypeFromString;
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index c2d7a2f..6dafc87 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -391,92 +391,6 @@ int virNetDevGetMAC(const char *ifname,
#endif
-/**
- * virNetDevReplaceMacAddress:
- * @macaddress: new MAC address for interface
- * @linkdev: name of interface
- * @stateDir: directory to store old MAC address
- *
- * Returns 0 on success, -1 on failure
- *
- */
-int
-virNetDevReplaceMacAddress(const char *linkdev,
- const virMacAddr *macaddress,
- const char *stateDir)
-{
- virMacAddr oldmac;
- char *path = NULL;
- char macstr[VIR_MAC_STRING_BUFLEN];
- int ret = -1;
-
- if (virNetDevGetMAC(linkdev, &oldmac) < 0)
- return -1;
-
- if (virAsprintf(&path, "%s/%s",
- stateDir,
- linkdev) < 0)
- return -1;
- virMacAddrFormat(&oldmac, macstr);
- if (virFileWriteStr(path, macstr, O_CREAT|O_TRUNC|O_WRONLY) < 0) {
- virReportSystemError(errno, _("Unable to preserve mac for %s"),
- linkdev);
- goto cleanup;
- }
-
- if (virNetDevSetMAC(linkdev, macaddress) < 0)
- goto cleanup;
-
- ret = 0;
- cleanup:
- VIR_FREE(path);
- return ret;
-}
-
-/**
- * virNetDevRestoreMacAddress:
- * @linkdev: name of interface
- * @stateDir: directory containing old MAC address
- *
- * Returns 0 on success, -errno on failure.
- *
- */
-int
-virNetDevRestoreMacAddress(const char *linkdev,
- const char *stateDir)
-{
- int rc = -1;
- char *oldmacname = NULL;
- char *macstr = NULL;
- char *path = NULL;
- virMacAddr oldmac;
-
- if (virAsprintf(&path, "%s/%s",
- stateDir,
- linkdev) < 0)
- return -1;
-
- if (virFileReadAll(path, VIR_MAC_STRING_BUFLEN, &macstr) < 0)
- goto cleanup;
-
- if (virMacAddrParse(macstr, &oldmac) != 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Cannot parse MAC address from '%s'"),
- oldmacname);
- goto cleanup;
- }
-
- /*reset mac and remove file-ignore results*/
- rc = virNetDevSetMAC(linkdev, &oldmac);
- ignore_value(unlink(path));
-
- cleanup:
- VIR_FREE(macstr);
- VIR_FREE(path);
- return rc;
-}
-
-
#if defined(SIOCGIFMTU) && defined(HAVE_STRUCT_IFREQ)
/**
* virNetDevGetMTU:
@@ -1748,229 +1662,6 @@ virNetDevGetVfConfig(const char *ifname, int vf, virMacAddrPtr
mac,
return rc;
}
-static int
-virNetDevReplaceVfConfig(const char *pflinkdev, int vf,
- const virMacAddr *macaddress,
- int vlanid,
- const char *stateDir)
-{
- int ret = -1;
- virMacAddr oldmac;
- int oldvlanid = -1;
- char *path = NULL;
- char macstr[VIR_MAC_STRING_BUFLEN];
- char *fileData = NULL;
- bool pfIsOnline;
-
- /* Assure that PF is online prior to twiddling with the VF. It
- * *should* be, but if the PF isn't online the changes made to the
- * VF via the PF won't take effect, yet there will be no error
- * reported. In the case that it isn't online, fail and report the
- * error, since setting an unconfigured interface online
- * automatically turns on IPv6 autoconfig, which may not be what
- * the admin expects, so we want them to explicitly enable the PF
- * in the host system network config.
- */
- if (virNetDevGetOnline(pflinkdev, &pfIsOnline) < 0)
- goto cleanup;
- if (!pfIsOnline) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to configure VF %d of PF '%s' "
- "because the PF is not online. Please "
- "change host network config to put the "
- "PF online."),
- vf, pflinkdev);
- goto cleanup;
- }
-
- if (virNetDevGetVfConfig(pflinkdev, vf, &oldmac, &oldvlanid) < 0)
- goto cleanup;
-
- if (virAsprintf(&path, "%s/%s_vf%d",
- stateDir, pflinkdev, vf) < 0)
- goto cleanup;
-
- if (virAsprintf(&fileData, "%s\n%d\n",
- virMacAddrFormat(&oldmac, macstr), oldvlanid) < 0)
- goto cleanup;
- if (virFileWriteStr(path, fileData, O_CREAT|O_TRUNC|O_WRONLY) < 0) {
- virReportSystemError(errno, _("Unable to preserve mac/vlan tag "
- "for pf = %s, vf = %d"), pflinkdev, vf);
- goto cleanup;
- }
-
- ret = virNetDevSetVfConfig(pflinkdev, vf, macaddress, vlanid);
-
- cleanup:
- VIR_FREE(path);
- VIR_FREE(fileData);
- return ret;
-}
-
-static int
-virNetDevRestoreVfConfig(const char *pflinkdev,
- int vf, const char *vflinkdev,
- const char *stateDir)
-{
- int rc = -1;
- char *path = NULL;
- char *fileData = NULL;
- char *vlan = NULL;
- virMacAddr oldmac;
- int vlanid = -1;
-
- if (virAsprintf(&path, "%s/%s_vf%d",
- stateDir, pflinkdev, vf) < 0)
- return rc;
-
- if (vflinkdev && !virFileExists(path)) {
- /* this VF's config may have been stored with
- * virNetDevReplaceMacAddress while running an older version
- * of libvirt. If so, the ${pf}_vf${id} file won't exist. In
- * that case, try to restore using the older method with the
- * VF's name directly.
- */
- rc = virNetDevRestoreMacAddress(vflinkdev, stateDir);
- goto cleanup;
- }
-
- if (virFileReadAll(path, 128, &fileData) < 0)
- goto cleanup;
-
- if ((vlan = strchr(fileData, '\n'))) {
- char *endptr;
-
- *vlan++ = 0; /* NULL terminate the mac address */
- if (*vlan) {
- if ((virStrToLong_i(vlan, &endptr, 10, &vlanid) < 0) ||
- (endptr && *endptr != '\n' && *endptr != 0)) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Cannot parse vlan tag from '%s'"),
- vlan);
- goto cleanup;
- }
- }
- }
-
- if (virMacAddrParse(fileData, &oldmac) != 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Cannot parse MAC address from '%s'"),
- fileData);
- goto cleanup;
- }
-
- /*reset mac and remove file-ignore results*/
- rc = virNetDevSetVfConfig(pflinkdev, vf, &oldmac, vlanid);
- ignore_value(unlink(path));
-
- cleanup:
- VIR_FREE(path);
- VIR_FREE(fileData);
-
- return rc;
-}
-
-/**
- * virNetDevReplaceNetConfig:
- * @linkdev: name of the interface
- * @vf: vf index if linkdev is a pf
- * @macaddress: new MAC address for interface
- * @vlanid: new vlanid
- * @stateDir: directory to store old net config
- *
- * Returns 0 on success, -1 on failure
- *
- */
-int
-virNetDevReplaceNetConfig(const char *linkdev, int vf,
- const virMacAddr *macaddress,
- virNetDevVlanPtr vlan,
- const char *stateDir)
-{
- int ret = -1;
- char *pfdevname = NULL;
-
- if (vf == -1 && virNetDevIsVirtualFunction(linkdev) == 1) {
- /* If this really *is* a VF and the caller just didn't know
- * it, we should set the MAC address via PF+vf# instead of
- * setting directly via VF, because the latter will be
- * rejected any time after the former has been done.
- */
- if (virNetDevGetPhysicalFunction(linkdev, &pfdevname) < 0)
- goto cleanup;
- if (virNetDevGetVirtualFunctionIndex(pfdevname, linkdev, &vf) < 0)
- goto cleanup;
- linkdev = pfdevname;
- }
-
- if (vf == -1) {
- if (vlan) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("vlan can only be set for SR-IOV VFs, but "
- "%s is not a VF"), linkdev);
- goto cleanup;
- }
- ret = virNetDevReplaceMacAddress(linkdev, macaddress, stateDir);
- } else {
- int vlanid = 0; /* assure any current vlan tag is reset */
-
- if (vlan) {
- if (vlan->nTags != 1 || vlan->trunk) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("vlan trunking is not supported "
- "by SR-IOV network devices"));
- goto cleanup;
- }
- vlanid = vlan->tag[0];
- }
- ret = virNetDevReplaceVfConfig(linkdev, vf, macaddress, vlanid,
- stateDir);
- }
-
- cleanup:
- VIR_FREE(pfdevname);
- return ret;
-}
-
-/**
- * virNetDevRestoreNetConfig:
- * @linkdev: name of the interface
- * @vf: vf index if linkdev is a pf
- * @stateDir: directory containing old net config
- *
- * Returns 0 on success, -errno on failure.
- *
- */
-int
-virNetDevRestoreNetConfig(const char *linkdev, int vf, const char *stateDir)
-{
- int ret = -1;
- char *pfdevname = NULL;
- const char *vfdevname = NULL;
-
- if (vf == -1 && virNetDevIsVirtualFunction(linkdev) == 1) {
- /* If this really *is* a VF and the caller just didn't know
- * it, we should set the MAC address via PF+vf# instead of
- * setting directly via VF, because the latter will be
- * rejected any time after the former has been done.
- */
- if (virNetDevGetPhysicalFunction(linkdev, &pfdevname) < 0)
- goto cleanup;
- if (virNetDevGetVirtualFunctionIndex(pfdevname, linkdev, &vf) < 0)
- goto cleanup;
- vfdevname = linkdev;
- linkdev = pfdevname;
- }
-
- if (vf == -1)
- ret = virNetDevRestoreMacAddress(linkdev, stateDir);
- else
- ret = virNetDevRestoreVfConfig(linkdev, vf, vfdevname, stateDir);
-
- cleanup:
- VIR_FREE(pfdevname);
- return ret;
-}
# define VIR_NETDEV_KEYNAME_ADMIN_MAC "adminMac"
# define VIR_NETDEV_KEYNAME_VLAN_TAG "vlanTag"
@@ -2518,29 +2209,6 @@ virNetDevSetNetConfig(const char *linkdev, int vf,
#else /* defined(__linux__) && defined(HAVE_LIBNL) &&
defined(IFLA_VF_MAX) */
-int
-virNetDevReplaceNetConfig(const char *linkdev ATTRIBUTE_UNUSED,
- int vf ATTRIBUTE_UNUSED,
- const virMacAddr *macaddress ATTRIBUTE_UNUSED,
- virNetDevVlanPtr vlan ATTRIBUTE_UNUSED,
- const char *stateDir ATTRIBUTE_UNUSED)
-{
- virReportSystemError(ENOSYS, "%s",
- _("Unable to replace net config on this platform"));
- return -1;
-
-}
-
-int
-virNetDevRestoreNetConfig(const char *linkdev ATTRIBUTE_UNUSED,
- int vf ATTRIBUTE_UNUSED,
- const char *stateDir ATTRIBUTE_UNUSED)
-{
- virReportSystemError(ENOSYS, "%s",
- _("Unable to restore net config on this platform"));
- return -1;
-}
-
int
virNetDevSaveNetConfig(const char *linkdev ATTRIBUTE_UNUSED,
diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
index 00f94b7..437a776 100644
--- a/src/util/virnetdev.h
+++ b/src/util/virnetdev.h
@@ -216,15 +216,6 @@ virNetDevSetNetConfig(const char *linkdev, int vf,
bool setVLan)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
-int virNetDevReplaceNetConfig(const char *linkdev, int vf,
- const virMacAddr *macaddress,
- virNetDevVlanPtr vlan,
- const char *stateDir)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(5);
-
-int virNetDevRestoreNetConfig(const char *linkdev, int vf, const char *stateDir)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
-
int virNetDevGetVirtualFunctionInfo(const char *vfname, char **pfname,
int *vf)
ATTRIBUTE_NONNULL(1);
--
2.9.3