Example #1
0
func (c *VirConnection) NumOfInActiveDomains() (int, error) {
	result := int(C.virConnectNumOfDefinedDomains(c.ptr))
	if result == -1 {
		return 0, errors.New(GetLastError())
	}
	return result, nil
}
Example #2
0
func (h *Hypervisor) GetDefinedDomains() ([]string, error) {
	number := C.virConnectNumOfDefinedDomains(h.cptr)
	if number == -1 {
		return nil, GetLastError()
	}

	names := make([]string, number)

	if number == 0 {
		return names, nil
	}

	cnames := make([]*C.char, number)
	result := C.virConnectListDefinedDomains(h.cptr, &cnames[0], number)
	if result == -1 {
		return nil, GetLastError()
	}

	for i, v := range cnames {
		names[i] = C.GoString(v)
		defer C.free(unsafe.Pointer(v))
	}

	return names, nil
}
Example #3
0
//virConnectNumOf functions
func (h *Hypervisor) GetNumberOfDefinedDomains() (int, error) {
	number := C.virConnectNumOfDefinedDomains(h.cptr)
	if number == -1 {
		return 0, GetLastError()
	}

	return int(number), nil
}