ia64/xen-unstable

view tools/domain_builder/dom_kill.c @ 386:49c0cdb50376

bitkeeper revision 1.184.1.1 (3ea6af80NfieJpdXAH_E9VdoYOKtXQ)

fixed broken symlink creation
author jws@cairnwell.research
date Wed Apr 23 15:21:36 2003 +0000 (2003-04-23)
parents de6e697bb960
children 67a66de6d9a0
line source
1 /*
2 * A very(!) simple program to kill a domain. (c) Boris Dragovic
3 * Usage: <executable> <mem_kb> <os image> <num_vifs>
4 */
6 #include <unistd.h>
7 #include <stdio.h>
8 #include <errno.h>
9 #include <fcntl.h>
10 #include <sys/stat.h>
11 #include <sys/types.h>
13 #include "dom0_ops.h"
14 #include "dom0_defs.h"
16 #define PERR_STRING "Xen Domain Killer"
18 static int do_kill_domain(int dom_id, int force)
19 {
20 char cmd_path[MAX_PATH];
21 dom0_op_t dop;
22 int cmd_fd;
24 dop.cmd = DOM0_KILLDOMAIN;
25 dop.u.killdomain.domain = dom_id;
26 dop.u.killdomain.force = force;
28 /* open the /proc command interface */
29 sprintf(cmd_path, "%s%s%s%s", "/proc/", PROC_XENO_ROOT, "/", PROC_CMD);
30 cmd_fd = open(cmd_path, O_WRONLY);
31 if(cmd_fd < 0){
32 perror(PERR_STRING);
33 return -1;
34 }
36 write(cmd_fd, &dop, sizeof(dom0_op_t));
37 close(cmd_fd);
39 return 0;
40 }
42 int main(int argc, char **argv)
43 {
44 int ret;
46 if ( (argc < 2) || (argc > 3) )
47 {
48 usage:
49 printf("Usage: kill_domain [-f] <domain_id>\n");
50 printf(" -f: Forces immediate destruction of specified domain\n");
51 ret = -1;
52 goto out;
53 }
55 if ( (argc == 3) && strcmp("-f", argv[1]) ) goto usage;
57 ret = do_kill_domain(atoi(argv[argc-1]), argc == 3);
59 out:
60 return ret;
61 }