Device should be connected to downstream port bus using device number 0 #1819
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
QPCISwitchBus was designed to hide creation of downstream port from
user. To do that, it first creates a downstream port device and its bus,
connects the downstream port device to upstream port bus (represented by
QPCISwitchBus) at address specified by the device's addr parameter. Then
it connects the device to the downstream port bus (repsented by QPCIBus)
using the same address. This doesn't work when test wants to create a
topology like the following, because the device 2 would be connected to
downstream port 2 using a non-zero addr value, which cause the device
invisible to guest OS (QEMU doens't have a check for this so it starts
up happily).
root port -> upstream port +-> downstream port 1 -> device 1
+-> downstream port 2 -> devive 2
The nature of the issue is the current code reuses device attr value for
two different purposes: the address to connect downstream port to
upstream port bus and the address to connect device to downstream port
bus. These two values are not necessarily same. They actually have to be
different in many cases.
The change fixes this issue by making sure device is always connected to
downstream port bus using device number 0. It does this by introducing a
new QPCIDownstreamPortBus class and provides its own copy of insert(),
which is almost same as QSparseBus's insert() except it hardcodes device
address to [0, 0]. This is not the best way to fix it, but is the
simplest way I can find without changing API of related classes.
Signed-off-by: Huan Xiong [email protected]