Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device should be connected to downstream port bus using device number 0 #1819

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion virttest/qemu_devices/qdevices.py
Original file line number Diff line number Diff line change
Expand Up @@ -1970,7 +1970,7 @@ def add_downstream_port(self, addr):
if addr not in self.__downstream_ports:
_addr = int(addr, 16)
bus_id = "%s.%s" % (self.busid, _addr)
bus = QPCIBus(bus_id, 'PCIE', bus_id)
bus = QPCIDownstreamPortBus(bus_id, bus_id)
self.__downstream_ports["0x%x" % _addr] = bus
downstream = QDevice(self.__downstream_type,
{'id': bus_id,
Expand Down Expand Up @@ -2007,6 +2007,42 @@ def _set_device_props(self, device, addr):
self.__downstream_ports['0x%x' % addr[0]].insert(device)


class QPCIDownstreamPortBus(QPCIBus):

"""PCIE Switch Downstream Port Bus"""

def __init__(self, busid, aobject=None):
super(QPCIDownstreamPortBus, self).__init__(busid, 'PCIE', busid, length=1)

def insert(self, device, strict_mode=False):
"""
Insert device into this bus representation.

:param device: QBaseDevice device
:param strict_mode: Use strict mode (set optional params)
:return: list of added devices on success,
string indicating the failure on failure.
"""

additional_devices = []
if not self._check_bus(device):
return "BusId"
addr_pattern = [0, 0]
addr = self.get_free_slot(addr_pattern)
if addr is None:
return "UsedSlot"
elif addr is False:
return "BadAddr(%s)" % addr
else:
additional_devices.extend(self._insert(device,
self._addr2stor(addr)))
if strict_mode: # Set full address in strict_mode
self._set_device_props(device, addr)
else:
self._update_device_props(device, addr)
return additional_devices


class QSCSIBus(QSparseBus):

"""
Expand Down