//int libxl_domain_reboot(libxl_ctx *ctx, uint32_t domid);
974594
func (Ctx *Context) DomainReboot(id Domid) (err error) {
	err = Ctx.CheckOpen()
	if err != nil {
		return
	}

	ret := C.libxl_domain_reboot(Ctx.ctx, C.uint32_t(id))

	if ret != 0 {
		err = Error(-ret)
	}
	return
}
263288
func LibxlCtxFree(ctx LibxlCtxPtr) int {
	return (int)(C.hyperxl_ctx_free((*C.struct_libxl__ctx)(ctx)))
}
324661
func (c *Client) GetDomainID(domainName string) (string, error) {
	domainList := &DomainListResponse{}

	err := c.do(http.MethodGet, "/v1/domains", nil, domainList)
	if err != nil {
		return "", err
	}

	for _, domain := range domainList.Domains {
		if domain.Name == domainName {
			return domain.ID, nil
		}
	}
	return "", fmt.Errorf("no such domain: %s", domainName)
}
539726
func (d *Domain) GetBlockInfo(disk string, flag uint) (*DomainBlockInfo, error) {
	var cinfo C.virDomainBlockInfo
	cDisk := C.CString(disk)
	defer C.free(unsafe.Pointer(cDisk))
	var err C.virError
	result := C.virDomainGetBlockInfoWrapper(d.ptr, cDisk, &cinfo, C.uint(flag), &err)
	if result == -1 {
		return nil, makeError(&err)
	}

	return &DomainBlockInfo{
		Capacity:   uint64(cinfo.capacity),
		Allocation: uint64(cinfo.allocation),
		Physical:   uint64(cinfo.physical),
	}, nil
}
520305
func domainEventAgentLifecycleCallback(c C.virConnectPtr, d C.virDomainPtr, state C.int, reason C.int, goCallbackId int) {
	domain := &Domain{ptr: d}
	connection := &Connect{ptr: c}

	eventDetails := &DomainEventAgentLifecycle{
		State:  ConnectDomainEventAgentLifecycleState(state),
		Reason: ConnectDomainEventAgentLifecycleReason(reason),
	}
	callbackFunc := getCallbackId(goCallbackId)
	callback, ok := callbackFunc.(DomainEventAgentLifecycleCallback)
	if !ok {
		panic("Inappropriate callback type called")
	}
	callback(connection, domain, eventDetails)

}
868143
func (alloc *allocator) Rebase(tableID, requiredBase int64, allocIDs bool) error {
	if tableID == 0 {
		return errInvalidTableID.GenWithStack("Invalid tableID")
	}

	alloc.mu.Lock()
	defer alloc.mu.Unlock()

	if alloc.isUnsigned {
		return alloc.rebase4Unsigned(tableID, uint64(requiredBase), allocIDs)
	}
	return alloc.rebase4Signed(tableID, requiredBase, allocIDs)
}
1044483
func (r Virtual_Guest_Block_Device_Template_Group) SetBootMode(newBootMode *string) (resp bool, err error) {
	params := []interface{}{
		newBootMode,
	}
	err = r.Session.DoRequest("SoftLayer_Virtual_Guest_Block_Device_Template_Group", "setBootMode", params, &r.Options, &resp)
	return
}
832387
func (c *CDN) StopCdnDomain(domainName string, resp interface{}) (err error) {
	req := c.cdnReq.Clone().(*Request)
	req.Action = StopCdnDomainAction
	req.SetArgs("DomainName", domainName)
	err = c.rpc.Query(req, resp)
	return
}
1039090
func (s *DomainService) GetDomainChildrenID(name string, opts ...OptionFunc) (string, int, error) {
	p := &ListDomainChildrenParams{}
	p.p = make(map[string]interface{})

	p.p["name"] = name

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

	l, err := s.ListDomainChildren(p)
	if err != nil {
		return "", -1, err
	}

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

	if l.Count == 1 {
		return l.DomainChildren[0].Id, l.Count, nil
	}

	if l.Count > 1 {
		for _, v := range l.DomainChildren {
			if v.Name == name {
				return v.Id, l.Count, nil
			}
		}
	}
	return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
}
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
}
192219
func jujuXDGDataHomeLinux() string {
	xdgConfig := os.Getenv(XDGDataHome)
	if xdgConfig != "" {
		return filepath.Join(xdgConfig, "juju")
	}
	// If xdg config home is not defined, the standard indicates that its default value
	// is $HOME/.local/share
	home := utils.Home()
	return filepath.Join(home, ".local", "share", "juju")
}
770641
func (r Account_Link_OpenStack) DeleteOSDomain(domainId *string) (resp bool, err error) {
	params := []interface{}{
		domainId,
	}
	err = r.Session.DoRequest("SoftLayer_Account_Link_OpenStack", "deleteOSDomain", params, &r.Options, &resp)
	return
}
224413
func hyperxl_log_cgo(msg *C.char, len C.int) {
	if glog.V(1) {
		glog.Info("[libxl] ", C.GoStringN(msg, len))
	}
}
77821
func (c *Client) DomainResourceList(domainID int, resourceID *int) ([]DomainResource, error) {
	args := make(map[string]interface{})
	args["DomainID"] = domainID
	args["ResourceID"] = resourceID

	data, err := c.apiCall("domain.resource.list", args)
	if err != nil {
		return nil, err
	}

	var dr []DomainResource
	err = unmarshalMultiMap(data, &dr)
	if err != nil {
		return nil, err
	}

	return dr, nil
}
810370
func (Ctx *Context) DomainShutdown(id Domid) (err error) {
	err = Ctx.CheckOpen()
	if err != nil {
		return
	}

	ret := C.libxl_domain_shutdown(Ctx.ctx, C.uint32_t(id))

	if ret != 0 {
		err = Error(-ret)
	}
	return
}
800012
func (p *Provider) deleteUnnecessaryDomains(ctx context.Context) {
	var newDomains []types.Domain

	logger := log.FromContext(ctx)

	for idxDomainToCheck, domainToCheck := range p.Domains {
		keepDomain := true

		for idxDomain, domain := range p.Domains {
			if idxDomainToCheck == idxDomain {
				continue
			}

			if reflect.DeepEqual(domain, domainToCheck) {
				if idxDomainToCheck > idxDomain {
					logger.Warnf("The domain %v is duplicated in the configuration but will be process by ACME provider only once.", domainToCheck)
					keepDomain = false
				}
				break
			}

			// Check if CN or SANS to check already exists
			// or can not be checked by a wildcard
			var newDomainsToCheck []string
			for _, domainProcessed := range domainToCheck.ToStrArray() {
				if idxDomain < idxDomainToCheck && isDomainAlreadyChecked(domainProcessed, domain.ToStrArray()) {
					// The domain is duplicated in a CN
					logger.Warnf("Domain %q is duplicated in the configuration or validated by the domain %v. It will be processed once.", domainProcessed, domain)
					continue
				} else if domain.Main != domainProcessed && strings.HasPrefix(domain.Main, "*") && isDomainAlreadyChecked(domainProcessed, []string{domain.Main}) {
					// Check if a wildcard can validate the domain
					logger.Warnf("Domain %q will not be processed by ACME provider because it is validated by the wildcard %q", domainProcessed, domain.Main)
					continue
				}
				newDomainsToCheck = append(newDomainsToCheck, domainProcessed)
			}

			// Delete the domain if both Main and SANs can be validated by the wildcard domain
			// otherwise keep the unchecked values
			if newDomainsToCheck == nil {
				keepDomain = false
				break
			}
			domainToCheck.Set(newDomainsToCheck)
		}

		if keepDomain {
			newDomains = append(newDomains, domainToCheck)
		}
	}

	p.Domains = newDomains
}
204120
func (m *Machine) GetRebootFlag() (bool, error) {
	rebootCol, closer := m.st.db().GetCollection(rebootC)
	defer closer()

	count, err := rebootCol.FindId(m.doc.DocID).Count()
	if err != nil {
		return false, fmt.Errorf("failed to get reboot flag: %v", err)
	}
	if count == 0 {
		return false, nil
	}
	return true, nil
}