Second problem;
[handlervirt.git] / experiment.c
blob0394d9a1f320af971c0a19472ddbe78026026621
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);
36 virStoragePoolPtr pool = virStoragePoolLookupByName(conn, "netapp-nfs");
37 //virStorageVolPtr volume = virStorageVolLookupByName(pool, "klant1_test.qcow");
38 virStorageVolPtr volume = virStorageVolLookupByName(pool, "distro/gentoo.qcow");
40 if (volume == NULL)
41 printf("die bestaat niet!\n");
43 printf("%\n\n%s", virStorageVolGetKey(volume), virStorageVolGetXMLDesc(volume, 0));
45 virStoragePoolFree(pool);
47 virConnectClose(conn);
49 return ret;