And the files that actually handler the tender phase now.
[handlervirt.git] / experiment8.c
blob7a98af0106d04a64a8e08238d5b5a4fd6e24da9d
1 #include <string.h>
2 #include <time.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <assert.h>
6 #include <errno.h>
7 #include <inttypes.h>
9 #include <libvirt/libvirt.h>
11 virConnectPtr conn = NULL; /* the hypervisor connection */
13 int main(int argc, char*argv[]) {
14 // xenUnifiedPrivatePtr priv;
15 char *xenbus_path, s[256], *params, *param_pool, *param_volume;
16 unsigned int len = 0;
17 virStoragePoolPtr pool;
18 virStorageVolPtr volume;
21 /* NULL means connect to local Xen hypervisor */
22 conn = virConnectOpenReadOnly(NULL);
23 if (conn == NULL) {
24 fprintf(stderr, "Failed to connect to hypervisor\n");
25 return -1;
28 xenbus_path = getenv ("XENBUS_PATH");
30 if (xenbus_path == NULL) {
31 fprintf(stderr, "No XENBUS_PATH so fail\n");
32 return -1;
35 /* priv = (xenUnifiedPrivatePtr) conn->privateData;
37 if (priv->xshandle == NULL) {
38 fprintf(stderr, "No Xen connection so fail\n");
39 return -1;
42 snprintf(s, 255, "%s/params", xenbus_path);
43 s[255] = '\0';
45 params = xs_read(priv->xshandle, 0, &s[0], &len);*/
47 param_pool = &params[2];
48 param_volume = strchr(param_pool, '/');
50 if (param_volume == NULL) {
51 fprintf(stderr, "No Volume found\n");
52 return -1;
55 param_volume = '\0';
56 param_volume++;
58 printf("pool: %s, volume: %s\n", param_pool, param_volume);
60 pool = virStoragePoolLookupByName(conn, param_pool);
62 if (pool == NULL) {
63 fprintf(stderr, "Pool doesn't exist\n");
64 return -1;
67 volume = virStorageVolLookupByName(pool, param_volume);
69 if (volume == NULL) {
70 fprintf(stderr, "Volume doesn't exist\n");
71 return -1;
74 printf("%\n\n%s", virStorageVolGetKey(volume), virStorageVolGetXMLDesc(volume, 0));
76 free(params);
77 virStoragePoolFree(pool);
78 virStorageVolFree(volume);
79 virConnectClose(conn);
81 return 0;