blob: 2b8b0a50972c4622b895e5866e17b721580f554d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*
* A very(!) simple program to kill a domain. (c) Boris Dragovic
* Usage: <executable> <mem_kb> <os image> <num_vifs>
*/
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "dom0_ops.h"
#include "dom0_defs.h"
#define PERR_STRING "Xen Domain Killer"
static int do_kill_domain(int dom_id)
{
char cmd_path[MAX_PATH];
dom0_op_t dop;
int cmd_fd;
dop.cmd = DOM0_KILLDOMAIN;
dop.u.killdomain.domain = dom_id;
/* open the /proc command interface */
sprintf(cmd_path, "%s%s%s%s", "/proc/", PROC_XENO_ROOT, "/", PROC_CMD);
cmd_fd = open(cmd_path, O_WRONLY);
if(cmd_fd < 0){
perror(PERR_STRING);
return -1;
}
write(cmd_fd, &dop, sizeof(dom0_op_t));
close(cmd_fd);
return 0;
}
int main(int argc, char **argv)
{
int ret;
if(argc < 2){
printf("Usage: kill_domain <domain_id>\n");
ret = -1;
goto out;
}
ret = do_kill_domain(atoi(argv[1]));
out:
return ret;
}
|