Ejemplo n.º 1
0
// Version gets the version level of the Hypervisor running.
func (conn Connection) Version() (uint64, error) {
	var cVersion C.ulong
	conn.log.Println("reading hypervisor version...")
	cRet := C.virConnectGetVersion(conn.virConnect, &cVersion)
	ret := int32(cRet)

	if ret == -1 {
		err := LastError()
		conn.log.Printf("an error occurred: %v\n", err)
		return 0, err
	}

	version := uint64(cVersion)
	conn.log.Printf("hypervisor version: %v\n", version)

	return version, nil
}
Ejemplo n.º 2
0
func (h *Hypervisor) GetVersion() (map[string]int, error) {
	version := map[string]int{
		"major": 0,
		"minor": 0,
		"rel":   0,
	}

	var hver int
	result := C.virConnectGetVersion(h.cptr, (*C.ulong)(unsafe.Pointer(&hver)))
	if result == -1 {
		return version, GetLastError()
	}

	version["major"] = hver / 1000000
	hver %= 1000000
	version["minor"] = hver / 1000
	version["rel"] = hver % 1000

	return version, nil
}