* Makefile.am README TODO autogen.sh configure.in libvir.pc.in

libvir.spec.in docs/Makefile.am docs/apibuild.py docs/structures.fig
  include/Makefile.am include/libvir.h src/Makefile.am src/hash.c
  src/hash.h src/internal.h src/libvir.c src/libvir_sym.version
  src/virsh.c: renamed to libvir
Daniel
This commit is contained in:
Daniel Veillard 2005-12-05 11:16:07 +00:00
parent 79b43459ca
commit 1192a2ade3
23 changed files with 358 additions and 350 deletions

View File

@ -1,3 +1,11 @@
Mon Dec 5 12:15:16 CET 2005 Daniel Veillard <veillard@redhat.com>
* Makefile.am README TODO autogen.sh configure.in libvir.pc.in
libvir.spec.in docs/Makefile.am docs/apibuild.py docs/structures.fig
include/Makefile.am include/libvir.h src/Makefile.am src/hash.c
src/hash.h src/internal.h src/libvir.c src/libvir_sym.version
src/virsh.c: renamed to libvir
Fri Dec 2 15:15:26 CET 2005 Daniel Veillard <veillard@redhat.com>
* include/libxen.h src/libxen.c src/libxen_sym.version: adding

View File

@ -1,12 +1,12 @@
## Process this file with automake to produce Makefile.in
SUBDIRS = src include docs
EXTRA_DIST = libxen.spec.in libxen.spec COPYING.LIB \
libxen.pc.in libxen.pc TODO AUTHORS ChangeLog \
EXTRA_DIST = libvir.spec.in libvir.spec COPYING.LIB \
libvir.pc.in libvir.pc TODO AUTHORS ChangeLog \
NEWS README
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libxen.pc
pkgconfig_DATA = libvir.pc
rpm: clean
@(unset CDPATH ; $(MAKE) dist && rpmbuild -ta $(distdir).tar.gz)

2
README
View File

@ -1,5 +1,5 @@
LibXen : simple library to use the Xen hypervisor
LibVir : simple library to use the Xen hypervisor
As of Wed Nov 2 2005, this is a completely new project, it is not
usable in any way yet.

2
TODO
View File

@ -2,4 +2,4 @@
Done:
- make dist and make rpm targets
- set a no public by default policy for libxen symbols
- set a no public by default policy for libvir symbols

View File

@ -36,7 +36,7 @@ if test "$DIE" -eq 1; then
exit 1
fi
test -f src/libxen.c || {
test -f src/libvir.c || {
echo "You must run this script in the top-level libxen directory"
exit 1
}
@ -61,4 +61,4 @@ fi
$srcdir/configure "$@"
echo
echo "Now type 'make' to compile libxen."
echo "Now type 'make' to compile libvir."

View File

@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/libxen.c)
AC_INIT(src/libvir.c)
AM_CONFIG_HEADER(config.h)
AC_CANONICAL_HOST
@ -31,7 +31,7 @@ AC_SUBST(LIBXEN_VERSION_EXTRA)
VERSION=${LIBXEN_VERSION}
AM_INIT_AUTOMAKE(libxen, $VERSION)
AM_INIT_AUTOMAKE(libvir, $VERSION)
dnl Checks for programs.
AC_PROG_CC
@ -50,7 +50,7 @@ AM_PROG_LIBTOOL
dnl
dnl specific tests to setup DV devel environments with debug etc ...
dnl
if [[ "${LOGNAME}" = "veillard" -a "`pwd`" = "/u/veillard/libxen" ]] ; then
if [[ "${LOGNAME}" = "veillard" -a "`pwd`" = "/u/veillard/libvir" ]] ; then
if test "${GCC}" = "yes" ; then
CFLAGS="-g -O -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wall"
fi
@ -64,4 +64,4 @@ dnl search for the low level Xen library
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 docs/Makefile libxen.pc libxen.spec)
AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile libvir.pc libvir.spec)

View File

@ -8,14 +8,14 @@ PAGES= # index.html
APIPAGES=APIconstructors.html APIfiles.html APIfunctions.html \
APIsymbols.html APIchunk0.html
EXTRA_DIST= \
libxen-api.xml apibuild.py
libvir-api.xml apibuild.py
man_MANS=
all: web $(man_MANS)
api: libxen-api.xml libxen-refs.xml
api: libvir-api.xml libvir-refs.xml
web: $(PAGES)
@ -45,14 +45,14 @@ web: $(PAGES)
# echo "Validating the resulting XHTML pages" ; \
# $(XMLLINT) --nonet --valid --noout html/*.html ; fi );
libxen-api.xml libxen-refs.xml: apibuild.py ../include/*.h ../src/*.h ../src/*.c
libvir-api.xml libvir-refs.xml: apibuild.py ../include/*.h ../src/*.h ../src/*.c
-(./apibuild.py)
clean-local:
rm -f *~ *.bak *.hierarchy *.signals *-unused.txt
maintainer-clean-local: clean-local
rm -rf libxen-api.xml libxen-refs.xml
rm -rf libvir-api.xml libvir-refs.xml
rebuild: api all

View File

@ -18,7 +18,7 @@ debugsym=None
# C parser analysis code
#
ignored_files = {
"xensh.c": "testing tool",
"virsh.c": "testing tool",
"hash.c": "internal hash table stuff",
"hash.h": "internal hash table stuff",
}
@ -1068,7 +1068,7 @@ class CParser:
if self.collect_ref == 1:
oldtok = token
token = self.token()
if oldtok[0] == "name" and oldtok[1][0:3] == "xen":
if oldtok[0] == "name" and oldtok[1][0:3] == "vir":
if token[0] == "sep" and token[1] == "(":
self.index_add_ref(oldtok[1], self.filename,
0, "function")
@ -2044,13 +2044,13 @@ class docBuilder:
def rebuild():
builder = None
if glob.glob("../src/libxen.c") != [] :
print "Rebuilding API description for libxen"
builder = docBuilder("libxen", ["../src", "../include"],
if glob.glob("../src/libvir.c") != [] :
print "Rebuilding API description for libvir"
builder = docBuilder("libvir", ["../src", "../include"],
[])
elif glob.glob("src/parser.c") != [] :
print "Rebuilding API description for libxml2"
builder = docBuilder("libxen", ["src", "include"],
print "Rebuilding API description for libvir"
builder = docBuilder("libvir", ["src", "include"],
[])
else:
print "rebuild() failed, unable to guess the module"

View File

@ -59,8 +59,8 @@ Single
2250 4800 3900 4800
4 0 0 50 -1 0 18 0.0000 4 195 1005 1275 1125 Domains\001
4 0 0 50 -1 0 18 0.0000 4 195 585 1275 1440 hash \001
4 0 0 50 -1 0 18 0.0000 4 195 1650 4725 750 xenDomainPtr\001
4 0 0 50 -1 0 18 0.0000 4 195 2055 975 5700 xenConnectionPtr\001
4 0 0 50 -1 0 18 0.0000 4 195 1650 4725 750 virDomainPtr\001
4 0 0 50 -1 0 18 0.0000 4 195 2055 975 5700 virConnectionPtr\001
4 0 0 50 -1 0 18 0.0000 4 195 945 900 4200 domains\001
4 0 0 50 -1 0 18 0.0000 4 135 555 3450 2475 conn\001
4 0 0 50 -1 0 18 0.0000 4 135 615 6075 1050 name\001

View File

@ -1,9 +1,9 @@
## Process this file with automake to produce Makefile.in
xenincdir = $(includedir)/libxen
virincdir = $(includedir)/libvir
xeninc_HEADERS = libxen.h
virinc_HEADERS = libvir.h
install-exec-hook:
$(mkinstalldirs) $(DESTDIR)$(xenincdir)
$(mkinstalldirs) $(DESTDIR)$(virincdir)

109
include/libvir.h Normal file
View File

@ -0,0 +1,109 @@
/*
* libvir.h: interface for the libvir library to handle Xen domains
* from a process running in domain 0
*
* Copyright (C) 2005 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
* Daniel Veillard <veillard@redhat.com>
*/
#ifndef __VIR_VIRLIB_H__
#define __VIR_VIRLIB_H__
#ifdef __cplusplus
extern "C" {
#endif
/**
* virConnect:
*
* a virConnect is a private structure representing a connection to
* the Xen Hypervisor.
*/
typedef struct _virConnect virConnect;
/**
* virConnectPtr:
*
* a virConnectPtr is pointer to a virConnect private structure, this is the
* type used to reference a connection to the Xen Hypervisor in the API.
*/
typedef virConnect *virConnectPtr;
/**
* virDomain:
*
* a virDomain is a private structure representing a Xen domain.
*/
typedef struct _virDomain virDomain;
/**
* virDomainPtr:
*
* a virDomainPtr is pointer to a virDomain private structure, this is the
* type used to reference a Xen domain in the API.
*/
typedef virDomain *virDomainPtr;
/**
* virDomainFlags:
*
* Flags OR'ed together to provide specific behaviour when creating a
* Domain.
*/
typedef enum {
VIR_DOMAIN_NONE = 0
} virDomainFlags;
/*
* Connection and disconnections to the Hypervisor
*/
virConnectPtr virConnectOpen (const char *name);
virConnectPtr virConnectOpenReadOnly (const char *name);
int virConnectClose (virConnectPtr conn);
unsigned long virConnectGetVersion (virConnectPtr conn);
/*
* Gather list of running domains
*/
int virConnectListDomains (virConnectPtr conn,
int *ids,
int maxids);
/*
* Domain creation and destruction
*/
virDomainPtr virDomainCreateLinux (virConnectPtr conn,
const char *kernel_path,
const char *initrd_path,
const char *cmdline,
unsigned long memory,
unsigned int flags);
virDomainPtr virDomainLookupByName (virConnectPtr conn,
const char *name);
virDomainPtr virDomainLookupByID (virConnectPtr conn,
int id);
int virDomainDestroy (virDomainPtr domain);
/*
* Domain suspend/resume
*/
int virDomainSuspend (virDomainPtr domain);
int virDomainResume (virDomainPtr domain);
/*
* Dynamic control of domains
*/
const char * virDomainGetName (virDomainPtr domain);
unsigned int virDomainGetID (virDomainPtr domain);
unsigned long virDomainGetMaxMemory (virDomainPtr domain);
int virDomainSetMaxMemory (virDomainPtr domain,
unsigned long memory);
#ifdef __cplusplus
}
#endif
#endif /* __VIR_VIRLIB_H__ */

View File

@ -1,9 +1,9 @@
## Process this file with automake to produce Makefile.in
xenincdir = $(includedir)/libxen
virincdir = $(includedir)/libvir
xeninc_HEADERS = libxen.h
virinc_HEADERS = libvir.h
install-exec-hook:
$(mkinstalldirs) $(DESTDIR)$(xenincdir)
$(mkinstalldirs) $(DESTDIR)$(virincdir)

View File

@ -1,109 +0,0 @@
/*
* libxen.h: interface for the libxen library to handle Xen domains
* from a process running in domain 0
*
* Copyright (C) 2005 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
* Daniel Veillard <veillard@redhat.com>
*/
#ifndef __XEN_XENLIB_H__
#define __XEN_XENLIB_H__
#ifdef __cplusplus
extern "C" {
#endif
/**
* xenConnect:
*
* a xenConnect is a private structure representing a connection to
* the Xen Hypervisor.
*/
typedef struct _xenConnect xenConnect;
/**
* xenConnectPtr:
*
* a xenConnectPtr is pointer to a xenConnect private structure, this is the
* type used to reference a connection to the Xen Hypervisor in the API.
*/
typedef xenConnect *xenConnectPtr;
/**
* xenDomain:
*
* a xenDomain is a private structure representing a Xen domain.
*/
typedef struct _xenDomain xenDomain;
/**
* xenDomainPtr:
*
* a xenDomainPtr is pointer to a xenDomain private structure, this is the
* type used to reference a Xen domain in the API.
*/
typedef xenDomain *xenDomainPtr;
/**
* xenDomainFlags:
*
* Flags OR'ed together to provide specific behaviour when creating a
* Domain.
*/
typedef enum {
XEN_DOMAIN_NONE = 0
} xenDomainFlags;
/*
* Connection and disconnections to the Hypervisor
*/
xenConnectPtr xenConnectOpen (const char *name);
xenConnectPtr xenConnectOpenReadOnly (const char *name);
int xenConnectClose (xenConnectPtr conn);
unsigned long xenConnectGetVersion (xenConnectPtr conn);
/*
* Gather list of running domains
*/
int xenConnectListDomains (xenConnectPtr conn,
int *ids,
int maxids);
/*
* Domain creation and destruction
*/
xenDomainPtr xenDomainCreateLinux (xenConnectPtr conn,
const char *kernel_path,
const char *initrd_path,
const char *cmdline,
unsigned long memory,
unsigned int flags);
xenDomainPtr xenDomainLookupByName (xenConnectPtr conn,
const char *name);
xenDomainPtr xenDomainLookupByID (xenConnectPtr conn,
int id);
int xenDomainDestroy (xenDomainPtr domain);
/*
* Domain suspend/resume
*/
int xenDomainSuspend (xenDomainPtr domain);
int xenDomainResume (xenDomainPtr domain);
/*
* Dynamic control of domains
*/
const char * xenDomainGetName (xenDomainPtr domain);
unsigned int xenDomainGetID (xenDomainPtr domain);
unsigned long xenDomainGetMaxMemory (xenDomainPtr domain);
int xenDomainSetMaxMemory (xenDomainPtr domain,
unsigned long memory);
#ifdef __cplusplus
}
#endif
#endif /* __XEN_XENLIB_H__ */

View File

@ -1,10 +1,10 @@
Summary: Library providing an API to use the Xen virtualization
Name: libxen
Name: libvir
Version: @VERSION@
Release: 1
License: LGPL
Group: Development/Libraries
Source: libxen-%{version}.tar.gz
Source: libvir-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-root
URL: http://www.gnome.org/~veillard/gamin/
BuildRequires: xen
@ -14,9 +14,9 @@ Requires: xen
This C library provides an API to use the Xen virtualization framework
%package devel
Summary: Libraries, includes, etc. to compile with the libxen library
Summary: Libraries, includes, etc. to compile with the libvir library
Group: Development/Libraries
Requires: libxen = %{version}
Requires: libvir = %{version}
%description devel
This C library provides an API to use the Xen virtualization framework
@ -54,8 +54,8 @@ rm -fr %{buildroot}
%{_libdir}/lib*.so
%{_libdir}/*a
%{_includedir}/libxen/*.h
%{_libdir}/pkgconfig/libxen.pc
%{_includedir}/libvir/*.h
%{_libdir}/pkgconfig/libvir.pc
%changelog
* Wed Nov 2 2005 Daniel Veillard <veillard@redhat.com> 0.0.1-1

View File

@ -1,21 +1,21 @@
## Process this file with automake to produce Makefile.in
INCLUDES = -I$(top_builddir)/include -I@srcdir@/include
DEPS = libxen.la
LDADDS = @STATIC_BINARIES@ libxen.la
DEPS = libvir.la
LDADDS = @STATIC_BINARIES@ libvir.la
EXTRA_DIST = libxen_sym.version
EXTRA_DIST = libvir_sym.version
lib_LTLIBRARIES = libxen.la
libxen_la_LIBADD =
libxen_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libxen_sym.version \
lib_LTLIBRARIES = libvir.la
libvir_la_LIBADD =
libvir_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libvir_sym.version \
-version-info @LIBXEN_VERSION_INFO@
libxen_la_SOURCES = libxen.c internal.h hash.c hash.h
libvir_la_SOURCES = libvir.c internal.h hash.c hash.h
noinst_PROGRAMS=xensh
noinst_PROGRAMS=virsh
xensh_SOURCES=xensh.c
xensh_LDFLAGS =
xensh_DEPENDENCIES = $(DEPS)
xensh_LDADD= $(LDADDS)
virsh_SOURCES=virsh.c
virsh_LDFLAGS =
virsh_DEPENDENCIES = $(DEPS)
virsh_LDADD= $(LDADDS)

View File

@ -29,10 +29,10 @@
/*
* A single entry in the hash table
*/
typedef struct _xenHashEntry xenHashEntry;
typedef xenHashEntry *xenHashEntryPtr;
struct _xenHashEntry {
struct _xenHashEntry *next;
typedef struct _virHashEntry virHashEntry;
typedef virHashEntry *virHashEntryPtr;
struct _virHashEntry {
struct _virHashEntry *next;
char *name;
void *payload;
int valid;
@ -41,18 +41,18 @@ struct _xenHashEntry {
/*
* The entire hash table
*/
struct _xenHashTable {
struct _xenHashEntry *table;
struct _virHashTable {
struct _virHashEntry *table;
int size;
int nbElems;
};
/*
* xenHashComputeKey:
* virHashComputeKey:
* Calculate the hash key
*/
static unsigned long
xenHashComputeKey(xenHashTablePtr table, const char *name) {
virHashComputeKey(virHashTablePtr table, const char *name) {
unsigned long value = 0L;
char ch;
@ -66,27 +66,27 @@ xenHashComputeKey(xenHashTablePtr table, const char *name) {
}
/**
* xenHashCreate:
* virHashCreate:
* @size: the size of the hash table
*
* Create a new xenHashTablePtr.
* Create a new virHashTablePtr.
*
* Returns the newly created object, or NULL if an error occured.
*/
xenHashTablePtr
xenHashCreate(int size) {
xenHashTablePtr table;
virHashTablePtr
virHashCreate(int size) {
virHashTablePtr table;
if (size <= 0)
size = 256;
table = malloc(sizeof(xenHashTable));
table = malloc(sizeof(virHashTable));
if (table) {
table->size = size;
table->nbElems = 0;
table->table = malloc(size * sizeof(xenHashEntry));
table->table = malloc(size * sizeof(virHashEntry));
if (table->table) {
memset(table->table, 0, size * sizeof(xenHashEntry));
memset(table->table, 0, size * sizeof(virHashEntry));
return(table);
}
free(table);
@ -95,7 +95,7 @@ xenHashCreate(int size) {
}
/**
* xenHashGrow:
* virHashGrow:
* @table: the hash table
* @size: the new size of the hash table
*
@ -104,11 +104,11 @@ xenHashCreate(int size) {
* Returns 0 in case of success, -1 in case of failure
*/
static int
xenHashGrow(xenHashTablePtr table, int size) {
virHashGrow(virHashTablePtr table, int size) {
unsigned long key;
int oldsize, i;
xenHashEntryPtr iter, next;
struct _xenHashEntry *oldtable;
virHashEntryPtr iter, next;
struct _virHashEntry *oldtable;
#ifdef DEBUG_GROW
unsigned long nbElem = 0;
#endif
@ -125,12 +125,12 @@ xenHashGrow(xenHashTablePtr table, int size) {
if (oldtable == NULL)
return(-1);
table->table = malloc(size * sizeof(xenHashEntry));
table->table = malloc(size * sizeof(virHashEntry));
if (table->table == NULL) {
table->table = oldtable;
return(-1);
}
memset(table->table, 0, size * sizeof(xenHashEntry));
memset(table->table, 0, size * sizeof(virHashEntry));
table->size = size;
/* If the two loops are merged, there would be situations where
@ -142,8 +142,8 @@ xenHashGrow(xenHashTablePtr table, int size) {
for (i = 0; i < oldsize; i++) {
if (oldtable[i].valid == 0)
continue;
key = xenHashComputeKey(table, oldtable[i].name);
memcpy(&(table->table[key]), &(oldtable[i]), sizeof(xenHashEntry));
key = virHashComputeKey(table, oldtable[i].name);
memcpy(&(table->table[key]), &(oldtable[i]), sizeof(virHashEntry));
table->table[key].next = NULL;
}
@ -156,9 +156,9 @@ xenHashGrow(xenHashTablePtr table, int size) {
* put back the entry in the new table
*/
key = xenHashComputeKey(table, iter->name);
key = virHashComputeKey(table, iter->name);
if (table->table[key].valid == 0) {
memcpy(&(table->table[key]), iter, sizeof(xenHashEntry));
memcpy(&(table->table[key]), iter, sizeof(virHashEntry));
table->table[key].next = NULL;
free(iter);
} else {
@ -178,14 +178,14 @@ xenHashGrow(xenHashTablePtr table, int size) {
#ifdef DEBUG_GROW
xmlGenericError(xmlGenericErrorContext,
"xenHashGrow : from %d to %d, %d elems\n", oldsize, size, nbElem);
"virHashGrow : from %d to %d, %d elems\n", oldsize, size, nbElem);
#endif
return(0);
}
/**
* xenHashFree:
* virHashFree:
* @table: the hash table
* @f: the deallocator function for items in the hash
*
@ -193,10 +193,10 @@ xenHashGrow(xenHashTablePtr table, int size) {
* deallocated with @f if provided.
*/
void
xenHashFree(xenHashTablePtr table, xenHashDeallocator f) {
virHashFree(virHashTablePtr table, virHashDeallocator f) {
int i;
xenHashEntryPtr iter;
xenHashEntryPtr next;
virHashEntryPtr iter;
virHashEntryPtr next;
int inside_table = 0;
int nbElems;
@ -230,7 +230,7 @@ xenHashFree(xenHashTablePtr table, xenHashDeallocator f) {
}
/**
* xenHashAddEntry3:
* virHashAddEntry3:
* @table: the hash table
* @name: the name of the userdata
* @userdata: a pointer to the userdata
@ -241,11 +241,11 @@ xenHashFree(xenHashTablePtr table, xenHashDeallocator f) {
* Returns 0 the addition succeeded and -1 in case of error.
*/
int
xenHashAddEntry(xenHashTablePtr table, const char *name,
virHashAddEntry(virHashTablePtr table, const char *name,
void *userdata) {
unsigned long key, len = 0;
xenHashEntryPtr entry;
xenHashEntryPtr insert;
virHashEntryPtr entry;
virHashEntryPtr insert;
if ((table == NULL) || (name == NULL))
return(-1);
@ -253,7 +253,7 @@ xenHashAddEntry(xenHashTablePtr table, const char *name,
/*
* Check for duplicate and insertion location.
*/
key = xenHashComputeKey(table, name);
key = virHashComputeKey(table, name);
if (table->table[key].valid == 0) {
insert = NULL;
} else {
@ -270,7 +270,7 @@ xenHashAddEntry(xenHashTablePtr table, const char *name,
if (insert == NULL) {
entry = &(table->table[key]);
} else {
entry = malloc(sizeof(xenHashEntry));
entry = malloc(sizeof(virHashEntry));
if (entry == NULL)
return(-1);
}
@ -287,13 +287,13 @@ xenHashAddEntry(xenHashTablePtr table, const char *name,
table->nbElems++;
if (len > MAX_HASH_LEN)
xenHashGrow(table, MAX_HASH_LEN * table->size);
virHashGrow(table, MAX_HASH_LEN * table->size);
return(0);
}
/**
* xenHashUpdateEntry:
* virHashUpdateEntry:
* @table: the hash table
* @name: the name of the userdata
* @userdata: a pointer to the userdata
@ -306,11 +306,11 @@ xenHashAddEntry(xenHashTablePtr table, const char *name,
* Returns 0 the addition succeeded and -1 in case of error.
*/
int
xenHashUpdateEntry(xenHashTablePtr table, const char *name,
void *userdata, xenHashDeallocator f) {
virHashUpdateEntry(virHashTablePtr table, const char *name,
void *userdata, virHashDeallocator f) {
unsigned long key;
xenHashEntryPtr entry;
xenHashEntryPtr insert;
virHashEntryPtr entry;
virHashEntryPtr insert;
if ((table == NULL) || name == NULL)
return(-1);
@ -318,7 +318,7 @@ xenHashUpdateEntry(xenHashTablePtr table, const char *name,
/*
* Check for duplicate and insertion location.
*/
key = xenHashComputeKey(table, name);
key = virHashComputeKey(table, name);
if (table->table[key].valid == 0) {
insert = NULL;
} else {
@ -342,7 +342,7 @@ xenHashUpdateEntry(xenHashTablePtr table, const char *name,
if (insert == NULL) {
entry = &(table->table[key]);
} else {
entry = malloc(sizeof(xenHashEntry));
entry = malloc(sizeof(virHashEntry));
if (entry == NULL)
return(-1);
}
@ -361,7 +361,7 @@ xenHashUpdateEntry(xenHashTablePtr table, const char *name,
}
/**
* xenHashLookup:
* virHashLookup:
* @table: the hash table
* @name: the name of the userdata
*
@ -370,15 +370,15 @@ xenHashUpdateEntry(xenHashTablePtr table, const char *name,
* Returns the a pointer to the userdata
*/
void *
xenHashLookup(xenHashTablePtr table, const char *name) {
virHashLookup(virHashTablePtr table, const char *name) {
unsigned long key;
xenHashEntryPtr entry;
virHashEntryPtr entry;
if (table == NULL)
return(NULL);
if (name == NULL)
return(NULL);
key = xenHashComputeKey(table, name);
key = virHashComputeKey(table, name);
if (table->table[key].valid == 0)
return(NULL);
for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
@ -389,7 +389,7 @@ xenHashLookup(xenHashTablePtr table, const char *name) {
}
/**
* xenHashSize:
* virHashSize:
* @table: the hash table
*
* Query the number of elements installed in the hash @table.
@ -398,14 +398,14 @@ xenHashLookup(xenHashTablePtr table, const char *name) {
* -1 in case of error
*/
int
xenHashSize(xenHashTablePtr table) {
virHashSize(virHashTablePtr table) {
if (table == NULL)
return(-1);
return(table->nbElems);
}
/**
* xenHashRemoveEntry:
* virHashRemoveEntry:
* @table: the hash table
* @name: the name of the userdata
* @f: the deallocator function for removed item (if any)
@ -417,16 +417,16 @@ xenHashSize(xenHashTablePtr table) {
* Returns 0 if the removal succeeded and -1 in case of error or not found.
*/
int
xenHashRemoveEntry(xenHashTablePtr table, const char *name,
xenHashDeallocator f) {
virHashRemoveEntry(virHashTablePtr table, const char *name,
virHashDeallocator f) {
unsigned long key;
xenHashEntryPtr entry;
xenHashEntryPtr prev = NULL;
virHashEntryPtr entry;
virHashEntryPtr prev = NULL;
if (table == NULL || name == NULL)
return(-1);
key = xenHashComputeKey(table, name);
key = virHashComputeKey(table, name);
if (table->table[key].valid == 0) {
return(-1);
} else {
@ -445,7 +445,7 @@ xenHashRemoveEntry(xenHashTablePtr table, const char *name,
entry->valid = 0;
} else {
entry = entry->next;
memcpy(&(table->table[key]), entry, sizeof(xenHashEntry));
memcpy(&(table->table[key]), entry, sizeof(virHashEntry));
free(entry);
}
}

View File

@ -8,8 +8,8 @@
* Author: Bjorn Reese <bjorn.reese@systematic.dk>
*/
#ifndef __XEN_HASH_H__
#define __XEN_HASH_H__
#ifndef __VIR_HASH_H__
#define __VIR_HASH_H__
#ifdef __cplusplus
extern "C" {
@ -18,54 +18,54 @@ extern "C" {
/*
* The hash table.
*/
typedef struct _xenHashTable xenHashTable;
typedef xenHashTable *xenHashTablePtr;
typedef struct _virHashTable virHashTable;
typedef virHashTable *virHashTablePtr;
/*
* function types:
*/
/**
* xenHashDeallocator:
* virHashDeallocator:
* @payload: the data in the hash
* @name: the name associated
*
* Callback to free data from a hash.
*/
typedef void (*xenHashDeallocator)(void *payload, char *name);
typedef void (*virHashDeallocator)(void *payload, char *name);
/*
* Constructor and destructor.
*/
xenHashTablePtr xenHashCreate (int size);
virHashTablePtr virHashCreate (int size);
void
xenHashFree (xenHashTablePtr table,
xenHashDeallocator f);
int xenHashSize (xenHashTablePtr table);
virHashFree (virHashTablePtr table,
virHashDeallocator f);
int virHashSize (virHashTablePtr table);
/*
* Add a new entry to the hash table.
*/
int xenHashAddEntry (xenHashTablePtr table,
int virHashAddEntry (virHashTablePtr table,
const char *name,
void *userdata);
int xenHashUpdateEntry(xenHashTablePtr table,
int virHashUpdateEntry(virHashTablePtr table,
const char *name,
void *userdata,
xenHashDeallocator f);
virHashDeallocator f);
/*
* Remove an entry from the hash table.
*/
int xenHashRemoveEntry(xenHashTablePtr table,
int virHashRemoveEntry(virHashTablePtr table,
const char *name,
xenHashDeallocator f);
virHashDeallocator f);
/*
* Retrieve the userdata.
*/
void * xenHashLookup (xenHashTablePtr table,
void * virHashLookup (virHashTablePtr table,
const char *name);
#ifdef __cplusplus
}
#endif
#endif /* ! __XEN_HASH_H__ */
#endif /* ! __VIR_HASH_H__ */

View File

@ -2,8 +2,8 @@
* internal.h: internal definitions just used by code from the library
*/
#ifndef __XEN_INTERNAL_H__
#define __XEN_INTERNAL_H__
#ifndef __VIR_INTERNAL_H__
#define __VIR_INTERNAL_H__
#ifdef __cplusplus
extern "C" {
@ -38,4 +38,4 @@ extern "C" {
}
#endif /* __cplusplus */
#endif /* __XEN_INTERNAL_H__ */
#endif /* __VIR_INTERNAL_H__ */

View File

@ -1,5 +1,5 @@
/*
* libxen.h: Main interfaces for the libxen library to handle virtualization
* libvir.h: Main interfaces for the libvir library to handle virtualization
* domains from a process running in domain 0
*
* Copyright (C) 2005 Red Hat, Inc.
@ -9,7 +9,7 @@
* Daniel Veillard <veillard@redhat.com>
*/
#include "libxen.h"
#include "libvir.h"
#include <stdio.h>
#include <stdlib.h>
@ -27,43 +27,43 @@
* - memory wrappers for malloc/free ?
*/
#define XEN_CONNECT_MAGIC 0x4F23DEAD
#define VIR_CONNECT_MAGIC 0x4F23DEAD
/*
* Flags for Xen connections
*/
#define XEN_CONNECT_RO 1
#define VIR_CONNECT_RO 1
/**
* _xenConnect:
* _virConnect:
*
* Internal structure associated to a connection
*/
struct _xenConnect {
struct _virConnect {
unsigned int magic; /* specific value to check */
int handle; /* internal handle used for hypercall */
struct xs_handle *xshandle; /* handle to talk to the xenstore */
xenHashTablePtr domains; /* hash table for known domains */
virHashTablePtr domains; /* hash table for known domains */
int flags; /* a set of connection flags */
};
#define XEN_DOMAIN_MAGIC 0xDEAD4321
#define VIR_DOMAIN_MAGIC 0xDEAD4321
/**
* _xenDomain:
* _virDomain:
*
* Internal structure associated to a domain
*/
struct _xenDomain {
struct _virDomain {
unsigned int magic; /* specific value to check */
xenConnectPtr conn; /* pointer back to the connection */
virConnectPtr conn; /* pointer back to the connection */
char *name; /* the domain external name */
char *path; /* the domain internal path */
int handle; /* internal handle for the dmonain ID */
};
/**
* xenConnectOpen:
* virConnectOpen:
* @name: optional argument currently unused, pass NULL
*
* This function should be called first to get a connection to the
@ -71,9 +71,9 @@ struct _xenDomain {
*
* Returns a pointer to the hypervisor connection or NULL in case of error
*/
xenConnectPtr
xenConnectOpen(const char *name) {
xenConnectPtr ret = NULL;
virConnectPtr
virConnectOpen(const char *name) {
virConnectPtr ret = NULL;
int handle = -1;
struct xs_handle *xshandle = NULL;
@ -88,13 +88,13 @@ xenConnectOpen(const char *name) {
if (xshandle == NULL)
goto failed;
ret = (xenConnectPtr) malloc(sizeof(xenConnect));
ret = (virConnectPtr) malloc(sizeof(virConnect));
if (ret == NULL)
goto failed;
ret->magic = XEN_CONNECT_MAGIC;
ret->magic = VIR_CONNECT_MAGIC;
ret->handle = handle;
ret->xshandle = xshandle;
ret->domains = xenHashCreate(20);
ret->domains = virHashCreate(20);
ret->flags = 0;
if (ret->domains == NULL)
goto failed;
@ -111,7 +111,7 @@ failed:
}
/**
* xenConnectOpenReadOnly:
* virConnectOpenReadOnly:
* @name: optional argument currently unused, pass NULL
*
* This function should be called first to get a read-only connection to the
@ -119,9 +119,9 @@ failed:
*
* Returns a pointer to the hypervisor connection or NULL in case of error
*/
xenConnectPtr
xenConnectOpenReadOnly(const char *name) {
xenConnectPtr ret = NULL;
virConnectPtr
virConnectOpenReadOnly(const char *name) {
virConnectPtr ret = NULL;
struct xs_handle *xshandle = NULL;
/* we can only talk to the local Xen supervisor ATM */
@ -132,14 +132,14 @@ xenConnectOpenReadOnly(const char *name) {
if (xshandle == NULL)
goto failed;
ret = (xenConnectPtr) malloc(sizeof(xenConnect));
ret = (virConnectPtr) malloc(sizeof(virConnect));
if (ret == NULL)
goto failed;
ret->magic = XEN_CONNECT_MAGIC;
ret->magic = VIR_CONNECT_MAGIC;
ret->handle = -1;
ret->xshandle = xshandle;
ret->domains = xenHashCreate(20);
ret->flags = XEN_CONNECT_RO;
ret->domains = virHashCreate(20);
ret->flags = VIR_CONNECT_RO;
if (ret->domains == NULL)
goto failed;
@ -153,7 +153,7 @@ failed:
}
/**
* xenDomainDestroyName:
* virDomainDestroyName:
* @domain: a domain object
*
* Destroy the domain object, this is just used by the domain hash callback.
@ -161,12 +161,12 @@ failed:
* Returns 0 in case of success and -1 in case of failure.
*/
static int
xenDomainDestroyName(xenDomainPtr domain, const char *name ATTRIBUTE_UNUSED) {
return(xenDomainDestroy(domain));
virDomainDestroyName(virDomainPtr domain, const char *name ATTRIBUTE_UNUSED) {
return(virDomainDestroy(domain));
}
/**
* xenConnectClose:
* virConnectClose:
* @conn: pointer to the hypervisor connection
*
* This function closes the connection to the Hypervisor. This should
@ -177,11 +177,11 @@ xenDomainDestroyName(xenDomainPtr domain, const char *name ATTRIBUTE_UNUSED) {
* Returns 0 in case of success or -1 in case of error.
*/
int
xenConnectClose(xenConnectPtr conn) {
if ((conn == NULL) || (conn->magic != XEN_CONNECT_MAGIC))
virConnectClose(virConnectPtr conn) {
if ((conn == NULL) || (conn->magic != VIR_CONNECT_MAGIC))
return(-1);
xenHashFree(conn->domains, (xenHashDeallocator) xenDomainDestroyName);
virHashFree(conn->domains, (virHashDeallocator) virDomainDestroyName);
conn->magic = -1;
xs_daemon_close(conn->xshandle);
conn->xshandle = NULL;
@ -193,7 +193,7 @@ xenConnectClose(xenConnectPtr conn) {
}
/**
* xenConnectGetVersion:
* virConnectGetVersion:
* @conn: pointer to the hypervisor connection
*
* Get the version level of the Hypervisor running.
@ -201,7 +201,7 @@ xenConnectClose(xenConnectPtr conn) {
* Returns -1 in case of error or major * 10,000 + minor * 100 + rev otherwise
*/
unsigned long
xenConnectGetVersion(xenConnectPtr conn) {
virConnectGetVersion(virConnectPtr conn) {
if (conn == NULL)
return(-1);
TODO
@ -209,7 +209,7 @@ xenConnectGetVersion(xenConnectPtr conn) {
}
/**
* xenConnectListDomains:
* virConnectListDomains:
* @conn: pointer to the hypervisor connection
* @ids: array to collect the list of IDs of active domains
* @maxids: size of @ids
@ -219,14 +219,14 @@ xenConnectGetVersion(xenConnectPtr conn) {
* Returns the number of domain found or -1 in case of error
*/
int
xenConnectListDomains(xenConnectPtr conn, int *ids, int maxids) {
virConnectListDomains(virConnectPtr conn, int *ids, int maxids) {
struct xs_transaction_handle* t;
int ret = -1;
unsigned int num, i;
long id;
char **idlist = NULL, *endptr;
if ((conn == NULL) || (conn->magic != XEN_CONNECT_MAGIC) ||
if ((conn == NULL) || (conn->magic != VIR_CONNECT_MAGIC) ||
(ids == NULL) || (maxids <= 0))
return(-1);
@ -257,23 +257,23 @@ done:
}
/**
* xenDomainCreateLinux:
* virDomainCreateLinux:
* @conn: pointer to the hypervisor connection
* @kernel_path: the file path to the kernel image
* @initrd_path: an optional file path to an initrd
* @cmdline: optional command line parameters for the kernel
* @memory: the memory size in kilobytes
* @flags: an optional set of xenDomainFlags
* @flags: an optional set of virDomainFlags
*
* Launch a new Linux guest domain
*
* Returns a new domain object or NULL in case of failure
*/
xenDomainPtr
xenDomainCreateLinux(xenConnectPtr conn, const char *kernel_path,
virDomainPtr
virDomainCreateLinux(virConnectPtr conn, const char *kernel_path,
const char *initrd_path, const char *cmdline,
unsigned long memory, unsigned int flags) {
if ((conn == NULL) || (conn->magic != XEN_CONNECT_MAGIC) ||
if ((conn == NULL) || (conn->magic != VIR_CONNECT_MAGIC) ||
(kernel_path == NULL) || (memory < 4096))
return(NULL);
TODO
@ -281,7 +281,7 @@ xenDomainCreateLinux(xenConnectPtr conn, const char *kernel_path,
}
/**
* xenDomainLookupByName:
* virDomainLookupByName:
* @conn: pointer to the hypervisor connection
* @name: name for the domain
*
@ -289,16 +289,16 @@ xenDomainCreateLinux(xenConnectPtr conn, const char *kernel_path,
*
* Returns a new domain object or NULL in case of failure
*/
xenDomainPtr
xenDomainLookupByName(xenConnectPtr conn, const char *name) {
if ((conn == NULL) || (conn->magic != XEN_CONNECT_MAGIC) || (name == NULL))
virDomainPtr
virDomainLookupByName(virConnectPtr conn, const char *name) {
if ((conn == NULL) || (conn->magic != VIR_CONNECT_MAGIC) || (name == NULL))
return(NULL);
TODO
return(NULL);
}
/**
* xenConnectDoStoreQuery:
* virConnectDoStoreQuery:
* @conn: pointer to the hypervisor connection
* @path: the absolute path of the data in the store to retrieve
*
@ -307,7 +307,7 @@ xenDomainLookupByName(xenConnectPtr conn, const char *name) {
* Returns a string which must be freed by the caller or NULL in case of error
*/
static char *
xenConnectDoStoreQuery(xenConnectPtr conn, const char *path) {
virConnectDoStoreQuery(virConnectPtr conn, const char *path) {
struct xs_transaction_handle* t;
char *ret = NULL;
unsigned int len = 0;
@ -325,7 +325,7 @@ done:
}
/**
* xenDomainDoStoreQuery:
* virDomainDoStoreQuery:
* @domain: a domain object
* @path: the relative path of the data in the store to retrieve
*
@ -334,7 +334,7 @@ done:
* Returns a string which must be freed by the caller or NULL in case of error
*/
static char *
xenDomainDoStoreQuery(xenDomainPtr domain, const char *path) {
virDomainDoStoreQuery(virDomainPtr domain, const char *path) {
struct xs_transaction_handle* t;
char s[256];
char *ret = NULL;
@ -356,7 +356,7 @@ done:
}
/**
* xenDomainLookupByID:
* virDomainLookupByID:
* @conn: pointer to the hypervisor connection
* @id: the domain ID number
*
@ -364,17 +364,17 @@ done:
*
* Returns a new domain object or NULL in case of failure
*/
xenDomainPtr
xenDomainLookupByID(xenConnectPtr conn, int id) {
virDomainPtr
virDomainLookupByID(virConnectPtr conn, int id) {
char *path;
xenDomainPtr ret;
virDomainPtr ret;
xc_dominfo_t info;
int res;
if ((conn == NULL) || (conn->magic != XEN_CONNECT_MAGIC) || (id < 0))
if ((conn == NULL) || (conn->magic != VIR_CONNECT_MAGIC) || (id < 0))
return(NULL);
if ((conn->flags & XEN_CONNECT_RO) == 0) {
if ((conn->flags & VIR_CONNECT_RO) == 0) {
res = xc_domain_getinfo(conn->handle, (uint32_t) id, 1, &info);
if (res != 1) {
return(NULL);
@ -385,22 +385,22 @@ xenDomainLookupByID(xenConnectPtr conn, int id) {
if (path == NULL) {
return(NULL);
}
ret = (xenDomainPtr) malloc(sizeof(xenDomain));
ret = (virDomainPtr) malloc(sizeof(virDomain));
if (ret == NULL) {
free(path);
return(NULL);
}
ret->magic = XEN_DOMAIN_MAGIC;
ret->magic = VIR_DOMAIN_MAGIC;
ret->conn = conn;
ret->handle = id;
ret->path = path;
ret->name = xenDomainDoStoreQuery(ret, "name");
ret->name = virDomainDoStoreQuery(ret, "name");
return(ret);
}
/**
* xenDomainDestroy:
* virDomainDestroy:
* @domain: a domain object
*
* Destroy the domain object. The running instance is shutdown if not down
@ -409,51 +409,51 @@ xenDomainLookupByID(xenConnectPtr conn, int id) {
* Returns 0 in case of success and -1 in case of failure.
*/
int
xenDomainDestroy(xenDomainPtr domain) {
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
virDomainDestroy(virDomainPtr domain) {
if ((domain == NULL) || (domain->magic != VIR_DOMAIN_MAGIC))
return(-1);
TODO
return(-1);
}
/**
* xenDomainSuspend:
* virDomainSuspend:
* @domain: a domain object
*
* Suspends an active domain, the process is frozen without further access
* to CPU resources and I/O but the memory used by the domain at the
* hypervisor level will stay allocated. Use xenDomainResume() to reactivate
* hypervisor level will stay allocated. Use virDomainResume() to reactivate
* the domain.
*
* Returns 0 in case of success and -1 in case of failure.
*/
int
xenDomainSuspend(xenDomainPtr domain) {
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
virDomainSuspend(virDomainPtr domain) {
if ((domain == NULL) || (domain->magic != VIR_DOMAIN_MAGIC))
return(-1);
TODO
return(-1);
}
/**
* xenDomainResume:
* virDomainResume:
* @domain: a domain object
*
* Resume an suspended domain, the process is restarted from the state where
* it was frozen by calling xenSuspendDomain().
* it was frozen by calling virSuspendDomain().
*
* Returns 0 in case of success and -1 in case of failure.
*/
int
xenDomainResume(xenDomainPtr domain) {
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
virDomainResume(virDomainPtr domain) {
if ((domain == NULL) || (domain->magic != VIR_DOMAIN_MAGIC))
return(-1);
TODO
return(-1);
}
/**
* xenDomainGetName:
* virDomainGetName:
* @domain: a domain object
*
* Get the public name for that domain
@ -462,14 +462,14 @@ xenDomainResume(xenDomainPtr domain) {
* its lifetime will be the same as the domain object.
*/
const char *
xenDomainGetName(xenDomainPtr domain) {
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
virDomainGetName(virDomainPtr domain) {
if ((domain == NULL) || (domain->magic != VIR_DOMAIN_MAGIC))
return(NULL);
return(domain->name);
}
/**
* xenDomainGetID:
* virDomainGetID:
* @domain: a domain object
*
* Get the hypervisor ID number for the domain
@ -477,14 +477,14 @@ xenDomainGetName(xenDomainPtr domain) {
* Returns the domain ID number or (unsigned int) -1 in case of error
*/
unsigned int
xenDomainGetID(xenDomainPtr domain) {
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
virDomainGetID(virDomainPtr domain) {
if ((domain == NULL) || (domain->magic != VIR_DOMAIN_MAGIC))
return((unsigned int) -1);
return(domain->handle);
}
/**
* xenDomainGetMaxMemory:
* virDomainGetMaxMemory:
* @domain: a domain object or NULL
*
* Retrieve the maximum amount of physical memory allocated to a
@ -494,15 +494,15 @@ xenDomainGetID(xenDomainPtr domain) {
* Returns the memory size in kilobytes or 0 in case of error.
*/
unsigned long
xenDomainGetMaxMemory(xenDomainPtr domain) {
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
virDomainGetMaxMemory(virDomainPtr domain) {
if ((domain == NULL) || (domain->magic != VIR_DOMAIN_MAGIC))
return(0);
TODO
return(0);
}
/**
* xenDomainSetMaxMemory:
* virDomainSetMaxMemory:
* @domain: a domain object or NULL
* @memory: the memory size in kilobytes
*
@ -513,8 +513,8 @@ xenDomainGetMaxMemory(xenDomainPtr domain) {
* Returns 0 in case of success and -1 in case of failure.
*/
int
xenDomainSetMaxMemory(xenDomainPtr domain, unsigned long memory) {
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC) ||
virDomainSetMaxMemory(virDomainPtr domain, unsigned long memory) {
if ((domain == NULL) || (domain->magic != VIR_DOMAIN_MAGIC) ||
(memory < 4096))
return(-1);
TODO

19
src/libvir_sym.version Normal file
View File

@ -0,0 +1,19 @@
{
global:
virConnectOpen;
virConnectOpenReadOnly;
virConnectClose;
virConnectGetVersion;
virDomainCreateLinux;
virConnectListDomains;
virDomainLookupByName;
virDomainLookupByID;
virDomainDestroy;
virDomainSuspend;
virDomainResume;
virDomainGetName;
virDomainGetID;
virDomainGetMaxMemory;
virDomainSetMaxMemory;
local: *;
};

View File

@ -1,19 +0,0 @@
{
global:
xenConnectOpen;
xenConnectOpenReadOnly;
xenConnectClose;
xenConnectGetVersion;
xenDomainCreateLinux;
xenConnectListDomains;
xenDomainLookupByName;
xenDomainLookupByID;
xenDomainDestroy;
xenDomainSuspend;
xenDomainResume;
xenDomainGetName;
xenDomainGetID;
xenDomainGetMaxMemory;
xenDomainSetMaxMemory;
local: *;
};

View File

@ -1,5 +1,5 @@
/*
* xensh.c: a Xen shell used to exercise the libxen API
* virsh.c: a Xen shell used to exercise the libvir API
*
* Copyright (C) 2005 Red Hat, Inc.
*
@ -8,36 +8,36 @@
* Daniel Veillard <veillard@redhat.com>
*/
#include "libxen.h"
#include "libvir.h"
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#define MAX_DOM 100
int errcode = 0;
xenConnectPtr conn;
xenDomainPtr dom0;
virConnectPtr conn;
virDomainPtr dom0;
int ids[MAX_DOM];
static void printDomain(xenDomainPtr dom) {
printf("id %d: name %s\n", xenDomainGetID(dom), xenDomainGetName(dom));
static void printDomain(virDomainPtr dom) {
printf("id %d: name %s\n", virDomainGetID(dom), virDomainGetName(dom));
}
int main(int argc, char **argv) {
int ret, i;
xenDomainPtr dom;
virDomainPtr dom;
if (getuid() == 0) {
conn = xenConnectOpen(NULL);
conn = virConnectOpen(NULL);
} else {
conn = xenConnectOpenReadOnly(NULL);
conn = virConnectOpenReadOnly(NULL);
}
if (conn == NULL) {
fprintf(stderr, "Failed to connect to the hypervisor\n");
errcode = 1;
goto done;
}
dom0 = xenDomainLookupByID(conn, 0);
dom0 = virDomainLookupByID(conn, 0);
if (dom0 == NULL) {
fprintf(stderr, "Failed to get domain 0 informations\n");
errcode = 2;
@ -47,7 +47,7 @@ int main(int argc, char **argv) {
printf("Dom0: ");
printDomain(dom0);
ret = xenConnectListDomains(conn, &ids[0], MAX_DOM);
ret = virConnectListDomains(conn, &ids[0], MAX_DOM);
if (ret < 0) {
fprintf(stderr, "Failed to list active domains\n");
errcode = 3;
@ -58,7 +58,7 @@ int main(int argc, char **argv) {
if (ids[i] == 0)
continue;
printf(" ");
dom = xenDomainLookupByID(conn, ids[i]);
dom = virDomainLookupByID(conn, ids[i]);
if (dom == NULL) {
printf("domain %d disapeared\n", ids[i]);
} else {
@ -68,7 +68,7 @@ int main(int argc, char **argv) {
done:
if (conn != NULL) {
ret = xenConnectClose(conn);
ret = virConnectClose(conn);
if (ret != 0) {
fprintf(stderr, "Failed to connect to the hypervisor\n");
if (errcode == 0)