Exemplo n.º 1
0
func (c *VirConnection) GetHostname() (string, error) {
	str := C.virConnectGetHostname(c.ptr)
	if str == nil {
		return "", GetLastError()
	}
	hostname := C.GoString(str)
	C.free(unsafe.Pointer(str))
	return hostname, nil
}
Exemplo n.º 2
0
func (h *Hypervisor) GetHostname() (string, error) {
	result := C.virConnectGetHostname(h.cptr)
	if result == nil {
		return "", GetLastError()
	}

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

	return hostname, nil
}
Exemplo n.º 3
0
// Hostname returns a system hostname on which the hypervisor is running
// (based on the result of the gethostname system call, but possibly expanded
// to a fully-qualified domain name via getaddrinfo). If we are connected to a
// remote system, then this returns the hostname of the remote system.
func (conn Connection) Hostname() (string, error) {
	conn.log.Println("reading system hostname...")
	cHostname := C.virConnectGetHostname(conn.virConnect)
	if cHostname == nil {
		err := LastError()
		conn.log.Printf("an error occurred: %v\n", err)
		return "", err
	}
	defer C.free(unsafe.Pointer(cHostname))

	hostname := C.GoString(cHostname)
	conn.log.Printf("system hostname: %v\n", hostname)

	return hostname, nil
}