Generate virtual device number for disks
        :param offset: offset of user_root_vdev.
        :return: virtual device number, string of 4 bit hex.
779731
def generate_disk_vdev(self, start_vdev=None, offset=0):
        
        if not start_vdev:
            start_vdev = CONF.zvm.user_root_vdev
        vdev = self._generate_vdev(start_vdev, offset)
        if offset >= 0 and offset < 254:
            return vdev
        else:
            msg = ("Failed to generate disk vdev, invalid virtual device"
                   "number for disk:%s" % vdev)
            LOG.error(msg)
            raise exception.SDKGuestOperationError(rs=2, msg=msg)
542977
def merge_partition_offsets(*partition_offsets):
    
    output = dict()
    for partition_offset in partition_offsets:
        for partition, offset in six.iteritems(partition_offset):
            prev_offset = output.get(partition, 0)
            output[partition] = max(prev_offset, offset)
    return output
53513
def _use_vxrentry(self, f, VXRoffset, recStart, recEnd, offset):
        '''
        
        '''
        # Select the next unused entry in a VXR for a VVR/CVVR
        f.seek(VXRoffset+20)
        # num entries
        numEntries = int.from_bytes(f.read(4), 'big', signed=True)
        # used entries
        usedEntries = int.from_bytes(f.read(4), 'big', signed=True)
        # VXR's First
        self._update_offset_value(f, VXRoffset+28+4*usedEntries, 4, recStart)
        # VXR's Last
        self._update_offset_value(f, VXRoffset+28+4*numEntries+4*usedEntries,
                                  4, recEnd)
        # VXR's Offset
        self._update_offset_value(f, VXRoffset+28+2*4*numEntries+8*usedEntries,
                                  8, offset)
        # VXR's NusedEntries
        usedEntries += 1
        self._update_offset_value(f, VXRoffset+24, 4, usedEntries)
        return usedEntries
1250858
def get_reg_name(arch, reg_offset):
        
        # todo does this make sense
        if reg_offset is None:
            return None

        original_offset = reg_offset
        while reg_offset >= 0 and reg_offset >= original_offset - (arch.bytes):
            if reg_offset in arch.register_names:
                return arch.register_names[reg_offset]
            else:
                reg_offset -= 1
        return None
300691
def set_bytes_at_rva(self, rva, data):
        
        
        offset = self.get_physical_by_rva(rva)
        if not offset:
            raise False
        
        return self.set_bytes_at_offset(offset, data)
97209
def get_device_address(usb_device):
        
        try:
            usb_device.ctrl_transfer(0x21, 0x09, 0x0300, 0, GrizzlyUSB.COMMAND_GET_ADDR)
            internal_addr = usb_device.ctrl_transfer(0xa1, 0x01, 0x0301, 0, 2)[1]
            return internal_addr >> 1
        except usb.USBError as e:
            return GrizzlyUSB.USB_DEVICE_ERROR
45666
private byte[] getDiskBytes(long offset)
      throws IOException {
    mappedFile.seek(dataOffset + offset);

    //Get size of data
    int size = LongPacker.unpackInt(mappedFile);

    //Create output bytes
    byte[] res = new byte[size];

    //Read data
    if (mappedFile.read(res) == -1) {
      throw new EOFException();
    }

    return res;
  }
176765
def unpack_guid(self, offset):
        
        o = self._offset + offset

        try:
            _bin = bytes(self._buf[o:o + 16])
        except IndexError:
            raise OverrunBufferException(o, len(self._buf))

        # Yeah, this is ugly
        h = [six.indexbytes(_bin, i) for i in range(len(_bin))]
        return """{:02x}{:02x}{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}""".format(
            h[3], h[2], h[1], h[0],
            h[5], h[4],
            h[7], h[6],
            h[8], h[9],
            h[10], h[11], h[12], h[13], h[14], h[15])
758992
def devices_data():
    
    response = {}
    for part in psutil.disk_partitions():
        device = part.device
        response[device] = {
            'device': device,
            'mountpoint': part.mountpoint,
            'fstype': part.fstype,
            'opts': part.opts,
        }
        if part.mountpoint:
            usage = psutil.disk_usage(part.mountpoint)
            response[device]['usage'] = {
                'size': mark(usage.total, 'bytes'),
                'used': mark(usage.used, 'bytes'),
                'free': mark(usage.free, 'bytes'),
                'percent': mark(usage.percent, 'percentage')
            }
    return response
1229724
def is_device_virtual(self):
        
        for ip in self.obj_dict:
            drvr_obj = self.obj_dict.get(ip).get('drvr_obj')
            ret = drvr_obj.is_device_virtual()
            # No way to pin a device as of now, so return the first
            # TODO(padkrish)
            return ret
974602
def GetMemMappedMB(self):
        ''''''
        counter = c_uint()
        ret = vmGuestLib.VMGuestLib_GetMemMappedMB(self.handle.value, byref(counter))
        if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
        return counter.value
1166368
def _get_register_size(self, reg_offset):
        

        # TODO: support registers that are not aligned
        if reg_offset in self.project.arch.register_names:
            reg_name = self.project.arch.register_names[reg_offset]
            reg_size = self.project.arch.registers[reg_name][1]
            return reg_size

        l.warning("_get_register_size(): unsupported register offset %d. Assum size 1. "
                  "More register name mappings should be implemented in archinfo.", reg_offset)
        return 1
365614
def swd_read32(self, offset):
        
        value = self._dll.JLINK_SWD_GetU32(offset)
        return ctypes.c_uint32(value).value
390308
public int getPrevOpcode(int offset) {
        if (offset < 0) {
            throw new IllegalArgumentException("offset (" + offset + ") must be nonnegative");
        }
        if (offset >= prevOpcode.length || offset > sizePrevOpcodeBuffer) {
            return Const.NOP;
        }
        int pos = currentPosInPrevOpcodeBuffer - offset;
        if (pos < 0) {
            pos += prevOpcode.length;
        }
        return prevOpcode[pos];
    }
646171
def set_offset_and_sequence_number(self, event_data):
        
        if not event_data:
            raise Exception(event_data)
        self.offset = event_data.offset.value
        self.sequence_number = event_data.sequence_number
798182
def set_vm_status(self, device='FLOPPY',
                      boot_option='BOOT_ONCE', write_protect='YES'):
        
        dic = {'DEVICE': device.upper()}
        xml = self._create_dynamic_xml(
            'SET_VM_STATUS', 'RIB_INFO', 'write', dic)

        if six.PY2:
            child_iterator = xml.getiterator()
        else:
            child_iterator = xml.iter()

        for child in child_iterator:
            if child.tag == 'SET_VM_STATUS':
                etree.SubElement(child, 'VM_BOOT_OPTION',
                                 VALUE=boot_option.upper())
                etree.SubElement(child, 'VM_WRITE_PROTECT',
                                 VALUE=write_protect.upper())

        d = self._request_ilo(xml)
        data = self._parse_output(d)
        return data
703544
def create_vnic_spec(device):
        
        nic_spec = vim.vm.device.VirtualDeviceSpec()
        nic_spec.operation = vim.vm.device.VirtualDeviceSpec.Operation.edit
        nic_spec.device = device
        return nic_spec