コード例 #1
0
ファイル: libvirt.go プロジェクト: ericcapricorn/flynn
func (c *VirConnection) GetURI() (string, error) {
	cStr := C.virConnectGetURI(c.ptr)
	if cStr == nil {
		return "", GetLastError()
	}
	uri := C.GoString(cStr)
	C.free(unsafe.Pointer(cStr))
	return uri, nil
}
コード例 #2
0
ファイル: hypervisor.go プロジェクト: hooklift/golibvirt
func (h *Hypervisor) GetConnectionUri() (string, error) {
	result := C.virConnectGetURI(h.cptr)
	if result == nil {
		return "", GetLastError()
	}

	uri := C.GoString(result)
	defer C.free(unsafe.Pointer(result))

	return uri, nil
}
コード例 #3
0
// URI returns the URI (name) of the hypervisor connection. Normally this is
// the same as or similar to the string passed to the Open/OpenReadOnly call,
// but the driver may make the URI canonical. If uri == "" was passed to Open,
// then the driver will return a non-NULL URI which can be used to connect tos
// the same hypervisor later.
func (conn Connection) URI() (string, error) {
	conn.log.Println("reading connection URI...")
	cURI := C.virConnectGetURI(conn.virConnect)
	if cURI == nil {
		err := LastError()
		conn.log.Printf("an error occurred: %v\n", err)
		return "", err
	}
	defer C.free(unsafe.Pointer(cURI))

	uri := C.GoString(cURI)
	conn.log.Printf("connection URI: %v\n", uri)
	return uri, nil
}