提交 0a583c26 编写于 作者: L Laine Stump

util: remove unused args from virNetDevSetVfConfig()

This function is only called in two places, and the ifindex,
nltarget_kernel, and getPidFunc args are never used (and never will
be).

ifindex - we always know the name of the device, and never know the
ifindex - if we really did need the ifindex we would have to get it
from the name using virNetDevGetIndex(). In practice, we just send -1
to virNetDevSetVfConfig(), which doesn't bother to learn the real
ifindex (you only need a name *or* an ifindex for the netlink command
to succeed, not both).

nltarget_kernel - messages to set the config of an SRIOV VF will
always go to netlink in the kernel, not to another user process, so
this arg is always true (there are other uses of netlink messages
where the message might need to go to another user process, but never
in the case of RTM_SETLINK for SRIOV).

getPidFunc - this arg is only used if nltarget_kernel is false, and it
never is.

None of this has any functional effect, it just makes it easier to
follow what's happening when virNetDevSetVfConfig() is called.
上级 176229dd
...@@ -1447,20 +1447,18 @@ static struct nla_policy ifla_vf_policy[IFLA_VF_MAX+1] = { ...@@ -1447,20 +1447,18 @@ static struct nla_policy ifla_vf_policy[IFLA_VF_MAX+1] = {
static int static int
virNetDevSetVfConfig(const char *ifname, int ifindex, int vf, virNetDevSetVfConfig(const char *ifname, int vf,
bool nltarget_kernel, const virMacAddr *macaddr, const virMacAddr *macaddr, int vlanid)
int vlanid, uint32_t (*getPidFunc)(void))
{ {
int rc = -1; int rc = -1;
struct nlmsghdr *resp = NULL; struct nlmsghdr *resp = NULL;
struct nlmsgerr *err; struct nlmsgerr *err;
unsigned int recvbuflen = 0; unsigned int recvbuflen = 0;
uint32_t pid = 0;
struct nl_msg *nl_msg; struct nl_msg *nl_msg;
struct nlattr *vfinfolist, *vfinfo; struct nlattr *vfinfolist, *vfinfo;
struct ifinfomsg ifinfo = { struct ifinfomsg ifinfo = {
.ifi_family = AF_UNSPEC, .ifi_family = AF_UNSPEC,
.ifi_index = ifindex .ifi_index = -1,
}; };
if (!macaddr && vlanid < 0) if (!macaddr && vlanid < 0)
...@@ -1514,15 +1512,7 @@ virNetDevSetVfConfig(const char *ifname, int ifindex, int vf, ...@@ -1514,15 +1512,7 @@ virNetDevSetVfConfig(const char *ifname, int ifindex, int vf,
nla_nest_end(nl_msg, vfinfo); nla_nest_end(nl_msg, vfinfo);
nla_nest_end(nl_msg, vfinfolist); nla_nest_end(nl_msg, vfinfolist);
if (!nltarget_kernel) { if (virNetlinkCommand(nl_msg, &resp, &recvbuflen, 0, 0,
pid = getPidFunc();
if (pid == 0) {
rc = -1;
goto cleanup;
}
}
if (virNetlinkCommand(nl_msg, &resp, &recvbuflen, 0, pid,
NETLINK_ROUTE, 0) < 0) NETLINK_ROUTE, 0) < 0)
goto cleanup; goto cleanup;
...@@ -1540,13 +1530,13 @@ virNetDevSetVfConfig(const char *ifname, int ifindex, int vf, ...@@ -1540,13 +1530,13 @@ virNetDevSetVfConfig(const char *ifname, int ifindex, int vf,
virReportSystemError(-err->error, virReportSystemError(-err->error,
_("Cannot set interface MAC/vlanid to %s/%d " _("Cannot set interface MAC/vlanid to %s/%d "
"for ifname %s ifindex %d vf %d"), "for ifname %s vf %d"),
(macaddr (macaddr
? virMacAddrFormat(macaddr, macstr) ? virMacAddrFormat(macaddr, macstr)
: "(unchanged)"), : "(unchanged)"),
vlanid, vlanid,
ifname ? ifname : "(unspecified)", ifname ? ifname : "(unspecified)",
ifindex, vf); vf);
goto cleanup; goto cleanup;
} }
break; break;
...@@ -1662,7 +1652,6 @@ virNetDevReplaceVfConfig(const char *pflinkdev, int vf, ...@@ -1662,7 +1652,6 @@ virNetDevReplaceVfConfig(const char *pflinkdev, int vf,
char *path = NULL; char *path = NULL;
char macstr[VIR_MAC_STRING_BUFLEN]; char macstr[VIR_MAC_STRING_BUFLEN];
char *fileData = NULL; char *fileData = NULL;
int ifindex = -1;
bool pfIsOnline; bool pfIsOnline;
/* Assure that PF is online prior to twiddling with the VF. It /* Assure that PF is online prior to twiddling with the VF. It
...@@ -1702,8 +1691,7 @@ virNetDevReplaceVfConfig(const char *pflinkdev, int vf, ...@@ -1702,8 +1691,7 @@ virNetDevReplaceVfConfig(const char *pflinkdev, int vf,
goto cleanup; goto cleanup;
} }
ret = virNetDevSetVfConfig(pflinkdev, ifindex, vf, true, ret = virNetDevSetVfConfig(pflinkdev, vf, macaddress, vlanid);
macaddress, vlanid, NULL);
cleanup: cleanup:
VIR_FREE(path); VIR_FREE(path);
...@@ -1722,7 +1710,6 @@ virNetDevRestoreVfConfig(const char *pflinkdev, ...@@ -1722,7 +1710,6 @@ virNetDevRestoreVfConfig(const char *pflinkdev,
char *vlan = NULL; char *vlan = NULL;
virMacAddr oldmac; virMacAddr oldmac;
int vlanid = -1; int vlanid = -1;
int ifindex = -1;
if (virAsprintf(&path, "%s/%s_vf%d", if (virAsprintf(&path, "%s/%s_vf%d",
stateDir, pflinkdev, vf) < 0) stateDir, pflinkdev, vf) < 0)
...@@ -1765,8 +1752,7 @@ virNetDevRestoreVfConfig(const char *pflinkdev, ...@@ -1765,8 +1752,7 @@ virNetDevRestoreVfConfig(const char *pflinkdev,
} }
/*reset mac and remove file-ignore results*/ /*reset mac and remove file-ignore results*/
rc = virNetDevSetVfConfig(pflinkdev, ifindex, vf, true, rc = virNetDevSetVfConfig(pflinkdev, vf, &oldmac, vlanid);
&oldmac, vlanid, NULL);
ignore_value(unlink(path)); ignore_value(unlink(path));
cleanup: cleanup:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册