コード例 #1
0
ファイル: hypervisor.go プロジェクト: hooklift/golibvirt
func (h *Hypervisor) GetMaxVcpus(dtype string) (uint8, error) {
	domainType := C.CString(dtype)
	defer C.free(unsafe.Pointer(domainType))

	result := C.virConnectGetMaxVcpus(h.cptr, domainType)
	if result == -1 {
		return uint8(result), GetLastError()
	}

	return uint8(result), nil
}
コード例 #2
0
ファイル: libvirt.go プロジェクト: ericcapricorn/flynn
func (c *VirConnection) GetMaxVcpus(typeAttr string) (int, error) {
	var cTypeAttr *C.char
	if typeAttr != "" {
		cTypeAttr = C.CString(typeAttr)
		defer C.free(unsafe.Pointer(cTypeAttr))
	}
	result := int(C.virConnectGetMaxVcpus(c.ptr, cTypeAttr))
	if result == -1 {
		return 0, GetLastError()
	}
	return result, nil
}
コード例 #3
0
// MaxVCPUs provides the maximum number of virtual CPUs supported for a guest
// VM of a specific type. The 'type' parameter here corresponds to the 'type'
// attribute in the <domain> element of the XML
func (conn Connection) MaxVCPUs(typ string) (int32, error) {
	cTyp := C.CString(typ)
	defer C.free(unsafe.Pointer(cTyp))

	conn.log.Printf("querying maximum VCPUs count for %v...\n", typ)
	cRet := C.virConnectGetMaxVcpus(conn.virConnect, cTyp)
	ret := int32(cRet)

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

	conn.log.Printf("max VCPUs count: %v\n", ret)

	return ret, nil
}