commit c8f073fd4ff032b88dff78d0aae93576a8dcf035 Author: David Allan Date: Mon Jan 26 23:37:21 2009 -0500 Added a little code to let the user specify the URI of the hypervisor on the command line, per the suggestion of Rich Jones. diff --git a/examples/hellolibvirt/hellolibvirt.c b/examples/hellolibvirt/hellolibvirt.c index aae79b8..22d3309 100644 --- a/examples/hellolibvirt/hellolibvirt.c +++ b/examples/hellolibvirt/hellolibvirt.c @@ -97,15 +97,21 @@ out: int -main(void) +main(int argc, char *argv[]) { int ret = 0; virConnectPtr conn = NULL; + char *uri = NULL; printf("Attempting to connect to hypervisor\n"); - /* virConnectOpenAuth called here with all default parameters */ - conn = virConnectOpenAuth(NULL, virConnectAuthPtrDefault, 0); + if (argc > 0) { + uri = argv[1]; + } + + /* virConnectOpenAuth is called here with all default parameters, + * except, possibly, the URI of the hypervisor. */ + conn = virConnectOpenAuth(uri, virConnectAuthPtrDefault, 0); if (NULL == conn) { ret = 1; @@ -113,7 +119,15 @@ main(void) goto out; } - printf("Connected to hypervisor\n"); + uri = virConnectGetURI(conn); + if (NULL == uri) { + ret = 1; + printf("Failed to get URI for hypervisor connection\n"); + goto disconnect; + } + + printf("Connected to hypervisor at \"%s\"\n", uri); + free(uri); if (0 != showHypervisorInfo(conn)) { ret = 1;