Exemple #1
0
func (c *VirConnection) NumOfDomains() (int, error) {
	result := int(C.virConnectNumOfDomains(c.ptr))
	if result == -1 {
		return 0, GetLastError()
	}
	return result, nil
}
Exemple #2
0
func (h *Hypervisor) GetNumberOfActiveDomains() (int, error) {
	number := C.virConnectNumOfDomains(h.cptr)
	if number == -1 {
		return 0, GetLastError()
	}

	return int(number), nil
}
Exemple #3
0
func (h *Hypervisor) GetActiveDomains() ([]int, error) {
	number := C.virConnectNumOfDomains(h.cptr)
	if number == -1 {
		return nil, GetLastError()
	}

	ids := make([]int, number)

	if number == 0 {
		return ids, nil
	}

	cids := make([]C.int, number)
	result := C.virConnectListDomains(h.cptr, &cids[0], number)
	if result == -1 {
		return nil, GetLastError()
	}

	for i, v := range cids {
		ids[i] = int(v)
	}

	return ids, nil
}