// See also https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectNumOfDomains
974869
func (c *Connect) NumOfDomains() (int, error) {
	var err C.virError
	result := int(C.virConnectNumOfDomainsWrapper(c.ptr, &err))
	if result == -1 {
		return 0, makeError(&err)
	}
	return result, nil
}
341319
func (c *Connect) NumOfInterfaces() (int, error) {
	var err C.virError
	result := int(C.virConnectNumOfInterfacesWrapper(c.ptr, &err))
	if result == -1 {
		return 0, makeError(&err)
	}
	return result, nil
}
732415
func (c *Connect) LookupDomainById(id uint32) (*Domain, error) {
	var err C.virError
	ptr := C.virDomainLookupByIDWrapper(c.ptr, C.int(id), &err)
	if ptr == nil {
		return nil, makeError(&err)
	}
	return &Domain{ptr: ptr}, nil
}
928765
func domainEventGenericCallback(c C.virConnectPtr, d C.virDomainPtr,
	opaque int) {

	domain := VirDomain{ptr: d}
	connection := VirConnection{ptr: c}

	callDomainCallbackId(opaque, &connection, &domain, nil)
}
628678
func (s *DomainService) GetDomainChildrenByName(name string, opts ...OptionFunc) (*DomainChildren, int, error) {
	id, count, err := s.GetDomainChildrenID(name, opts...)
	if err != nil {
		return nil, count, err
	}

	r, count, err := s.GetDomainChildrenByID(id, opts...)
	if err != nil {
		return nil, count, err
	}
	return r, count, nil
}
652140
func (c *Connect) NumOfDefinedInterfaces() (int, error) {
	var err C.virError
	result := int(C.virConnectNumOfDefinedInterfacesWrapper(c.ptr, &err))
	if result == -1 {
		return 0, makeError(&err)
	}
	return result, nil
}
1081616
func (client *Client) GetDomains(ctx context.Context) ([]DNSDomain, error) {
	resp, err := client.dnsRequest(ctx, "/v1/domains", nil, "", "GET")
	if err != nil {
		return nil, err
	}

	var d []DNSDomainResponse
	if err := json.Unmarshal(resp, &d); err != nil {
		return nil, err
	}

	domains := make([]DNSDomain, len(d))
	for i := range d {
		domains[i] = *d[i].Domain
	}
	return domains, nil
}
356186
func (c *Connect) DomainCreateXML(xmlConfig string, flags DomainCreateFlags) (*Domain, error) {
	cXml := C.CString(string(xmlConfig))
	defer C.free(unsafe.Pointer(cXml))
	var err C.virError
	ptr := C.virDomainCreateXMLWrapper(c.ptr, cXml, C.uint(flags), &err)
	if ptr == nil {
		return nil, makeError(&err)
	}
	return &Domain{ptr: ptr}, nil
}
1031643
func (h *Hostlist) FilterByDomain(domain string) (hostnames []*Hostname) {
	for _, hostname := range *h {
		if hostname.Domain == domain {
			hostnames = append(hostnames, hostname)
		}
	}
	return
}
649000
func (d *Domain) CoreDumpWithFormat(to string, format DomainCoreDumpFormat, flags DomainCoreDumpFlags) error {
	if C.LIBVIR_VERSION_NUMBER < 1002003 {
		makeNotImplementedError("virDomainCoreDumpWithFormat")
	}
	cto := C.CString(to)
	defer C.free(unsafe.Pointer(cto))

	var err C.virError
	ret := C.virDomainCoreDumpWithFormatWrapper(d.ptr, cto, C.uint(format), C.uint(flags), &err)
	if ret == -1 {
		return makeError(&err)
	}

	return nil
}
178711
func (c *Connect) DomainRestore(srcFile string) error {
	cPath := C.CString(srcFile)
	defer C.free(unsafe.Pointer(cPath))
	var err C.virError
	if result := C.virDomainRestoreWrapper(c.ptr, cPath, &err); result == -1 {
		return makeError(&err)
	}
	return nil
}
1023878
func (r Dns_Domain_Registration) LockDomain() (resp bool, err error) {
	err = r.Session.DoRequest("SoftLayer_Dns_Domain_Registration", "lockDomain", nil, &r.Options, &resp)
	return
}
100918
func (r *PCPRegistry) InstanceDomainCount() int {
	r.indomlock.RLock()
	defer r.indomlock.RUnlock()

	return len(r.instanceDomains)
}
485916
func (c *Connect) DomainXMLFromNative(nativeFormat string, nativeConfig string, flags uint32) (string, error) {
	cnativeFormat := C.CString(nativeFormat)
	defer C.free(unsafe.Pointer(cnativeFormat))
	cnativeConfig := C.CString(nativeConfig)
	defer C.free(unsafe.Pointer(cnativeConfig))

	var err C.virError
	ret := C.virConnectDomainXMLFromNativeWrapper(c.ptr, cnativeFormat, cnativeConfig, C.uint(flags), &err)
	if ret == nil {
		return "", makeError(&err)
	}

	defer C.free(unsafe.Pointer(ret))

	return C.GoString(ret), nil
}
5081
func (s *DomainService) GetDomainChildrenByID(id string, opts ...OptionFunc) (*DomainChildren, int, error) {
	p := &ListDomainChildrenParams{}
	p.p = make(map[string]interface{})

	p.p["id"] = id

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return nil, -1, err
		}
	}

	l, err := s.ListDomainChildren(p)
	if err != nil {
		if strings.Contains(err.Error(), fmt.Sprintf(
			"Invalid parameter id value=%s due to incorrect long value format, "+
				"or entity does not exist", id)) {
			return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
		}
		return nil, -1, err
	}

	if l.Count == 0 {
		return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
	}

	if l.Count == 1 {
		return l.DomainChildren[0], l.Count, nil
	}
	return nil, l.Count, fmt.Errorf("There is more then one result for DomainChildren UUID: %s!", id)
}
1351915
func domainEventDiskChangeCallback(c C.virConnectPtr, d C.virDomainPtr,
	oldSrcPath *C.char, newSrcPath *C.char, devAlias *C.char,
	reason int, opaque int) {

	domain := VirDomain{ptr: d}
	connection := VirConnection{ptr: c}

	eventDetails := DomainDiskChangeEvent{
		OldSrcPath: C.GoString(oldSrcPath),
		NewSrcPath: C.GoString(newSrcPath),
		DevAlias:   C.GoString(devAlias),
		Reason:     reason,
	}

	callDomainCallbackId(opaque, &connection, &domain, eventDetails)
}
394077
func (s *ListDomainsInput) SetMaxNumberOfDomains(v int64) *ListDomainsInput {
	s.MaxNumberOfDomains = &v
	return s
}