ia64/xen-unstable

view tools/internal/xi_stop.c @ 522:07cb518caf2f

bitkeeper revision 1.289 (3f09877bT-kkJTOM1WvHevpN2wY-qw)

Prune old code
author rac61@labyrinth.cl.cam.ac.uk
date Mon Jul 07 14:45:15 2003 +0000 (2003-07-07)
parents 62a46bc69cac
children b912fe2f29ba 49232d5003e6
line source
1 #include <unistd.h>
2 #include <stdio.h>
3 #include <errno.h>
4 #include <fcntl.h>
5 #include <sys/mman.h>
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <stdlib.h>
10 #include "hypervisor_defs.h"
11 #include "dom0_ops.h"
12 #include "dom0_defs.h"
13 #include "mem_defs.h"
15 /***********************************************************************/
17 static char *argv0 = "internal_domain_stop";
19 static void ERROR (char *message)
20 {
21 fprintf (stderr, "%s: %s\n", argv0, message);
22 exit (-1);
23 }
25 static void PERROR (char *message)
26 {
27 fprintf (stderr, "%s: %s (%s)\n", argv0, message, strerror(errno));
28 exit (-1);
29 }
31 /***********************************************************************/
33 static int stop_domain(int id)
34 {
35 dom0_newdomain_t * dom_data;
36 char cmd_path[MAX_PATH];
37 char dom_id_path[MAX_PATH];
38 dom0_op_t dop;
39 int cmd_fd;
40 int id_fd;
42 /* Set up the DOM0_STOPDOMAIN command */
43 dop.cmd = DOM0_STOPDOMAIN;
44 dop.u.meminfo.domain = id;
46 /* open the /proc command interface */
47 sprintf(cmd_path, "%s%s%s%s", "/proc/", PROC_XENO_ROOT, "/", PROC_CMD);
48 cmd_fd = open(cmd_path, O_WRONLY);
49 if(cmd_fd < 0){
50 PERROR ("Count not open PROC_CMD interface");
51 }
53 /* Issue the command */
54 write(cmd_fd, &dop, sizeof(dom0_op_t));
55 close(cmd_fd);
57 return 0;
58 }
60 /***********************************************************************/
62 int main(int argc, char **argv)
63 {
64 int rc;
66 if (argv[0] != NULL)
67 {
68 argv0 = argv[0];
69 }
71 if(argc != 2)
72 {
73 fprintf (stderr, "Usage: %s <domain-id>\n", argv0);
74 return -1;
75 }
77 rc = stop_domain(atol(argv[1]));
79 return rc;
80 }