Commit Graph
280 Commits
Author SHA1 Message Date
Ian Jackson 2157eba42a tools/xenstore: add XS_RESTRICT operation to C xenstore client libs.
The OCaml xenstored supports the XS_RESTRICT operation, which
deprivileges a dom0 xenstore connection so it can only affect one
domain's entries.   Add the relevant definitions to the C libraries
so that callers can use it.

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
2010-07-06 11:57:20 +01:00
Keir Fraser 5cc436c1d2 libxc: eliminate static variables, use xentoollog; API change
This patch eliminate the global variables in libxenctrl (used for
logging and error reporting).

Instead the information which was in the global variables is now in a
new xc_interface* opaque structure, which xc_interface open returns
instead of the raw file descriptor; furthermore, logging is done via
xentoollog.

There are three new parameters to xc_interface_open to control the
logging, but existing callers can just pass "0" for all three to get
the old behaviour.

All libxc callers have been adjusted accordingly.

Also update QEMU_TAG for corresponding qemu change.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-05-28 09:30:19 +01:00
Keir Fraser a705c15428 xenstore: Make sure that libxs reports an error if xenstored drops
the connection, rather than getting stuck forever.

Patch from: Steven Smith <steven.smith@eu.citrix.com>
Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
2010-05-27 08:20:26 +01:00
Keir Fraser b4dee233da xenstore: Fix cleanup_pop() definition for some (buggy) pthread.h headers.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2010-05-13 12:21:16 +01:00
Keir Fraser 990e331218 xs: avoid pthread_join deadlock in xs_daemon_close
Doing a pthread_cancel and join on the reader thread while holding all
the request/reply/watch mutexes can deadlock if the thread needs to
take any of those mutexes to exit.  Kill off the reader thread before
taking any mutexes (which should be redundant if we're
single-threaded at that point).

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
2010-05-12 08:49:13 +01:00
Keir Fraser 20a817b0a7 xs: make sure mutexes are cleaned up and memory freed if the read thread is cancelled
If the read thread is terminated with pthread cancel, it must make
sure all memory is freed and mutexes are unlocked.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
2010-05-12 08:48:14 +01:00
Keir Fraser 99462ede4c xenstored: Always build and install.
It coexists quite happily with oxenstored.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2010-05-07 11:45:18 +01:00
Keir Fraser 3c82abc294 ocaml: remove hook to external repository.
Signed-off-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
2010-05-06 11:06:08 +01:00
Keir Fraser aa8978e2d9 xenstore,libxl: cleanup of xenstore connections across fork()
Provide a new function xs_daemon_destroy_postfork which can be called
by a libxenstore user who has called fork, to close the fd for the
connection to xenstored and free the memory, without trying to do
anything to any threads which libxenstore may have created.

Use this new function in libxl_fork, to avoid accidental use of a
xenstore connection in both parent and child.

Also, fix the doc comment for libxl_spawn_spawn to have the success
return codes the right way round.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
2010-04-12 17:41:58 +01:00
Keir Fraser e0c77842c7 xenstore: Resolve gcc4.5 type error
Without this, gcc 4.5 complains with,
error: case value '3' not in enumerated type 'const enum xs_perm_type'

Signed-off-by: Charles Arnold <carnold@novell.com>
2010-03-06 13:31:42 +00:00
Keir Fraser 80031349d5 xenstore: Fix memory leak in command 'xenstore rm'
When option '-t' is used to do tidy remove, routine xs_directory()
will be called in order to check there are brother directories or not.
The returned pointer should be passed to free() after this check.

Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
2009-12-21 10:39:48 +00:00
Keir Fraser 344e13af46 xenstore: Fix the method of get options and the usage
Add long option '--flat' correspond to short option '-f',
and let it just can be used for subcommand 'ls' (because
in fact it's useless for subcommand 'read' and 'list').
And fix the usage of subcommands 'ls', 'list' and 'chmod'.

Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
2009-12-18 07:53:27 +00:00
Keir Fraser a0f0199e90 Remove redundant semicolons
Signed-off-by: Rikiya Ayukawa <ayukawa.rikiya@jp.fujitsu.com>
2009-07-01 10:54:25 +01:00
Keir Fraser c7367160e4 ocaml-xenstored: Allow to build ocaml xenstored instead of C version
To use, set CONFIG_OCAML_XENSTORED=y at build time.
Then the build system will automatically download the remote repo
to tools/ocaml-xenstored.

Signed-off-by: Alex Zeffertt <alex.zeffertt@eu.citrix.com>
2009-05-19 14:13:20 +01:00
Keir Fraser ffc362fcd3 xenstore: Add brief notice regarding xenstore protocol limits to xs.h.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-04-30 09:43:29 +01:00
Keir Fraser a7eb53a53f xenstore: Don't hardcode install path
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2009-03-20 10:37:12 +00:00
Keir Fraser cce99fb132 Move the suspend event channel function to libxc, it will use the
/var/lib/xen/suspend_evtchn_lock.d to protect the access.

Signed-off-by: Jiang Yunhong <yunhong.jiang@intel.com>
2009-03-18 11:49:26 +00:00
Keir Fraser 1622101b19 xenstored: fix use-after free bug
Problem:  Handling requests for one connection can not only zap the
connection itself, due to socket disconnects for example.  It can also
zap *other* connections, due to domain release requests.  Especially
it can zap the connection we have saved a pointer to in the "next"
variable.

From: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-03-01 14:50:04 +00:00
Keir Fraser 9f8501582f Use -MMD -MF in tools/* rather than -Wp,-M...
If you use -MMD -MF then the correct .o filename is written to the
.*.d file as the compiler driver arranges everything.  This was done
in 19010:275abe1c5d24 for the hypervisor.

In this patch we do the same elsewhere in the xen-unstable tree,
particularly tools/.  Specifically:
 * Change tools/Rules.mk to add -MMD -MF ... to CFLAGS and set DEPS.
 * Remove -Wp,-MD... from every other Makefile
 * Remove setting of DEPS from every other Makefile
 * Ensure that every Makefile says -include $(DEPS)
 * Ensure that every Makefile's clean target removes $(DEPS)

Some Makefiles were already halfway there, but often for a different
variable name eg PROG_DEP.  The variable name is now standardised in
Rules.mk as DEPS.

I have done a test build with this change, on Debian etch.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
2009-01-12 10:16:05 +00:00
Keir Fraser b0a9e1205f xenstore: Fix a memory leak in 'xs_is_domain_introduced'.
Signed-off-by: Konrad Rzeszutek <konrad@virtualiron.com>
2008-09-11 18:00:06 +01:00
Keir Fraser 7eb8d34c18 tools: Declare functions static where they should be, and provide
proper prototypes for others as required.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2008-07-15 13:19:26 +01:00
Keir Fraser aefef84f02 xenstore: Fix error path broken by c/s 17816
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2008-06-10 14:17:20 +01:00
Keir Fraser df8a7719e5 xenstore: cleanups
Attached patch uses calloc() for hash allocation.
This makes sure, the allocated memory is always initialized.
Also cleanup error handling a bit.

On *BSD avoid conflicts with BSD list macros.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2008-06-10 13:49:54 +01:00
Keir Fraser 83b38ce276 Fix xenstore-client.c compile
errx() is not necessarily defined as a never-returns function. Fix
lookup_mode() to account for this.

Signed-off-by: John Levon <john.levon@sun.com>
2008-05-01 16:37:28 +01:00
Keir Fraser 84aaf4530b xemnstored: Fix xenstored abort when connection dropped.
If a connection is dropped with pending input and output data then the
connection will be dereferenced by both handle_input and handle_output
resulting in a double free when the main loop dereferences the
connection.

Fix this issue by taking/releasing a reference over the calls to
handle_input and handle_output separately and checking the result of
talloc_free to see if the connection went away.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2008-05-01 10:00:00 +01:00
Keir Fraser 02cb043f47 xenstore: Place return statement in the correct place to fix the build.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2008-04-09 16:02:49 +01:00
Keir Fraser 3d40548921 xenstore: fix canonicalize for metanodes
Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
2008-04-09 15:59:54 +01:00
Keir Fraser 1cdc9dd9e2 xenstore: fix Solaris compile with newer GCC versions
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2008-04-09 13:32:21 +01:00
Keir Fraser ad2d0860f3 xenstore: merge xenstore-ls into the multicall binary.
This is done separately from moving the other utilities into the
mutlicall since ls is slightly different and was already separate.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2008-04-09 13:31:19 +01:00
Keir Fraser 58b534c5d7 xenstore: make the xenstore clients a single multicall binary
rather than multiply compiled source.

This saves a bunch of space when statically compiling.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2008-04-09 13:30:37 +01:00
Keir Fraser dde3e02b70 xenstore: support building the xenstore clients statically.
This removes threading from libxenstore.a (but not libxenstore.so)
since pthreads is incompatible with static linking and none of the
command line clients require threads anyway.

It is now possible to build these utilities statically with a uclibc
toolchain which is useful for small userspace utility domains.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2008-04-09 13:27:33 +01:00
Keir Fraser 716c9e12d8 Clean up xenstore Makefile.
Signed-off-by: Bastian Blank <waldi@debian.org>
2008-03-17 10:58:12 +00:00
Keir Fraser 67bfbd67d1 libxenctrl headers should not pollute macro namespace with
mb/rmb/wmb. Instead add a xen_ prefix. Modify Xen's public headers to
expect the prefixed names instead of bare mb/rmb/wmb, but gate this
expectation on a bump of __XEN_INTERFACE_VERSION__.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2008-02-12 11:37:45 +00:00
Keir Fraser d66e065f7f Add DTrace support to xenstored
Add USDT probes for significant xenstore operations to allow dynamic
tracing.

Signed-off-by: John Levon <john.levon@sun.com>
2008-01-31 09:13:27 +00:00
Keir Fraser ad44c013ec Define CFLAGS and LDFLAGS for libxenctrl.
Signed-off-by: Bastian Blank <waldi@debian.org>
2008-01-27 12:57:14 +00:00
Keir Fraser be5fbf9a7f Move generation of public header hierarchy into the tools.
This patch merges the two versions of public header generation
currently used in the build into one.

Signed-off-by: Bastian Blank <waldi@debian.org>
2008-01-26 10:38:44 +00:00
Keir Fraser f9f9329313 New XS_SET_TARGET
Stubdomains (and probably other domain disagregation elements too)
need to be able to tinker with another domain.  This adds
XS_SET_TARGET so that XenStore allows domains to have permissions on
files on which the "target" has permissions.  This also adds
xs_set_target, called by the domain builder when the 'target' option
is used in the configuration.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
2008-01-23 13:22:13 +00:00
Keir Fraser 93e3de7b94 Add SBINDIR. Use it always.
Signed-off-by: Bastian Blank <waldi@debian.org>
2008-01-22 14:35:02 +00:00
Keir Fraser 83f34fdcdd Add BINDIR. Use it.
Signed-off-by: Bastian Blank <waldi@debian.org>
2008-01-22 14:31:10 +00:00
Keir Fraser 2faf0fc95c Add INCLUDEDIR. Use it.
Signed-off-by: Bastian Blank <waldi@debian.org>
2008-01-22 14:30:21 +00:00
Keir Fraser c8107e1564 Apply PREFIX directly to LIBDIR.
Signed-off-by: Bastian Blank <waldi@debian.org>
2008-01-22 14:29:11 +00:00
Keir Fraser 625a82b59c xenstore size limits
* Documents the existing 4kby size limit on xenstore message payloads
 * Causes xs.c in libxenstore to fail locally rather than violating
   said limit (which is good because xenstored kills the client
   connection if it's exceeded).
 * Introduces some limits on path lengths in xenstored.  I trust
   no-one is using path lengths >2kby.  This is good because currently
   a domain client can create a 4kby relative path that the dom0 tools
   cannot access since they'd have to specify the somewhat longer
   absolute path.
 * Removes uses of the host's PATH_MAX (!)

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
2007-12-14 10:15:00 +00:00
Keir Fraser af3ade42b9 Revert 16560:822d4ec5cfb1.
Preference seems to be to update library versions only when the ABI
changes. Only libxenctrl/libxenguest have their version number changed
to 3.2.0, as a reminder that they change on pretty much every major
release.

libfsimage/libxenstore/libblktap have not changed substantially
recently, hence the ABI has not changed, and version number stays the
same as in Xen 3.1 (and before).

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2007-12-08 17:32:01 +00:00
Keir Fraser 7f9e1cf31e tools: Rationalise library soname versions.
* Arrange for the sonames of libxenstore, libxc, libfsimage and
   libblktap to be set from a single place in Config.mk.
 * Bumps the soname major version number to 3.2 in preparation for
   3.2 rc1 after which we do not expect to have ABI changes.

I have not done anything about libaio and libflask.  The former is
imported from elsewhere and if we're lucky will have sane versioning
upstream.

libflask has a very small interface and I'm hoping that the XSM
authors have been keeping some ABI discipline.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
2007-12-07 14:44:13 +00:00
Keir Fraser 3d87f3ac6c xenstore: expanding_buffer variables are supposed to be static. Apart
from anything else, this was guaranteeing they were initialised.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2007-12-05 17:56:13 +00:00
Keir Fraser c5f554d5c1 xenstore: document the xenstore protocol
The attached patch adds a new text file docs/misc/xenstore.txt which
describes the actual protocol implemented by xenstored.  This was
reverse-engineered from the actual code in tools/xenstore.

I didn't bother making any automatic arrangements to ensure that the
implemented and documented protocols are kept in step (for example,
automatic code generation, etc.)  The protocol is rather messy
unfortunately and unsuitable for an xdr approach, and in any case is
not likely to change very quickly.

Also in this patch are a couple of comments for xenstored_core.c which
help clarify the behaviour of some payload parsing helper functions.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
2007-12-05 11:08:07 +00:00
Keir Fraser 1bb3512f96 xenstore-ls -f for find(1)-like output
The current output of xenstore-ls can be quite hard to read and it is
not very intractable for postprocessing with sort|diff and the like.

The patch below provides a -f option which produces output with the
full key pathname on each line, and which disables the value
truncation and the `.'-padding when used with -p (since these latter
two aren't likely to be very useful when values are preceded by long
pathnames).

While I was at it I added the `-s' option to the usage message, where
it was previously missing.

The results looks like this:

...
/local/domain/1 = ""
/local/domain/1/vm = "/vm/8b5fd34a-e268-fab5-9cde-c06eda21df16"
/local/domain/1/device = ""
/local/domain/1/device/vbd = ""
/local/domain/1/device/vbd/2049 = ""
/local/domain/1/device/vbd/2049/virtual-device = "2049"
/local/domain/1/device/vbd/2049/device-type = "disk"
/local/domain/1/device/vbd/2049/protocol = "x86_32-abi"
...

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
2007-12-05 11:07:12 +00:00
Keir Fraser dd36792405 xenstore: deprecating but \-quoting binary data.
Presently it's not clear what the allowable character set is for
values in xenstore.  The current command-line tools just pass values
to printf("%s",...) so implicitly assume that it's 7-bit printable
ASCII (since the interpretation of 8-bit characters would be unclear).
However there are rumours of programs which dump binary data into
xenstore and/or bugs involving nul bytes being added to the ends of
xenstore values (and even of some drivers insisting on a spurious
nul).

There isn't all that much useful documentation about xenstore.  There
is a doc detailing which xenstore keys may be used and what their
meanings are (interface.tex) but it is very out of date, amongst other
reasons because it's in format which is not very easy to update when
adding functionality to the code and because there is no way to check
programs' behaviour in xenstore against the spec.  I think the
xenstore part of interface.tex should be replaced with a new document
in a simpler format, which should amonst other things be sufficiently
machine-readable that automatic testing could reveal at least basic
out-of-spec behaviours like setting or using undocumented keys.

This new document ought to specify the allowable character set of both
keys and values, and ought to specify the xenstored protocol as well.

It seems to me that the appropriate character set for xenstore values
is 7-bit printing ASCII (0x20..0x7e).  Values should not have a
trailing nul byte `on the wire' but of course the xs library interface
should continue to add an additional nul beyond the quoted length for
the convenience of callers.

That is consistent with nearly all of the existing uses and makes the
whole system much more tractable compared to an explicit expectation
that binary data will be stored.  (For example, if we like binary data
in xenstore, why are uuids represented in their printable hex
encoding?)  xenstore data is supposedly non-performance-critical
metadata for use by control plane machinery so the overhead of
printing and parsing text strings is hardly a problem.

Applications which set binary values should be deprecated but to avoid
breaking those applications xenstored should continue indefinitely to
be binary-transparent.

Under these circumstances it can only be regarded as a bug that the
current command-line tools are lossy in the presence of binary data.
Not only does this make them break for those now-deprecated uses, but
it also prevents them from being used to detect and debug problems
relating to the exact byte strings being recorded in xenstore.

As a first step towards the utopia I describe above, this patch
causes xenstore-read and -ls to \-escape the values of xenstore
keys, and xenstore-write to un-\-escape them.  The escaping is a
subset of that permitted by C89; only \t \r \n \\ and hex and octal
are used and recognised.  (So no \f, \a etc.)

This change will not change the representation by these tools of
values which contain only 7-bit printing ASCII characters unless they
contain \'s.

Values which contain \'s will need to be quoted on entry and dequoted
on exit if being manipulated by xenstore-*.  The only values likely to
be affected are paths in Windows guest filesystems and in practice we
believe that any such filename which is actually relevant to anything
will be set other than via xenstore-write.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
2007-12-05 11:05:47 +00:00
Keir Fraser 7c5ba0bb00 Fire watch for non-dom0 backend when frontend is removed from xenstore
in a transaction.
Signed-off-by: Max Zhen <max.zhen@sun.com>
2007-10-26 11:48:58 +01:00
Keir Fraser bdeaa9684d A few small fixes for xenstored:
- Proper sizeof parameter to snprintf
 - Return proper xs_domain_dev for netbsd.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2007-10-22 14:22:39 +01:00