ia64/xen-unstable

view tools/internal/xi_vbd_create.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"
5 /*
6 ** Create a new VBD for a given domain; the VBD can be read-only or
7 ** read/write, and will be referred to by the relevant domain as 'vdevice'.
8 */
9 int main(int argc, char *argv[])
10 {
11 block_io_op_t op;
12 unsigned int domain;
13 unsigned short vdevice;
14 int ret;
16 if ( argc != 4 )
17 {
18 fprintf(stderr, "Usage: xi_vbd_create <domain> <vdevice> <r/rw>\n");
19 return 1;
20 }
22 domain = atoi(argv[1]);
23 vdevice = atoi(argv[2]);
25 op.cmd = BLOCK_IO_OP_VBD_CREATE;
26 op.u.create_params.domain = domain;
27 op.u.create_params.vdevice = vdevice;
28 op.u.create_params.mode = 0;
29 if ( strchr(argv[3], 'r') )
30 op.u.create_params.mode |= VBD_MODE_R;
31 if ( strchr(argv[3], 'w') )
32 op.u.create_params.mode |= VBD_MODE_W;
34 ret = do_block_io_op(&op);
36 if(ret < 0) {
37 fprintf(stderr, "error %d attempting to create VBD %04x\n", ret,
38 atoi(argv[2]));
39 return ret;
40 }
42 return 0;
43 }