direct-io.hg

view tools/xenstore/xs.h @ 7480:a90d670c98b9

Change the semantics of GetDomainPath so that it always succeeds, regardless of
whether a domain has been introduced to the store. Added a separate message
XS_IS_DOMAIN_INTRODUCED and API for that (xs_is_domain_introduced) to determine
whether the domain has really been introduced. This change means that the
tools can determine the correct domain path earlier in the domain creation
process, which is particularly a factor with live migration, as it allows us
to create the devices earlier in the process, and unpause the new domain before
performing the introduce. Until recently we already had these features, but
the simplification of the interface between xend and xenstored caused breakage.

No longer clear out the domain path when a domain is introduced -- this was a
hack to work around the recent problematic semantics of GetDomainPath.

Do not write the contents of the info block to the store. All the configuration
info is written to the /vm path, and anything else in the info block is either
dealt with explicitly or is ephemeral and has no place in the store.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Sun Oct 23 22:45:15 2005 +0100 (2005-10-23)
parents 75ec60b67f64
children d507f32afba9
line source
1 /*
2 Xen Store Daemon providing simple tree-like database.
3 Copyright (C) 2005 Rusty Russell IBM Corporation
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library 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 GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
20 #ifndef _XS_H
21 #define _XS_H
23 #include <xs_lib.h>
25 struct xs_handle;
26 struct xs_transaction_handle;
28 /* On failure, these routines set errno. */
30 /* Connect to the xs daemon.
31 * Returns a handle or NULL.
32 */
33 struct xs_handle *xs_daemon_open(void);
34 struct xs_handle *xs_domain_open(void);
36 /* Connect to the xs daemon (readonly for non-root clients).
37 * Returns a handle or NULL.
38 */
39 struct xs_handle *xs_daemon_open_readonly(void);
41 /* Close the connection to the xs daemon. */
42 void xs_daemon_close(struct xs_handle *);
44 /* Get contents of a directory.
45 * Returns a malloced array: call free() on it after use.
46 * Num indicates size.
47 */
48 char **xs_directory(struct xs_handle *h, struct xs_transaction_handle *t,
49 const char *path, unsigned int *num);
51 /* Get the value of a single file, nul terminated.
52 * Returns a malloced value: call free() on it after use.
53 * len indicates length in bytes, not including terminator.
54 */
55 void *xs_read(struct xs_handle *h, struct xs_transaction_handle *t,
56 const char *path, unsigned int *len);
58 /* Write the value of a single file.
59 * Returns false on failure.
60 */
61 bool xs_write(struct xs_handle *h, struct xs_transaction_handle *t,
62 const char *path, const void *data, unsigned int len);
64 /* Create a new directory.
65 * Returns false on failure, or success if it already exists.
66 */
67 bool xs_mkdir(struct xs_handle *h, struct xs_transaction_handle *t,
68 const char *path);
70 /* Destroy a file or directory (and children).
71 * Returns false on failure, or success if it doesn't exist.
72 */
73 bool xs_rm(struct xs_handle *h, struct xs_transaction_handle *t,
74 const char *path);
76 /* Get permissions of node (first element is owner, first perms is "other").
77 * Returns malloced array, or NULL: call free() after use.
78 */
79 struct xs_permissions *xs_get_permissions(struct xs_handle *h,
80 struct xs_transaction_handle *t,
81 const char *path, unsigned int *num);
83 /* Set permissions of node (must be owner).
84 * Returns false on failure.
85 */
86 bool xs_set_permissions(struct xs_handle *h, struct xs_transaction_handle *t,
87 const char *path, struct xs_permissions *perms,
88 unsigned int num_perms);
90 /* Watch a node for changes (poll on fd to detect, or call read_watch()).
91 * When the node (or any child) changes, fd will become readable.
92 * Token is returned when watch is read, to allow matching.
93 * Returns false on failure.
94 */
95 bool xs_watch(struct xs_handle *h, const char *path, const char *token);
97 /* Return the FD to poll on to see if a watch has fired. */
98 int xs_fileno(struct xs_handle *h);
100 /* Find out what node change was on (will block if nothing pending).
101 * Returns array containing the path and token. Use XS_WATCH_* to access these
102 * elements. Call free() after use.
103 */
104 char **xs_read_watch(struct xs_handle *h, unsigned int *num);
106 /* Remove a watch on a node: implicitly acks any outstanding watch.
107 * Returns false on failure (no watch on that node).
108 */
109 bool xs_unwatch(struct xs_handle *h, const char *path, const char *token);
111 /* Start a transaction: changes by others will not be seen during this
112 * transaction, and changes will not be visible to others until end.
113 * You can only have one transaction at any time.
114 * Returns NULL on failure.
115 */
116 struct xs_transaction_handle *xs_transaction_start(struct xs_handle *h);
118 /* End a transaction.
119 * If abandon is true, transaction is discarded instead of committed.
120 * Returns false on failure: if errno == EAGAIN, you have to restart
121 * transaction.
122 */
123 bool xs_transaction_end(struct xs_handle *h, struct xs_transaction_handle *t,
124 bool abort);
126 /* Introduce a new domain.
127 * This tells the store daemon about a shared memory page, event channel and
128 * store path associated with a domain: the domain uses these to communicate.
129 */
130 bool xs_introduce_domain(struct xs_handle *h,
131 unsigned int domid,
132 unsigned long mfn,
133 unsigned int eventchn);
134 /* Release a domain.
135 * Tells the store domain to release the memory page to the domain.
136 */
137 bool xs_release_domain(struct xs_handle *h, unsigned int domid);
139 /* Query the home path of a domain.
140 */
141 char *xs_get_domain_path(struct xs_handle *h, unsigned int domid);
143 /* Return whether the domain specified has been introduced to xenstored.
144 */
145 bool xs_is_domain_introduced(struct xs_handle *h, unsigned int domid);
147 /* Only useful for DEBUG versions */
148 char *xs_debug_command(struct xs_handle *h, const char *cmd,
149 void *data, unsigned int len);
151 #endif /* _XS_H */
153 /*
154 * Local variables:
155 * c-file-style: "linux"
156 * indent-tabs-mode: t
157 * c-indent-level: 8
158 * c-basic-offset: 8
159 * tab-width: 8
160 * End:
161 */