/* * Clean up session connection etc */ static void cleanup(void) { curl_global_cleanup(); xmlCleanupParser(); xen_session_logout(session); xen_fini(); }
void xen_common_destroy(void) { curl_global_cleanup(); xen_fini(); xmlCleanupParser(); return; }
int main(int argc, char **argv) { if (argc != 4) { fprintf(stderr, "Usage:\n\n%s <url> <username> <password>\n", argv[0]); } url = argv[1]; /* General setup */ xen_init(); curl_global_init(CURL_GLOBAL_ALL); xen_session *session = xen_session_login_with_password(call_func, NULL, argv[2], argv[3]); if(session->ok) { /* Get the host */ xen_host host; xen_session_get_this_host(session, &host, session); /* Get the set of VMs */ struct xen_vm_set * VMs; xen_host_get_resident_vms(session, &VMs, host); /* Print the names */ for(unsigned int i=0 ; i<VMs->size ; i++) { char * name; xen_host_get_name_label(session, &name, host); printf("VM %d: %s\n", i, name); } } else { printf(stderr, "Connection failed\n"); } xen_session_logout(session); curl_global_cleanup(); xen_fini(); return 0; }