ia64/xen-unstable

view tools/internal/xi_phys_grant.c @ 926:0a901de56d7c

bitkeeper revision 1.588 (3fafd2ccYgSbWe9z2kLiH-DeviUaIA)

Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into labyrinth.cl.cam.ac.uk:/local/scratch/smh22/xeno.bk
author smh22@labyrinth.cl.cam.ac.uk
date Mon Nov 10 18:02:52 2003 +0000 (2003-11-10)
parents 352a82eb57ad 4aba3a48d64f
children
line source
2 #define _GNU_SOURCE
3 #include "dom0_defs.h"
6 int main(int argc, char *argv[])
7 {
8 block_io_op_t op;
9 unsigned int domain;
10 unsigned short vdevice, device;
11 int ret;
13 if ( argc != 7 )
14 {
15 fprintf(stderr, "Usage: xi_physdev_grant_new <r/rw> <domain> "
16 "<device> <start sector> <n_sectors> <partition>\n");
17 return 1;
18 }
21 /*
22 ** XXX SMH: guests can refer to 'real' devices as anything; however
23 ** for this particular use ("physdisk access") we want to use the
24 ** same device number in the guest as is used in xen => both 'vdevice'
25 ** (XL name) and "device" (Xen name) are the same.
26 */
27 domain = atoi(argv[2]);
28 device = atoi(argv[3]);
29 /* XXX SMH: hack -- generate device name by addition ptn number */
30 vdevice = device + atoi(argv[6]);
32 op.cmd = BLOCK_IO_OP_VBD_CREATE;
33 op.u.create_params.domain = domain;
34 op.u.create_params.vdevice = vdevice;
35 op.u.create_params.mode = 0;
36 if ( strchr(argv[1], 'r') )
37 op.u.create_params.mode |= VBD_MODE_R;
38 if ( strchr(argv[1], 'w') )
39 op.u.create_params.mode |= VBD_MODE_W;
41 ret = do_block_io_op(&op);
43 if(ret < 0) {
44 fprintf(stderr, "error %d attempting to create VBD %04x\n", ret,
45 atoi(argv[2]));
46 return ret;
47 }
50 op.cmd = BLOCK_IO_OP_VBD_ADD;
51 op.u.add_params.domain = domain;
52 op.u.add_params.vdevice = vdevice;
54 op.u.add_params.extent.device = device;
55 op.u.add_params.extent.start_sector = atol(argv[4]);
56 op.u.add_params.extent.nr_sectors = atol(argv[5]);
58 ret = do_block_io_op(&op);
60 if(ret < 0) {
61 fprintf(stderr, "error %d attempting to add extent to VBD %04x\n",
62 ret, atoi(argv[2]));
63 return ret;
64 }
66 return 0;
67 }