[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH] Rename public xenstore headers
On Sat, 2012-05-12 at 06:47 +0100, Ian Campbell wrote: > > You've been shovelling stuff in all day ;-) I'll refresh/resend on > Monday. It applied for me this morning so I suspect you hadn't noticed this: > You did take note of the "git-ness" of the patch though? -- ISTR your > tools had trouble with this format last time. Here it is a gain in non-git format and with the header guards removed from the compat headers as requested. I stuck with the compat subdir. qemu-xs-compat.patch is again attached. 8<-------------------------------- # HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1336984299 -3600 # Node ID e71b19157a4788d8a56bb578f9ddc01cb92c331f # Parent 54fcdee8740f86c9d3ca4f8bf5b780d292cd11f7 xenstore: rename public xenstore headers The xenstore header xs.h is producing conflicts with other software[1]. xs is a too short identifier and does not matche the library. Renaming the headers to xenstore.h and xenstore_lib.h is the easiest way to make them easy recognizable and prevent furthe problems. [1]: http://bugs.debian.org/668550 Signed-off-by: Bastian Blank <waldi@xxxxxxxxxx> Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> diff -r 54fcdee8740f -r e71b19157a47 Makefile --- a/Makefile Mon May 14 09:11:00 2012 +0100 +++ b/Makefile Mon May 14 09:31:39 2012 +0100 @@ -241,6 +241,8 @@ uninstall: rm -rf $(D)$(BINDIR)/xenpvnetboot $(D)$(BINDIR)/qemu-*-xen rm -rf $(D)$(INCLUDEDIR)/xenctrl* $(D)$(INCLUDEDIR)/xenguest.h rm -rf $(D)$(INCLUDEDIR)/xs_lib.h $(D)$(INCLUDEDIR)/xs.h + rm -rf $(D)$(INCLUDEDIR)/xenstore-compat/xs_lib.h $(D)$(INCLUDEDIR)/xensotre-compat/xs.h + rm -rf $(D)$(INCLUDEDIR)/xenstore_lib.h $(D)$(INCLUDEDIR)/xenstore.h rm -rf $(D)$(INCLUDEDIR)/xen rm -rf $(D)$(INCLUDEDIR)/_libxl* $(D)$(INCLUDEDIR)/libxl* rm -rf $(D)$(INCLUDEDIR)/xenstat.h $(D)$(INCLUDEDIR)/xentoollog.h diff -r 54fcdee8740f -r e71b19157a47 extras/mini-os/lib/sys.c --- a/extras/mini-os/lib/sys.c Mon May 14 09:11:00 2012 +0100 +++ b/extras/mini-os/lib/sys.c Mon May 14 09:31:39 2012 +0100 @@ -28,7 +28,7 @@ #include <blkfront.h> #include <fbfront.h> #include <xenbus.h> -#include <xs.h> +#include <xenstore.h> #include <sys/types.h> #include <sys/unistd.h> diff -r 54fcdee8740f -r e71b19157a47 extras/mini-os/lib/xs.c --- a/extras/mini-os/lib/xs.c Mon May 14 09:11:00 2012 +0100 +++ b/extras/mini-os/lib/xs.c Mon May 14 09:31:39 2012 +0100 @@ -9,7 +9,7 @@ #ifdef HAVE_LIBC #include <os.h> #include <lib.h> -#include <xs.h> +#include <xenstore.h> #include <xenbus.h> #include <stdlib.h> #include <unistd.h> diff -r 54fcdee8740f -r e71b19157a47 tools/Makefile --- a/tools/Makefile Mon May 14 09:11:00 2012 +0100 +++ b/tools/Makefile Mon May 14 09:31:39 2012 +0100 @@ -150,7 +150,8 @@ subdir-all-qemu-xen-dir subdir-install-q --source-path=$$source \ --extra-cflags="-I$(XEN_ROOT)/tools/include \ -I$(XEN_ROOT)/tools/libxc \ - -I$(XEN_ROOT)/tools/xenstore" \ + -I$(XEN_ROOT)/tools/xenstore \ + -I$(XEN_ROOT)/tools/xenstore/compat" \ --extra-ldflags="-L$(XEN_ROOT)/tools/libxc \ -L$(XEN_ROOT)/tools/xenstore" \ --bindir=$(LIBEXEC) \ diff -r 54fcdee8740f -r e71b19157a47 tools/blktap/drivers/blktapctrl.c --- a/tools/blktap/drivers/blktapctrl.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/blktap/drivers/blktapctrl.c Mon May 14 09:31:39 2012 +0100 @@ -47,7 +47,7 @@ #include <sys/ioctl.h> #include <string.h> #include <unistd.h> -#include <xs.h> +#include <xenstore.h> #include <sys/time.h> #include <syslog.h> #ifdef MEMSHR diff -r 54fcdee8740f -r e71b19157a47 tools/blktap/lib/blktaplib.h --- a/tools/blktap/lib/blktaplib.h Mon May 14 09:11:00 2012 +0100 +++ b/tools/blktap/lib/blktaplib.h Mon May 14 09:31:39 2012 +0100 @@ -38,7 +38,7 @@ #include <xen/xen.h> #include <xen/io/blkif.h> #include <xen/io/ring.h> -#include <xs.h> +#include <xenstore.h> #include <sys/types.h> #include <unistd.h> diff -r 54fcdee8740f -r e71b19157a47 tools/blktap/lib/xenbus.c --- a/tools/blktap/lib/xenbus.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/blktap/lib/xenbus.c Mon May 14 09:31:39 2012 +0100 @@ -41,7 +41,7 @@ #include <err.h> #include <stdarg.h> #include <errno.h> -#include <xs.h> +#include <xenstore.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> diff -r 54fcdee8740f -r e71b19157a47 tools/blktap/lib/xs_api.c --- a/tools/blktap/lib/xs_api.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/blktap/lib/xs_api.c Mon May 14 09:31:39 2012 +0100 @@ -38,7 +38,7 @@ #include <err.h> #include <stdarg.h> #include <errno.h> -#include <xs.h> +#include <xenstore.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> diff -r 54fcdee8740f -r e71b19157a47 tools/console/client/main.c --- a/tools/console/client/main.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/console/client/main.c Mon May 14 09:31:39 2012 +0100 @@ -39,7 +39,7 @@ #include <sys/stropts.h> #endif -#include "xs.h" +#include <xenstore.h> #include "xenctrl.h" #define ESCAPE_CHARACTER 0x1d diff -r 54fcdee8740f -r e71b19157a47 tools/console/daemon/io.c --- a/tools/console/daemon/io.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/console/daemon/io.c Mon May 14 09:31:39 2012 +0100 @@ -22,7 +22,7 @@ #include "utils.h" #include "io.h" -#include <xs.h> +#include <xenstore.h> #include <xen/io/console.h> #include <stdlib.h> diff -r 54fcdee8740f -r e71b19157a47 tools/console/daemon/utils.h --- a/tools/console/daemon/utils.h Mon May 14 09:11:00 2012 +0100 +++ b/tools/console/daemon/utils.h Mon May 14 09:31:39 2012 +0100 @@ -26,7 +26,7 @@ #include <stdio.h> #include <xenctrl.h> -#include "xs.h" +#include <xenstore.h> void daemonize(const char *pidfile); bool xen_setup(void); diff -r 54fcdee8740f -r e71b19157a47 tools/libvchan/init.c --- a/tools/libvchan/init.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/libvchan/init.c Mon May 14 09:31:39 2012 +0100 @@ -40,7 +40,7 @@ #include <unistd.h> #include <fcntl.h> -#include <xs.h> +#include <xenstore.h> #include <xen/sys/evtchn.h> #include <xen/sys/gntalloc.h> #include <xen/sys/gntdev.h> diff -r 54fcdee8740f -r e71b19157a47 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Mon May 14 09:11:00 2012 +0100 +++ b/tools/libxl/libxl_internal.h Mon May 14 09:31:39 2012 +0100 @@ -44,7 +44,7 @@ #include <sys/wait.h> #include <sys/socket.h> -#include <xs.h> +#include <xenstore.h> #include <xenctrl.h> #include "xentoollog.h" diff -r 54fcdee8740f -r e71b19157a47 tools/misc/xen-lowmemd.c --- a/tools/misc/xen-lowmemd.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/misc/xen-lowmemd.c Mon May 14 09:31:39 2012 +0100 @@ -5,7 +5,7 @@ #include <stdio.h> #include <xenctrl.h> -#include <xs.h> +#include <xenstore.h> #include <stdlib.h> #include <string.h> diff -r 54fcdee8740f -r e71b19157a47 tools/python/xen/lowlevel/checkpoint/checkpoint.c --- a/tools/python/xen/lowlevel/checkpoint/checkpoint.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/python/xen/lowlevel/checkpoint/checkpoint.c Mon May 14 09:31:39 2012 +0100 @@ -2,7 +2,7 @@ #include <Python.h> -#include <xs.h> +#include <xenstore.h> #include <xenctrl.h> #include "checkpoint.h" diff -r 54fcdee8740f -r e71b19157a47 tools/python/xen/lowlevel/checkpoint/checkpoint.h --- a/tools/python/xen/lowlevel/checkpoint/checkpoint.h Mon May 14 09:11:00 2012 +0100 +++ b/tools/python/xen/lowlevel/checkpoint/checkpoint.h Mon May 14 09:31:39 2012 +0100 @@ -8,7 +8,7 @@ #include <time.h> #include <xenguest.h> -#include <xs.h> +#include <xenstore.h> typedef enum { dt_unknown, diff -r 54fcdee8740f -r e71b19157a47 tools/python/xen/lowlevel/checkpoint/libcheckpoint.c --- a/tools/python/xen/lowlevel/checkpoint/libcheckpoint.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/python/xen/lowlevel/checkpoint/libcheckpoint.c Mon May 14 09:31:39 2012 +0100 @@ -11,7 +11,7 @@ #include <xenctrl.h> #include <xenguest.h> -#include <xs.h> +#include <xenstore.h> #include "checkpoint.h" diff -r 54fcdee8740f -r e71b19157a47 tools/python/xen/lowlevel/xs/xs.c --- a/tools/python/xen/lowlevel/xs/xs.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/python/xen/lowlevel/xs/xs.c Mon May 14 09:31:39 2012 +0100 @@ -30,7 +30,7 @@ #include <fcntl.h> #include <errno.h> -#include "xs.h" +#include <xenstore.h> /** @file * Python interface to the Xen Store Daemon (xs). diff -r 54fcdee8740f -r e71b19157a47 tools/tests/mce-test/tools/xen-mceinj.c --- a/tools/tests/mce-test/tools/xen-mceinj.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/tests/mce-test/tools/xen-mceinj.c Mon May 14 09:31:39 2012 +0100 @@ -38,7 +38,7 @@ #include <sys/time.h> #include <xen/arch-x86/xen-mca.h> #include <xg_save_restore.h> -#include <xs.h> +#include <xenstore.h> #define MCi_type_CTL 0x0 #define MCi_type_STATUS 0x1 diff -r 54fcdee8740f -r e71b19157a47 tools/xcutils/xc_save.c --- a/tools/xcutils/xc_save.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/xcutils/xc_save.c Mon May 14 09:31:39 2012 +0100 @@ -19,7 +19,7 @@ #include <fcntl.h> #include <err.h> -#include <xs.h> +#include <xenstore.h> #include <xenctrl.h> #include <xenguest.h> diff -r 54fcdee8740f -r e71b19157a47 tools/xenbackendd/xenbackendd.c --- a/tools/xenbackendd/xenbackendd.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/xenbackendd/xenbackendd.c Mon May 14 09:31:39 2012 +0100 @@ -28,7 +28,7 @@ #include <string.h> #include <syslog.h> -#include <xs.h> +#include <xenstore.h> #define DEVTYPE_UNKNOWN 0 #define DEVTYPE_VIF 1 diff -r 54fcdee8740f -r e71b19157a47 tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/xenpaging/xenpaging.c Mon May 14 09:31:39 2012 +0100 @@ -29,7 +29,7 @@ #include <unistd.h> #include <poll.h> #include <xc_private.h> -#include <xs.h> +#include <xenstore.h> #include <getopt.h> #include "xc_bitops.h" diff -r 54fcdee8740f -r e71b19157a47 tools/xenpmd/xenpmd.c --- a/tools/xenpmd/xenpmd.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/xenpmd/xenpmd.c Mon May 14 09:31:39 2012 +0100 @@ -40,7 +40,7 @@ #include <dirent.h> #include <unistd.h> #include <sys/stat.h> -#include <xs.h> +#include <xenstore.h> /* #define RUN_STANDALONE */ #define RUN_IN_SIMULATE_MODE diff -r 54fcdee8740f -r e71b19157a47 tools/xenstat/libxenstat/src/xenstat_priv.h --- a/tools/xenstat/libxenstat/src/xenstat_priv.h Mon May 14 09:11:00 2012 +0100 +++ b/tools/xenstat/libxenstat/src/xenstat_priv.h Mon May 14 09:31:39 2012 +0100 @@ -24,7 +24,7 @@ #define XENSTAT_PRIV_H #include <sys/types.h> -#include <xs.h> +#include <xenstore.h> #include "xenstat.h" #include "xenctrl.h" diff -r 54fcdee8740f -r e71b19157a47 tools/xenstore/COPYING --- a/tools/xenstore/COPYING Mon May 14 09:11:00 2012 +0100 +++ b/tools/xenstore/COPYING Mon May 14 09:31:39 2012 +0100 @@ -1,6 +1,6 @@ This license (LGPL) applies to the xenstore library which interfaces -with the xenstore daemon (as stated in xs.c, xs.h, xs_lib.c and -xs_lib.h). The remaining files in the directory are licensed as +with the xenstore daemon (as stated in xs.c, xenstore.h, xs_lib.c and +xenstore_lib.h). The remaining files in the directory are licensed as stated in the comments (as of this writing, GPL, see ../../COPYING). diff -r 54fcdee8740f -r e71b19157a47 tools/xenstore/Makefile --- a/tools/xenstore/Makefile Mon May 14 09:11:00 2012 +0100 +++ b/tools/xenstore/Makefile Mon May 14 09:31:39 2012 +0100 @@ -109,6 +109,7 @@ install: all $(INSTALL_DIR) $(DESTDIR)$(BINDIR) $(INSTALL_DIR) $(DESTDIR)$(SBINDIR) $(INSTALL_DIR) $(DESTDIR)$(INCLUDEDIR) + $(INSTALL_DIR) $(DESTDIR)$(INCLUDEDIR)/xenstore-compat $(INSTALL_DIR) $(DESTDIR)/var/run/xenstored $(INSTALL_DIR) $(DESTDIR)/var/lib/xenstored $(INSTALL_PROG) xenstored $(DESTDIR)$(SBINDIR) @@ -122,8 +123,12 @@ install: all ln -sf libxenstore.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)/libxenstore.so.$(MAJOR) ln -sf libxenstore.so.$(MAJOR) $(DESTDIR)$(LIBDIR)/libxenstore.so $(INSTALL_DATA) libxenstore.a $(DESTDIR)$(LIBDIR) - $(INSTALL_DATA) xs.h $(DESTDIR)$(INCLUDEDIR) - $(INSTALL_DATA) xs_lib.h $(DESTDIR)$(INCLUDEDIR) + $(INSTALL_DATA) xenstore.h $(DESTDIR)$(INCLUDEDIR) + $(INSTALL_DATA) xenstore_lib.h $(DESTDIR)$(INCLUDEDIR) + $(INSTALL_DATA) compat/xs.h $(DESTDIR)$(INCLUDEDIR)/xenstore-compat/xs.h + $(INSTALL_DATA) compat/xs_lib.h $(DESTDIR)$(INCLUDEDIR)/xenstore-compat/xs_lib.h + ln -sf xenstore-compat/xs.h $(DESTDIR)$(INCLUDEDIR)/xs.h + ln -sf xenstore-compat/xs_lib.h $(DESTDIR)$(INCLUDEDIR)/xs_lib.h -include $(DEPS) diff -r 54fcdee8740f -r e71b19157a47 tools/xenstore/compat/xs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/xenstore/compat/xs.h Mon May 14 09:31:39 2012 +0100 @@ -0,0 +1,2 @@ +#warning xs.h is deprecated use xenstore.h instead +#include <xenstore.h> diff -r 54fcdee8740f -r e71b19157a47 tools/xenstore/compat/xs_lib.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/xenstore/compat/xs_lib.h Mon May 14 09:31:39 2012 +0100 @@ -0,0 +1,2 @@ +#warning xs_lib.h is deprecated use xenstore_lib.h instead +#include <xenstore_lib.h> diff -r 54fcdee8740f -r e71b19157a47 tools/xenstore/init-xenstore-domain.c --- a/tools/xenstore/init-xenstore-domain.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/xenstore/init-xenstore-domain.c Mon May 14 09:31:39 2012 +0100 @@ -7,7 +7,7 @@ #include <sys/mman.h> #include <xenctrl.h> #include <xc_dom.h> -#include <xs.h> +#include <xenstore.h> #include <xen/sys/xenbus_dev.h> static uint32_t domid = -1; diff -r 54fcdee8740f -r e71b19157a47 tools/xenstore/xenstore.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/xenstore/xenstore.h Mon May 14 09:31:39 2012 +0100 @@ -0,0 +1,236 @@ +/* + Xen Store Daemon providing simple tree-like database. + Copyright (C) 2005 Rusty Russell IBM Corporation + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef XENSTORE_H +#define XENSTORE_H + +#include <xenstore_lib.h> + +#define XBT_NULL 0 + +#define XS_OPEN_READONLY 1UL<<0 +#define XS_OPEN_SOCKETONLY 1UL<<1 + +struct xs_handle; +typedef uint32_t xs_transaction_t; + +/* IMPORTANT: For details on xenstore protocol limits, see + * docs/misc/xenstore.txt in the Xen public source repository, and use the + * XENSTORE_*_MAX limit macros defined in xen/io/xs_wire.h. + */ + +/* On failure, these routines set errno. */ + +/* Open a connection to the xs daemon. + * Attempts to make a connection over the socket interface, + * and if it fails, then over the xenbus interface. + * Mode 0 specifies read-write access, XS_OPEN_READONLY for + * read-only access. + * Returns a handle or NULL. + */ +struct xs_handle *xs_open(unsigned long flags); + +/* Close the connection to the xs daemon. */ +void xs_close(struct xs_handle *xsh); + +/* Connect to the xs daemon. + * Returns a handle or NULL. + * Deprecated, please use xs_open(0) instead + */ +struct xs_handle *xs_daemon_open(void); +struct xs_handle *xs_domain_open(void); + +/* Connect to the xs daemon (readonly for non-root clients). + * Returns a handle or NULL. + * Deprecated, please use xs_open(XS_OPEN_READONLY) instead + */ +struct xs_handle *xs_daemon_open_readonly(void); + +/* Close the connection to the xs daemon. + * Deprecated, please use xs_close() instead + */ +void xs_daemon_close(struct xs_handle *); + +/* Throw away the connection to the xs daemon, for use after fork(). */ +void xs_daemon_destroy_postfork(struct xs_handle *); + +/* Get contents of a directory. + * Returns a malloced array: call free() on it after use. + * Num indicates size. + */ +char **xs_directory(struct xs_handle *h, xs_transaction_t t, + const char *path, unsigned int *num); + +/* Get the value of a single file, nul terminated. + * Returns a malloced value: call free() on it after use. + * len indicates length in bytes, not including terminator. + */ +void *xs_read(struct xs_handle *h, xs_transaction_t t, + const char *path, unsigned int *len); + +/* Write the value of a single file. + * Returns false on failure. + */ +bool xs_write(struct xs_handle *h, xs_transaction_t t, + const char *path, const void *data, unsigned int len); + +/* Create a new directory. + * Returns false on failure, or success if it already exists. + */ +bool xs_mkdir(struct xs_handle *h, xs_transaction_t t, + const char *path); + +/* Destroy a file or directory (and children). + * Returns false on failure, or if it doesn't exist. + */ +bool xs_rm(struct xs_handle *h, xs_transaction_t t, + const char *path); + +/* Restrict a xenstore handle so that it acts as if it had the + * permissions of domain @domid. The handle must currently be + * using domain 0's credentials. + * + * Returns false on failure, in which case the handle continues + * to use the old credentials, or true on success. + */ +bool xs_restrict(struct xs_handle *h, unsigned domid); + +/* Get permissions of node (first element is owner, first perms is "other"). + * Returns malloced array, or NULL: call free() after use. + */ +struct xs_permissions *xs_get_permissions(struct xs_handle *h, + xs_transaction_t t, + const char *path, unsigned int *num); + +/* Set permissions of node (must be owner). + * Returns false on failure. + */ +bool xs_set_permissions(struct xs_handle *h, xs_transaction_t t, + const char *path, struct xs_permissions *perms, + unsigned int num_perms); + +/* Watch a node for changes (poll on fd to detect, or call read_watch()). + * When the node (or any child) changes, fd will become readable. + * Token is returned when watch is read, to allow matching. + * Returns false on failure. + */ +bool xs_watch(struct xs_handle *h, const char *path, const char *token); + +/* Return the FD to poll on to see if a watch has fired. */ +int xs_fileno(struct xs_handle *h); + +/* Check for node changes. On success, returns a non-NULL pointer ret + * such that ret[0] and ret[1] are valid C strings, namely the + * triggering path (see docs/misc/xenstore.txt) and the token (from + * xs_watch). On error return value is NULL setting errno. + * + * Callers should, after xs_fileno has become readable, repeatedly + * call xs_check_watch until it returns NULL and sets errno to EAGAIN. + * (If the fd became readable, xs_check_watch is allowed to make it no + * longer show up as readable even if future calls to xs_check_watch + * will return more watch events.) + * + * After the caller is finished with the returned information it + * should be freed all in one go with free(ret). + */ +char **xs_check_watch(struct xs_handle *h); + +/* Find out what node change was on (will block if nothing pending). + * Returns array containing the path and token. Use XS_WATCH_* to access these + * elements. Call free() after use. + */ +char **xs_read_watch(struct xs_handle *h, unsigned int *num); + +/* Remove a watch on a node: implicitly acks any outstanding watch. + * Returns false on failure (no watch on that node). + */ +bool xs_unwatch(struct xs_handle *h, const char *path, const char *token); + +/* Start a transaction: changes by others will not be seen during this + * transaction, and changes will not be visible to others until end. + * Returns NULL on failure. + */ +xs_transaction_t xs_transaction_start(struct xs_handle *h); + +/* End a transaction. + * If abandon is true, transaction is discarded instead of committed. + * Returns false on failure: if errno == EAGAIN, you have to restart + * transaction. + */ +bool xs_transaction_end(struct xs_handle *h, xs_transaction_t t, + bool abort); + +/* Introduce a new domain. + * This tells the store daemon about a shared memory page, event channel and + * store path associated with a domain: the domain uses these to communicate. + */ +bool xs_introduce_domain(struct xs_handle *h, + unsigned int domid, + unsigned long mfn, + unsigned int eventchn); + +/* Set the target of a domain + * This tells the store daemon that a domain is targetting another one, so + * it should let it tinker with it. + */ +bool xs_set_target(struct xs_handle *h, + unsigned int domid, + unsigned int target); + +/* Resume a domain. + * Clear the shutdown flag for this domain in the store. + */ +bool xs_resume_domain(struct xs_handle *h, unsigned int domid); + +/* Release a domain. + * Tells the store domain to release the memory page to the domain. + */ +bool xs_release_domain(struct xs_handle *h, unsigned int domid); + +/* Query the home path of a domain. Call free() after use. + */ +char *xs_get_domain_path(struct xs_handle *h, unsigned int domid); + +/* Returns true if child is either equal to parent, or a node underneath + * parent; or false otherwise. Done by string comparison, so relative and + * absolute pathnames never in a parent/child relationship by this + * definition. Cannot fail. + */ +bool xs_path_is_subpath(const char *parent, const char *child); + +/* Return whether the domain specified has been introduced to xenstored. + */ +bool xs_is_domain_introduced(struct xs_handle *h, unsigned int domid); + +/* Only useful for DEBUG versions */ +char *xs_debug_command(struct xs_handle *h, const char *cmd, + void *data, unsigned int len); + +int xs_suspend_evtchn_port(int domid); +#endif /* XENSTORE_H */ + +/* + * Local variables: + * c-file-style: "linux" + * indent-tabs-mode: t + * c-indent-level: 8 + * c-basic-offset: 8 + * tab-width: 8 + * End: + */ diff -r 54fcdee8740f -r e71b19157a47 tools/xenstore/xenstore_client.c --- a/tools/xenstore/xenstore_client.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/xenstore/xenstore_client.c Mon May 14 09:31:39 2012 +0100 @@ -18,7 +18,7 @@ #include <string.h> #include <termios.h> #include <unistd.h> -#include <xs.h> +#include <xenstore.h> #include <sys/ioctl.h> diff -r 54fcdee8740f -r e71b19157a47 tools/xenstore/xenstore_control.c --- a/tools/xenstore/xenstore_control.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/xenstore/xenstore_control.c Mon May 14 09:31:39 2012 +0100 @@ -2,7 +2,7 @@ #include <stdlib.h> #include <string.h> -#include "xs.h" +#include "xenstore.h" int main(int argc, char **argv) diff -r 54fcdee8740f -r e71b19157a47 tools/xenstore/xenstore_lib.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/xenstore/xenstore_lib.h Mon May 14 09:31:39 2012 +0100 @@ -0,0 +1,85 @@ +/* + Common routines between Xen store user library and daemon. + Copyright (C) 2005 Rusty Russell IBM Corporation + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef XENSTORE_LIB_H +#define XENSTORE_LIB_H + +#include <stdbool.h> +#include <limits.h> +#include <errno.h> +#include <stdint.h> +#include <xen/io/xs_wire.h> + +/* Bitmask of permissions. */ +enum xs_perm_type { + XS_PERM_NONE = 0, + XS_PERM_READ = 1, + XS_PERM_WRITE = 2, + /* Internal use. */ + XS_PERM_ENOENT_OK = 4, + XS_PERM_OWNER = 8, +}; + +struct xs_permissions +{ + unsigned int id; + enum xs_perm_type perms; +}; + +/* Each 10 bits takes ~ 3 digits, plus one, plus one for nul terminator. */ +#define MAX_STRLEN(x) ((sizeof(x) * CHAR_BIT + CHAR_BIT-1) / 10 * 3 + 2) + +/* Path for various daemon things: env vars can override. */ +const char *xs_daemon_rootdir(void); +const char *xs_daemon_rundir(void); +const char *xs_daemon_socket(void); +const char *xs_daemon_socket_ro(void); +const char *xs_domain_dev(void); +const char *xs_daemon_tdb(void); + +/* Simple write function: loops for you. */ +bool xs_write_all(int fd, const void *data, unsigned int len); + +/* Convert strings to permissions. False if a problem. */ +bool xs_strings_to_perms(struct xs_permissions *perms, unsigned int num, + const char *strings); + +/* Convert permissions to a string (up to len MAX_STRLEN(unsigned int)+1). */ +bool xs_perm_to_string(const struct xs_permissions *perm, + char *buffer, size_t buf_len); + +/* Given a string and a length, count how many strings (nul terms). */ +unsigned int xs_count_strings(const char *strings, unsigned int len); + +/* Sanitising (quoting) possibly-binary strings. */ +struct expanding_buffer { + char *buf; + int avail; +}; + +/* Ensure that given expanding buffer has at least min_avail characters. */ +char *expanding_buffer_ensure(struct expanding_buffer *, int min_avail); + +/* sanitise_value() may return NULL if malloc fails. */ +char *sanitise_value(struct expanding_buffer *, const char *val, unsigned len); + +/* *out_len_r on entry is ignored; out must be at least strlen(in)+1 bytes. */ +void unsanitise_value(char *out, unsigned *out_len_r, const char *in); + +#endif /* XENSTORE_LIB_H */ diff -r 54fcdee8740f -r e71b19157a47 tools/xenstore/xenstored_core.c --- a/tools/xenstore/xenstored_core.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/xenstore/xenstored_core.c Mon May 14 09:31:39 2012 +0100 @@ -44,7 +44,7 @@ #include "utils.h" #include "list.h" #include "talloc.h" -#include "xs_lib.h" +#include "xenstore_lib.h" #include "xenstored_core.h" #include "xenstored_watch.h" #include "xenstored_transaction.h" diff -r 54fcdee8740f -r e71b19157a47 tools/xenstore/xenstored_core.h --- a/tools/xenstore/xenstored_core.h Mon May 14 09:11:00 2012 +0100 +++ b/tools/xenstore/xenstored_core.h Mon May 14 09:31:39 2012 +0100 @@ -27,7 +27,7 @@ #include <stdbool.h> #include <stdint.h> #include <errno.h> -#include "xs_lib.h" +#include "xenstore_lib.h" #include "list.h" #include "tdb.h" diff -r 54fcdee8740f -r e71b19157a47 tools/xenstore/xenstored_transaction.c --- a/tools/xenstore/xenstored_transaction.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/xenstore/xenstored_transaction.c Mon May 14 09:31:39 2012 +0100 @@ -33,7 +33,7 @@ #include "xenstored_transaction.h" #include "xenstored_watch.h" #include "xenstored_domain.h" -#include "xs_lib.h" +#include "xenstore_lib.h" #include "utils.h" struct changed_node diff -r 54fcdee8740f -r e71b19157a47 tools/xenstore/xenstored_watch.c --- a/tools/xenstore/xenstored_watch.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/xenstore/xenstored_watch.c Mon May 14 09:31:39 2012 +0100 @@ -27,7 +27,7 @@ #include "talloc.h" #include "list.h" #include "xenstored_watch.h" -#include "xs_lib.h" +#include "xenstore_lib.h" #include "utils.h" #include "xenstored_domain.h" diff -r 54fcdee8740f -r e71b19157a47 tools/xenstore/xs.c --- a/tools/xenstore/xs.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/xenstore/xs.c Mon May 14 09:31:39 2012 +0100 @@ -32,7 +32,7 @@ #include <signal.h> #include <stdint.h> #include <errno.h> -#include "xs.h" +#include "xenstore.h" #include "list.h" #include "utils.h" diff -r 54fcdee8740f -r e71b19157a47 tools/xenstore/xs.h --- a/tools/xenstore/xs.h Mon May 14 09:11:00 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,236 +0,0 @@ -/* - Xen Store Daemon providing simple tree-like database. - Copyright (C) 2005 Rusty Russell IBM Corporation - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef _XS_H -#define _XS_H - -#include <xs_lib.h> - -#define XBT_NULL 0 - -#define XS_OPEN_READONLY 1UL<<0 -#define XS_OPEN_SOCKETONLY 1UL<<1 - -struct xs_handle; -typedef uint32_t xs_transaction_t; - -/* IMPORTANT: For details on xenstore protocol limits, see - * docs/misc/xenstore.txt in the Xen public source repository, and use the - * XENSTORE_*_MAX limit macros defined in xen/io/xs_wire.h. - */ - -/* On failure, these routines set errno. */ - -/* Open a connection to the xs daemon. - * Attempts to make a connection over the socket interface, - * and if it fails, then over the xenbus interface. - * Mode 0 specifies read-write access, XS_OPEN_READONLY for - * read-only access. - * Returns a handle or NULL. - */ -struct xs_handle *xs_open(unsigned long flags); - -/* Close the connection to the xs daemon. */ -void xs_close(struct xs_handle *xsh); - -/* Connect to the xs daemon. - * Returns a handle or NULL. - * Deprecated, please use xs_open(0) instead - */ -struct xs_handle *xs_daemon_open(void); -struct xs_handle *xs_domain_open(void); - -/* Connect to the xs daemon (readonly for non-root clients). - * Returns a handle or NULL. - * Deprecated, please use xs_open(XS_OPEN_READONLY) instead - */ -struct xs_handle *xs_daemon_open_readonly(void); - -/* Close the connection to the xs daemon. - * Deprecated, please use xs_close() instead - */ -void xs_daemon_close(struct xs_handle *); - -/* Throw away the connection to the xs daemon, for use after fork(). */ -void xs_daemon_destroy_postfork(struct xs_handle *); - -/* Get contents of a directory. - * Returns a malloced array: call free() on it after use. - * Num indicates size. - */ -char **xs_directory(struct xs_handle *h, xs_transaction_t t, - const char *path, unsigned int *num); - -/* Get the value of a single file, nul terminated. - * Returns a malloced value: call free() on it after use. - * len indicates length in bytes, not including terminator. - */ -void *xs_read(struct xs_handle *h, xs_transaction_t t, - const char *path, unsigned int *len); - -/* Write the value of a single file. - * Returns false on failure. - */ -bool xs_write(struct xs_handle *h, xs_transaction_t t, - const char *path, const void *data, unsigned int len); - -/* Create a new directory. - * Returns false on failure, or success if it already exists. - */ -bool xs_mkdir(struct xs_handle *h, xs_transaction_t t, - const char *path); - -/* Destroy a file or directory (and children). - * Returns false on failure, or if it doesn't exist. - */ -bool xs_rm(struct xs_handle *h, xs_transaction_t t, - const char *path); - -/* Restrict a xenstore handle so that it acts as if it had the - * permissions of domain @domid. The handle must currently be - * using domain 0's credentials. - * - * Returns false on failure, in which case the handle continues - * to use the old credentials, or true on success. - */ -bool xs_restrict(struct xs_handle *h, unsigned domid); - -/* Get permissions of node (first element is owner, first perms is "other"). - * Returns malloced array, or NULL: call free() after use. - */ -struct xs_permissions *xs_get_permissions(struct xs_handle *h, - xs_transaction_t t, - const char *path, unsigned int *num); - -/* Set permissions of node (must be owner). - * Returns false on failure. - */ -bool xs_set_permissions(struct xs_handle *h, xs_transaction_t t, - const char *path, struct xs_permissions *perms, - unsigned int num_perms); - -/* Watch a node for changes (poll on fd to detect, or call read_watch()). - * When the node (or any child) changes, fd will become readable. - * Token is returned when watch is read, to allow matching. - * Returns false on failure. - */ -bool xs_watch(struct xs_handle *h, const char *path, const char *token); - -/* Return the FD to poll on to see if a watch has fired. */ -int xs_fileno(struct xs_handle *h); - -/* Check for node changes. On success, returns a non-NULL pointer ret - * such that ret[0] and ret[1] are valid C strings, namely the - * triggering path (see docs/misc/xenstore.txt) and the token (from - * xs_watch). On error return value is NULL setting errno. - * - * Callers should, after xs_fileno has become readable, repeatedly - * call xs_check_watch until it returns NULL and sets errno to EAGAIN. - * (If the fd became readable, xs_check_watch is allowed to make it no - * longer show up as readable even if future calls to xs_check_watch - * will return more watch events.) - * - * After the caller is finished with the returned information it - * should be freed all in one go with free(ret). - */ -char **xs_check_watch(struct xs_handle *h); - -/* Find out what node change was on (will block if nothing pending). - * Returns array containing the path and token. Use XS_WATCH_* to access these - * elements. Call free() after use. - */ -char **xs_read_watch(struct xs_handle *h, unsigned int *num); - -/* Remove a watch on a node: implicitly acks any outstanding watch. - * Returns false on failure (no watch on that node). - */ -bool xs_unwatch(struct xs_handle *h, const char *path, const char *token); - -/* Start a transaction: changes by others will not be seen during this - * transaction, and changes will not be visible to others until end. - * Returns NULL on failure. - */ -xs_transaction_t xs_transaction_start(struct xs_handle *h); - -/* End a transaction. - * If abandon is true, transaction is discarded instead of committed. - * Returns false on failure: if errno == EAGAIN, you have to restart - * transaction. - */ -bool xs_transaction_end(struct xs_handle *h, xs_transaction_t t, - bool abort); - -/* Introduce a new domain. - * This tells the store daemon about a shared memory page, event channel and - * store path associated with a domain: the domain uses these to communicate. - */ -bool xs_introduce_domain(struct xs_handle *h, - unsigned int domid, - unsigned long mfn, - unsigned int eventchn); - -/* Set the target of a domain - * This tells the store daemon that a domain is targetting another one, so - * it should let it tinker with it. - */ -bool xs_set_target(struct xs_handle *h, - unsigned int domid, - unsigned int target); - -/* Resume a domain. - * Clear the shutdown flag for this domain in the store. - */ -bool xs_resume_domain(struct xs_handle *h, unsigned int domid); - -/* Release a domain. - * Tells the store domain to release the memory page to the domain. - */ -bool xs_release_domain(struct xs_handle *h, unsigned int domid); - -/* Query the home path of a domain. Call free() after use. - */ -char *xs_get_domain_path(struct xs_handle *h, unsigned int domid); - -/* Returns true if child is either equal to parent, or a node underneath - * parent; or false otherwise. Done by string comparison, so relative and - * absolute pathnames never in a parent/child relationship by this - * definition. Cannot fail. - */ -bool xs_path_is_subpath(const char *parent, const char *child); - -/* Return whether the domain specified has been introduced to xenstored. - */ -bool xs_is_domain_introduced(struct xs_handle *h, unsigned int domid); - -/* Only useful for DEBUG versions */ -char *xs_debug_command(struct xs_handle *h, const char *cmd, - void *data, unsigned int len); - -int xs_suspend_evtchn_port(int domid); -#endif /* _XS_H */ - -/* - * Local variables: - * c-file-style: "linux" - * indent-tabs-mode: t - * c-indent-level: 8 - * c-basic-offset: 8 - * tab-width: 8 - * End: - */ diff -r 54fcdee8740f -r e71b19157a47 tools/xenstore/xs_lib.c --- a/tools/xenstore/xs_lib.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/xenstore/xs_lib.c Mon May 14 09:31:39 2012 +0100 @@ -23,7 +23,7 @@ #include <stdlib.h> #include <errno.h> #include <assert.h> -#include "xs_lib.h" +#include "xenstore_lib.h" /* Common routines for the Xen store daemon and client library. */ diff -r 54fcdee8740f -r e71b19157a47 tools/xenstore/xs_lib.h --- a/tools/xenstore/xs_lib.h Mon May 14 09:11:00 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* - Common routines between Xen store user library and daemon. - Copyright (C) 2005 Rusty Russell IBM Corporation - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef _XS_LIB_H -#define _XS_LIB_H - -#include <stdbool.h> -#include <limits.h> -#include <errno.h> -#include <stdint.h> -#include <xen/io/xs_wire.h> - -/* Bitmask of permissions. */ -enum xs_perm_type { - XS_PERM_NONE = 0, - XS_PERM_READ = 1, - XS_PERM_WRITE = 2, - /* Internal use. */ - XS_PERM_ENOENT_OK = 4, - XS_PERM_OWNER = 8, -}; - -struct xs_permissions -{ - unsigned int id; - enum xs_perm_type perms; -}; - -/* Each 10 bits takes ~ 3 digits, plus one, plus one for nul terminator. */ -#define MAX_STRLEN(x) ((sizeof(x) * CHAR_BIT + CHAR_BIT-1) / 10 * 3 + 2) - -/* Path for various daemon things: env vars can override. */ -const char *xs_daemon_rootdir(void); -const char *xs_daemon_rundir(void); -const char *xs_daemon_socket(void); -const char *xs_daemon_socket_ro(void); -const char *xs_domain_dev(void); -const char *xs_daemon_tdb(void); - -/* Simple write function: loops for you. */ -bool xs_write_all(int fd, const void *data, unsigned int len); - -/* Convert strings to permissions. False if a problem. */ -bool xs_strings_to_perms(struct xs_permissions *perms, unsigned int num, - const char *strings); - -/* Convert permissions to a string (up to len MAX_STRLEN(unsigned int)+1). */ -bool xs_perm_to_string(const struct xs_permissions *perm, - char *buffer, size_t buf_len); - -/* Given a string and a length, count how many strings (nul terms). */ -unsigned int xs_count_strings(const char *strings, unsigned int len); - -/* Sanitising (quoting) possibly-binary strings. */ -struct expanding_buffer { - char *buf; - int avail; -}; - -/* Ensure that given expanding buffer has at least min_avail characters. */ -char *expanding_buffer_ensure(struct expanding_buffer *, int min_avail); - -/* sanitise_value() may return NULL if malloc fails. */ -char *sanitise_value(struct expanding_buffer *, const char *val, unsigned len); - -/* *out_len_r on entry is ignored; out must be at least strlen(in)+1 bytes. */ -void unsanitise_value(char *out, unsigned *out_len_r, const char *in); - -#endif /* _XS_LIB_H */ diff -r 54fcdee8740f -r e71b19157a47 tools/xenstore/xs_tdb_dump.c --- a/tools/xenstore/xs_tdb_dump.c Mon May 14 09:11:00 2012 +0100 +++ b/tools/xenstore/xs_tdb_dump.c Mon May 14 09:31:39 2012 +0100 @@ -5,7 +5,7 @@ #include <stdio.h> #include <stdarg.h> #include <string.h> -#include "xs_lib.h" +#include "xenstore_lib.h" #include "tdb.h" #include "talloc.h" #include "utils.h" Attachment:
qemu-xs-compat.patch _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |