Skip to contentSkip to conversation

add xenbus token support and separate watch event queues

PATCH New Samuel Thibault 1 participant 1 message Jan 17, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add xenbus token support and separate watch event queues

add xenbus token support and separate watch event queues

# HG changeset patch
# User Samuel Thibault <[email protected]> # Date 1200582503 0
# Node ID 112c1180720c87a0bfa99142399e3ef3f79f1711 # Parent 33d1c7f9217a1c915afe01fe822811ce69b3a90f add xenbus token support and separate watch event queues

extras/mini-os/include/xenbus.h +40 -3
diff -r 33d1c7f9217a -r 112c1180720c extras/mini-os/include/xenbus.h
@@ -12,13 +12,45 @@ void init_xenbus(void);
    set to a malloc'd copy of the value. */
 char *xenbus_read(xenbus_transaction_t xbt, const char *path, char **value);
 
-char *xenbus_watch_path(xenbus_transaction_t xbt, const char *path);
-void wait_for_watch(void);
-char* xenbus_wait_for_value(const char*,const char*);
+/* Watch event queue */
+struct xenbus_event {
+    /* Keep these two as this for xs.c */
+    char *path;
+    char *token;
+    struct xenbus_event *next;
+};
+
+char *xenbus_watch_path_token(xenbus_transaction_t xbt, const char *path, const char *token, struct xenbus_event *volatile *events);
+char *xenbus_unwatch_path_token(xenbus_transaction_t xbt, const char *path, const char *token);
+extern struct wait_queue_head xenbus_watch_queue;
+void xenbus_wait_for_watch(void);
+char **xenbus_wait_for_watch_return(void);
+char* xenbus_wait_for_value(const char *path, const char *value);
+
+/* When no token is provided, use a global queue. */
+#define XENBUS_WATCH_PATH_TOKEN "xenbus_watch_path"
+extern struct xenbus_event * volatile xenbus_events;
+#define xenbus_watch_path(xbt, path) xenbus_watch_path_token(xbt, path, XENBUS_WATCH_PATH_TOKEN, NULL)
+#define xenbus_unwatch_path(xbt, path) xenbus_unwatch_path_token(xbt, path, XENBUS_WATCH_PATH_TOKEN)
+
 
 /* Associates a value with a path.  Returns a malloc'd error string on
    failure. */
 char *xenbus_write(xenbus_transaction_t xbt, const char *path, const char *value);
+
+struct write_req {
+    const void *data;
+    unsigned len;
+};
+
+/* Send a message to xenbus, in the same fashion as xb_write, and
+   block waiting for a reply.  The reply is malloced and should be
+   freed by the caller. */
+struct xsd_sockmsg *
+xenbus_msg_reply(int type,
+                 xenbus_transaction_t trans,
+                 struct write_req *io,
+                 int nr_reqs);
 
 /* Removes the value associated with a path.  Returns a malloc'd error
    string on failure. */
@@ -52,4 +84,9 @@ char *xenbus_transaction_end(xenbus_tran
 /* Read path and parse it as an integer.  Returns -1 on error. */
 int xenbus_read_integer(char *path);
 
+/* Contraction of snprintf and xenbus_write(path/node). */
+char* xenbus_printf(xenbus_transaction_t xbt,
+                                  char* node, char* path,
+                                  char* fmt, ...);
+
 #endif /* XENBUS_H__ */
extras/mini-os/netfront.c +0 -14
diff -r 33d1c7f9217a -r 112c1180720c extras/mini-os/netfront.c
@@ -26,20 +26,6 @@ struct net_info {
 
 } net_info;
 
-
-char* xenbus_printf(xenbus_transaction_t xbt,
-        char* node,char* path,
-        char* fmt,unsigned int arg)
-{
-    char fullpath[256];
-    char val[256];
-
-    sprintf(fullpath,"%s/%s",node,path);
-    sprintf(val,fmt,arg);
-    xenbus_write(xbt,fullpath,val);
-
-    return NULL;
-}
 
 
 #define NET_TX_RING_SIZE __RING_SIZE((struct netif_tx_sring *)0, PAGE_SIZE)
extras/mini-os/xenbus/xenbus.c +103 -27

200 lines not on this page · raw message