Commit Graph
261 Commits
Author SHA1 Message Date
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
Keir Fraser 3e43914aa8 Fix xenstore unwatch with node name starting with "@"
Watch node starting with "@" should not be canonicalized.
Signed-off-by: Xiaowei Yang <xiaowei.yang@intel.com>
2007-10-17 10:02:49 +01:00
Keir Fraser f056fc9b80 xenstore: sprintf->snprintf, and fix for OpenBSD.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2007-10-05 14:11:36 +01:00
Keir Fraser 98418f1c1e Missed files in previous changeset.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2007-09-24 15:41:20 +01:00
Keir Fraser d1729249ef xenstat/xenstore: NetBSD fixes.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2007-09-24 15:38:52 +01:00
kfraser@localhost.localdomain 6c87e8965f xenstore: Remove incorrect comment.
Signed-off-by: Keir Fraser <keir@xensource.com>
2007-09-11 08:34:04 +01:00
kfraser@localhost.localdomain 038aa6bdc0 Fix xenstored's dup2() usage.
The dup2() calls had their arguments reversed. Also remove the
unnecessary close() calls.

Signed-off-by: John Levon <john.levon@sun.com>
2007-09-07 10:26:33 +01:00
kfraser@localhost.localdomain 140b3cd627 xenstore: Redirect stdin/stdout/stderr to /dev/null.
Signed-off-by: Keir Fraser <keir@xensource.com>
2007-08-01 19:34:56 +01:00
kfraser@localhost.localdomain 79a18447fe xenstore: Do not assign to stdout/stderr/stdin - they are not
implemented as variables on all systems.
Signed-off-by: Keir Fraser <keir@xensource.com>
2007-08-01 19:17:08 +01:00
kfraser@localhost.localdomain b1757490f0 xenstored: Do not write to stderr if we are daemonised!
This fixes client reader-thread deaths in which a 'garbage string' was
being read instead of a well-formed message header.
Signed-off-by: Keir Fraser <keir@xensource.com>
2007-08-01 12:55:10 +01:00
kfraser@localhost.localdomain 019e22bb40 xenstored: Remove unused util code.
Signed-off-by: Keir Fraser <keir@xensource.com>
2007-08-01 12:05:42 +01:00
kfraser@localhost.localdomain 504e6b5eae xenstored: Fix socket-based connection teardown. Reading zero bytes
*should* in fact cause the connection to be destroyed. Fix this with a
little extra code in the readfd() handler.
Signed-off-by: Keir Fraser <keir@xensource.com>
2007-07-25 09:51:14 +01:00
kfraser@localhost.localdomain 698543a313 xenstore: Small cleanups and fixes.
1. readfd/writefd account for EINTR/EAGAIN errno returns.
 2. Handle zero return from ->read() and ->write() handlers
    symmetrically.
 3. Fix some indentation issues (use hard tabs).
Signed-off-by: Keir Fraser <keir@xensource.com>
2007-07-24 18:28:48 +01:00
kfraser@localhost.localdomain 407ce07bc8 xenstored: Fairly round-robin schedule work across all connections.
Avoids total starvation under some workloads.
Signed-off-by: Keir Fraser <keir@xensource.com>
2007-07-24 14:50:50 +01:00
kfraser@localhost.localdomain e573cbf520 xenstored: Guarantee to fire @releaseDomain watch when a domain is destructed.
Previously this would be missed on some bail paths within xenstored
which would talloc_free() the connection.
Signed-off-by: Keir Fraser <keir@xensource.com>
2007-07-24 14:50:05 +01:00
kfraser@localhost.localdomain ae9db74d17 [xenstore] adds a -w (wide) flag to xenstore-ls to support seeing full
contents of xenstore entries. There is a bit of code cleanup as well
(snprintf vs. sprintf), one formatting fix, and comments).

There is no change to the behavior of xenstore-ls without -w.

Signed-off-by: John Zulauf <john.zulauf@intel.com>
2007-07-11 10:52:19 +01:00
kfraser@localhost.localdomain fed1946117 xenstore: Remove broken and unmaintained test code.
Signed-off-by: Keir Fraser <keir@xensource.com>
2007-07-03 15:51:59 +01:00
Keir Fraser 840f138cfa tools: Fix xenstored build error by checking vasprintf() return code.
Signed-off-by: Charles Coffing <ccoffing@novell.com>
2007-06-10 19:58:22 +01:00
kfraser@localhost.localdomain 29dd27927c Fix xenstore entry accounting
xenstored is incorrectly accounting domain nodes when transactions
fail. Store pending count changes in the transaction structure, and
apply at transaction completion, instead of directly applying the
changes.

Signed-off-by: Max Zhen <max.zhen@sun.com>
2007-05-30 10:04:23 +01:00
Steven Hand e6dc4d5108 Handle EOF on xenstored socket.
Suggested by Pavel Kankovsky <peak@argo.troja.mff.cuni.cz>.

Signed-off-by: Steven Hand <steven@xensource.com>
2007-04-27 16:17:44 +01:00