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
;
17 virStoragePoolPtr pool
;
18 virStorageVolPtr volume
;
21 /* NULL means connect to local Xen hypervisor */
22 conn
= virConnectOpenReadOnly(NULL
);
24 fprintf(stderr
, "Failed to connect to hypervisor\n");
28 xenbus_path
= getenv ("XENBUS_PATH");
30 if (xenbus_path
== NULL
) {
31 fprintf(stderr
, "No XENBUS_PATH so fail\n");
35 /* priv = (xenUnifiedPrivatePtr) conn->privateData;
37 if (priv->xshandle == NULL) {
38 fprintf(stderr, "No Xen connection so fail\n");
42 snprintf(s, 255, "%s/params", xenbus_path);
45 params = xs_read(priv->xshandle, 0, &s[0], &len);*/
47 param_pool
= ¶ms
[2];
48 param_volume
= strchr(param_pool
, '/');
50 if (param_volume
== NULL
) {
51 fprintf(stderr
, "No Volume found\n");
58 printf("pool: %s, volume: %s\n", param_pool
, param_volume
);
60 pool
= virStoragePoolLookupByName(conn
, param_pool
);
63 fprintf(stderr
, "Pool doesn't exist\n");
67 volume
= virStorageVolLookupByName(pool
, param_volume
);
70 fprintf(stderr
, "Volume doesn't exist\n");
74 printf("%\n\n%s", virStorageVolGetKey(volume
), virStorageVolGetXMLDesc(volume
, 0));
77 virStoragePoolFree(pool
);
78 virStorageVolFree(volume
);
79 virConnectClose(conn
);