Esempio n. 1
0
    def setupDevice(self, config):
        """Setup devices from config
        """
        pci_dev_list = config.get('devs', [])
        pci_str_list = map(pci_dict_to_bdf_str, pci_dev_list)

        if len(pci_str_list) != len(set(pci_str_list)):
            raise VmError('pci: duplicate devices specified in guest config?')

        for pci_dev in pci_dev_list:
            try:
                dev = PciDevice(pci_dev)
            except Exception, e:
                raise VmError("pci: failed to locate device and "+
                        "parse it's resources - "+str(e))
            if (dev.dev_type == DEV_TYPE_PCIe_ENDPOINT) and not dev.pcie_flr:
                if dev.bus == 0:
                    # We cope with this case by using the Dstate transition
                    # method or some vendor specific methods for now.
                    err_msg = 'pci: %s: it is on bus 0, but has no PCIe' +\
                        ' FLR Capability. Will try the Dstate transition'+\
                        ' method or some vendor specific methods if available.'
                    log.warn(err_msg % dev.name)
                else:
                    funcs = dev.find_all_the_multi_functions()
                    dev.devs_check_driver(funcs)
                    for f in funcs:
                        if not f in pci_str_list:
                            (f_dom, f_bus, f_slot, f_func) = parse_pci_name(f)
                            f_pci_str = '0x%x,0x%x,0x%x,0x%x' % \
                                (f_dom, f_bus, f_slot, f_func)
                            # f has been assigned to other guest?
                            if xc.test_assign_device(0, f_pci_str) != 0:
                                err_msg = 'pci: %s must be co-assigned to' + \
                                    ' the same guest with %s'
                                raise VmError(err_msg % (f, dev.name))
            elif dev.dev_type == DEV_TYPE_PCI:
                if dev.bus == 0 or arch.type == "ia64":
                    if not dev.pci_af_flr:
                        # We cope with this case by using the Dstate transition
                        # method or some vendor specific methods for now.
                        err_msg = 'pci: %s: it is on bus 0, but has no PCI' +\
                            ' Advanced Capabilities for FLR. Will try the'+\
                            ' Dstate transition method or some vendor' +\
                            ' specific methods if available.'
                        log.warn(err_msg % dev.name)
                else:
                    # All devices behind the uppermost PCI/PCI-X bridge must be\
                    # co-assigned to the same guest.
                    devs_str = dev.find_coassigned_pci_devices(True)
                    # Remove the element 0 which is a bridge
                    del devs_str[0]

                    dev.devs_check_driver(devs_str)
                    for s in devs_str:
                        if not s in pci_str_list:
                            s_pci_str = pci_dict_to_bdf_str(parse_pci_name(s))
                            # s has been assigned to other guest?
                            if xc.test_assign_device(0, s_pci_str) != 0:
                                err_msg = 'pci: %s must be co-assigned to the'+\
                                    ' same guest with %s'
                                raise VmError(err_msg % (s, dev.name))
Esempio n. 2
0
    def setupDevice(self, config):
        """Setup devices from config
        """
        pci_str_list = []
        pci_dev_list = []
        for pci_config in config.get('devs', []):
            domain = parse_hex(pci_config.get('domain', 0))
            bus = parse_hex(pci_config.get('bus', 0))
            slot = parse_hex(pci_config.get('slot', 0))
            func = parse_hex(pci_config.get('func', 0))            
            pci_str = '%04x:%02x:%02x.%01x' % (domain, bus, slot, func)
            pci_str_list = pci_str_list + [pci_str]
            pci_dev_list = pci_dev_list + [(domain, bus, slot, func)]

        for (domain, bus, slot, func) in pci_dev_list:
            try:
                dev = PciDevice(domain, bus, slot, func)
            except Exception, e:
                raise VmError("pci: failed to locate device and "+
                        "parse it's resources - "+str(e))
            if (dev.dev_type == DEV_TYPE_PCIe_ENDPOINT) and not dev.pcie_flr:
                if dev.bus == 0:
                    # We cope with this case by using the Dstate transition
                    # method or some vendor specific methods for now.
                    err_msg = 'pci: %s: it is on bus 0, but has no PCIe' +\
                        ' FLR Capability. Will try the Dstate transition'+\
                        ' method or some vendor specific methods if available.'
                    log.warn(err_msg % dev.name)
                else:
                    funcs = dev.find_all_the_multi_functions()
                    for f in funcs:
                        if not f in pci_str_list:
                            (f_dom, f_bus, f_slot, f_func) = parse_pci_name(f)
                            f_pci_str = '0x%x,0x%x,0x%x,0x%x' % \
                                (f_dom, f_bus, f_slot, f_func)
                            # f has been assigned to other guest?
                            if xc.test_assign_device(0, f_pci_str) != 0:
                                err_msg = 'pci: %s must be co-assigned to' + \
                                    ' the same guest with %s'
                                raise VmError(err_msg % (f, dev.name))
            elif dev.dev_type == DEV_TYPE_PCI:
                if dev.bus == 0 or arch.type == "ia64":
                    if not dev.pci_af_flr:
                        # We cope with this case by using the Dstate transition
                        # method or some vendor specific methods for now.
                        err_msg = 'pci: %s: it is on bus 0, but has no PCI' +\
                            ' Advanced Capabilities for FLR. Will try the'+\
                            ' Dstate transition method or some vendor' +\
                            ' specific methods if available.'
                        log.warn(err_msg % dev.name)
                else:
                    # All devices behind the uppermost PCI/PCI-X bridge must be\
                    # co-assigned to the same guest.
                    devs_str = dev.find_coassigned_devices(True)
                    # Remove the element 0 which is a bridge
                    del devs_str[0]

                    for s in devs_str:
                        if not s in pci_str_list:
                            (s_dom, s_bus, s_slot, s_func) = parse_pci_name(s)
                            s_pci_str = '0x%x,0x%x,0x%x,0x%x' % \
                                (s_dom, s_bus, s_slot, s_func)
                            # s has been assigned to other guest?
                            if xc.test_assign_device(0, s_pci_str) != 0:
                                err_msg = 'pci: %s must be co-assigned to the'+\
                                    ' same guest with %s'
                                raise VmError(err_msg % (s, dev.name))
Esempio n. 3
0
    def setupDevice(self, config):
        """Setup devices from config
        """
        pci_str_list = []
        pci_dev_list = []
        for pci_config in config.get('devs', []):
            domain = parse_hex(pci_config.get('domain', 0))
            bus = parse_hex(pci_config.get('bus', 0))
            slot = parse_hex(pci_config.get('slot', 0))
            func = parse_hex(pci_config.get('func', 0))
            pci_str = '%04x:%02x:%02x.%01x' % (domain, bus, slot, func)
            pci_str_list = pci_str_list + [pci_str]
            pci_dev_list = pci_dev_list + [(domain, bus, slot, func)]

        for (domain, bus, slot, func) in pci_dev_list:
            try:
                dev = PciDevice(domain, bus, slot, func)
            except Exception, e:
                raise VmError("pci: failed to locate device and " +
                              "parse it's resources - " + str(e))
            if (dev.dev_type == DEV_TYPE_PCIe_ENDPOINT) and not dev.pcie_flr:
                if dev.bus == 0:
                    # We cope with this case by using the Dstate transition
                    # method or some vendor specific methods for now.
                    err_msg = 'pci: %s: it is on bus 0, but has no PCIe' +\
                        ' FLR Capability. Will try the Dstate transition'+\
                        ' method or some vendor specific methods if available.'
                    log.warn(err_msg % dev.name)
                else:
                    funcs = dev.find_all_the_multi_functions()
                    for f in funcs:
                        if not f in pci_str_list:
                            (f_dom, f_bus, f_slot, f_func) = parse_pci_name(f)
                            f_pci_str = '0x%x,0x%x,0x%x,0x%x' % \
                                (f_dom, f_bus, f_slot, f_func)
                            # f has been assigned to other guest?
                            if xc.test_assign_device(0, f_pci_str) != 0:
                                err_msg = 'pci: %s must be co-assigned to' + \
                                    ' the same guest with %s'
                                raise VmError(err_msg % (f, dev.name))
            elif dev.dev_type == DEV_TYPE_PCI:
                if dev.bus == 0 or arch.type == "ia64":
                    if not dev.pci_af_flr:
                        # We cope with this case by using the Dstate transition
                        # method or some vendor specific methods for now.
                        err_msg = 'pci: %s: it is on bus 0, but has no PCI' +\
                            ' Advanced Capabilities for FLR. Will try the'+\
                            ' Dstate transition method or some vendor' +\
                            ' specific methods if available.'
                        log.warn(err_msg % dev.name)
                else:
                    # All devices behind the uppermost PCI/PCI-X bridge must be\
                    # co-assigned to the same guest.
                    devs_str = dev.find_coassigned_devices(True)
                    # Remove the element 0 which is a bridge
                    del devs_str[0]

                    for s in devs_str:
                        if not s in pci_str_list:
                            (s_dom, s_bus, s_slot, s_func) = parse_pci_name(s)
                            s_pci_str = '0x%x,0x%x,0x%x,0x%x' % \
                                (s_dom, s_bus, s_slot, s_func)
                            # s has been assigned to other guest?
                            if xc.test_assign_device(0, s_pci_str) != 0:
                                err_msg = 'pci: %s must be co-assigned to the'+\
                                    ' same guest with %s'
                                raise VmError(err_msg % (s, dev.name))