2008-01-30 02:15:54 +08:00
|
|
|
#include <config.h>
|
2007-12-07 18:08:06 +08:00
|
|
|
|
2006-09-21 17:15:33 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2007-12-07 22:38:34 +08:00
|
|
|
|
2007-03-07 05:55:44 +08:00
|
|
|
#include "internal.h"
|
2006-11-09 18:14:01 +08:00
|
|
|
|
2007-03-07 05:55:44 +08:00
|
|
|
static void errorHandler(void *userData ATTRIBUTE_UNUSED,
|
2008-04-11 00:54:54 +08:00
|
|
|
virErrorPtr error ATTRIBUTE_UNUSED) {
|
2006-11-09 18:14:01 +08:00
|
|
|
}
|
2006-09-21 17:15:33 +08:00
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
int id = 0;
|
2006-11-09 18:14:01 +08:00
|
|
|
int ro = 0;
|
2006-09-21 17:15:33 +08:00
|
|
|
virConnectPtr conn;
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2006-11-09 18:14:01 +08:00
|
|
|
virSetErrorFunc(NULL, errorHandler);
|
|
|
|
|
|
|
|
conn = virConnectOpen(NULL);
|
|
|
|
if (conn == NULL) {
|
|
|
|
ro = 1;
|
2008-04-11 00:54:54 +08:00
|
|
|
conn = virConnectOpenReadOnly(NULL);
|
2006-11-09 18:14:01 +08:00
|
|
|
}
|
2006-09-21 17:15:33 +08:00
|
|
|
if (conn == NULL) {
|
|
|
|
fprintf(stderr, "First virConnectOpen() failed\n");
|
2008-04-11 00:54:54 +08:00
|
|
|
exit(1);
|
2006-09-21 17:15:33 +08:00
|
|
|
}
|
|
|
|
dom = virDomainLookupByID(conn, id);
|
|
|
|
if (dom == NULL) {
|
|
|
|
fprintf(stderr, "First lookup for domain %d failed\n", id);
|
2008-04-11 00:54:54 +08:00
|
|
|
exit(1);
|
2006-09-21 17:15:33 +08:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
|
|
|
virConnectClose(conn);
|
2006-11-09 18:14:01 +08:00
|
|
|
if (ro == 1)
|
2008-04-11 00:54:54 +08:00
|
|
|
conn = virConnectOpenReadOnly(NULL);
|
2006-11-09 18:14:01 +08:00
|
|
|
else
|
2008-04-11 00:54:54 +08:00
|
|
|
conn = virConnectOpen(NULL);
|
2006-09-21 17:15:33 +08:00
|
|
|
if (conn == NULL) {
|
|
|
|
fprintf(stderr, "Second virConnectOpen() failed\n");
|
2008-04-11 00:54:54 +08:00
|
|
|
exit(1);
|
2006-09-21 17:15:33 +08:00
|
|
|
}
|
|
|
|
dom = virDomainLookupByID(conn, id);
|
|
|
|
if (dom == NULL) {
|
|
|
|
fprintf(stderr, "Second lookup for domain %d failed\n", id);
|
2008-04-11 00:54:54 +08:00
|
|
|
exit(1);
|
2006-09-21 17:15:33 +08:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
|
|
|
virConnectClose(conn);
|
|
|
|
printf("OK\n");
|
|
|
|
exit(0);
|
2008-02-06 03:27:37 +08:00
|
|
|
|
2006-09-21 17:15:33 +08:00
|
|
|
}
|
|
|
|
|