Skip to content

Commit

Permalink
virtual_network/element_model: don't check pci model on s390x
Browse files Browse the repository at this point in the history
On s390x, interfaces are not PCI devices per default.
Don't check the pci model.

Signed-off-by: Sebastian Mitterle <[email protected]>
  • Loading branch information
smitterl committed Dec 5, 2023
1 parent a767a31 commit caff0c6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
- virtio:
iface_driver = virtio_net
pci_model = pcie-root-port
s390-virtio:
check_pci_model = no
- e1000e:
iface_driver = e1000e
pci_model = pcie-root-port
Expand All @@ -30,4 +32,6 @@
- test:
status_error = yes
err_msg = is not a valid device model name
s390-virtio:
check_pci_model = no
iface_attrs = {'source': {'network': 'default'}, 'model': '${model_type}', 'type_name': 'network'}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@
LOG = logging.getLogger('avocado.' + __name__)


def check_model_controller(vm_name, pci_model, test):
"""
Checks that the controllers are the expected pci model
:param vm_name: VM name
:param pci_model: The expected pci model
:param test: Test instance
"""
vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name)
iface = vmxml.get_devices('interface')[0]
LOG.debug(f'Interface xml after vm started:\n{iface}')
ctrl_index = int(iface.fetch_attrs()['address']['attrs']['bus'], 16)
controllers = vmxml.get_devices('controller')
iface_controller = [c for c in controllers if c.type == 'pci' and
c.index == str(ctrl_index)][0]
LOG.debug(f'Controller xml:\n{iface_controller}')

if iface_controller.model == pci_model:
LOG.debug('XML controller model check: PASS')
else:
test.fail(f'Expect pci model: {pci_model}, '
f'and got {iface_controller.model}')


def run(test, params, env):
"""
Test 'model' element of interface
Expand All @@ -26,6 +50,7 @@ def run(test, params, env):
iface_attrs = eval(params.get('iface_attrs', '{}'))
iface_driver = params.get('iface_driver')
model_type = params.get('model_type')
check_pci_model = params.get('check_pci_model', 'yes') == "yes"
if model_type == 'default':
iface_attrs.pop('model')

Expand Down Expand Up @@ -72,19 +97,7 @@ def run(test, params, env):
network_base.ping_check(params, ips, session, force_ipv4=True)
session.close()

vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name)
iface = vmxml.get_devices('interface')[0]
LOG.debug(f'Interface xml after vm started:\n{iface}')
ctrl_index = int(iface.fetch_attrs()['address']['attrs']['bus'], 16)
controllers = vmxml.get_devices('controller')
iface_controller = [c for c in controllers if c.type == 'pci' and
c.index == str(ctrl_index)][0]
LOG.debug(f'Controller xml:\n{iface_controller}')

if iface_controller.model == pci_model:
LOG.debug('XML controller model check: PASS')
else:
test.fail(f'Expect pci model: {pci_model}, '
f'and got {iface_controller.model}')
if check_pci_model:
check_model_controller(vm_name, pci_model, test)
finally:
bkxml.sync()

0 comments on commit caff0c6

Please sign in to comment.