Skip to content
Draft
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
18 changes: 2 additions & 16 deletions libvirt/tests/src/gpu/hotplug_gpu.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from virttest import virsh

from virttest.libvirt_xml import vm_xml
from virttest.utils_libvirt import libvirt_vmxml
from virttest.utils_test import libvirt

Expand All @@ -9,7 +8,8 @@

def run(test, params, env):
"""
Hotplug/unplug GPU device
Hotplug GPU device
Note: Hotunplug is not supported for nvidia GPUs
"""
vm_name = params.get("main_vm", "avocado-vt-vm1")
vm = env.get_vm(vm_name)
Expand All @@ -33,24 +33,10 @@ def run(test, params, env):
gpu_test.install_latest_driver(vm_session)
gpu_test.nvidia_smi_check(vm_session)

test.log.info("TEST_STEP: Unplug a gpu device from vm")
vm_hostdev = vm_xml.VMXML.new_from_dumpxml(vm.name)\
.devices.by_device_tag("hostdev")[0]
virsh.detach_device(vm.name, vm_hostdev.xml,
wait_for_event=True, event_timeout=30,
**virsh_args)
gpu_test.check_gpu_dev(vm, True)

test.log.info("TEST_STEP: Hotplug back the gpu device")
virsh.attach_device(vm.name, gpu_dev.xml, **virsh_args)
gpu_test.check_gpu_dev(vm)
gpu_test.nvidia_smi_check(vm_session)

test.log.info("TEST_STEP: Check gpu device exclusivity")
res = virsh.attach_device(vm.name, gpu_dev.xml, debug=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The device will be hotplugged in Line 29, these lines can be removed I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept this to align with the polarion case VIRT-304169: "Install gpu driver and run nvidia-smi in guest; nvidia-smi -q returns correct info." I did edit the case to remove hotunplug parts but this step was right before the hotunplug parts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for the explanation!

libvirt.check_result(res, "in use")
gpu_test.check_gpu_dev(vm)
gpu_test.nvidia_smi_check(vm_session)
vm_session.close()
finally:
gpu_test.teardown_default()