From aa605800970894eee1407b7e5b4f21d5d439f99b Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Wed, 23 Nov 2005 07:47:13 +0000 Subject: [PATCH] * configure.in: checking xenstore library, error out on missing libs * include/libxen.h src/libxen.c src/libxen_sym.version: adding new entry points Daniel --- ChangeLog | 6 ++++ configure.in | 3 +- include/libxen.h | 5 ++- src/libxen.c | 82 +++++++++++++++++++++++++++++++++++++----- src/libxen_sym.version | 3 ++ 5 files changed, 88 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf243547da..a9c61f5c40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Nov 22 17:09:11 CET 2005 Daniel Veillard + + * configure.in: checking xenstore library, error out on missing libs + * include/libxen.h src/libxen.c src/libxen_sym.version: adding new + entry points + Thu Nov 10 17:11:03 CET 2005 Daniel Veillard * src/makefile.am src/libxen.c src/xensh.c: add a small tool sensh, diff --git a/configure.in b/configure.in index 4975649bfb..11e9c96611 100644 --- a/configure.in +++ b/configure.in @@ -48,6 +48,7 @@ test "x$U" != "x" && AC_MSG_ERROR(Compiler not ANSI compliant) AM_PROG_LIBTOOL dnl search for the low level Xen library -AC_SEARCH_LIBS(xc_domain_create, [xenctrl]) +AC_SEARCH_LIBS(xc_domain_create, [xenctrl], [], [AC_MSG_ERROR([Xen control library not found])]) +AC_SEARCH_LIBS(xs_read, [xenstore], [], [AC_MSG_ERROR([Xen store library not found])]) AC_OUTPUT(Makefile src/Makefile include/Makefile libxen.pc libxen.spec) diff --git a/include/libxen.h b/include/libxen.h index 3832d23fd3..79514c6828 100644 --- a/include/libxen.h +++ b/include/libxen.h @@ -73,7 +73,8 @@ xenDomainPtr xenCreateLinuxDomain (xenConnectPtr conn, const char *cmdline, unsigned long memory, unsigned int flags); - +xenDomainPtr xenLookupDomain (xenConnectPtr conn, + const char *name); int xenDestroyDomain (xenDomainPtr domain); /* @@ -85,6 +86,8 @@ int xenResumeDomain (xenDomainPtr domain); /* * Dynamic control of domains */ +const char * xenGetName (xenDomainPtr domain); +unsigned long xenGetMaxMemory (xenDomainPtr domain); int xenSetMaxMemory (xenDomainPtr domain, unsigned long memory); diff --git a/src/libxen.c b/src/libxen.c index ff107ca351..7566b454a5 100644 --- a/src/libxen.c +++ b/src/libxen.c @@ -31,6 +31,7 @@ struct _xenConnect { unsigned int magic; /* specific value to check */ int handle; /* internal handle used for hypercall */ + int xshandle; /* handle to talk to the xenstore */ }; /** @@ -38,28 +39,37 @@ struct _xenConnect { * @name: optional argument currently unused, pass NULL * * This function should be called first to get a connection to the - * Hypervisor + * Hypervisor and xen store * * Returns a pointer to the hypervisor connection or NULL in case of error */ xenConnectPtr xenOpenConnect(const char *name) { xenConnectPtr ret; - int handle; + int handle = -1; + int xshandle = -1; handle = xc_interface_open(); - if (handle == -1) { - return(NULL); - } + if (handle == -1) + goto failed; + xshandle = xs_daemon_open(); + if (xshandle < 0) + goto failed; + ret = (xenConnectPtr) malloc(sizeof(xenConnect)); - if (ret == NULL) { - xc_interface_close(handle); - return(NULL); - } + if (ret == NULL) + goto failed; ret->magic = XEN_CONNECT_MAGIC; ret->handle = handle; + ret->xshandle = xshandle; return(ret); +failed: + if (handle >= 0) + xc_interface_close(handle); + if (xshandle >= 0) + xs_daemon_close(xshandle); + return(NULL); } /** @@ -79,6 +89,8 @@ xenCloseConnect(xenConnectPtr conn) { return(-1); conn->magic = -1; + xs_daemon_close(conn->xshandle); + conn->xshandle = -1; xc_interface_close(conn->handle); conn->handle = -1; free(conn); @@ -122,6 +134,23 @@ xenCreateLinuxDomain(xenConnectPtr conn, const char *kernel_path, return(NULL); } +/** + * xenLookupDomain: + * @conn: pointer to the hypervisor connection + * @name: name for the domain + * + * Try to lookup a domain on the given hypervisor + * + * Returns a new domain object or NULL in case of failure + */ +xenDomainPtr +xenLookupDomain(xenConnectPtr conn, const char *name) { + if ((conn == NULL) || (name == NULL)) + return(NULL); + TODO + return(NULL); +} + /** * xenDestroyDomain: * @domain: a domain object @@ -175,6 +204,41 @@ xenResumeDomain(xenDomainPtr domain) { return(-1); } +/** + * xenGetName: + * @domain: a domain object + * + * Get the public name for that domain + * + * Returns a pointer to the name or NULL, the string need not be deallocated + * its lifetime will be the same as the domain object. + */ +const char * +xenGetName(xenDomainPtr domain) { + if (domain == NULL) + return(NULL); + TODO + return(NULL); +} + +/** + * xenGetMaxMemory: + * @domain: a domain object or NULL + * + * Retrieve the maximum amount of physical memory allocated to a + * domain. If domain is NULL, then this get the amount of memory reserved + * to Domain0 i.e. the domain where the application runs. + * + * Returns the memory size in kilobytes or 0 in case of error. + */ +unsigned long +xenGetMaxMemory(xenDomainPtr domain) { + if (domain == NULL) + return(0); + TODO + return(0); +} + /** * xenSetMaxMemory: * @domain: a domain object or NULL diff --git a/src/libxen_sym.version b/src/libxen_sym.version index 0ac937ac5b..fa49bf78d9 100644 --- a/src/libxen_sym.version +++ b/src/libxen_sym.version @@ -4,9 +4,12 @@ xenCloseConnect; xenGetVersion; xenCreateLinuxDomain; + xenLookupDomain; xenDestroyDomain; xenSuspendDomain; xenResumeDomain; + xenGetName; + xenGetMaxMemory; xenSetMaxMemory; local: *; };