提交 546026a5 编写于 作者: D Daniel Veillard

* src/Makefile.am: add a tst target to ease building test progs

* src/xend_internal.c: fix the reconnection problem to xend pointed
  by Philippe Berthault
* tests/Makefile.am tests/reconnect.c: add a specific test case
Daniel
上级 29182e99
Thu Sep 21 10:19:01 CEST 2006 Daniel Veillard <veillard@redhat.com>
* src/Makefile.am: add a tst target to ease building test progs
* src/xend_internal.c: fix the reconnection problem to xend pointed
by Philippe Berthault
* tests/Makefile.am tests/reconnect.c: add a specific test case
Tue Sep 19 16:59:53 CEST 2006 Daniel Veillard <veillard@redhat.com> Tue Sep 19 16:59:53 CEST 2006 Daniel Veillard <veillard@redhat.com>
* src/xen_internal.c: applied patch from Jim Fehlig, about * src/xen_internal.c: applied patch from Jim Fehlig, about
......
...@@ -35,3 +35,8 @@ virsh_LDFLAGS = ...@@ -35,3 +35,8 @@ virsh_LDFLAGS =
virsh_DEPENDENCIES = $(DEPS) virsh_DEPENDENCIES = $(DEPS)
virsh_LDADD = $(LDADDS) $(VIRSH_LIBS) virsh_LDADD = $(LDADDS) $(VIRSH_LIBS)
#
# target to ease building test programs
#
tst: tst.c
$(CC) $(CFLAGS) -I../include -o tst tst.c .libs/libvirt.a -lxml2 -lxenstore -lpthread
...@@ -2421,8 +2421,11 @@ xenDaemonGetType(virConnectPtr conn) ...@@ -2421,8 +2421,11 @@ xenDaemonGetType(virConnectPtr conn)
int int
xenDaemonGetVersion(virConnectPtr conn, unsigned long *hvVer) xenDaemonGetVersion(virConnectPtr conn, unsigned long *hvVer)
{ {
static unsigned long version = 0; struct sexpr *root;
const char *extra;
int major, minor, release = 0;
unsigned long version;
if (!VIR_IS_CONNECT(conn)) { if (!VIR_IS_CONNECT(conn)) {
virXendError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__); virXendError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
return (-1); return (-1);
...@@ -2431,28 +2434,22 @@ xenDaemonGetVersion(virConnectPtr conn, unsigned long *hvVer) ...@@ -2431,28 +2434,22 @@ xenDaemonGetVersion(virConnectPtr conn, unsigned long *hvVer)
virXendError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__); virXendError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (-1); return (-1);
} }
if (version == 0) { root = sexpr_get(conn, "/xend/node/");
struct sexpr *root; if (root == NULL)
const char *extra; return(-1);
int major, minor, release = 0;
major = sexpr_int(root, "node/xen_major");
root = sexpr_get(conn, "/xend/node/"); minor = sexpr_int(root, "node/xen_minor");
if (root == NULL) extra = sexpr_node(root, "node/xen_extra");
return(-1); if (extra != NULL) {
while (*extra != 0) {
major = sexpr_int(root, "node/xen_major"); if ((*extra >= '0') && (*extra <= '9'))
minor = sexpr_int(root, "node/xen_minor"); release = release * 10 + (*extra - '0');
extra = sexpr_node(root, "node/xen_extra"); extra++;
if (extra != NULL) {
while (*extra != 0) {
if ((*extra >= '0') && (*extra <= '9'))
release = release * 10 + (*extra - '0');
extra++;
}
} }
sexpr_free(root);
version = major * 1000000 + minor * 1000 + release;
} }
sexpr_free(root);
version = major * 1000000 + minor * 1000 + release;
*hvVer = version; *hvVer = version;
return(0); return(0);
} }
......
...@@ -19,9 +19,10 @@ LDADDS = \ ...@@ -19,9 +19,10 @@ LDADDS = \
EXTRA_DIST = xmlrpcserver.py test_conf.sh EXTRA_DIST = xmlrpcserver.py test_conf.sh
noinst_PROGRAMS = xmlrpctest xml2sexprtest sexpr2xmltest virshtest conftest noinst_PROGRAMS = xmlrpctest xml2sexprtest sexpr2xmltest virshtest conftest \
reconnect
TESTS = xml2sexprtest sexpr2xmltest virshtest test_conf.sh TESTS = xml2sexprtest sexpr2xmltest virshtest test_conf.sh reconnect
valgrind: valgrind:
$(MAKE) check TESTS_ENVIRONMENT="valgrind --quiet" $(MAKE) check TESTS_ENVIRONMENT="valgrind --quiet"
...@@ -59,5 +60,10 @@ conftest_SOURCES = \ ...@@ -59,5 +60,10 @@ conftest_SOURCES = \
conftest_LDFLAGS = conftest_LDFLAGS =
conftest_LDADD = $(LDADDS) conftest_LDADD = $(LDADDS)
reconnect_SOURCES = \
reconnect.c
reconnect_LDFLAGS =
reconnect_LDADD = $(LDADDS)
$(LIBVIRT): $(LIBVIRT):
-@(cd $(top_builddir)/src && $(MAKE) MAKEFLAGS+=--silent) -@(cd $(top_builddir)/src && $(MAKE) MAKEFLAGS+=--silent)
#include <stdio.h>
#include <stdlib.h>
#include <libvirt/libvirt.h>
int main(void) {
int id = 0;
virConnectPtr conn;
virDomainPtr dom;
conn = virConnectOpen("");
if (conn == NULL) {
fprintf(stderr, "First virConnectOpen() failed\n");
exit(1);
}
dom = virDomainLookupByID(conn, id);
if (dom == NULL) {
fprintf(stderr, "First lookup for domain %d failed\n", id);
exit(1);
}
virDomainFree(dom);
virConnectClose(conn);
conn = virConnectOpen("");
if (conn == NULL) {
fprintf(stderr, "Second virConnectOpen() failed\n");
exit(1);
}
dom = virDomainLookupByID(conn, id);
if (dom == NULL) {
fprintf(stderr, "Second lookup for domain %d failed\n", id);
exit(1);
}
virDomainFree(dom);
virConnectClose(conn);
printf("OK\n");
exit(0);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册