Save to file checks
[handlervirt.git] / experiment.c
blob7db2b74957342fd57c79e5d525a137400599b201
1 #include <time.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <assert.h>
5 #include <errno.h>
6 #include <inttypes.h>
8 #include <libvirt/libvirt.h>
11 virConnectPtr conn = NULL; /* the hypervisor connection */
13 int main(int argc, char*argv[]) {
14 int error;
15 int ret = 1;
17 /* NULL means connect to local Xen hypervisor */
18 conn = virConnectOpenReadOnly(NULL);
19 if (conn == NULL) {
20 fprintf(stderr, "Failed to connect to hypervisor\n");
23 if (argc == 2) {
24 unsigned long long required = strtoul(argv[1], (char **) NULL, 10);
25 unsigned long long free = virNodeGetFreeMemory(conn);
26 if (errno != ERANGE)
27 printf("%f\n", (float)required / (float)free);
30 printf("%lu\n", virNodeGetFreeMemory(conn));
32 virDomainPtr domu = virDomainLookupByName(conn, "klant1_testdomein");
33 printf("%lu\n", virDomainGetMaxMemory(domu));
34 virDomainFree(domu);
37 virConnectClose(conn);
39 return ret;