提交 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>
* src/xen_internal.c: applied patch from Jim Fehlig, about
......
......@@ -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
......@@ -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);
}
......
......@@ -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)
#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.
先完成此消息的编辑!
想要评论请 注册