ia64/xen-unstable

changeset 6695:7bc32f4c67fb

merge?
author cl349@firebug.cl.cam.ac.uk
date Wed Sep 07 21:34:17 2005 +0000 (2005-09-07)
parents a39b1fa10edc b7c7cb88f0ba
children 10a3d4fbd9b4
files tools/console/client/main.c tools/console/daemon/io.c tools/python/xen/xend/XendCheckpoint.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/xenstore/xsobj.py tools/xenstore/xenstored_domain.c
line diff
     1.1 --- a/tools/xenstore/xenstored_domain.c	Wed Sep 07 21:24:34 2005 +0000
     1.2 +++ b/tools/xenstore/xenstored_domain.c	Wed Sep 07 21:34:17 2005 +0000
     1.3 @@ -1,4 +1,4 @@
     1.4 -/* 
     1.5 +/*
     1.6      Domain communications for Xen Store Daemon.
     1.7      Copyright (C) 2005 Rusty Russell IBM Corporation
     1.8  
     1.9 @@ -407,7 +407,7 @@ void do_get_domain_path(struct connectio
    1.10  	else
    1.11  		domain = find_domain_by_domid(domid);
    1.12  
    1.13 -	if (!domain) 
    1.14 +	if (!domain)
    1.15  		send_error(conn, ENOENT);
    1.16  	else
    1.17  		send_reply(conn, XS_GET_DOMAIN_PATH, domain->path,
    1.18 @@ -433,27 +433,49 @@ void restore_existing_connections(void)
    1.19  {
    1.20  }
    1.21  
    1.22 +#define EVTCHN_DEV_NAME  "/dev/xen/evtchn"
    1.23 +#define EVTCHN_DEV_MAJOR 10
    1.24 +#define EVTCHN_DEV_MINOR 201
    1.25 +
    1.26  /* Returns the event channel handle. */
    1.27  int domain_init(void)
    1.28  {
    1.29 +	struct stat st;
    1.30 +
    1.31  	/* The size of the ringbuffer: half a page minus head structure. */
    1.32  	ringbuf_datasize = getpagesize() / 2 - sizeof(struct ringbuf_head);
    1.33  
    1.34  	xc_handle = talloc(talloc_autofree_context(), int);
    1.35  	if (!xc_handle)
    1.36  		barf_perror("Failed to allocate domain handle");
    1.37 +
    1.38  	*xc_handle = xc_interface_open();
    1.39  	if (*xc_handle < 0)
    1.40  		barf_perror("Failed to open connection to hypervisor");
    1.41 +
    1.42  	talloc_set_destructor(xc_handle, close_xc_handle);
    1.43  
    1.44  #ifdef TESTING
    1.45  	eventchn_fd = fake_open_eventchn();
    1.46  #else
    1.47 -	eventchn_fd = open("/dev/xen/evtchn", O_RDWR);
    1.48 +	/* Make sure any existing device file links to correct device. */
    1.49 +	if ((lstat(EVTCHN_DEV_NAME, &st) != 0) || !S_ISCHR(st.st_mode) ||
    1.50 +	    (st.st_rdev != makedev(EVTCHN_DEV_MAJOR, EVTCHN_DEV_MINOR)))
    1.51 +		(void)unlink(EVTCHN_DEV_NAME);
    1.52 +
    1.53 + reopen:
    1.54 +	eventchn_fd = open(EVTCHN_DEV_NAME, O_NONBLOCK|O_RDWR);
    1.55 +	if (eventchn_fd == -1) {
    1.56 +		if ((errno == ENOENT) &&
    1.57 +		    ((mkdir("/dev/xen", 0755) == 0) || (errno == EEXIST)) &&
    1.58 +		    (mknod(EVTCHN_DEV_NAME, S_IFCHR|0600,
    1.59 +			   makedev(EVTCHN_DEV_MAJOR, EVTCHN_DEV_MINOR)) == 0))
    1.60 +			goto reopen;
    1.61 +		return -errno;
    1.62 +	}
    1.63  #endif
    1.64  	if (eventchn_fd < 0)
    1.65 -		barf_perror("Failed to open connection to hypervisor");
    1.66 +		barf_perror("Failed to open connection evtchn device");
    1.67  
    1.68  	if (xc_evtchn_bind_virq(*xc_handle, VIRQ_DOM_EXC, &virq_port))
    1.69  		barf_perror("Failed to bind to domain exception virq");