ia64/xen-unstable

changeset 4226:720d41954256

bitkeeper revision 1.1236.1.93 (423d82c8btqnwP7LAh0nPWlLBJA1_w)

This patch will cause xcsdump to display more verbose information about the
xcs traffic.

This includes human-readable names of the message type and subtype and
all of the parameters and their values. It's against today's
xen-unstable and has been tested against a number of xen-unstable
snapshots going back a few weeks (one line has to be removed to support
older versions of xen-unstable).

The message types displayed are configurable via a bitmask passed as a
'-v' option in xcsdump.

The code is very useful for figuring out what management tools (Xend,
VM-Tools) are actually doing. I would not have been able to write
vm-tools without it.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: ian@xensource.com
author iap10@firebug.cl.cam.ac.uk
date Sun Mar 20 14:03:52 2005 +0000 (2005-03-20)
parents e23288ce8c14
children 697ebfe04406
files .rootkeys tools/xcs/Makefile tools/xcs/dump.c tools/xcs/dump.h tools/xcs/xcsdump.c
line diff
     1.1 --- a/.rootkeys	Sun Mar 20 11:53:26 2005 +0000
     1.2 +++ b/.rootkeys	Sun Mar 20 14:03:52 2005 +0000
     1.3 @@ -865,6 +865,8 @@ 41d58ba63w1WfBmd6Cr_18nhLNv7PA tools/xcs
     1.4  41d58ba6NxgkfzD_rmsGjgd_zJ3H_w tools/xcs/bindings.c
     1.5  41d58ba6I2umi60mShq4Pl0RDg7lzQ tools/xcs/connection.c
     1.6  41d58ba6YyYu53bFuoIAw9hNNmneEg tools/xcs/ctrl_interface.c
     1.7 +423d82c7ZKf2bDOxRcR4Nc1kN5StNQ tools/xcs/dump.c
     1.8 +423d82c7U__LHy9dvkUNUvSIhOqnBQ tools/xcs/dump.h
     1.9  41d58ba6Ru9ZbhTjgYX_oiszSIwCww tools/xcs/evtchn.c
    1.10  41d58ba6x9KO1CQBT7kKOKq_pJYC3g tools/xcs/xcs.c
    1.11  41d58ba6R6foSMtSFEcu-yxWFrT8VQ tools/xcs/xcs.h
     2.1 --- a/tools/xcs/Makefile	Sun Mar 20 11:53:26 2005 +0000
     2.2 +++ b/tools/xcs/Makefile	Sun Mar 20 14:03:52 2005 +0000
     2.3 @@ -33,9 +33,9 @@ all: $(BIN) xcsdump
     2.4  clean:
     2.5  	$(RM) *.a *.so *.o *.rpm $(BIN) xcsdump
     2.6  
     2.7 -xcsdump: xcsdump.c
     2.8 +xcsdump: xcsdump.c dump.c
     2.9  	$(CC) $(CFLAGS) -o xcsdump xcsdump.c -L$(XEN_LIBXC) -L$(XEN_LIBXUTIL) \
    2.10 -              ctrl_interface.c evtchn.c  -lxc -lxutil
    2.11 +              ctrl_interface.c evtchn.c dump.c -lxc -lxutil
    2.12  
    2.13  $(BIN): $(OBJS)
    2.14  	$(CC) $(CFLAGS) $^ -o $@ -L$(XEN_LIBXC) -L$(XEN_LIBXUTIL) -lxc -lxutil 
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tools/xcs/dump.c	Sun Mar 20 14:03:52 2005 +0000
     3.3 @@ -0,0 +1,526 @@
     3.4 +/*\
     3.5 + *  Copyright (C) International Business Machines  Corp., 2005
     3.6 + *  Author(s): Anthony Liguori <aliguori@us.ibm.com>
     3.7 + *
     3.8 + *  This program is free software; you can redistribute it and/or modify
     3.9 + *  it under the terms of the GNU General Public License as published by
    3.10 + *  the Free Software Foundation; under version 2 of the License.
    3.11 + * 
    3.12 + *  This program is distributed in the hope that it will be useful,
    3.13 + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.14 + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.15 + *  GNU General Public License for more details.
    3.16 + * 
    3.17 + *  You should have received a copy of the GNU General Public License
    3.18 + *  along with this program; if not, write to the Free Software
    3.19 + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    3.20 +\*/
    3.21 +
    3.22 +#include <stdio.h>
    3.23 +#include <stdarg.h>
    3.24 +
    3.25 +#include "dump.h"
    3.26 +
    3.27 +#define str(a) # a
    3.28 +#define error(a, ...) do { \
    3.29 + _error("%s:%s():L%d: " a, __FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__);\
    3.30 +  exit(1); \
    3.31 +} while (0)
    3.32 +#define warn(a, ...) do { \
    3.33 + _error("%s:%s():L%d: " a, __FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__);\
    3.34 +} while (0)
    3.35 +#define debug(a, ...) do { \
    3.36 + _error(a, ## __VA_ARGS__);\
    3.37 +} while (0)
    3.38 +
    3.39 +void _error(const char *fmt, ...);
    3.40 +
    3.41 +#define debug_begin(a, b) debug("CMSG_" a "_" b " {")
    3.42 +#define debug_end(a, b) debug("}")
    3.43 +#define debug_field(a, b, c) debug("\t." str(b) " = " c, a->b)
    3.44 +#define debug_field_mac(a, b) \
    3.45 +  debug("\t." str(b) " = %.2x:%.2x:%.2x:%.2x:%.2x:%.2x", \
    3.46 +        a->b[0], a->b[1], a->b[2], a->b[3], a->b[4], a->b[5])
    3.47 +
    3.48 +#define debug_dump(a, b, c) debug_hex("\t." str(b) " = ", a->b, a->c)
    3.49 +
    3.50 +#include <stdint.h>
    3.51 +#include <string.h>
    3.52 +#include <stdio.h>
    3.53 +#include <ctype.h>
    3.54 +
    3.55 +static int strcount(const char *str, char ch)
    3.56 +{
    3.57 +	int i;
    3.58 +	int count = 0;
    3.59 +
    3.60 +	for (i = 0; str[i]; i++) {
    3.61 +		if (str[i] == ch) {
    3.62 +			count++;
    3.63 +		}
    3.64 +	}
    3.65 +
    3.66 +	return count;
    3.67 +}
    3.68 +
    3.69 +void debug_hex(const char *info, const uint8_t *data, size_t length)
    3.70 +{
    3.71 +	int indent = strlen(info) + (strcount(info, '\t') * 8 - 1);
    3.72 +	int words_per_row = (2 * (80 - indent - 2) / 7) & ~1;
    3.73 +	size_t i;
    3.74 +
    3.75 +	for (i = 0; i < length; i += words_per_row) {
    3.76 +		size_t ind;
    3.77 +
    3.78 +		if (i == 0) {
    3.79 +			fprintf(stderr, "%s", info);
    3.80 +		} else {
    3.81 +			int j;
    3.82 +			for (j = 0; j < indent; j++) {
    3.83 +				fprintf(stderr, " ");
    3.84 +			}
    3.85 +		}
    3.86 +
    3.87 +		for (ind = 0; ind < words_per_row; ind++) {
    3.88 +			if (ind % 2 == 0) {
    3.89 +				fprintf(stderr, " ");
    3.90 +			}
    3.91 +
    3.92 +			if (i + ind < length) {
    3.93 +				fprintf(stderr, "%.2X", data[i + ind]);
    3.94 +			} else {
    3.95 +				fprintf(stderr, "  ");
    3.96 +			}
    3.97 +		}
    3.98 +
    3.99 +		fprintf(stderr, " ");
   3.100 +
   3.101 +		for (ind = 0; ind < words_per_row; ind++) {
   3.102 +			if (i + ind < length) {
   3.103 +				if (isprint(data[i + ind])) {
   3.104 +					fprintf(stderr, "%c", data[i + ind]);
   3.105 +				} else {
   3.106 +					fprintf(stderr, ".");
   3.107 +				}
   3.108 +			} else {
   3.109 +				fprintf(stderr, " ");
   3.110 +			}
   3.111 +		}
   3.112 +		fprintf(stderr, "\n");
   3.113 +	}
   3.114 +}
   3.115 +
   3.116 +void dump_msg(const control_msg_t *msg, uint64_t flags)
   3.117 +{
   3.118 +	if ((flags & (1 << msg->type)) == 0) {
   3.119 +		return;
   3.120 +	}
   3.121 +
   3.122 +	switch (msg->type) {
   3.123 +	case CMSG_CONSOLE:
   3.124 +		if (msg->subtype == CMSG_CONSOLE_DATA) {
   3.125 +			debug_begin("CONSOLE", "DATA");
   3.126 +			debug_field(msg, length, "%u");
   3.127 +			debug_dump(msg, msg, length);
   3.128 +			debug_end("CONSOLE", "DATA");
   3.129 +		} else {
   3.130 +			debug_begin("CONSOLE", "UNKNOWN");
   3.131 +			debug_field(msg, subtype, "%u");
   3.132 +			debug_field(msg, length, "%u");
   3.133 +			debug_dump(msg, msg, length);
   3.134 +			debug_end("CONSOLE", "UNKNOWN");
   3.135 +		}
   3.136 +		break;
   3.137 +	case CMSG_BLKIF_BE:
   3.138 +		if (msg->subtype == CMSG_BLKIF_BE_CREATE) {
   3.139 +			blkif_be_create_t *load;
   3.140 +			load = (blkif_be_create_t *)msg->msg;
   3.141 +			debug_begin("BLKIF_BE", "CREATE");
   3.142 +			debug_field(load, domid, "%u");
   3.143 +			debug_field(load, blkif_handle, "%u");
   3.144 +			debug_field(load, status, "%u");
   3.145 +			debug_end("BLKIF_BE", "CREATE");
   3.146 +		} else if (msg->subtype == CMSG_BLKIF_BE_DESTROY) {
   3.147 +			blkif_be_destroy_t *load;
   3.148 +			load = (blkif_be_destroy_t *)msg->msg;
   3.149 +			debug_begin("BLKIF_BE", "DESTROY");
   3.150 +			debug_field(load, domid, "%u");
   3.151 +			debug_field(load, blkif_handle, "%u");
   3.152 +			debug_field(load, status, "%u");
   3.153 +			debug_end("BLKIF_BE", "DESTROY");
   3.154 +		} else if (msg->subtype == CMSG_BLKIF_BE_CONNECT) {
   3.155 +			blkif_be_connect_t *load;
   3.156 +			load = (blkif_be_connect_t *)msg->msg;
   3.157 +			debug_begin("BLKIF_BE", "CONNECT");
   3.158 +			debug_field(load, domid, "%u");
   3.159 +			debug_field(load, blkif_handle, "%u");
   3.160 +			debug_field(load, shmem_frame, "%lu");
   3.161 +			debug_field(load, evtchn, "%u");
   3.162 +			debug_field(load, status, "%u");
   3.163 +			debug_end("BLKIF_BE", "CONNECT");
   3.164 +		} else if (msg->subtype == CMSG_BLKIF_BE_DISCONNECT) {
   3.165 +			blkif_be_disconnect_t *load;
   3.166 +			load = (blkif_be_disconnect_t *)msg->msg;
   3.167 +			debug_begin("BLKIF_BE", "DISCONNECT");
   3.168 +			debug_field(load, domid, "%u");
   3.169 +			debug_field(load, blkif_handle, "%u");
   3.170 +			debug_field(load, status, "%u");
   3.171 +			debug_end("BLKIF_BE", "DISCONNECT");
   3.172 +		} else if (msg->subtype == CMSG_BLKIF_BE_VBD_CREATE) {
   3.173 +			blkif_be_vbd_create_t *load;
   3.174 +			load = (blkif_be_vbd_create_t *)msg->msg;
   3.175 +			debug_begin("BLKIF_BE", "VBD_CREATE");
   3.176 +			debug_field(load, domid, "%u");
   3.177 +			debug_field(load, blkif_handle, "%u");
   3.178 +			debug_field(load, vdevice, "%u");
   3.179 +			debug_field(load, readonly, "%u");
   3.180 +			debug_field(load, status, "%u");
   3.181 +			debug_end("BLKIF_BE", "VBD_CREATE");
   3.182 +		} else if (msg->subtype == CMSG_BLKIF_BE_VBD_DESTROY) {
   3.183 +			blkif_be_vbd_destroy_t *load;
   3.184 +			load = (blkif_be_vbd_destroy_t *)msg->msg;
   3.185 +			debug_begin("BLKIF_BE", "VBD_DESTROY");
   3.186 +			debug_field(load, domid, "%u");
   3.187 +			debug_field(load, blkif_handle, "%u");
   3.188 +			debug_field(load, vdevice, "%u");
   3.189 +			debug_field(load, status, "%u");
   3.190 +			debug_end("BLKIF_BE", "VBD_DESTROY");
   3.191 +		} else if (msg->subtype == CMSG_BLKIF_BE_VBD_GROW) {
   3.192 +			blkif_be_vbd_grow_t *load;
   3.193 +			load = (blkif_be_vbd_grow_t *)msg->msg;
   3.194 +			debug_begin("BLKIF_BE", "VBD_GROW");
   3.195 +			debug_field(load, domid, "%u");
   3.196 +			debug_field(load, blkif_handle, "%u");
   3.197 +			debug_field(load, extent.sector_start, "%llu");
   3.198 +			debug_field(load, extent.sector_length, "%llu");
   3.199 +			debug_field(load, extent.device, "%u");
   3.200 +			debug_field(load, vdevice, "%u");
   3.201 +			debug_field(load, status, "%u");
   3.202 +			debug_end("BLKIF_BE", "VBD_GROW");
   3.203 +		} else if (msg->subtype == CMSG_BLKIF_BE_VBD_SHRINK) {
   3.204 +			blkif_be_vbd_shrink_t *load;
   3.205 +			load = (blkif_be_vbd_shrink_t *)msg->msg;
   3.206 +			debug_begin("BLKIF_BE", "VBD_SHRINK");
   3.207 +			debug_field(load, domid, "%u");
   3.208 +			debug_field(load, blkif_handle, "%u");
   3.209 +			debug_field(load, vdevice, "%u");
   3.210 +			debug_field(load, status, "%u");
   3.211 +			debug_end("BLKIF_BE", "VBD_SHRINK");
   3.212 +		} else if (msg->subtype == CMSG_BLKIF_BE_DRIVER_STATUS) {
   3.213 +			blkif_be_driver_status_t *load;
   3.214 +			load = (blkif_be_driver_status_t *)msg->msg;
   3.215 +			debug_begin("BLKIF_BE", "DRIVER_STATUS");
   3.216 +			debug_field(load, status, "%u");
   3.217 +			debug_end("BLKIF_BE", "DRIVER_STATUS");
   3.218 +		} else {
   3.219 +			debug_begin("BLKIF_BE", "UNKNOWN");
   3.220 +			debug_field(msg, subtype, "%u");
   3.221 +			debug_field(msg, length, "%u");
   3.222 +			debug_dump(msg, msg, length);
   3.223 +			debug_end("BLKIF_BE", "UNKNOWN");
   3.224 +		}
   3.225 +		break;
   3.226 +	case CMSG_BLKIF_FE:
   3.227 +		if (msg->subtype == CMSG_BLKIF_FE_INTERFACE_STATUS) {
   3.228 +			blkif_fe_interface_status_t *load;
   3.229 +			load = (blkif_fe_interface_status_t *)msg->msg;
   3.230 +			debug_begin("BLKIF_FE", "INTERFACE_STATUS");
   3.231 +			debug_field(load, handle, "%u");
   3.232 +			debug_field(load, status, "%u");
   3.233 +			debug_field(load, evtchn, "%u");
   3.234 +			debug_field(load, domid, "%u");
   3.235 +			debug_end("BLKIF_FE", "INTERFACE_STATUS");
   3.236 +		} else if (msg->subtype == CMSG_BLKIF_FE_DRIVER_STATUS) {
   3.237 +			blkif_fe_driver_status_t *load;
   3.238 +			load = (blkif_fe_driver_status_t *)msg->msg;
   3.239 +			debug_begin("BLKIF_FE", "DRIVER_STATUS");
   3.240 +			debug_field(load, status, "%u");
   3.241 +			debug_field(load, max_handle, "%u");
   3.242 +			debug_end("BLKIF_FE", "DRIVER_STATUS");
   3.243 +		} else if (msg->subtype == CMSG_BLKIF_FE_INTERFACE_CONNECT) {
   3.244 +			blkif_fe_interface_connect_t *load;
   3.245 +			load = (blkif_fe_interface_connect_t *)msg->msg;
   3.246 +			debug_begin("BLKIF_FE", "INTERFACE_CONNECT");
   3.247 +			debug_field(load, handle, "%u");
   3.248 +			debug_field(load, shmem_frame, "%lu");
   3.249 +			debug_end("BLKIF_FE", "INTERFACE_CONNECT");
   3.250 +		} else if (msg->subtype == CMSG_BLKIF_FE_INTERFACE_DISCONNECT) {
   3.251 +			blkif_fe_interface_disconnect_t *load;
   3.252 +			load = (blkif_fe_interface_disconnect_t *)msg->msg;
   3.253 +			debug_begin("BLKIF_FE", "INTERFACE_DISCONNECT");
   3.254 +			debug_field(load, handle, "%u");
   3.255 +			debug_end("BLKIF_FE", "INTERFACE_DISCONNECT");
   3.256 +		} else if (msg->subtype == CMSG_BLKIF_FE_INTERFACE_QUERY) {
   3.257 +			blkif_fe_interface_query_t *load;
   3.258 +			load = (blkif_fe_interface_query_t *)msg->msg;
   3.259 +			debug_begin("BLKIF_FE", "INTERFACE_QUERY");
   3.260 +			debug_field(load, handle, "%u");
   3.261 +			debug_field(load, status, "%u");
   3.262 +			debug_field(load, evtchn, "%u");
   3.263 +			debug_field(load, domid, "%u");
   3.264 +			debug_end("BLKIF_FE", "INTERFACE_QUERY");
   3.265 +		} else {
   3.266 +			debug_begin("BLKIF_FE", "UNKNOWN");
   3.267 +			debug_field(msg, subtype, "%u");
   3.268 +			debug_field(msg, length, "%u");
   3.269 +			debug_dump(msg, msg, length);
   3.270 +			debug_end("BLKIF_FE", "UNKNOWN");
   3.271 +		}
   3.272 +		break;
   3.273 +	case CMSG_NETIF_BE:
   3.274 +		if (msg->subtype == CMSG_NETIF_BE_CREATE) {
   3.275 +			netif_be_create_t *load;
   3.276 +			load = (netif_be_create_t *)msg->msg;
   3.277 +			debug_begin("NETIF_BE", "CREATE");
   3.278 +			debug_field(load, domid, "%u");
   3.279 +			debug_field(load, netif_handle, "%u");
   3.280 +			debug_field_mac(load, mac);
   3.281 +			debug_field_mac(load, be_mac);
   3.282 +			debug_field(load, status, "%u");
   3.283 +			debug_end("NETIF_BE", "CREATE");
   3.284 +		} else if (msg->subtype == CMSG_NETIF_BE_DESTROY) {
   3.285 +			netif_be_destroy_t *load;
   3.286 +			load = (netif_be_destroy_t *)msg->msg;
   3.287 +			debug_begin("NETIF_BE", "DESTROY");
   3.288 +			debug_field(load, domid, "%u");
   3.289 +			debug_field(load, netif_handle, "%u");
   3.290 +			debug_field(load, status, "%u");
   3.291 +			debug_end("NETIF_BE", "DESTROY");
   3.292 +		} else if (msg->subtype == CMSG_NETIF_BE_CONNECT) {
   3.293 +			netif_be_connect_t *load;
   3.294 +			load = (netif_be_connect_t *)msg->msg;
   3.295 +			debug_begin("NETIF_BE", "CONNECT");
   3.296 +			debug_field(load, domid, "%u");
   3.297 +			debug_field(load, netif_handle, "%u");
   3.298 +			debug_field(load, tx_shmem_frame, "%lu");
   3.299 +			debug_field(load, rx_shmem_frame, "%lu");
   3.300 +			debug_field(load, evtchn, "%u");
   3.301 +			debug_field(load, status, "%u");
   3.302 +			debug_end("NETIF_BE", "CONNECT");
   3.303 +		} else if (msg->subtype == CMSG_NETIF_BE_DISCONNECT) {
   3.304 +			netif_be_disconnect_t *load;
   3.305 +			load = (netif_be_disconnect_t *)msg->msg;
   3.306 +			debug_begin("NETIF_BE", "DISCONNECT");
   3.307 +			debug_field(load, domid, "%u");
   3.308 +			debug_field(load, netif_handle, "%u");
   3.309 +			debug_field(load, status, "%u");
   3.310 +			debug_end("NETIF_BE", "DISCONNECT");
   3.311 +		} else if (msg->subtype == CMSG_NETIF_BE_DRIVER_STATUS) {
   3.312 +			netif_be_driver_status_t *load;
   3.313 +			load = (netif_be_driver_status_t *)msg->msg;
   3.314 +			debug_begin("NETIF_BE", "DRIVER_STATUS");
   3.315 +			debug_field(load, status, "%u");
   3.316 +			debug_end("NETIF_BE", "DRIVER_STATUS");
   3.317 +		} else {
   3.318 +			debug_begin("NETIF_BE", "UNKNOWN");
   3.319 +			debug_field(msg, subtype, "%u");
   3.320 +			debug_field(msg, length, "%u");
   3.321 +			debug_dump(msg, msg, length);
   3.322 +			debug_end("NETIF_BE", "UNKNOWN");
   3.323 +		}
   3.324 +		break;
   3.325 +	case CMSG_NETIF_FE:
   3.326 +		if (msg->subtype == CMSG_NETIF_FE_INTERFACE_STATUS) {
   3.327 +			netif_fe_interface_status_t *load;
   3.328 +			load = (netif_fe_interface_status_t *)msg->msg;
   3.329 +			debug_begin("NETIF_FE", "INTERFACE_STATUS");
   3.330 +			debug_field(load, handle, "%u");
   3.331 +			debug_field(load, status, "%u");
   3.332 +			debug_field(load, evtchn, "%u");
   3.333 +			debug_field_mac(load, mac);
   3.334 +			debug_field(load, domid, "%u");
   3.335 +			debug_end("NETIF_FE", "INTERFACE_STATUS");
   3.336 +		} else if (msg->subtype == CMSG_NETIF_FE_DRIVER_STATUS) {
   3.337 +			netif_fe_driver_status_t *load;
   3.338 +			load = (netif_fe_driver_status_t *)msg->msg;
   3.339 +			debug_begin("NETIF_FE", "DRIVER_STATUS");
   3.340 +			debug_field(load, status, "%u");
   3.341 +			debug_field(load, max_handle, "%u");
   3.342 +			debug_end("NETIF_FE", "DRIVER_STATUS");
   3.343 +		} else if (msg->subtype == CMSG_NETIF_FE_INTERFACE_CONNECT) {
   3.344 +			netif_fe_interface_connect_t *load;
   3.345 +			load = (netif_fe_interface_connect_t *)msg->msg;
   3.346 +			debug_begin("NETIF_FE", "INTERFACE_CONNECT");
   3.347 +			debug_field(load, handle, "%u");
   3.348 +			debug_field(load, tx_shmem_frame, "%lu");
   3.349 +			debug_field(load, rx_shmem_frame, "%lu");
   3.350 +			debug_end("NETIF_FE", "INTERFACE_CONNECT");
   3.351 +		} else if (msg->subtype == CMSG_NETIF_FE_INTERFACE_DISCONNECT) {
   3.352 +			netif_fe_interface_disconnect_t *load;
   3.353 +			load = (netif_fe_interface_disconnect_t *)msg->msg;
   3.354 +			debug_begin("NETIF_FE", "INTERFACE_DISCONNECT");
   3.355 +			debug_field(load, handle, "%u");
   3.356 +			debug_end("NETIF_FE", "INTERFACE_DISCONNECT");
   3.357 +		} else if (msg->subtype == CMSG_NETIF_FE_INTERFACE_QUERY) {
   3.358 +			netif_fe_interface_query_t *load;
   3.359 +			load = (netif_fe_interface_query_t *)msg->msg;
   3.360 +			debug_begin("NETIF_FE", "INTERFACE_QUERY");
   3.361 +			debug_field(load, handle, "%u");
   3.362 +			debug_field(load, status, "%u");
   3.363 +			debug_field(load, evtchn, "%u");
   3.364 +			debug_field_mac(load, mac);
   3.365 +			debug_field(load, domid, "%u");
   3.366 +			debug_end("NETIF_FE", "INTERFACE_QUERY");
   3.367 +		} else {
   3.368 +			debug_begin("NETIF_FE", "UNKNOWN");
   3.369 +			debug_field(msg, subtype, "%u");
   3.370 +			debug_field(msg, length, "%u");
   3.371 +			debug_dump(msg, msg, length);
   3.372 +			debug_end("NETIF_FE", "UNKNOWN");
   3.373 +		}
   3.374 +		break;
   3.375 +	case CMSG_SHUTDOWN:
   3.376 +		if (msg->subtype == CMSG_SHUTDOWN_POWEROFF) {
   3.377 +			debug_begin("SHUTDOWN", "POWEROFF");
   3.378 +			debug_end("SHUTDOWN", "POWEROFF");
   3.379 +		} else if (msg->subtype == CMSG_SHUTDOWN_REBOOT) {
   3.380 +			debug_begin("SHUTDOWN", "REBOOT");
   3.381 +			debug_end("SHUTDOWN", "REBOOT");
   3.382 +		} else if (msg->subtype == CMSG_SHUTDOWN_SUSPEND) {
   3.383 +			debug_begin("SHUTDOWN", "SUSPEND");
   3.384 +			debug_end("SHUTDOWN", "SUSPEND");
   3.385 +		} else if (msg->subtype == CMSG_SHUTDOWN_SYSRQ) {
   3.386 +			debug_begin("SHUTDOWN", "SYSRQ");
   3.387 +			debug_end("SHUTDOWN", "SYSRQ");
   3.388 +		} else {
   3.389 +			debug_begin("SHUTDOWN", "UNKNOWN");
   3.390 +			debug_field(msg, subtype, "%u");
   3.391 +			debug_field(msg, length, "%u");
   3.392 +			debug_dump(msg, msg, length);
   3.393 +			debug_end("SHUTDOWN", "UNKNOWN");
   3.394 +		}		
   3.395 +		break;
   3.396 +	case CMSG_MEM_REQUEST:
   3.397 +		if (msg->subtype == CMSG_MEM_REQUEST_SET) {
   3.398 +			mem_request_t *load;
   3.399 +			load = (mem_request_t *)msg->msg;
   3.400 +			debug_begin("MEM_REQUEST", "SET");
   3.401 +			debug_field(load, target, "%u");
   3.402 +			debug_field(load, status, "%u");
   3.403 +			debug_end("MEM_REQUEST", "SET");
   3.404 +		} else {
   3.405 +			debug_begin("MEM_REQUEST", "UNKNOWN");
   3.406 +			debug_field(msg, subtype, "%u");
   3.407 +			debug_field(msg, length, "%u");
   3.408 +			debug_dump(msg, msg, length);
   3.409 +			debug_end("MEM_REQUEST", "UNKNOWN");
   3.410 +		}		
   3.411 +		break;
   3.412 +	case CMSG_USBIF_BE:
   3.413 +		if (msg->subtype == CMSG_USBIF_BE_CREATE) {
   3.414 +			usbif_be_create_t *load;
   3.415 +			load = (usbif_be_create_t *)msg->msg;
   3.416 +			debug_begin("USBIF_BE", "CREATE");
   3.417 +			debug_field(load, domid, "%u");
   3.418 +			debug_field(load, status, "%u");
   3.419 +			debug_end("USBIF_BE", "CREATE");
   3.420 +		} else if (msg->subtype == CMSG_USBIF_BE_DESTROY) {
   3.421 +			usbif_be_destroy_t *load;
   3.422 +			load = (usbif_be_destroy_t *)msg->msg;
   3.423 +			debug_begin("USBIF_BE", "DESTROY");
   3.424 +			debug_field(load, domid, "%u");
   3.425 +			debug_field(load, status, "%u");
   3.426 +			debug_end("USBIF_BE", "DESTROY");
   3.427 +		} else if (msg->subtype == CMSG_USBIF_BE_CONNECT) {
   3.428 +			usbif_be_connect_t *load;
   3.429 +			load = (usbif_be_connect_t *)msg->msg;
   3.430 +			debug_begin("USBIF_BE", "CONNECT");
   3.431 +			debug_field(load, domid, "%u");
   3.432 +			debug_field(load, shmem_frame, "%lu");
   3.433 +			debug_field(load, evtchn, "%u");
   3.434 +			debug_field(load, bandwidth, "%u");
   3.435 +			debug_field(load, status, "%u");
   3.436 +			debug_end("USBIF_BE", "CONNECT");
   3.437 +		} else if (msg->subtype == CMSG_USBIF_BE_DISCONNECT) {
   3.438 +			usbif_be_disconnect_t *load;
   3.439 +			load = (usbif_be_disconnect_t *)msg->msg;
   3.440 +			debug_begin("USBIF_BE", "DISCONNECT");
   3.441 +			debug_field(load, domid, "%u");
   3.442 +			debug_field(load, status, "%u");
   3.443 +			debug_end("USBIF_BE", "DISCONNECT");
   3.444 +		} else if (msg->subtype == CMSG_USBIF_BE_CLAIM_PORT) {
   3.445 +			usbif_be_claim_port_t *load;
   3.446 +			load = (usbif_be_claim_port_t *)msg->msg;
   3.447 +			debug_begin("USBIF_BE", "CLAIM_PORT");
   3.448 +			debug_field(load, domid, "%u");
   3.449 +			debug_field(load, usbif_port, "%u");
   3.450 +			debug_field(load, status, "%u");
   3.451 +			debug_field(load, path, "%s");
   3.452 +			debug_end("USBIF_BE", "CLAIM_PORT");
   3.453 +		} else if (msg->subtype == CMSG_USBIF_BE_RELEASE_PORT) {
   3.454 +			usbif_be_release_port_t *load;
   3.455 +			load = (usbif_be_release_port_t *)msg->msg;
   3.456 +			debug_begin("USBIF_BE", "RELEASE_PORT");
   3.457 +			debug_field(load, path, "%s");
   3.458 +			debug_end("USBIF_BE", "RELEASE_PORT");
   3.459 +		} else if (msg->subtype == CMSG_USBIF_BE_DRIVER_STATUS_CHANGED) {
   3.460 +			usbif_be_driver_status_changed_t *load;
   3.461 +			load = (usbif_be_driver_status_changed_t *)msg->msg;
   3.462 +			debug_begin("USBIF_BE", "DRIVER_STATUS_CHANGED");
   3.463 +			debug_field(load, status, "%u");
   3.464 +			debug_end("USBIF_BE", "DRIVER_STATUS_CHANGED");
   3.465 +		} else {
   3.466 +			debug_begin("USBIF_BE", "UNKNOWN");
   3.467 +			debug_field(msg, subtype, "%u");
   3.468 +			debug_field(msg, length, "%u");
   3.469 +			debug_dump(msg, msg, length);
   3.470 +			debug_end("USBIF_BE", "UNKNOWN");
   3.471 +		}
   3.472 +		break;
   3.473 +	case CMSG_USBIF_FE:
   3.474 +		if (msg->subtype == CMSG_USBIF_FE_INTERFACE_STATUS_CHANGED) {
   3.475 +			usbif_fe_interface_status_changed_t *load;
   3.476 +			load = (usbif_fe_interface_status_changed_t *)msg->msg;
   3.477 +			debug_begin("USBIF_FE", "INTERFACE_STATUS_CHANGED");
   3.478 +			debug_field(load, status, "%u");
   3.479 +			debug_field(load, evtchn, "%u");
   3.480 +			debug_field(load, domid, "%u");
   3.481 +			debug_field(load, bandwidth, "%u");
   3.482 +			debug_field(load, num_ports, "%u");
   3.483 +			debug_end("USBIF_FE", "INTERFACE_STATUS_CHANGED");
   3.484 +		} else if (msg->subtype == CMSG_USBIF_FE_DRIVER_STATUS_CHANGED) {
   3.485 +			usbif_fe_driver_status_changed_t *load;
   3.486 +			load = (usbif_fe_driver_status_changed_t *)msg->msg;
   3.487 +			debug_begin("USBIF_FE", "DRIVER_STATUS_CHANGED");
   3.488 +			debug_field(load, status, "%u");
   3.489 +			debug_end("USBIF_FE", "DRIVER_STATUS_CHANGED");
   3.490 +		} else if (msg->subtype == CMSG_USBIF_FE_INTERFACE_CONNECT) {
   3.491 +			usbif_fe_interface_connect_t *load;
   3.492 +			load = (usbif_fe_interface_connect_t *)msg->msg;
   3.493 +			debug_begin("USBIF_FE", "INTERFACE_CONNECT");
   3.494 +			debug_field(load, shmem_frame, "%lu");
   3.495 +			debug_end("USBIF_FE", "INTERFACE_CONNECT");
   3.496 +		} else if (msg->subtype == CMSG_USBIF_FE_INTERFACE_DISCONNECT) {
   3.497 +			debug_begin("USBIF_FE", "INTERFACE_DISCONNECT");
   3.498 +			debug_end("USBIF_FE", "INTERFACE_DISCONNECT");
   3.499 +		} else {
   3.500 +			debug_begin("USBIF_FE", "UNKNOWN");
   3.501 +			debug_field(msg, subtype, "%u");
   3.502 +			debug_field(msg, length, "%u");
   3.503 +			debug_dump(msg, msg, length);
   3.504 +			debug_end("USBIF_FE", "UNKNOWN");
   3.505 +		}
   3.506 +		break;
   3.507 +	default:
   3.508 +		debug_begin("UNKNOWN", "UNKNOWN");
   3.509 +		debug_field(msg, type, "%u");
   3.510 +		debug_field(msg, subtype, "%u");
   3.511 +		debug_field(msg, length, "%u");
   3.512 +		debug_dump(msg, msg, length);
   3.513 +		debug_end("UNKNOWN", "UNKNOWN");
   3.514 +		break;
   3.515 +	}
   3.516 +}
   3.517 +
   3.518 +void _error(const char *fmt, ...)
   3.519 +{
   3.520 +	va_list ap;
   3.521 +	char buffer[4096];
   3.522 +
   3.523 +	va_start(ap, fmt);
   3.524 +	vsnprintf(buffer, sizeof(buffer), fmt, ap);
   3.525 +	va_end(ap);
   3.526 +
   3.527 +	fprintf(stderr, "%s\n", buffer);
   3.528 +}
   3.529 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/tools/xcs/dump.h	Sun Mar 20 14:03:52 2005 +0000
     4.3 @@ -0,0 +1,28 @@
     4.4 +/*\
     4.5 + *  Copyright (C) International Business Machines  Corp., 2005
     4.6 + *  Author(s): Anthony Liguori <aliguori@us.ibm.com>
     4.7 + *
     4.8 + *  This program is free software; you can redistribute it and/or modify
     4.9 + *  it under the terms of the GNU General Public License as published by
    4.10 + *  the Free Software Foundation; under version 2 of the License.
    4.11 + * 
    4.12 + *  This program is distributed in the hope that it will be useful,
    4.13 + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.14 + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    4.15 + *  GNU General Public License for more details.
    4.16 + * 
    4.17 + *  You should have received a copy of the GNU General Public License
    4.18 + *  along with this program; if not, write to the Free Software
    4.19 + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    4.20 +\*/
    4.21 +
    4.22 +#ifndef XENCTLD_ERROR_H
    4.23 +#define XENCTLD_ERROR_H
    4.24 +
    4.25 +#include <stdint.h>
    4.26 +#include <xc.h>
    4.27 +#include <xen/io/domain_controller.h>
    4.28 +
    4.29 +void dump_msg(const control_msg_t *msg, uint64_t flags);
    4.30 +
    4.31 +#endif
     5.1 --- a/tools/xcs/xcsdump.c	Sun Mar 20 11:53:26 2005 +0000
     5.2 +++ b/tools/xcs/xcsdump.c	Sun Mar 20 14:03:52 2005 +0000
     5.3 @@ -3,6 +3,9 @@
     5.4   * little tool to sniff control messages.
     5.5   *
     5.6   * Copyright (c) 2004, Andrew Warfield
     5.7 + *
     5.8 + * Modifications by Anthony Liguori <aliguori@us.ibm.com> are:
     5.9 + *   Copyright (C) 2005, International Business Machines, Corp.
    5.10   */
    5.11  
    5.12  #include <stdio.h>
    5.13 @@ -16,9 +19,12 @@
    5.14  #include <xc.h>
    5.15  #include <xen/xen.h>
    5.16  #include <xen/io/domain_controller.h>
    5.17 +#include <getopt.h>
    5.18  #include "xcs_proto.h"
    5.19  #include "xcs.h"
    5.20  
    5.21 +#include "dump.h"
    5.22 +
    5.23  static int xcs_ctrl_fd = -1; /* connection to the xcs server. */
    5.24  static int xcs_data_fd = -1; /* connection to the xcs server. */
    5.25  
    5.26 @@ -80,14 +86,32 @@ void xcs_send(int fd, xcs_msg_t *msg)
    5.27  
    5.28  int main(int argc, char* argv[])
    5.29  {
    5.30 -    int ret, i;
    5.31 +    int ret;
    5.32      xcs_msg_t msg;
    5.33      control_msg_t *cmsg;
    5.34      int verbose = 0;
    5.35 -    
    5.36 -    if (argc > 1) 
    5.37 -        if ((strlen(argv[1]) >=2) && (strncmp(argv[1], "-v", 2) == 0))
    5.38 -            verbose = 1;
    5.39 +    int ch;
    5.40 +
    5.41 +    while ((ch = getopt(argc, argv, "hv:")) != -1)
    5.42 +    {
    5.43 +        switch (ch)
    5.44 +        {
    5.45 +        case 'v':
    5.46 +            verbose = atoi(optarg);
    5.47 +            break;
    5.48 +        case 'h':
    5.49 +  	    printf("Usage: %s [-v FLAGS]\n"
    5.50 +"Displays XCS control message traffic.\n"
    5.51 +"\n"
    5.52 +"FLAGS is a bitmask where each bit (numbering starts from LSB) represents\n"
    5.53 +"whether to display a particular message type.\n"
    5.54 +"\n"
    5.55 +"For example, -v 1022 will display all messages except for console messages.\n"
    5.56 +		   , argv[0]);
    5.57 +	    exit(0);
    5.58 +	    break;
    5.59 +        }
    5.60 +    }
    5.61      
    5.62      ret = sock_connect(XCS_SUN_PATH);
    5.63      if (ret < 0) 
    5.64 @@ -142,33 +166,34 @@ int main(int argc, char* argv[])
    5.65          xcs_read(xcs_data_fd, &msg);
    5.66          cmsg = &msg.u.control.msg;
    5.67          
    5.68 -        for (i=0; i<60; i++)
    5.69 -            if ((!isprint(cmsg->msg[i])) && (cmsg->msg[i] != '\0'))
    5.70 -                cmsg->msg[i] = '.';
    5.71 -        cmsg->msg[59] = '\0';
    5.72 -        
    5.73          switch (msg.type)
    5.74          {
    5.75          case XCS_REQUEST:
    5.76 -            printf("[REQUEST ] : (dom:%u port:%d) (type:(%d,%d) len %d) \n",
    5.77 -                    msg.u.control.remote_dom,
    5.78 -                    msg.u.control.local_port,
    5.79 -                    msg.u.control.msg.type, 
    5.80 -                    msg.u.control.msg.subtype, 
    5.81 -                    msg.u.control.msg.length);
    5.82 -            if (verbose)
    5.83 -                printf("           : %s\n", msg.u.control.msg.msg);
    5.84 -            break; 
    5.85 +  	    if (!verbose || verbose & (1 << msg.u.control.msg.type))
    5.86 +            {
    5.87 +	        printf("[REQUEST ] : (dom:%u port:%d) (type:(%d,%d) len %d)\n",
    5.88 +		       msg.u.control.remote_dom,
    5.89 +		       msg.u.control.local_port,
    5.90 +		       msg.u.control.msg.type, 
    5.91 +		       msg.u.control.msg.subtype, 
    5.92 +		       msg.u.control.msg.length);
    5.93 +
    5.94 +		dump_msg(cmsg, verbose);
    5.95 +	    }
    5.96 +	    break; 
    5.97          case XCS_RESPONSE:
    5.98 -            printf("[RESPONSE] : (dom:%u port:%d) (type:(%d,%d) len %d) \n",
    5.99 -                    msg.u.control.remote_dom,
   5.100 -                    msg.u.control.local_port,
   5.101 -                    msg.u.control.msg.type, 
   5.102 -                    msg.u.control.msg.subtype, 
   5.103 -                    msg.u.control.msg.length);
   5.104 -            if (verbose)
   5.105 -                printf("           : %s\n", msg.u.control.msg.msg);
   5.106 -            break;
   5.107 +  	    if (!verbose || verbose & (1 << msg.u.control.msg.type))
   5.108 +            {
   5.109 +	        printf("[RESPONSE] : (dom:%u port:%d) (type:(%d,%d) len %d)\n",
   5.110 +		       msg.u.control.remote_dom,
   5.111 +		       msg.u.control.local_port,
   5.112 +		       msg.u.control.msg.type, 
   5.113 +		       msg.u.control.msg.subtype, 
   5.114 +		       msg.u.control.msg.length);
   5.115 +
   5.116 +		dump_msg(cmsg, verbose);
   5.117 +	    }
   5.118 +	    break;
   5.119          case XCS_VIRQ:
   5.120              printf("[VIRQ    ] : %d\n", msg.u.control.local_port);
   5.121          default: