aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2003-04-17 12:26:14 +0000
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2003-04-17 12:26:14 +0000
commit2c6f432e14345aacd41430870a7fc7fc68f8f8a2 (patch)
tree181254a721490825467be8f33e2b0db2da6b3f14 /tools
parentb9e6f59dc1aab2cc6159658f7b4327c9294c1d42 (diff)
downloadxen-2c6f432e14345aacd41430870a7fc7fc68f8f8a2.tar.gz
xen-2c6f432e14345aacd41430870a7fc7fc68f8f8a2.tar.bz2
xen-2c6f432e14345aacd41430870a7fc7fc68f8f8a2.zip
bitkeeper revision 1.179 (3e9e9d6686NgD7eyGZqkrhBZ7IgkDw)
sched.h, schedule.c, domain.c, dom0_ops.c, dom_builder.c: Fixed domain death so we can now kill domains that were never actually launched.
Diffstat (limited to 'tools')
-rw-r--r--tools/domain_builder/dom_builder.c46
1 files changed, 37 insertions, 9 deletions
diff --git a/tools/domain_builder/dom_builder.c b/tools/domain_builder/dom_builder.c
index d2ba7db2c7..13ee8d8735 100644
--- a/tools/domain_builder/dom_builder.c
+++ b/tools/domain_builder/dom_builder.c
@@ -43,6 +43,30 @@ static void dbstatus(char * msg)
printf("Domain Builder: %s\n", msg);
}
+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;
+}
+
/* clean up domain's memory allocations */
static void dom_mem_cleanup(dom_mem_t * dom_mem)
{
@@ -162,7 +186,7 @@ static dom0_newdomain_t * create_new_domain(long req_mem)
sprintf(dom_id_path, "%s%s%s%s", "/proc/", PROC_XENO_ROOT, "/",
PROC_DOM_DATA);
- while((id_fd = open(dom_id_path, O_RDONLY)) < 0){}
+ while((id_fd = open(dom_id_path, O_RDONLY)) < 0) continue;
dom_data = (dom0_newdomain_t *)malloc(sizeof(dom0_newdomain_t));
read(id_fd, dom_data, sizeof(dom0_newdomain_t));
close(id_fd);
@@ -445,20 +469,18 @@ int main(int argc, char **argv)
if(argc < 4) {
dberr("Usage: dom_builder <kbytes_mem> <image> <num_vifs> "
"[<initrd=initrd_name>] <boot_params>\n");
- goto out;
+ return -1;
}
/* create new domain and set up all the neccessary mappings */
kernel_fd = do_kernel_chcks(argv[2], atol(argv[1]), &load_addr, &ksize);
- if(kernel_fd < 0) {
- rc = errno;
- goto out;
- }
+ if(kernel_fd < 0)
+ return -1;
/* request the creation of new domain */
if(!(dom_data = create_new_domain(atol(argv[1]))))
- goto out;
+ return -1;
/* map domain's memory */
if(map_dom_mem(dom_data->pg_head, dom_data->memory_kb >> (PAGE_SHIFT-10),
@@ -520,7 +542,13 @@ int main(int argc, char **argv)
out:
if( rc >= 0 )
- return meminfo->domain;
+ {
+ return meminfo->domain;
+ }
else
- return rc;
+ {
+ if ( dom_data->domain != 0 )
+ do_kill_domain(dom_data->domain, 1);
+ return rc;
+ }
}