debuggers.hg
changeset 6686:83bcc68aaf32
Use @releaseDomain watch-events.
This replaces listening to the domain exception virq through xcs.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
This replaces listening to the domain exception virq through xcs.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author | cl349@firebug.cl.cam.ac.uk |
---|---|
date | Tue Sep 06 18:29:27 2005 +0000 (2005-09-06) |
parents | 0922c82a4bf3 |
children | 8db9c5873b9b |
files | tools/console/Makefile tools/console/daemon/io.c tools/console/daemon/utils.c tools/console/daemon/utils.h |
line diff
1.1 --- a/tools/console/Makefile Tue Sep 06 18:18:56 2005 +0000 1.2 +++ b/tools/console/Makefile Tue Sep 06 18:29:27 2005 +0000 1.3 @@ -11,7 +11,6 @@ INSTALL_DIR = $(INSTALL) -d -m0755 1.4 1.5 CFLAGS += -Wall -Werror -g3 1.6 1.7 -CFLAGS += -I $(XEN_XCS) 1.8 CFLAGS += -I $(XEN_LIBXC) 1.9 CFLAGS += -I $(XEN_XENSTORE) 1.10
2.1 --- a/tools/console/daemon/io.c Tue Sep 06 18:18:56 2005 +0000 2.2 +++ b/tools/console/daemon/io.c Tue Sep 06 18:29:27 2005 +0000 2.3 @@ -26,7 +26,6 @@ 2.4 #include "xenctrl.h" 2.5 #include "xs.h" 2.6 #include "xen/io/domain_controller.h" 2.7 -#include "xcs_proto.h" 2.8 2.9 #include <malloc.h> 2.10 #include <stdlib.h> 2.11 @@ -462,18 +461,6 @@ static void handle_ring_read(struct doma 2.12 (void)write_sync(dom->evtchn_fd, &v, sizeof(v)); 2.13 } 2.14 2.15 -static void handle_xcs_msg(int fd) 2.16 -{ 2.17 - xcs_msg_t msg; 2.18 - 2.19 - if (!read_sync(fd, &msg, sizeof(msg))) { 2.20 - dolog(LOG_ERR, "read from xcs failed! %m"); 2.21 - exit(1); 2.22 - } 2.23 - 2.24 - enum_domains(); 2.25 -} 2.26 - 2.27 static void handle_xs(int fd) 2.28 { 2.29 char **vec; 2.30 @@ -484,7 +471,7 @@ static void handle_xs(int fd) 2.31 if (!vec) 2.32 return; 2.33 2.34 - if (!strcmp(vec[1], "introduceDomain")) 2.35 + if (!strcmp(vec[1], "domlist")) 2.36 enum_domains(); 2.37 else if (sscanf(vec[1], "dom%u", &domid) == 1) { 2.38 dom = lookup_domain(domid); 2.39 @@ -509,9 +496,6 @@ void handle_io(void) 2.40 FD_ZERO(&readfds); 2.41 FD_ZERO(&writefds); 2.42 2.43 - FD_SET(xcs_data_fd, &readfds); 2.44 - max_fd = MAX(xcs_data_fd, max_fd); 2.45 - 2.46 FD_SET(xs_fileno(xs), &readfds); 2.47 max_fd = MAX(xs_fileno(xs), max_fd); 2.48 2.49 @@ -536,9 +520,6 @@ void handle_io(void) 2.50 if (FD_ISSET(xs_fileno(xs), &readfds)) 2.51 handle_xs(xs_fileno(xs)); 2.52 2.53 - if (FD_ISSET(xcs_data_fd, &readfds)) 2.54 - handle_xcs_msg(xcs_data_fd); 2.55 - 2.56 for (d = dom_head; d; d = n) { 2.57 n = d->next; 2.58 if (d->evtchn_fd != -1 &&
3.1 --- a/tools/console/daemon/utils.c Tue Sep 06 18:18:56 2005 +0000 3.2 +++ b/tools/console/daemon/utils.c Tue Sep 06 18:29:27 2005 +0000 3.3 @@ -35,16 +35,12 @@ 3.4 3.5 #include "xenctrl.h" 3.6 #include "xen/io/domain_controller.h" 3.7 -#include "xcs_proto.h" 3.8 3.9 #include "utils.h" 3.10 3.11 struct xs_handle *xs; 3.12 int xc; 3.13 3.14 -int xcs_ctrl_fd = -1; 3.15 -int xcs_data_fd = -1; 3.16 - 3.17 bool _read_write_sync(int fd, void *data, size_t size, bool do_read) 3.18 { 3.19 size_t offset = 0; 3.20 @@ -71,32 +67,6 @@ bool _read_write_sync(int fd, void *data 3.21 return true; 3.22 } 3.23 3.24 -static int open_domain_socket(const char *path) 3.25 -{ 3.26 - struct sockaddr_un addr; 3.27 - int sock; 3.28 - size_t addr_len; 3.29 - 3.30 - if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) { 3.31 - goto out; 3.32 - } 3.33 - 3.34 - addr.sun_family = AF_UNIX; 3.35 - strcpy(addr.sun_path, path); 3.36 - addr_len = sizeof(addr.sun_family) + strlen(XCS_SUN_PATH) + 1; 3.37 - 3.38 - if (connect(sock, (struct sockaddr *)&addr, addr_len) == -1) { 3.39 - goto out_close_sock; 3.40 - } 3.41 - 3.42 - return sock; 3.43 - 3.44 - out_close_sock: 3.45 - close(sock); 3.46 - out: 3.47 - return -1; 3.48 -} 3.49 - 3.50 static void child_exit(int sig) 3.51 { 3.52 while (waitpid(-1, NULL, WNOHANG) > 0); 3.53 @@ -155,34 +125,8 @@ void daemonize(const char *pidfile) 3.54 signal(SIGTTIN, SIG_IGN); 3.55 } 3.56 3.57 -/* synchronized send/recv strictly for setting up xcs */ 3.58 -/* always use asychronize callbacks any other time */ 3.59 -static bool xcs_send_recv(int fd, xcs_msg_t *msg) 3.60 -{ 3.61 - bool ret = false; 3.62 - 3.63 - if (!write_sync(fd, msg, sizeof(*msg))) { 3.64 - dolog(LOG_ERR, "Write failed at %s:%s():L%d? Possible bug.", 3.65 - __FILE__, __FUNCTION__, __LINE__); 3.66 - goto out; 3.67 - } 3.68 - 3.69 - if (!read_sync(fd, msg, sizeof(*msg))) { 3.70 - dolog(LOG_ERR, "Read failed at %s:%s():L%d? Possible bug.", 3.71 - __FILE__, __FUNCTION__, __LINE__); 3.72 - goto out; 3.73 - } 3.74 - 3.75 - ret = true; 3.76 - 3.77 - out: 3.78 - return ret; 3.79 -} 3.80 - 3.81 bool xen_setup(void) 3.82 { 3.83 - int sock; 3.84 - xcs_msg_t msg; 3.85 3.86 xs = xs_daemon_open(); 3.87 if (xs == NULL) { 3.88 @@ -197,58 +141,23 @@ bool xen_setup(void) 3.89 goto out; 3.90 } 3.91 3.92 - sock = open_domain_socket(XCS_SUN_PATH); 3.93 - if (sock == -1) { 3.94 - dolog(LOG_ERR, "Failed to contact xcs (%m). Is it running?"); 3.95 - goto out_close_store; 3.96 + if (!xs_watch(xs, "@introduceDomain", "domlist")) { 3.97 + dolog(LOG_ERR, "xenstore watch on @introduceDomain fails."); 3.98 + goto out; 3.99 } 3.100 3.101 - xcs_ctrl_fd = sock; 3.102 - 3.103 - sock = open_domain_socket(XCS_SUN_PATH); 3.104 - if (sock == -1) { 3.105 - dolog(LOG_ERR, "Failed to contact xcs (%m). Is it running?"); 3.106 - goto out_close_ctrl; 3.107 - } 3.108 - 3.109 - xcs_data_fd = sock; 3.110 - 3.111 - memset(&msg, 0, sizeof(msg)); 3.112 - msg.type = XCS_CONNECT_CTRL; 3.113 - if (!xcs_send_recv(xcs_ctrl_fd, &msg) || msg.result != XCS_RSLT_OK) { 3.114 - dolog(LOG_ERR, "xcs control connect failed. Possible bug."); 3.115 - goto out_close_data; 3.116 - } 3.117 - 3.118 - msg.type = XCS_CONNECT_DATA; 3.119 - if (!xcs_send_recv(xcs_data_fd, &msg) || msg.result != XCS_RSLT_OK) { 3.120 - dolog(LOG_ERR, "xcs data connect failed. Possible bug."); 3.121 - goto out_close_data; 3.122 - } 3.123 - 3.124 - msg.type = XCS_VIRQ_BIND; 3.125 - msg.u.virq.virq = VIRQ_DOM_EXC; 3.126 - if (!xcs_send_recv(xcs_ctrl_fd, &msg) || msg.result != XCS_RSLT_OK) { 3.127 - dolog(LOG_ERR, "xcs virq bind failed. Possible bug."); 3.128 - goto out_close_data; 3.129 - } 3.130 - 3.131 - if (!xs_watch(xs, "@introduceDomain", "introduceDomain")) { 3.132 - dolog(LOG_ERR, "xenstore watch on @introduceDomain fails."); 3.133 - goto out_close_data; 3.134 + if (!xs_watch(xs, "@releaseDomain", "domlist")) { 3.135 + dolog(LOG_ERR, "xenstore watch on @releaseDomain fails."); 3.136 + goto out; 3.137 } 3.138 3.139 return true; 3.140 3.141 - out_close_data: 3.142 - close(xcs_data_fd); 3.143 - xcs_data_fd = -1; 3.144 - out_close_ctrl: 3.145 - close(xcs_ctrl_fd); 3.146 - xcs_ctrl_fd = -1; 3.147 - out_close_store: 3.148 - xs_daemon_close(xs); 3.149 out: 3.150 + if (xs) 3.151 + xs_daemon_close(xs); 3.152 + if (xc != -1) 3.153 + xc_interface_close(xc); 3.154 return false; 3.155 } 3.156
4.1 --- a/tools/console/daemon/utils.h Tue Sep 06 18:18:56 2005 +0000 4.2 +++ b/tools/console/daemon/utils.h Tue Sep 06 18:29:27 2005 +0000 4.3 @@ -33,8 +33,6 @@ bool xen_setup(void); 4.4 #define write_sync(fd, buffer, size) _read_write_sync(fd, buffer, size, false) 4.5 bool _read_write_sync(int fd, void *data, size_t size, bool do_read); 4.6 4.7 -extern int xcs_ctrl_fd; 4.8 -extern int xcs_data_fd; 4.9 extern struct xs_handle *xs; 4.10 extern int xc; 4.11