autotest / virt-test

Linux Virtualization Tests
Other
97 stars 140 forks source link

pci_id getting modified within qemu_vm.py incorrectly #2290

Closed bssrikanth closed 9 years ago

bssrikanth commented 9 years ago

I am enabling sriov_sanity[qemu test] test case to run on power. During this exercise I found a issue with qemu_vm.py, where the PCI ID of the device which had to be assigned to the guest is being purposefully modified @ ./virttest/qemu_vm.py line 1549, and qemu becomes defunct as soon as guest is started since the pass througed PCI is invalid/nonexistent on the host.

Debug snap of qemu_vm.py:

1547 logging.info("pci_id: %s", vm.pa_pci_ids[iov]) 1548 pci_id = vm.pa_pci_ids[iov] 1549 pci_id = ":".join(pci_id.split(":")[1:]) 1550 logging.info("pci_id after join: %s", pci_id)

Output:

23:18:22 INFO | pci_id: 0004:01:00.1 23:18:22 INFO | pci_id after join: 01:00.1

We can see the issue in above output. [0004:01:00.1] exists on the host but not "01:00.1".

If I comment line 1549 @ qemu_vm.py, the error [host device] not found is gone.

Before submitting a patch, I thought of discussing here. Welcome any thoughts.

Srikanth Aithal sraithal@linux.vnet.ibm.com

bssrikanth commented 9 years ago

I see now that the PCI device ID format on Power is different than x86, which the existing logic does. Will try to modify accordingly and post a patch

bssrikanth commented 9 years ago

the current code in qemu_vm.py is found to be discarding pci domain part [look at my initial comment] which is not expected. lspci [which test_setup.py uses to identify pci id] does not display domain ID for pci devices if all devices in host are in same domain [example pci domain 0000]. But if the pci devices are on different domains, like in my scenario, we end up in issue where the pci_id used will not be found on the host.

bssrikanth commented 9 years ago

same issue here:

05:12:34 INFO | The following pci_ids were found: ['0004:01:00.1'] 05:12:34 INFO | Context: preprocessing --> Bind device 0004:01:00.1 to stub 05:12:34 INFO | short ID: 01:00.1 05:12:34 INFO | Vendor ID: 15b3 1004 10df f100 10df e220 05:12:34 INFO | stub_new_id: /sys/bus/pci/drivers/pci-stub/new_id 05:12:34 INFO | unbind_dev : 05:12:34 INFO | stub_bind : /sys/bus/pci/drivers/pci-stub/bind 05:12:34 INFO | stub_remove_id : /sys/bus/pci/drivers/pci-stub/remove_id 05:12:34 INFO | Write '15b3 1004 10df f100 10df e220' to file '/sys/bus/pci/drivers/pci-stub/new_id' 05:12:34 INFO | Write '0004:01:00.1' to file '' 05:12:34 INFO | Write '0004:01:00.1' to file '/sys/bus/pci/drivers/pci-stub/bind' 05:12:34 INFO | Write '15b3 1004 10df f100 10df e220' to file '/sys/bus/pci/drivers/pci-stub/remove_id' 05:12:34 ERROR| Binding device 0004:01:00.1 to stub failed

test_setup.py:

def request_devs(self, devices=None):
    """
    Implement setup process: unbind the PCI device and then bind it
    to the device driver.

    :param devices: List of device dict
    :type devices: List of dict
    :return: List of successfully requested devices' PCI IDs.
    :rtype: List of string
    """
    if not self.pf_vf_info:
        self.pf_vf_info = self.get_pf_vf_info()
    base_dir = "/sys/bus/pci"
    stub_path = os.path.join(base_dir, "drivers/%s" % self.device_driver)
    self.pci_ids = self.get_devs(devices)
    logging.info("The following pci_ids were found: %s", self.pci_ids)
    requested_pci_ids = []
    # Setup all devices specified for assignment to guest
    for p_id in self.pci_ids:
        if self.device_driver == "vfio-pci":
            pci_ids = self.get_same_group_devs(p_id)
            logging.info("Following devices are in same group: %s", pci_ids)
        else:
            pci_ids = [p_id]
        for pci_id in pci_ids:
           short_id = pci_id[5:]

similar issue in _release_dev as well

bssrikanth commented 9 years ago

I have this issue addressed for Power arch in PR 2303