WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Make xenstored bind to domain exception virq directly, i

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Make xenstored bind to domain exception virq directly, instead of via xcs.
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 07 Sep 2005 17:26:12 +0000
Delivery-date: Wed, 07 Sep 2005 17:24:49 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID acde14d25398daa50263c1a890371e19d9dcf78a
# Parent  652bd7876153830eead6c292d3787a9c29256e36
Make xenstored bind to domain exception virq directly, instead of via xcs.
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r 652bd7876153 -r acde14d25398 tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c   Wed Sep  7 14:19:05 2005
+++ b/tools/xenstore/xenstored_core.c   Wed Sep  7 15:53:04 2005
@@ -51,7 +51,6 @@
 #include "xenstored_domain.h"
 #include "xenctrl.h"
 #include "xen/io/domain_controller.h"
-#include "xcs_proto.h"
 
 static bool verbose;
 LIST_HEAD(connections);
@@ -325,7 +324,7 @@
 }
 
 static int initialize_set(fd_set *inset, fd_set *outset, int sock, int ro_sock,
-                         int event_fd, int xcs_fd)
+                         int event_fd)
 {
        struct connection *i;
        int max;
@@ -340,9 +339,6 @@
        FD_SET(event_fd, inset);
        if (event_fd > max)
                max = event_fd;
-       FD_SET(xcs_fd, inset);
-       if (xcs_fd > max)
-               max = xcs_fd;
        list_for_each_entry(i, &connections, list) {
                if (i->domain)
                        continue;
@@ -1650,125 +1646,6 @@
        umask(0);
 }
 
-static int open_domain_socket(const char *path)
-{
-       struct sockaddr_un addr;
-       int sock;
-       size_t addr_len;
-
-       if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) {
-               goto out;
-       }
-
-       addr.sun_family = AF_UNIX;
-       strcpy(addr.sun_path, path);
-       addr_len = sizeof(addr.sun_family) + strlen(XCS_SUN_PATH) + 1;
-
-       if (connect(sock, (struct sockaddr *)&addr, addr_len) == -1) {
-               goto out_close_sock;
-       }
-
-       return sock;
-
- out_close_sock:
-       close(sock);
- out:
-       return -1;
-}
-
-bool _read_write_sync(int fd, void *data, size_t size, bool do_read)
-{
-       size_t offset = 0;
-       ssize_t len;
-
-       while (offset < size) {
-               if (do_read) {
-                       len = read(fd, data + offset, size - offset);
-               } else {
-                       len = write(fd, data + offset, size - offset);
-               }
-
-               if (len < 1) {
-                       if (len == -1 && (errno == EAGAIN || errno == EINTR)) {
-                               continue;
-                       } else {
-                               return false;
-                       }
-               } else {
-                       offset += len;
-               }
-       }
-
-       return true;
-}
-
-#define read_sync(fd, buffer, size) _read_write_sync(fd, buffer, size, true)
-#define write_sync(fd, buffer, size) _read_write_sync(fd, buffer, size, false)
-
-/* synchronized send/recv strictly for setting up xcs */
-/* always use asychronize callbacks any other time */
-static bool xcs_send_recv(int fd, xcs_msg_t *msg)
-{
-       bool ret = false;
-
-       if (!write_sync(fd, msg, sizeof(*msg))) {
-               eprintf("Write failed at %s:%s():L%d?  Possible bug.",
-                       __FILE__, __FUNCTION__, __LINE__);
-               goto out;
-       }
-
-       if (!read_sync(fd, msg, sizeof(*msg))) {
-               eprintf("Read failed at %s:%s():L%d?  Possible bug.",
-                       __FILE__, __FUNCTION__, __LINE__);
-               goto out;
-       }
-
-       ret = true;
-
- out:
-       return ret;
-}
-
-static void handle_xcs(int xcs_fd)
-{
-       xcs_msg_t msg;
-
-       if (!read_sync(xcs_fd, &msg, sizeof(msg)))
-               barf_perror("read from xcs failed!");
-
-       domain_cleanup();
-}
-
-static int xcs_init(void)
-{
-       int ctrl_fd, data_fd;
-       xcs_msg_t msg;
-
-       ctrl_fd = open_domain_socket(XCS_SUN_PATH);
-       if (ctrl_fd == -1)
-               barf_perror("Failed to contact xcs.  Is it running?");
-
-       data_fd = open_domain_socket(XCS_SUN_PATH);
-       if (data_fd == -1)
-               barf_perror("Failed to contact xcs.  Is it running?");
-       
-       memset(&msg, 0, sizeof(msg));
-       msg.type = XCS_CONNECT_CTRL;
-       if (!xcs_send_recv(ctrl_fd, &msg) || msg.result != XCS_RSLT_OK)
-               barf_perror("xcs control connect failed.");
-
-       msg.type = XCS_CONNECT_DATA;
-       if (!xcs_send_recv(data_fd, &msg) || msg.result != XCS_RSLT_OK)
-               barf_perror("xcs data connect failed.");
-
-       msg.type = XCS_VIRQ_BIND;
-       msg.u.virq.virq = VIRQ_DOM_EXC;
-       if (!xcs_send_recv(ctrl_fd, &msg) || msg.result != XCS_RSLT_OK)
-               barf_perror("xcs virq bind failed.");
-
-       return data_fd;
-}
-
 
 static struct option options[] = {
        { "pid-file", 1, NULL, 'F' },
@@ -1780,7 +1657,7 @@
 
 int main(int argc, char *argv[])
 {
-       int opt, *sock, *ro_sock, event_fd, xcs_fd, max;
+       int opt, *sock, *ro_sock, event_fd, max;
        struct sockaddr_un addr;
        fd_set inset, outset;
        bool dofork = true;
@@ -1864,9 +1741,6 @@
        /* Listen to hypervisor. */
        event_fd = domain_init();
 
-       /* Listen to hypervisor - more. */
-       xcs_fd = xcs_init();
-
        /* Restore existing connections. */
        restore_existing_connections();
 
@@ -1887,8 +1761,7 @@
 #endif
 
        /* Get ready to listen to the tools. */
-       max = initialize_set(&inset, &outset, *sock, *ro_sock, event_fd,
-                            xcs_fd);
+       max = initialize_set(&inset, &outset, *sock, *ro_sock, event_fd);
 
        /* Main loop. */
        /* FIXME: Rewrite so noone can starve. */
@@ -1918,9 +1791,6 @@
 
                if (FD_ISSET(event_fd, &inset))
                        handle_event(event_fd);
-
-               if (FD_ISSET(xcs_fd, &inset))
-                       handle_xcs(xcs_fd);
 
                list_for_each_entry(i, &connections, list) {
                        if (i->domain)
@@ -1965,6 +1835,6 @@
                unblock_connections();
 
                max = initialize_set(&inset, &outset, *sock, *ro_sock,
-                                    event_fd, xcs_fd);
-       }
-}
+                                    event_fd);
+       }
+}
diff -r 652bd7876153 -r acde14d25398 tools/xenstore/xenstored_domain.c
--- a/tools/xenstore/xenstored_domain.c Wed Sep  7 14:19:05 2005
+++ b/tools/xenstore/xenstored_domain.c Wed Sep  7 15:53:04 2005
@@ -38,6 +38,7 @@
 
 static int *xc_handle;
 static int eventchn_fd;
+static int virq_port;
 static unsigned int ringbuf_datasize;
 
 struct domain
@@ -224,6 +225,10 @@
 
        if (read(event_fd, &port, sizeof(port)) != sizeof(port))
                barf_perror("Failed to read from event fd");
+
+       if (port == virq_port)
+               domain_cleanup();
+
 #ifndef TESTING
        if (write(event_fd, &port, sizeof(port)) != sizeof(port))
                barf_perror("Failed to write to event fd");
@@ -449,5 +454,12 @@
 #endif
        if (eventchn_fd < 0)
                barf_perror("Failed to open connection to hypervisor");
+
+       if (xc_evtchn_bind_virq(*xc_handle, VIRQ_DOM_EXC, &virq_port))
+               barf_perror("Failed to bind to domain exception virq");
+
+       if (ioctl(eventchn_fd, EVENTCHN_BIND, virq_port) != 0)
+               barf_perror("Failed to bind to domain exception virq port");
+
        return eventchn_fd;
 }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Make xenstored bind to domain exception virq directly, instead of via xcs., Xen patchbot -unstable <=