libvirt/tests/reconnect.c
Jim Meyering 2e5efc3d6e avoid calling exit with a constant; use EXIT_* instead
This appeases a new gnulib-provided "syntax-check".
* daemon/libvirtd.c (main): Use EXIT_FAILURE, not 1.
* proxy/libvirt_proxy.c (main): Likewise, and EXIT_SUCCESS, not 0.
* tests/conftest.c (main): Likewise.
* tests/reconnect.c (main): Likewise.
* tests/testutils.h (EXIT_AM_SKIP): Define.
* tests/nodeinfotest.c (mymain): Use EXIT_AM_SKIP, not 77.
* tests/qemuargv2xmltest.c: Likewise.
* tests/qemuxml2xmltest.c: Likewise.
* tests/virshtest.c (mymain): Likewise.
2009-12-15 17:46:04 +01:00

55 lines
1.3 KiB
C

#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include "internal.h"
static void errorHandler(void *userData ATTRIBUTE_UNUSED,
virErrorPtr error ATTRIBUTE_UNUSED) {
}
int main(void) {
int id = 0;
int ro = 0;
virConnectPtr conn;
virDomainPtr dom;
virSetErrorFunc(NULL, errorHandler);
conn = virConnectOpen(NULL);
if (conn == NULL) {
ro = 1;
conn = virConnectOpenReadOnly(NULL);
}
if (conn == NULL) {
fprintf(stderr, "First virConnectOpen() failed\n");
exit(EXIT_FAILURE);
}
dom = virDomainLookupByID(conn, id);
if (dom == NULL) {
fprintf(stderr, "First lookup for domain %d failed\n", id);
exit(EXIT_FAILURE);
}
virDomainFree(dom);
virConnectClose(conn);
if (ro == 1)
conn = virConnectOpenReadOnly(NULL);
else
conn = virConnectOpen(NULL);
if (conn == NULL) {
fprintf(stderr, "Second virConnectOpen() failed\n");
exit(EXIT_FAILURE);
}
dom = virDomainLookupByID(conn, id);
if (dom == NULL) {
fprintf(stderr, "Second lookup for domain %d failed\n", id);
exit(EXIT_FAILURE);
}
virDomainFree(dom);
virConnectClose(conn);
printf("OK\n");
exit(EXIT_SUCCESS);
}