libvirt/tests/reconnect.c
Daniel Veillard 546026a5be * 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
2006-09-21 09:15:33 +00:00

39 lines
852 B
C

#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);
}