debuggers.hg

view tools/internal/xi_create.c @ 648:cda951fc1bef

bitkeeper revision 1.341 (3f1120a2WW6KGE81TArq_p654xy38Q)

Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into labyrinth.cl.cam.ac.uk:/auto/anfs/scratch/labyrinth/iap10/xeno-clone/xeno.bk
author iap10@labyrinth.cl.cam.ac.uk
date Sun Jul 13 09:04:34 2003 +0000 (2003-07-13)
parents 3539152a9fab 9339f3942f4e
children 8305b95a7772
line source
1 /*
2 * XenoDomainBuilder, copyright (c) Boris Dragovic, bd240@cl.cam.ac.uk
3 * This code is released under terms and conditions of GNU GPL :).
4 * Usage: <executable> <mem_kb> <os image> <num_vifs>
5 */
7 #include <hypervisor-ifs/dom0_ops.h>
8 #include "dom0_defs.h"
9 #include "mem_defs.h"
11 static char *argv0 = "internal_domain_create";
13 static int create_new_domain(long req_mem, char *name)
14 {
15 int err;
16 dom0_op_t op;
18 op.cmd = DOM0_CREATEDOMAIN;
19 op.u.newdomain.memory_kb = req_mem;
20 strncpy(op.u.newdomain.name, name, MAX_DOMAIN_NAME);
21 op.u.newdomain.name[MAX_DOMAIN_NAME-1] = '\0';
23 err = do_dom0_op(&op);
25 return (err < 0) ? err : op.u.newdomain.domain;
26 }
28 int main(int argc, char **argv)
29 {
30 int dom_id;
32 if ( argv[0] != NULL )
33 argv0 = argv[0];
35 if ( argc != 3 )
36 {
37 fprintf(stderr, "Usage: %s <kbytes-mem> <domain-name>\n", argv0);
38 return 1;
39 }
41 dom_id = create_new_domain(atol(argv[1]), argv[2]);
42 if ( dom_id < 0 )
43 return 1;
45 printf("%d\n", dom_id);
46 return 0;
47 }