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. --- src/util/virnetdev.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 6f3e681..ea95552 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -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; -- 2.5.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list