diff options
author | Daniel Veillard <veillard@redhat.com> | 2006-09-21 09:15:33 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@redhat.com> | 2006-09-21 09:15:33 +0000 |
commit | 546026a5bea2420f8a073f7baae01c034a9b0ff5 (patch) | |
tree | cc9671351c7758f7b646807fe73f5026605f9fa9 | |
parent | * src/xen_internal.c: applied patch from Jim Fehlig, about (diff) | |
download | libvirt-546026a5bea2420f8a073f7baae01c034a9b0ff5.tar.gz libvirt-546026a5bea2420f8a073f7baae01c034a9b0ff5.tar.bz2 libvirt-546026a5bea2420f8a073f7baae01c034a9b0ff5.zip |
* 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
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/xend_internal.c | 41 | ||||
-rw-r--r-- | tests/Makefile.am | 10 | ||||
-rw-r--r-- | tests/reconnect.c | 38 |
5 files changed, 77 insertions, 24 deletions
@@ -1,3 +1,10 @@ +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> * src/xen_internal.c: applied patch from Jim Fehlig, about diff --git a/src/Makefile.am b/src/Makefile.am index 7adfed32b..9544a61f2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -35,3 +35,8 @@ virsh_LDFLAGS = virsh_DEPENDENCIES = $(DEPS) 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 diff --git a/src/xend_internal.c b/src/xend_internal.c index 1df2d0703..1c4908b2f 100644 --- a/src/xend_internal.c +++ b/src/xend_internal.c @@ -2421,8 +2421,11 @@ xenDaemonGetType(virConnectPtr conn) int 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)) { virXendError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__); return (-1); @@ -2431,28 +2434,22 @@ xenDaemonGetVersion(virConnectPtr conn, unsigned long *hvVer) virXendError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__); return (-1); } - if (version == 0) { - struct sexpr *root; - const char *extra; - int major, minor, release = 0; - - root = sexpr_get(conn, "/xend/node/"); - if (root == NULL) - return(-1); - - major = sexpr_int(root, "node/xen_major"); - minor = sexpr_int(root, "node/xen_minor"); - extra = sexpr_node(root, "node/xen_extra"); - if (extra != NULL) { - while (*extra != 0) { - if ((*extra >= '0') && (*extra <= '9')) - release = release * 10 + (*extra - '0'); - extra++; - } + root = sexpr_get(conn, "/xend/node/"); + if (root == NULL) + return(-1); + + major = sexpr_int(root, "node/xen_major"); + minor = sexpr_int(root, "node/xen_minor"); + extra = sexpr_node(root, "node/xen_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; return(0); } diff --git a/tests/Makefile.am b/tests/Makefile.am index 98e7d4402..00d24a82f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -19,9 +19,10 @@ LDADDS = \ 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: $(MAKE) check TESTS_ENVIRONMENT="valgrind --quiet" @@ -59,5 +60,10 @@ conftest_SOURCES = \ conftest_LDFLAGS = conftest_LDADD = $(LDADDS) +reconnect_SOURCES = \ + reconnect.c +reconnect_LDFLAGS = +reconnect_LDADD = $(LDADDS) + $(LIBVIRT): -@(cd $(top_builddir)/src && $(MAKE) MAKEFLAGS+=--silent) diff --git a/tests/reconnect.c b/tests/reconnect.c new file mode 100644 index 000000000..eee844f6f --- /dev/null +++ b/tests/reconnect.c @@ -0,0 +1,38 @@ +#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); + +} + |