diff options
author | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2006-10-17 18:21:25 +0100 |
---|---|---|
committer | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2006-10-17 18:21:25 +0100 |
commit | b9488ab5f5c72a1856ef21e7fd79f422799f6469 (patch) | |
tree | 4e1c29972bd515530aec4a9f5a16fdf38807c99a /tools/xenstore | |
parent | 5b8acb9ddfd8efc1d0f10760cc4510f50b0c466f (diff) | |
download | xen-b9488ab5f5c72a1856ef21e7fd79f422799f6469.tar.gz xen-b9488ab5f5c72a1856ef21e7fd79f422799f6469.tar.bz2 xen-b9488ab5f5c72a1856ef21e7fd79f422799f6469.zip |
[SOLARIS] Create kernel-interface implementations for libxc and xenstored.
Additionally, on Solaris, tell the kernel when xenstored is running.
Signed-off-by: John Levon <john.levon@sun.com>
Diffstat (limited to 'tools/xenstore')
-rw-r--r-- | tools/xenstore/Makefile | 5 | ||||
-rw-r--r-- | tools/xenstore/xenstored_core.c | 3 | ||||
-rw-r--r-- | tools/xenstore/xenstored_core.h | 3 | ||||
-rw-r--r-- | tools/xenstore/xenstored_linux.c | 4 | ||||
-rw-r--r-- | tools/xenstore/xenstored_solaris.c | 66 | ||||
-rw-r--r-- | tools/xenstore/xs_lib.c | 9 |
6 files changed, 87 insertions, 3 deletions
diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile index 4507b72240..bb96026746 100644 --- a/tools/xenstore/Makefile +++ b/tools/xenstore/Makefile @@ -27,9 +27,10 @@ CLIENTS_OBJS := $(patsubst xenstore-%,xenstore_%.o,$(CLIENTS)) XENSTORED_OBJS = xenstored_core.o xenstored_watch.o xenstored_domain.o xenstored_transaction.o xs_lib.o talloc.o utils.o tdb.o hashtable.o -XENSTORED_Linux = xenstored_linux.o +XENSTORED_OBJS_$(CONFIG_Linux) = xenstored_linux.o +XENSTORED_OBJS_$(CONFIG_SunOS) = xenstored_solaris.o -XENSTORED_OBJS += $(XENSTORED_$(XEN_OS)) +XENSTORED_OBJS += $(XENSTORED_OBJS_y) .PHONY: all all: libxenstore.so libxenstore.a xenstored $(CLIENTS) xs_tdb_dump xenstore-control xenstore-ls diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index d71a773237..890f852d73 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -1924,6 +1924,9 @@ int main(int argc, char *argv[]) /* Get ready to listen to the tools. */ max = initialize_set(&inset, &outset, *sock, *ro_sock); + /* Tell the kernel we're up and running. */ + xenbus_notify_running(); + /* Main loop. */ /* FIXME: Rewrite so noone can starve. */ for (;;) { diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_core.h index 0849e7ba78..d46d77f026 100644 --- a/tools/xenstore/xenstored_core.h +++ b/tools/xenstore/xenstored_core.h @@ -172,6 +172,9 @@ void *xenbus_map(void); /* Return the event channel used by xenbus. */ evtchn_port_t xenbus_evtchn(void); +/* Tell the kernel xenstored is running. */ +void xenbus_notify_running(void); + #endif /* _XENSTORED_CORE_H */ /* diff --git a/tools/xenstore/xenstored_linux.c b/tools/xenstore/xenstored_linux.c index dabc5ff1a4..5460ca5573 100644 --- a/tools/xenstore/xenstored_linux.c +++ b/tools/xenstore/xenstored_linux.c @@ -67,3 +67,7 @@ void *xenbus_map(void) return addr; } + +void xenbus_notify_running(void) +{ +} diff --git a/tools/xenstore/xenstored_solaris.c b/tools/xenstore/xenstored_solaris.c new file mode 100644 index 0000000000..376a00081b --- /dev/null +++ b/tools/xenstore/xenstored_solaris.c @@ -0,0 +1,66 @@ +/****************************************************************************** + * + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright (C) 2005 Rusty Russell IBM Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2 of the + * License. + */ + +#include <fcntl.h> +#include <unistd.h> +#include <stdlib.h> +#include <sys/mman.h> +#include <xen/sys/xenbus.h> + +#include "xenstored_core.h" + +evtchn_port_t xenbus_evtchn(void) +{ + int fd; + evtchn_port_t port; + + fd = open("/dev/xen/xenbus", O_RDONLY); + if (fd == -1) + return -1; + + port = ioctl(fd, IOCTL_XENBUS_XENSTORE_EVTCHN); + + close(fd); + return port; +} + +void *xenbus_map(void) +{ + int fd; + void *addr; + + fd = open("/dev/xen/xenbus", O_RDWR); + if (fd == -1) + return NULL; + + addr = mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE, + MAP_SHARED, fd, 0); + + if (addr == MAP_FAILED) + addr = NULL; + + close(fd); + + return addr; +} + +void xenbus_notify_running(void) +{ + int fd; + + fd = open("/dev/xen/xenbus", O_RDONLY); + + (void) ioctl(fd, IOCTL_XENBUS_NOTIFY_UP); + + close(fd); +} diff --git a/tools/xenstore/xs_lib.c b/tools/xenstore/xs_lib.c index 750d1823cf..0afe87d325 100644 --- a/tools/xenstore/xs_lib.c +++ b/tools/xenstore/xs_lib.c @@ -76,7 +76,14 @@ const char *xs_daemon_socket_ro(void) const char *xs_domain_dev(void) { char *s = getenv("XENSTORED_PATH"); - return (s ? s : "/proc/xen/xenbus"); + if (s) + return s; + +#ifdef __linux__ + return "/proc/xen/xenbus"; +#else + return "/dev/xen/xenbus"; +#endif } /* Simple routines for writing to sockets, etc. */ |