ia64/xen-unstable

view tools/xenstore/xenstored_core.h @ 10878:c471b326b75e

Add a transaction_started field in xenstored connection structure instead of
browsing the list of transaction each time
Bump the default to 10, and make it configurable through the command line.

Signed-off-by: Vincent Hanquez <vincent@xensource.com>
author vhanquez@gwig.uk.xensource.com
date Mon Jul 31 09:30:36 2006 +0000 (2006-07-31)
parents 041127f2c687
children 398ab18ffed1
line source
1 /*
2 Internal interfaces for Xen Store Daemon.
3 Copyright (C) 2005 Rusty Russell IBM Corporation
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
20 #ifndef _XENSTORED_CORE_H
21 #define _XENSTORED_CORE_H
23 #include <xenctrl.h>
25 #include <sys/types.h>
26 #include <dirent.h>
27 #include <stdbool.h>
28 #include <stdint.h>
29 #include <errno.h>
30 #include "xs_lib.h"
31 #include "list.h"
32 #include "tdb.h"
34 struct buffered_data
35 {
36 struct list_head list;
38 /* Are we still doing the header? */
39 bool inhdr;
41 /* How far are we? */
42 unsigned int used;
44 union {
45 struct xsd_sockmsg msg;
46 char raw[sizeof(struct xsd_sockmsg)];
47 } hdr;
49 /* The actual data. */
50 char *buffer;
51 };
53 struct connection;
54 typedef int connwritefn_t(struct connection *, const void *, unsigned int);
55 typedef int connreadfn_t(struct connection *, void *, unsigned int);
57 struct connection
58 {
59 struct list_head list;
61 /* The file descriptor we came in on. */
62 int fd;
64 /* Who am I? 0 for socket connections. */
65 unsigned int id;
67 /* Is this a read-only connection? */
68 bool can_write;
70 /* Buffered incoming data. */
71 struct buffered_data *in;
73 /* Buffered output data */
74 struct list_head out_list;
76 /* Transaction context for current request (NULL if none). */
77 struct transaction *transaction;
79 /* List of in-progress transactions. */
80 struct list_head transaction_list;
81 uint32_t next_transaction_id;
82 unsigned int transaction_started;
84 /* The domain I'm associated with, if any. */
85 struct domain *domain;
87 /* My watches. */
88 struct list_head watches;
90 /* Methods for communicating over this connection: write can be NULL */
91 connwritefn_t *write;
92 connreadfn_t *read;
93 };
94 extern struct list_head connections;
96 struct node {
97 const char *name;
99 /* Database I came from */
100 TDB_CONTEXT *tdb;
102 /* Parent (optional) */
103 struct node *parent;
105 /* Permissions. */
106 unsigned int num_perms;
107 struct xs_permissions *perms;
109 /* Contents. */
110 unsigned int datalen;
111 void *data;
113 /* Children, each nul-terminated. */
114 unsigned int childlen;
115 char *children;
116 };
118 /* Break input into vectors, return the number, fill in up to num of them. */
119 unsigned int get_strings(struct buffered_data *data,
120 char *vec[], unsigned int num);
122 /* Is child node a child or equal to parent node? */
123 bool is_child(const char *child, const char *parent);
125 void send_reply(struct connection *conn, enum xsd_sockmsg_type type,
126 const void *data, unsigned int len);
128 /* Some routines (write, mkdir, etc) just need a non-error return */
129 void send_ack(struct connection *conn, enum xsd_sockmsg_type type);
131 /* Send an error: error is usually "errno". */
132 void send_error(struct connection *conn, int error);
134 /* Canonicalize this path if possible. */
135 char *canonicalize(struct connection *conn, const char *node);
137 /* Check if node is an event node. */
138 bool check_event_node(const char *node);
140 /* Get this node, checking we have permissions. */
141 struct node *get_node(struct connection *conn,
142 const char *name,
143 enum xs_perm_type perm);
145 /* Get TDB context for this connection */
146 TDB_CONTEXT *tdb_context(struct connection *conn);
148 /* Destructor for tdbs: required for transaction code */
149 int destroy_tdb(void *_tdb);
151 /* Replace the tdb: required for transaction code */
152 bool replace_tdb(const char *newname, TDB_CONTEXT *newtdb);
154 struct connection *new_connection(connwritefn_t *write, connreadfn_t *read);
157 /* Is this a valid node name? */
158 bool is_valid_nodename(const char *node);
161 /* Tracing infrastructure. */
162 void trace_create(const void *data, const char *type);
163 void trace_destroy(const void *data, const char *type);
164 void trace_watch_timeout(const struct connection *conn, const char *node, const char *token);
165 void trace(const char *fmt, ...);
167 extern int event_fd;
169 /* Map the kernel's xenstore page. */
170 void *xenbus_map(void);
172 /* Return the event channel used by xenbus. */
173 evtchn_port_t xenbus_evtchn(void);
175 #endif /* _XENSTORED_CORE_H */
177 /*
178 * Local variables:
179 * c-file-style: "linux"
180 * indent-tabs-mode: t
181 * c-indent-level: 8
182 * c-basic-offset: 8
183 * tab-width: 8
184 * End:
185 */