Exemplo n.º 1
0
    def getDeviceDetails(self, config):
        """@see DevController.getDeviceDetails"""
        def get_param(field):
            try:
                val = config.get(field)

                if not val:
                    raise VmError('irq: Missing %s config setting' % field)

                if isinstance(val, types.StringType):
                    return int(val, 10)
                    radix = 10
                else:
                    return val
            except:
                raise VmError('irq: Invalid config setting %s: %s' %
                              (field, val))

        pirq = get_param('irq')

        rc = xc.domain_irq_permission(domid=self.getDomid(),
                                      pirq=pirq,
                                      allow_access=True)

        if rc < 0:
            #todo non-fatal
            raise VmError('irq: Failed to configure irq: %d' % (pirq))
        rc = xc.physdev_map_pirq(domid=self.getDomid(), index=pirq, pirq=pirq)
        if rc < 0:
            raise VmError('irq: Failed to map irq %x' % (pirq))
        back = dict([(k, config[k]) for k in self.valid_cfg if k in config])
        return (self.allocateDeviceID(), back, {})
Exemplo n.º 2
0
    def getDeviceDetails(self, config):
        """@see DevController.getDeviceDetails"""

        def get_param(field):
            try:
                val = config.get(field)

                if not val:
                    raise VmError('irq: Missing %s config setting' % field)

                if isinstance(val, types.StringType):
                    return int(val,10)
                    radix = 10
                else:
                    return val
            except:
                raise VmError('irq: Invalid config setting %s: %s' %
                              (field, val))
       
        pirq = get_param('irq')

        rc = xc.domain_irq_permission(domid        = self.getDomid(),
                                      pirq         = pirq,
                                      allow_access = True)

        if rc < 0:
            #todo non-fatal
            raise VmError(
                'irq: Failed to configure irq: %d' % (pirq))
        rc = xc.physdev_map_pirq(domid = self.getDomid(),
                                index = pirq,
                                pirq  = pirq)
        if rc < 0:
            raise VmError(
                'irq: Failed to map irq %x' % (pirq))
        back = dict([(k, config[k]) for k in self.valid_cfg if k in config])
        return (self.allocateDeviceID(), back, {})
Exemplo n.º 3
0
            # Round number of pages up to nearest page boundary (if not on one)
            nr_pfns = (size+(PAGE_SIZE-1))>>PAGE_SHIFT

            log.debug('pci: enabling iomem 0x%x/0x%x pfn 0x%x/0x%x'% \
                    (start,size,start_pfn,nr_pfns))
            rc = xc.domain_iomem_permission(domid =  fe_domid,
                    first_pfn = start_pfn,
                    nr_pfns = nr_pfns,
                    allow_access = True)
            if rc<0:
                raise VmError(('pci: failed to configure I/O memory on device '+
                            '%s - errno=%d')%(dev.name,rc))

        if dev.irq > 0:
            rc = xc.physdev_map_pirq(domid = fe_domid,
                                   index = dev.irq,
                                   pirq  = dev.irq)
            if rc < 0:
                raise VmError(('pci: failed to map irq on device '+
                            '%s - errno=%d')%(dev.name,rc))
        if dev.irq>0:
            log.debug('pci: enabling irq %d'%dev.irq)
            rc = xc.domain_irq_permission(domid =  fe_domid, pirq = dev.irq,
                    allow_access = True)
            if rc<0:
                raise VmError(('pci: failed to configure irq on device '+
                            '%s - errno=%d')%(dev.name,rc))

    def dev_check_assignability_and_do_FLR(self, config):
        pci_dev_list = config.get('devs', [])
        pci_str_list = map(pci_dict_to_bdf_str, pci_dev_list)
Exemplo n.º 4
0
            nr_pfns = (size + (PAGE_SIZE - 1)) >> PAGE_SHIFT

            log.debug('pci: enabling iomem 0x%x/0x%x pfn 0x%x/0x%x'% \
                    (start,size,start_pfn,nr_pfns))
            rc = xc.domain_iomem_permission(domid=fe_domid,
                                            first_pfn=start_pfn,
                                            nr_pfns=nr_pfns,
                                            allow_access=True)
            if rc < 0:
                raise VmError(
                    ('pci: failed to configure I/O memory on device ' +
                     '%s - errno=%d') % (dev.name, rc))

        if dev.irq > 0:
            rc = xc.physdev_map_pirq(domid=fe_domid,
                                     index=dev.irq,
                                     pirq=dev.irq)
            if rc < 0:
                raise VmError(
                    ('pci: failed to map irq on device ' + '%s - errno=%d') %
                    (dev.name, rc))
        if dev.irq > 0:
            log.debug('pci: enabling irq %d' % dev.irq)
            rc = xc.domain_irq_permission(domid=fe_domid,
                                          pirq=dev.irq,
                                          allow_access=True)
            if rc < 0:
                raise VmError(('pci: failed to configure irq on device ' +
                               '%s - errno=%d') % (dev.name, rc))

    def dev_check_assignability_and_do_FLR(self, config):