// EditDevice edits the given (existing) devices on the VirtualMachine
430940
func (v VirtualMachine) EditDevice(ctx context.Context, device ...types.BaseVirtualDevice) error {
	return v.configureDevice(ctx, types.VirtualDeviceConfigSpecOperationEdit, types.VirtualDeviceConfigSpecFileOperationReplace, device...)
}
905094
func (s *Problem) SetDevice(v *Device) *Problem {
	s.Device = v
	return s
}
546168
func (s *CreateDeviceDefinitionVersionInput) SetDevices(v []*Device) *CreateDeviceDefinitionVersionInput {
	s.Devices = v
	return s
}
881451
func (s *Device) SetDeviceId(v string) *Device {
	s.DeviceId = &v
	return s
}
1267349
func (c *Client) AddDevice(d contract.Device) (string, error) {
	conn := c.Pool.Get()
	defer conn.Close()

	return addDevice(conn, d)
}
1205426
func (h *netlinkHandle) DeleteDummyDevice(devName string) error {
	link, err := h.LinkByName(devName)
	if err != nil {
		_, ok := err.(netlink.LinkNotFoundError)
		if ok {
			return nil
		}
		return fmt.Errorf("error deleting a non-exist dummy device: %s, %v", devName, err)
	}
	dummy, ok := link.(*netlink.Dummy)
	if !ok {
		return fmt.Errorf("expect dummy device, got device type: %s", link.Type())
	}
	return h.LinkDel(dummy)
}
1052049
func (d *DeviceMapperDriver) addDevice(headDeviceHash string) (string, error) {

	// Generate the device ID.
	deviceHash, err := utils.NewUUID62()
	if err != nil {
		return "", err
	}

	// Create the device.
	if err := d.DeviceSet.AddDevice(deviceHash, headDeviceHash); err != nil {
		glog.Errorf("Unable to create device %s: %s", deviceHash, err)
		return "", err
	}

	if headDeviceHash == "" {

		// Activate the device.
		d.DeviceSet.GetDeviceStatus(deviceHash)

		// CC-2219: Ensure the device base size is equal or greater than the
		// configured dm.basesize.
		size, err := d.deviceSize(deviceHash)
		if err != nil {
			glog.Errorf("Could not read the size of device %s: %s", deviceHash, err)
			return "", err
		}
		if baseSize := d.baseSize(); baseSize > size {

			// Make the device to match dm.basesize
			glog.V(2).Infof("Device size is smaller than dm.basesize; expanding")
			if err := d.resize(deviceHash, baseSize); err != nil {
				glog.Errorf("Could not update the size of the device %s: %s", deviceHash, err)
				return "", err
			}
		}
	}

	return deviceHash, nil
}
1031107
func (g *Generator) AddDevice(device rspec.LinuxDevice) {
	g.initConfigLinux()

	for i, dev := range g.Config.Linux.Devices {
		if dev.Path == device.Path {
			g.Config.Linux.Devices[i] = device
			return
		}
		if dev.Type == device.Type && dev.Major == device.Major && dev.Minor == device.Minor {
			fmt.Fprintln(os.Stderr, "WARNING: The same type, major and minor should not be used for multiple devices.")
		}
	}

	g.Config.Linux.Devices = append(g.Config.Linux.Devices, device)
}
702302
func (devices *DeviceSet) MountDevice(hash, path, mountLabel string) error {
	info, err := devices.lookupDeviceWithLock(hash)
	if err != nil {
		return err
	}

	if info.Deleted {
		return fmt.Errorf("devmapper: Can't mount device %v as it has been marked for deferred deletion", info.Hash)
	}

	info.lock.Lock()
	defer info.lock.Unlock()

	devices.Lock()
	defer devices.Unlock()

	if err := devices.activateDeviceIfNeeded(info, false); err != nil {
		return fmt.Errorf("devmapper: Error activating devmapper device for '%s': %s", hash, err)
	}

	fstype, err := ProbeFsType(info.DevName())
	if err != nil {
		return err
	}

	options := ""

	if fstype == "xfs" {
		// XFS needs nouuid or it can't mount filesystems with the same fs
		options = joinMountOptions(options, "nouuid")
	}

	options = joinMountOptions(options, devices.mountOptions)
	options = joinMountOptions(options, label.FormatMountLabel("", mountLabel))

	if err := mount.Mount(info.DevName(), path, fstype, options); err != nil {
		return errors.Wrapf(err, "Failed to mount; dmesg: %s", string(dmesg.Dmesg(256)))
	}

	if fstype == "xfs" && devices.xfsNospaceRetries != "" {
		if err := devices.xfsSetNospaceRetries(info); err != nil {
			unix.Unmount(path, unix.MNT_DETACH)
			devices.deactivateDevice(info)
			return err
		}
	}

	return nil
}
765071
func (s folderDeviceSet) hasDevice(dev protocol.DeviceID) bool {
	for _, devices := range s {
		if _, ok := devices[dev]; ok {
			return true
		}
	}
	return false
}
1194591
func (devices *DeviceSet) MountDevice(hash, path string, moptions graphdriver.MountOpts) error {
	info, err := devices.lookupDeviceWithLock(hash)
	if err != nil {
		return err
	}

	if info.Deleted {
		return fmt.Errorf("devmapper: Can't mount device %v as it has been marked for deferred deletion", info.Hash)
	}

	info.lock.Lock()
	defer info.lock.Unlock()

	devices.Lock()
	defer devices.Unlock()

	if err := devices.activateDeviceIfNeeded(info, false); err != nil {
		return fmt.Errorf("devmapper: Error activating devmapper device for '%s': %s", hash, err)
	}

	fstype, err := ProbeFsType(info.DevName())
	if err != nil {
		return err
	}

	options := ""

	if fstype == "xfs" {
		// XFS needs nouuid or it can't mount filesystems with the same fs
		options = joinMountOptions(options, "nouuid")
	}

	mountOptions := devices.mountOptions
	if len(moptions.Options) > 0 {
		addNouuid := strings.Contains("nouuid", mountOptions)
		mountOptions = strings.Join(moptions.Options, ",")
		if addNouuid {
			mountOptions = fmt.Sprintf("nouuid,%s", mountOptions)
		}
	}

	options = joinMountOptions(options, mountOptions)
	options = joinMountOptions(options, label.FormatMountLabel("", moptions.MountLabel))

	if err := mount.Mount(info.DevName(), path, fstype, options); err != nil {
		return fmt.Errorf("devmapper: Error mounting '%s' on '%s': %s\n%v", info.DevName(), path, err, string(dmesg.Dmesg(256)))
	}

	if fstype == "xfs" && devices.xfsNospaceRetries != "" {
		if err := devices.xfsSetNospaceRetries(info); err != nil {
			unix.Unmount(path, unix.MNT_DETACH)
			devices.deactivateDevice(info)
			return err
		}
	}

	return nil
}
210208
func (d *Domain) DetachDevice(xml string) error {
	cXml := C.CString(xml)
	defer C.free(unsafe.Pointer(cXml))
	var err C.virError
	result := C.virDomainDetachDeviceWrapper(d.ptr, cXml, &err)
	if result == -1 {
		return makeError(&err)
	}
	return nil
}
203530
func (s *SubscribeToDatasetInput) SetDeviceId(v string) *SubscribeToDatasetInput {
	s.DeviceId = &v
	return s
}
1114217
func (a *ActiveDevice) DeviceID() keybase1.DeviceID {
	a.RLock()
	defer a.RUnlock()
	return a.deviceID
}
137382
func (_m *Protocol) GetDevice(id uint64) (common.Device, error) {
	ret := _m.Called(id)

	var r0 common.Device
	if rf, ok := ret.Get(0).(func(uint64) common.Device); ok {
		r0 = rf(id)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(common.Device)
		}
	}

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

	return r0, r1
}
339754
func (s *ListDevicesOutput) SetDevices(v []*DeviceDescription) *ListDevicesOutput {
	s.Devices = v
	return s
}
249466
func (_m *DBClient) AddDeviceReport(dr models.DeviceReport) (string, error) {
	ret := _m.Called(dr)

	var r0 string
	if rf, ok := ret.Get(0).(func(models.DeviceReport) string); ok {
		r0 = rf(dr)
	} else {
		r0 = ret.Get(0).(string)
	}

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

	return r0, r1
}