Add environment variable LIBVIRT_MIB_CONNECT_URI to control URI which snmp agent is connecting to. It is now possible to connect to all hypervisors (including test:///) instead of hardcoded qemu:///system, which is used now by default when variable is not set. --- src/libvirtSnmp.c | 5 ++++- src/libvirtSnmp.h | 3 +++ 2 files changed, 7 insertions(+), 1 deletions(-) diff --git a/src/libvirtSnmp.c b/src/libvirtSnmp.c index ce21369..7652da0 100644 --- a/src/libvirtSnmp.c +++ b/src/libvirtSnmp.c @@ -180,7 +180,10 @@ int libvirtSnmpInit(void) /* virConnectOpenAuth is called here with all default parameters, * except, possibly, the URI of the hypervisor. */ /* TODO: configure the URI */ - conn = virConnectOpenAuth("qemu:///system", virConnectAuthPtrDefault, 0); + /* A simple workaround for testing - environment variable */ + char *connect_uri = getenv(CONNECT_URI_ENV); + + conn = virConnectOpenAuth((connect_uri ? connect_uri : "qemu:///system"), virConnectAuthPtrDefault, 0); if (NULL == conn) { printf("No connection to hypervisor\n"); diff --git a/src/libvirtSnmp.h b/src/libvirtSnmp.h index 4ac6130..67b6125 100644 --- a/src/libvirtSnmp.h +++ b/src/libvirtSnmp.h @@ -10,6 +10,9 @@ #include <net-snmp/net-snmp-includes.h> #include <net-snmp/agent/net-snmp-agent-includes.h> +/* Environment variable to control connection URI */ +#define CONNECT_URI_ENV "LIBVIRT_MIB_CONNECT_URI" + /* * Populate libvirtGuestTable into given container. */ -- 1.7.3.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list