// See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainPinVcpu
511275
func (d *Domain) PinVcpu(vcpu uint, cpuMap []bool) error {
	maplen := (len(cpuMap) + 7) / 8
	ccpumap := make([]C.uchar, maplen)
	for i := 0; i < len(cpuMap); i++ {
		if cpuMap[i] {
			byte := i / 8
			bit := i % 8
			ccpumap[byte] |= (1 << uint(bit))
		}
	}

	var err C.virError
	result := C.virDomainPinVcpuWrapper(d.ptr, C.uint(vcpu), &ccpumap[0], C.int(maplen), &err)

	if result == -1 {
		return makeError(&err)
	}

	return nil
}
845793
func (d *Domain) PMWakeup(flags uint32) error {
	var err C.virError
	ret := C.virDomainPMWakeupWrapper(d.ptr, C.uint(flags), &err)
	if ret == -1 {
		return makeError(&err)
	}

	return nil
}
3025
func (p *propPrivateHostPlan) GetCPU() int {
	if p.Plan == nil {
		return -1
	}

	return p.Plan.GetCPU()
}
606639
func getPinnedCAFilepathByPrefix(gun data.GUN, t TrustPinConfig) (string, error) {
	specificGUN := ""
	specificCAFilepath := ""
	foundCA := false
	for gunPrefix, caFilepath := range t.CA {
		if strings.HasPrefix(gun.String(), gunPrefix) && len(gunPrefix) >= len(specificGUN) {
			specificGUN = gunPrefix
			specificCAFilepath = caFilepath
			foundCA = true
		}
	}
	if !foundCA {
		return "", fmt.Errorf("could not find pinned CA for GUN: %s", gun)
	}
	return specificCAFilepath, nil
}
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
}
683524
func OpenPin(n int, mode Mode) (Pin, error) {
	// export this pin to create the virtual files on the system
	pinBase, err := expose(n)
	if err != nil {
		return nil, err
	}
	value, err := os.OpenFile(filepath.Join(pinBase, "value"), os.O_RDWR, 0600)
	if err != nil {
		return nil, err
	}
	p := &pin{
		number:    n,
		modePath:  filepath.Join(pinBase, "direction"),
		edgePath:  filepath.Join(pinBase, "edge"),
		valueFile: value,
		initial:   true,
	}
	if err := p.setMode(mode); err != nil {
		p.Close()
		return nil, err
	}
	return p, nil
}
1010189
func (d *Domain) GetVcpusFlags(flags DomainVcpuFlags) (int32, error) {
	var err C.virError
	result := C.virDomainGetVcpusFlagsWrapper(d.ptr, C.uint(flags), &err)
	if result == -1 {
		return 0, makeError(&err)
	}
	return int32(result), nil
}
644377
func (s *VirtualMachineService) NewStopVirtualMachineParams(id string) *StopVirtualMachineParams {
	p := &StopVirtualMachineParams{}
	p.p = make(map[string]interface{})
	p.p["id"] = id
	return p
}
1185524
func (o *CustomInstance) SetVCPU(v *int) *CustomInstance {
	if o.VCPU = v; o.VCPU == nil {
		o.nullFields = append(o.nullFields, "VCPU")
	}
	return o
}
418757
func (s *ContainerDetail) SetVcpus(v int64) *ContainerDetail {
	s.Vcpus = &v
	return s
}
242342
func (c *Connect) GetMaxVcpus(typeAttr string) (int, error) {
	var cTypeAttr *C.char
	if typeAttr != "" {
		cTypeAttr = C.CString(typeAttr)
		defer C.free(unsafe.Pointer(cTypeAttr))
	}
	var err C.virError
	result := int(C.virConnectGetMaxVcpusWrapper(c.ptr, cTypeAttr, &err))
	if result == -1 {
		return 0, makeError(&err)
	}
	return result, nil
}
979145
func OpenPin(number int, mode gpio.Mode) (gpio.Pin, error) {
	initOnce.Do(initRPi)
	p, err := gpio.OpenPin(number, mode)
	return &pin{Pin: p, pin: uint8(number)}, err
}
645557
func (s *Session) verifyPin(pin []byte) error {
	if _, err := s.Channel.transmitEncrypted(claSCWallet, insVerifyPin, 0, 0, pin); err != nil {
		return err
	}
	s.verified = true
	return nil
}
679873
func (c *Connect) GetURI() (string, error) {
	var err C.virError
	cStr := C.virConnectGetURIWrapper(c.ptr, &err)
	if cStr == nil {
		return "", makeError(&err)
	}
	uri := C.GoString(cStr)
	C.free(unsafe.Pointer(cStr))
	return uri, nil
}
156976
func (_class PGPUClass) GetResidentVGPUs(sessionID SessionRef, self PGPURef) (_retval []VGPURef, _err error) {
	_method := "PGPU.get_resident_VGPUs"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertPGPURefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _selfArg)
	if _err != nil {
		return
	}
	_retval, _err = convertVGPURefSetToGo(_method + " -> ", _result.Value)
	return
}
224463
func (c *Client) currentPin() (string, string) {
	c.mu.RLock()
	defer c.mu.RUnlock()
	return c.leader, c.pinned
}
94222
func StartVReplicationUntil(uid uint32, pos string) string {
	return fmt.Sprintf(
		"update _vt.vreplication set state='%v', stop_pos=%v where id=%v",
		BlpRunning, encodeString(pos), uid)
}