From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH] Rename public xenstore headers Date: Mon, 14 May 2012 09:34:45 +0100 Message-ID: <1336984485.31817.17.camel@zakaz.uk.xensource.com> References: <20120416154210.GA6338@wavehammer.waldi.eu.org> <1334591484.14560.219.camel@zakaz.uk.xensource.com> <20374.54942.132249.434292@mariner.uk.xensource.com> <1336754999.23818.144.camel@zakaz.uk.xensource.com> <20120511170240.GA15662@wavehammer.waldi.eu.org> <20397.18234.50742.594420@mariner.uk.xensource.com> <1336801640.3891.17.camel@dagon.hellion.org.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-JAQUWIbHp0H2oacY4bGT" Return-path: In-Reply-To: <1336801640.3891.17.camel@dagon.hellion.org.uk> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: Bastian Blank , "xen-devel@lists.xensource.com" , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org --=-JAQUWIbHp0H2oacY4bGT Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit 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 # 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 Signed-off-by: Ian Campbell 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 #include #include -#include +#include #include #include 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 #include -#include +#include #include #include #include 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 #include #include -#include +#include #include #include #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 #include #include -#include +#include #include #include 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 #include #include -#include +#include #include #include #include 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 #include #include -#include +#include #include #include #include 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 #endif -#include "xs.h" +#include #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 +#include #include #include 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 #include -#include "xs.h" +#include 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 #include -#include +#include #include #include #include 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 #include -#include +#include #include #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 #include -#include +#include #include #include 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 -#include +#include #include #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 #include -#include +#include 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 #include -#include +#include #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 #include -#include "xs.h" +#include /** @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 #include #include -#include +#include #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 #include -#include +#include #include #include 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 #include -#include +#include #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 #include #include -#include +#include #include #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 #include #include -#include +#include /* #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 -#include +#include #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 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 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 #include #include -#include +#include #include 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 + +#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 #include #include -#include +#include #include 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 #include -#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 +#include +#include +#include +#include + +/* 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 #include #include -#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 #include #include -#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 - -#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 #include #include -#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 -#include -#include -#include -#include - -/* 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 #include #include -#include "xs_lib.h" +#include "xenstore_lib.h" #include "tdb.h" #include "talloc.h" #include "utils.h" --=-JAQUWIbHp0H2oacY4bGT Content-Disposition: attachment; filename="qemu-xs-compat.patch" Content-Type: text/x-patch; name="qemu-xs-compat.patch"; charset="UTF-8" Content-Transfer-Encoding: 7bit qemu-xen-traditional: use compat xenstore headers. Pending a transition to the new names Signed-off-by: Ian Campbell diff --git a/Makefile b/Makefile index 37c7066..a43ca67 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,7 @@ recurse-all: $(SUBDIR_RULES) CPPFLAGS += -I$(XEN_ROOT)/tools/libxc CPPFLAGS += -I$(XEN_ROOT)/tools/blktap/lib CPPFLAGS += -I$(XEN_ROOT)/tools/xenstore +CPPFLAGS += -I$(XEN_ROOT)/tools/xenstore/compat CPPFLAGS += -I$(XEN_ROOT)/tools/include tapdisk-ioemu: tapdisk-ioemu.c cutils.c block.c block-raw.c block-cow.c block-qcow.c aes.c block-vmdk.c block-cloop.c block-dmg.c block-bochs.c block-vpc.c block-vvfat.c block-qcow2.c hw/xen_blktap.c osdep.c diff --git a/xen-hooks.mak b/xen-hooks.mak index b55f45b..8e9cadf 100644 --- a/xen-hooks.mak +++ b/xen-hooks.mak @@ -1,5 +1,6 @@ CPPFLAGS+= -I$(XEN_ROOT)/tools/libxc CPPFLAGS+= -I$(XEN_ROOT)/tools/xenstore +CPPFLAGS+= -I$(XEN_ROOT)/tools/xenstore/compat CPPFLAGS+= -I$(XEN_ROOT)/tools/include SSE2 := $(call cc-option,-msse2,) --=-JAQUWIbHp0H2oacY4bGT Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=-JAQUWIbHp0H2oacY4bGT--