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

Resolve local variable 'res' referenced before assignment #5907

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
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def attach_device(vm, test_device, dev_dict):
:param vm: VM instance
:param test_device: the device type, e.g. disk
:param dev_dict: the device definition
:return: CmdResult object
"""

dev_obj = libvirt_vmxml.create_vm_device_by_type(test_device, dev_dict)
Expand Down Expand Up @@ -78,6 +79,7 @@ def run(test, params, env):
dev_dict, seclabel_attr = get_dev_dict(test_device, params)
test.log.debug("The device setting will be updated to %s.", dev_dict)
try:
res = None
if test_scenario != "hot_plug":
test.log.info("TEST_STEP: Start VM with per-device dac setting.")
try:
Expand All @@ -89,7 +91,9 @@ def run(test, params, env):
if not status_error:
test.fail(details)
test.log.debug("VM XML: %s.", VMXML.new_from_inactive_dumpxml(vm_name))
if res.exit_status == 0:
# res is None in case of non disk device and the VM should be started
# in case of disk, the VM should be started only in successful attach.
if res is None or res.exit_status == 0:
res = virsh.start(vm.name)
else:
test.log.info("TEST_STEP: Hot plug a device with dac setting.")
Expand Down
Loading