mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
07613d2020
by running this command: git ls-files -z | xargs -0 perl -pi -0777 -e 's/\n\n+$/\n/' This is in preparation for a more strict make syntax-check rule that will detect trailing blank lines.
55 lines
1.2 KiB
C
55 lines
1.2 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(1);
|
|
}
|
|
dom = virDomainLookupByID(conn, id);
|
|
if (dom == NULL) {
|
|
fprintf(stderr, "First lookup for domain %d failed\n", id);
|
|
exit(1);
|
|
}
|
|
virDomainFree(dom);
|
|
virConnectClose(conn);
|
|
if (ro == 1)
|
|
conn = virConnectOpenReadOnly(NULL);
|
|
else
|
|
conn = virConnectOpen(NULL);
|
|
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);
|
|
|
|
}
|