mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
* src/makefile.am src/libxen.c src/xensh.c: add a small tool sensh,
implement xenopenconnect and xencloseconnect. Daniel
This commit is contained in:
parent
5cc4af3e7d
commit
afcb25b9a5
@ -1,3 +1,8 @@
|
||||
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
|
||||
|
@ -1,6 +1,8 @@
|
||||
## 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)
|
||||
|
||||
|
26
src/libxen.c
26
src/libxen.c
@ -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);
|
||||
}
|
||||
|
37
src/xensh.c
Normal file
37
src/xensh.c
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user