Having this information available will make it easier to determine the
culprit when MAC or vlan tag appear to not be set, eg.:
https://bugzilla.redhat.com/1364073
(This patch doesn't fix that bug, just makes it easier to diagnose)
---
src/util/virnetdev.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 664a75d..86ae0d1 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -240,6 +240,7 @@ virNetDevSetMACInternal(const char *ifname,
int fd = -1;
int ret = -1;
struct ifreq ifr;
+ char macstr[VIR_MAC_STRING_BUFLEN];
if ((fd = virNetDevSetupControl(ifname, &ifr)) < 0)
return -1;
@@ -255,7 +256,6 @@ virNetDevSetMACInternal(const char *ifname,
virMacAddrGetRaw(macaddr, (unsigned char *)ifr.ifr_hwaddr.sa_data);
if (ioctl(fd, SIOCSIFHWADDR, &ifr) < 0) {
- char macstr[VIR_MAC_STRING_BUFLEN];
if (quiet && errno == EADDRNOTAVAIL)
goto cleanup;
@@ -269,6 +269,10 @@ virNetDevSetMACInternal(const char *ifname,
ret = 0;
cleanup:
+ VIR_DEBUG("SIOCSIFHWADDR %s MAC=%s - %s",
+ ifname, virMacAddrFormat(macaddr, macstr),
+ ret < 0 ? "Fail" : "Success");
+
VIR_FORCE_CLOSE(fd);
return ret;
}
@@ -311,6 +315,9 @@ virNetDevSetMACInternal(const char *ifname,
ret = 0;
cleanup:
+ VIR_DEBUG("SIOCSIFLLADDR %s MAC=%s - %s", ifname, mac + 1),
+ ret < 0 ? "Fail" : "Success");
+
VIR_FORCE_CLOSE(s);
return ret;
@@ -1435,6 +1442,7 @@ virNetDevSetVfConfig(const char *ifname, int vf,
bool *allowRetry)
{
int rc = -1;
+ char macstr[VIR_MAC_STRING_BUFLEN];
struct nlmsghdr *resp = NULL;
struct nlmsgerr *err;
unsigned int recvbuflen = 0;
@@ -1518,8 +1526,6 @@ virNetDevSetVfConfig(const char *ifname, int vf,
goto cleanup;
} else if (err->error) {
/* other errors are permanent */
- char macstr[VIR_MAC_STRING_BUFLEN];
-
virReportSystemError(-err->error,
_("Cannot set interface MAC/vlanid to %s/%d "
"for ifname %s vf %d"),
@@ -1543,6 +1549,11 @@ virNetDevSetVfConfig(const char *ifname, int vf,
rc = 0;
cleanup:
+ VIR_DEBUG("RTM_SETLINK %s vf %d MAC=%s vlanid=%d - %s",
+ ifname, vf,
+ macaddr ? virMacAddrFormat(macaddr, macstr) : "(unchanged)",
+ vlanid, rc < 0 ? "Fail" : "Success");
+
nlmsg_free(nl_msg);
VIR_FREE(resp);
return rc;
--
2.9.3