ia64/xen-unstable

view tools/internal/xi_vbd_list.c @ 929:d684fdc4329e

bitkeeper revision 1.589.1.1 (3fb01fd6z-bXVPc8graC98kD6hySjA)

add Steve's new xi_vbd_tools to fix last checkin
author iap10@labyrinth.cl.cam.ac.uk
date Mon Nov 10 23:31:34 2003 +0000 (2003-11-10)
parents
children 5e91938ceb1b
line source
2 #define _GNU_SOURCE
3 #include "dom0_defs.h"
6 #define MAX_DISKS 32
7 #define XDA_SIZE (MAX_DISKS * sizeof(xen_disk_t))
9 /*
10 ** List VBDs for oneself or a given domain, or list all VBDs in the system.
11 */
12 int main(int argc, char *argv[])
13 {
14 block_io_op_t op;
15 unsigned int domain;
16 xen_disk_info_t *xdi;
17 int i, ret;
19 if ( argc > 2 ) {
20 fprintf(stderr, "Usage: xi_vbd_list [ <domain> | all ]\n");
21 return 1;
22 }
24 /* the default (domain == 0) is to probe for own VBDs */
25 domain = 0;
27 if ( argc == 2) {
28 if (!strcmp(argv[1], "all"))
29 domain = VBD_PROBE_ALL;
30 else
31 domain = atoi(argv[1]);
32 }
34 /* allocate some space for the result */
35 op.cmd = BLOCK_IO_OP_VBD_PROBE;
36 op.u.probe_params.domain = domain;
37 op.u.probe_params.xdi.max = MAX_DISKS;
38 op.u.probe_params.xdi.disks = malloc(XDA_SIZE);
39 op.u.probe_params.xdi.count = 0;
41 xdi = &op.u.probe_params.xdi; // convenience
43 if(mlock(xdi->disks, XDA_SIZE) != 0 ) {
44 PERROR("Could not lock memory for Xen hypercall");
45 return -1;
46 }
48 ret = do_block_io_op(&op);
50 if(ret < 0)
51 fprintf(stderr, "error %d attempting to probe VBDs\n", ret);
53 (void)munlock(xdi->disks, XDA_SIZE);
55 for(i = 0; i < xdi->count; i++) {
56 fprintf(stderr,
57 "Domain %02d %cBD: [R/%c] device %04x capacity %ldkB\n",
58 xdi->disks[i].domain, XD_VIRTUAL(xdi->disks[i].info) ? 'V' :
59 'P', XD_READONLY(xdi->disks[i].info) ? 'O' : 'W',
60 xdi->disks[i].device, xdi->disks[i].capacity >> 1);
61 }
64 return ret;
65 }