]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: report the MAC address that couldn't be set
authorLaine Stump <laine@laine.org>
Fri, 18 Dec 2015 17:08:54 +0000 (12:08 -0500)
committerLaine Stump <laine@laine.org>
Mon, 4 Jan 2016 19:46:39 +0000 (14:46 -0500)
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

index 6f3e68170bf948c25bd67d430b51b25574ead212..ea955524fdef6297dc32e8b20af588986c3522cd 100644 (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;