提交 afcb25b9 编写于 作者: D Daniel Veillard

* src/makefile.am src/libxen.c src/xensh.c: add a small tool sensh,

  implement xenopenconnect and xencloseconnect.
Daniel
上级 5cc4af3e
Thu Nov 10 17:11:03 CET 2005 Daniel Veillard <veillard@redhat.com>
* src/makefile.am src/libxen.c src/xensh.c: add a small tool sensh,
implement xenopenconnect and xencloseconnect.
Wed Nov 9 10:57:12 CET 2005 Daniel Veillard <veillard@redhat.com>
* docs/Goals: added a Goals document for the library
......
## Process this file with automake to produce Makefile.in
INCLUDES = -I$(top_builddir)/include -I@srcdir@/include
DEPS = libxen.la
LDADDS = libxen.la
EXTRA_DIST = libxen_sym.version
......@@ -9,3 +11,11 @@ libxen_la_LIBADD =
libxen_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libxen_sym.version \
-version-info @LIBXEN_VERSION_INFO@
libxen_la_SOURCES = libxen.c internal.h
noinst_PROGRAMS=xensh
xensh_SOURCES=xensh.c
xensh_LDFLAGS =
xensh_DEPENDENCIES = $(DEPS)
xensh_LDADD= $(LDADDS)
......@@ -18,6 +18,8 @@
* TODO:
* - use lock to protect against concurrent accesses ?
* - use reference counting to garantee coherent pointer state ?
* - error reporting layer
* - memory wrappers for malloc/free ?
*/
#define XEN_CONNECT_MAGIC 0x4F23DEAD
......@@ -42,7 +44,22 @@ struct _xenConnect {
*/
xenConnectPtr
xenOpenConnect(const char *name) {
return(NULL);
xenConnectPtr ret;
int handle;
handle = xc_interface_open();
if (handle == -1) {
return(NULL);
}
ret = (xenConnectPtr) malloc(sizeof(xenConnect));
if (ret == NULL) {
xc_interface_close(handle);
return(NULL);
}
ret->magic = XEN_CONNECT_MAGIC;
ret->handle = handle;
return(ret);
}
/**
......@@ -60,11 +77,10 @@ int
xenCloseConnect(xenConnectPtr conn) {
if ((conn == NULL) || (conn->magic != XEN_CONNECT_MAGIC))
return(-1);
/*
* TODO:
* Free the domain pointers associated to this connection
*/
conn->magic = -1;
xc_interface_close(conn->handle);
conn->handle = -1;
free(conn);
return(0);
}
......
/*
* xensh.c: a Xen shell used to exercise the libxen API
*
* Copyright (C) 2005 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
* Daniel Veillard <veillard@redhat.com>
*/
#include "libxen.h"
#include <stdio.h>
int errcode = 0;
xenConnectPtr conn;
int main(int argc, char **argv) {
int ret;
conn = xenOpenConnect(NULL);
if (conn == NULL) {
fprintf(stderr, "Failed to connect to the hypervisor\n");
errcode = 1;
goto done;
}
done:
if (conn != NULL) {
ret = xenCloseConnect(conn);
if (ret != 0) {
fprintf(stderr, "Failed to connect to the hypervisor\n");
if (errcode == 0)
errcode = 1;
}
}
exit(errcode);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册