Files
xen/tools/domain_builder/dom_kill.c
T
kaf24@labyrinth.cl.cam.ac.uk 2b1c361bee bitkeeper revision 1.96 (3e5a5cd7-6YCRyx9vceH0j_ljuOe-Q)
hypervisor-ifs:
  new file
Many files:
  Allow forced killing of domains with 'kill_domain -f'. task_structs now reference counted.
.del-network.h~823d28e86ebe9d9b:
  Delete: xenolinux-2.4.21-pre4-sparse/include/asm-xeno/hypervisor-ifs/network.h
.del-hypervisor-if.h~d1f6a7dd4307ddfe:
  Delete: xenolinux-2.4.21-pre4-sparse/include/asm-xeno/hypervisor-ifs/hypervisor-if.h
.del-block.h~81aa08f4e2012da6:
  Delete: xenolinux-2.4.21-pre4-sparse/include/asm-xeno/hypervisor-ifs/block.h
2003-02-24 17:56:39 +00:00

62 lines
1.3 KiB
C

/*
* 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, int force)
{
char cmd_path[MAX_PATH];
dom0_op_t dop;
int cmd_fd;
dop.cmd = DOM0_KILLDOMAIN;
dop.u.killdomain.domain = dom_id;
dop.u.killdomain.force = force;
/* 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) || (argc > 3) )
{
usage:
printf("Usage: kill_domain [-f] <domain_id>\n");
printf(" -f: Forces immediate destruction of specified domain\n");
ret = -1;
goto out;
}
if ( (argc == 3) && strcmp("-f", argv[1]) ) goto usage;
ret = do_kill_domain(atoi(argv[argc-1]), argc == 3);
out:
return ret;
}