// cmdDevices converts a list of driver.DeviceConfigs into excutor.Devices.
422758
func cmdDevices(devices []*drivers.DeviceConfig) ([]*lconfigs.Device, error) {
	if len(devices) == 0 {
		return nil, nil
	}

	r := make([]*lconfigs.Device, len(devices))

	for i, d := range devices {
		ed, err := ldevices.DeviceFromPath(d.HostPath, d.Permissions)
		if err != nil {
			return nil, fmt.Errorf("failed to make device out for %s: %v", d.HostPath, err)
		}
		ed.Path = d.TaskPath
		r[i] = ed
	}

	return r, nil
}
529542
func (pdev podDevices) getContainerDevices(podUID, contName string) []*podresourcesapi.ContainerDevices {
	if _, podExists := pdev[podUID]; !podExists {
		return nil
	}
	if _, contExists := pdev[podUID][contName]; !contExists {
		return nil
	}
	cDev := []*podresourcesapi.ContainerDevices{}
	for resource, allocateInfo := range pdev[podUID][contName] {
		cDev = append(cDev, &podresourcesapi.ContainerDevices{
			ResourceName: resource,
			DeviceIds:    allocateInfo.deviceIds.UnsortedList(),
		})
	}
	return cDev
}
330221
func (_m *DBClient) GetDeviceProfilesByCommandId(id string) ([]models.DeviceProfile, error) {
	ret := _m.Called(id)

	var r0 []models.DeviceProfile
	if rf, ok := ret.Get(0).(func(string) []models.DeviceProfile); ok {
		r0 = rf(id)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]models.DeviceProfile)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(string) error); ok {
		r1 = rf(id)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
546168
func (s *CreateDeviceDefinitionVersionInput) SetDevices(v []*Device) *CreateDeviceDefinitionVersionInput {
	s.Devices = v
	return s
}
299398
func RemoveDevice(deviceName string, opts ...RemoveDeviceOpt) error {
	args := []string{
		"remove",
	}

	for _, opt := range opts {
		args = append(args, string(opt))
	}

	args = append(args, GetFullDevicePath(deviceName))

	_, err := dmsetup(args...)
	return err
}
325843
func (s *ListDevicePoolsOutput) SetDevicePools(v []*DevicePool) *ListDevicePoolsOutput {
	s.DevicePools = v
	return s
}
384506
func (s *ListDevicesOutput) SetDevices(v []*Device) *ListDevicesOutput {
	s.Devices = v
	return s
}
258664
func (pdev podDevices) containerDevices(podUID, contName, resource string) sets.String {
	if _, podExists := pdev[podUID]; !podExists {
		return nil
	}
	if _, contExists := pdev[podUID][contName]; !contExists {
		return nil
	}
	devs, resourceExists := pdev[podUID][contName][resource]
	if !resourceExists {
		return nil
	}
	return devs.deviceIds
}
566051
func (p Profile) ValidateConfigDevices() error {
	for _, val := range p.Devices {
		goodDevs := set.NewStrings("unix-char", "unix-block", "gpu", "usb")
		if devType, ok := val["type"]; ok {
			if !goodDevs.Contains(devType) {
				return fmt.Errorf("invalid lxd-profile: contains device type %q", devType)
			}
		}
	}
	for key := range p.Config {
		if strings.HasPrefix(key, "boot") ||
			strings.HasPrefix(key, "limits") ||
			strings.HasPrefix(key, "migration") {
			return fmt.Errorf("invalid lxd-profile: contains config value %q", key)
		}
	}
	return nil
}
376959
func Drivers() []string {
	var list []string
	for name := range drivers {
		list = append(list, name)
	}
	sort.Strings(list)
	return list
}
142759
func (mc MongoClient) GetDeviceProfilesByCommandId(id string) ([]contract.DeviceProfile, error) {
	command, err := mc.getCommandById(id)
	if err != nil {
		return []contract.DeviceProfile{}, err
	}

	dps, err := mc.getDeviceProfiles(bson.M{"commands.$id": command.Id})
	if err != nil {
		return []contract.DeviceProfile{}, err
	}
	return dps, nil
}
614008
func getDevices(pool, block, metadatadev string) (map[int]*DeviceBlockStats, error) {
	cmd := exec.Command("thin_dump", "-f", "xml", metadatadev, "-m", block)
	stdout, err := cmd.StdoutPipe()
	cmd.Stderr = os.Stderr
	if err != nil {
		return nil, err
	}
	if err := cmd.Start(); err != nil {
		return nil, err
	}
	devices, err := parseMetadata(stdout)
	if err != nil {
		return nil, err
	}
	if err := cmd.Wait(); err != nil {
		return nil, err
	}
	return devices, nil
}
1351551
func (e *PaperProvisionEngine) makeDeviceKeys(m libkb.MetaContext, args *DeviceWrapArgs) error {
	e.deviceWrapEng = NewDeviceWrap(m.G(), args)
	return RunEngine2(m, e.deviceWrapEng)
}
951728
func DeleteDevice(poolName string, deviceID uint32) error {
	_, err := dmsetup("message", poolName, "0", fmt.Sprintf("delete %d", deviceID))
	return err
}
1284700
func makeDevices(opts *kubecontainer.RunContainerOptions) []*runtimeapi.Device {
	devices := make([]*runtimeapi.Device, len(opts.Devices))

	for idx := range opts.Devices {
		device := opts.Devices[idx]
		devices[idx] = &runtimeapi.Device{
			HostPath:      device.PathOnHost,
			ContainerPath: device.PathInContainer,
			Permissions:   device.Permissions,
		}
	}

	return devices
}
285975
func WaitOnDevices(devs []string, stage string) error {
	conn, err := dbus.NewSystemdConnection()
	if err != nil {
		return err
	}

	results := map[string]chan string{}
	for _, dev := range devs {
		unitName := unit.UnitNamePathEscape(dev + ".device")
		results[unitName] = make(chan string, 1)

		if _, err = conn.StartUnit(unitName, "replace", results[unitName]); err != nil {
			return fmt.Errorf("failed starting device unit %s: %v", unitName, err)
		}
	}

	for unitName, result := range results {
		s := <-result

		if s != "done" {
			return fmt.Errorf("device unit %s %s", unitName, s)
		}
	}

	return nil
}
597139
func (c *Connect) ListDevices(cap string, flags uint32) ([]string, error) {
	ccap := C.CString(cap)
	defer C.free(unsafe.Pointer(ccap))
	const maxNodeDevices = 1024
	var uuids [maxNodeDevices](*C.char)
	uuidsPtr := unsafe.Pointer(&uuids)
	var err C.virError
	numNodeDevices := C.virNodeListDevicesWrapper(
		c.ptr, ccap,
		(**C.char)(uuidsPtr),
		maxNodeDevices, C.uint(flags), &err)
	if numNodeDevices == -1 {
		return nil, makeError(&err)
	}
	goUuids := make([]string, numNodeDevices)
	for k := 0; k < int(numNodeDevices); k++ {
		goUuids[k] = C.GoString(uuids[k])
		C.free(unsafe.Pointer(uuids[k]))
	}
	return goUuids, nil
}