Пример #1
0
func (c *VirConnection) GetLibVersion() (uint32, error) {
	var version C.ulong
	if err := C.virConnectGetLibVersion(c.ptr, &version); err < 0 {
		return 0, GetLastError()
	}
	return uint32(version), nil
}
Пример #2
0
// LibVersion provides the version of libvirt used by the daemon running on
// the host.
func (conn Connection) LibVersion() (uint64, error) {
	var cVersion C.ulong
	conn.log.Println("reading libvirt version...")
	cRet := C.virConnectGetLibVersion(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("libvirt version: %v\n", version)

	return version, nil
}
Пример #3
0
func (h *Hypervisor) GetLibVirtVersion() (map[string]int, error) {
	version := map[string]int{
		"major": 0,
		"minor": 0,
		"rel":   0,
	}

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

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

	return version, nil
}