Skip to content

Commit

Permalink
Merge pull request #1878 from vivianQizhu/extra_root_port
Browse files Browse the repository at this point in the history
qemu_vm: Move extra root port to the end of make_create_command
  • Loading branch information
vivianQizhu authored Jan 28, 2019
2 parents 633d793 + 8147296 commit e478dfd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion shared/cfg/machines.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ variants:
# port of pcie-switch, see RHBZ#1380285
no WinXP Win2000 Win2003 RHEL.5 RHEL.6
pci_bus = pci.0
pcie_extra_root_port = 3
pcie_extra_root_port = 1
- @pseries:
only ppc64, ppc64le
machine_type = pseries
Expand Down
20 changes: 16 additions & 4 deletions virttest/qemu_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from virttest import error_context
from virttest.compat_52lts import decode_to_text
from virttest.qemu_devices import qdevices, qcontainer
from virttest.qemu_devices.utils import DeviceError


class QemuSegFaultError(virt_vm.VMError):
Expand Down Expand Up @@ -1413,10 +1414,6 @@ def sort_key(dev):
for pcic in params.objects("pci_controllers"):
dev = devices.pcic_by_params(pcic, params.object_params(pcic))
pcics.append(dev)
pcie_extra_root_port = params.get('pcie_extra_root_port', 0)
for num in range(int(pcie_extra_root_port)):
pcics.append(devices.pcic_by_params("pcie_root_port_%s" % num,
{"type": "pcie-root-port"}))
if params.get("pci_controllers_autosort", "yes") == "yes":
pcics.sort(key=sort_key, reverse=False)
devices.insert(pcics)
Expand Down Expand Up @@ -2342,6 +2339,21 @@ def sort_key(dev):
if ats:
add_virtio_option("ats", ats, devices, device, dev_type)

# Add extra root_port at the end of the command line only if there is
# free slot on pci.0, discarding them otherwise
pcie_extra_root_port = int(params.get('pcie_extra_root_port', 0))
for num in range(pcie_extra_root_port):
try:
dev = devices.pcic_by_params(
"pcie_extra_root_port_%s"
% num, {"type": "pcie-root-port"})
devices.insert(dev)
except DeviceError:
logging.warning("No sufficient free slot for extra"
" root port, discarding %d of them"
% (pcie_extra_root_port - num))
break

return devices, spice_options

def _nic_tap_add_helper(self, nic):
Expand Down

0 comments on commit e478dfd

Please sign in to comment.