[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] libxl: add LIBXL_MAC_{FMT, FMTLEN, BYTES}



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1310646259 -3600
# Node ID fbb448cf5cba5f441ad94f7783a0a1394fd638f9
# Parent  7bac2b0e16dd48eb5410f201f34bf66f850f2b4b
libxl: add LIBXL_MAC_{FMT,FMTLEN,BYTES}

Modelled after LIBXL_UUID_... (where I also add FMTLEN).

signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
---


diff -r 7bac2b0e16dd -r fbb448cf5cba tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Thu Jul 14 13:24:11 2011 +0100
+++ b/tools/libxl/libxl.c       Thu Jul 14 13:24:19 2011 +0100
@@ -1215,9 +1215,8 @@
                                           nic->script));
     }
     flexarray_append(back, "mac");
-    flexarray_append(back, libxl__sprintf(&gc, "%02x:%02x:%02x:%02x:%02x:%02x",
-                                                 nic->mac[0], nic->mac[1], 
nic->mac[2],
-                                                 nic->mac[3], nic->mac[4], 
nic->mac[5]));
+    flexarray_append(back,libxl__sprintf(&gc,
+                                    LIBXL_MAC_FMT, LIBXL_MAC_BYTES(nic->mac)));
     if (nic->ip) {
         flexarray_append(back, "ip");
         flexarray_append(back, libxl__strdup(&gc, nic->ip));
@@ -1235,9 +1234,8 @@
     flexarray_append(front, "handle");
     flexarray_append(front, libxl__sprintf(&gc, "%d", nic->devid));
     flexarray_append(front, "mac");
-    flexarray_append(front, libxl__sprintf(&gc, 
"%02x:%02x:%02x:%02x:%02x:%02x",
-                                                  nic->mac[0], nic->mac[1], 
nic->mac[2],
-                                                  nic->mac[3], nic->mac[4], 
nic->mac[5]));
+    flexarray_append(front, libxl__sprintf(&gc,
+                                    LIBXL_MAC_FMT, LIBXL_MAC_BYTES(nic->mac)));
     libxl__device_generic_add(&gc, &device,
                              libxl__xs_kvs_of_flexarray(&gc, back, 
back->count),
                              libxl__xs_kvs_of_flexarray(&gc, front, 
front->count));
diff -r 7bac2b0e16dd -r fbb448cf5cba tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Thu Jul 14 13:24:11 2011 +0100
+++ b/tools/libxl/libxl.h       Thu Jul 14 13:24:19 2011 +0100
@@ -139,6 +139,9 @@
 #include <libxl_uuid.h>
 
 typedef uint8_t libxl_mac[6];
+#define LIBXL_MAC_FMT "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx"
+#define LIBXL_MAC_FMTLEN ((2*6)+5) /* 6 hex bytes plus 5 colons */
+#define LIBXL_MAC_BYTES(mac) mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
 
 typedef char **libxl_string_list;
 void libxl_string_list_destroy(libxl_string_list *sl);
diff -r 7bac2b0e16dd -r fbb448cf5cba tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c    Thu Jul 14 13:24:11 2011 +0100
+++ b/tools/libxl/libxl_dm.c    Thu Jul 14 13:24:19 2011 +0100
@@ -173,9 +173,8 @@
         }
         for (i = 0; i < num_vifs; i++) {
             if (vifs[i].nictype == LIBXL_NIC_TYPE_IOEMU) {
-                char *smac = libxl__sprintf(gc, 
"%02x:%02x:%02x:%02x:%02x:%02x",
-                                           vifs[i].mac[0], vifs[i].mac[1], 
vifs[i].mac[2],
-                                           vifs[i].mac[3], vifs[i].mac[4], 
vifs[i].mac[5]);
+                char *smac = libxl__sprintf(gc,
+                                   LIBXL_MAC_FMT, 
LIBXL_MAC_BYTES(vifs[i].mac));
                 char *ifname;
                 if (!vifs[i].ifname)
                     ifname = libxl__sprintf(gc, "tap%d.%d", info->domid, 
vifs[i].devid);
@@ -364,9 +363,8 @@
         }
         for (i = 0; i < num_vifs; i++) {
             if (vifs[i].nictype == LIBXL_NIC_TYPE_IOEMU) {
-                char *smac = libxl__sprintf(gc, 
"%02x:%02x:%02x:%02x:%02x:%02x",
-                                           vifs[i].mac[0], vifs[i].mac[1], 
vifs[i].mac[2],
-                                           vifs[i].mac[3], vifs[i].mac[4], 
vifs[i].mac[5]);
+                char *smac = libxl__sprintf(gc,
+                                LIBXL_MAC_FMT, LIBXL_MAC_BYTES(vifs[i].mac));
                 char *ifname;
                 if (!vifs[i].ifname) {
                     ifname = libxl__sprintf(gc, "tap%d.%d", info->domid, 
vifs[i].devid);
diff -r 7bac2b0e16dd -r fbb448cf5cba tools/libxl/libxl_uuid.h
--- a/tools/libxl/libxl_uuid.h  Thu Jul 14 13:24:11 2011 +0100
+++ b/tools/libxl/libxl_uuid.h  Thu Jul 14 13:24:19 2011 +0100
@@ -16,6 +16,7 @@
 #define __LIBXL_UUID_H__
 
 #define LIBXL_UUID_FMT 
"%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
+#define LIBXL_UUID_FMTLEN ((2*16)+4) /* 16 hex bytes plus 4 hypens */
 #define LIBXL__UUID_BYTES(uuid) uuid[0], uuid[1], uuid[2], uuid[3], \
                                 uuid[4], uuid[5], uuid[6], uuid[7], \
                                 uuid[8], uuid[9], uuid[10], uuid[11], \
diff -r 7bac2b0e16dd -r fbb448cf5cba tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Thu Jul 14 13:24:11 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Thu Jul 14 13:24:19 2011 +0100
@@ -3989,9 +3989,7 @@
             /* Idx BE */
             printf("%-3d %-2d ", nics[i].devid, nics[i].backend_id);
             /* MAC */
-            printf("%02x:%02x:%02x:%02x:%02x:%02x ",
-                   nics[i].mac[0], nics[i].mac[1], nics[i].mac[2],
-                   nics[i].mac[3], nics[i].mac[4], nics[i].mac[5]);
+            printf(LIBXL_MAC_FMT, LIBXL_MAC_BYTES(nics[i].mac));
             /* Hdl  Sta  evch txr/rxr  BE-path */
             printf("%6d %5d %6d %5d/%-11d %-30s\n",
                    nics[i].devid, nics[i].state, nics[i].evtch,

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.