1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

util: report the MAC address that couldn't be set

I noticed in a log file that we had failed to set a MAC address. The
log said which interface we were trying to set, but didn't give the
offending MAC address, which could have been useful in determining the
source of the problem. This patch modifies all three places in the
code that set MAC addresses to report the failed MAC as well as
interface.
This commit is contained in:
Laine Stump 2015-12-18 12:08:54 -05:00
parent 688623b5b0
commit 5ffa236bb4

View File

@ -256,9 +256,11 @@ int virNetDevSetMAC(const char *ifname,
virMacAddrGetRaw(macaddr, (unsigned char *)ifr.ifr_hwaddr.sa_data);
if (ioctl(fd, SIOCSIFHWADDR, &ifr) < 0) {
char macstr[VIR_MAC_STRING_BUFLEN];
virReportSystemError(errno,
_("Cannot set interface MAC on '%s'"),
ifname);
_("Cannot set interface MAC to %s on '%s'"),
virMacAddrFormat(macaddr, macstr), ifname);
goto cleanup;
}
@ -291,8 +293,8 @@ int virNetDevSetMAC(const char *ifname,
if (ioctl(s, SIOCSIFLLADDR, &ifr) < 0) {
virReportSystemError(errno,
_("Cannot set interface MAC on '%s'"),
ifname);
_("Cannot set interface MAC to %s on '%s'"),
mac + 1, ifname);
goto cleanup;
}
@ -2270,10 +2272,17 @@ virNetDevSetVfConfig(const char *ifname, int ifindex, int vf,
goto malformed_resp;
if (err->error) {
char macstr[VIR_MAC_STRING_BUFLEN];
virReportSystemError(-err->error,
_("error during set %s of ifindex %d"),
(macaddr ? (vlanid >= 0 ? "mac/vlan" : "mac") : "vlanid"),
ifindex);
_("Cannot set interface MAC/vlanid to %s/%d "
"for ifname %s ifindex %d vf %d"),
(macaddr
? virMacAddrFormat(macaddr, macstr)
: "(unchanged)"),
vlanid,
ifname ? ifname : "(unspecified)",
ifindex, vf);
goto cleanup;
}
break;