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

virttest.env_process: Keep vm.instance throughout the workflow #2020

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
21 changes: 11 additions & 10 deletions virttest/env_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -1496,10 +1496,11 @@ def _take_screendumps(test, params, env):

while True:
for vm in env.get_all_vms():
if vm.instance not in list(counter.keys()):
counter[vm.instance] = 0
if vm.instance not in list(inactivity.keys()):
inactivity[vm.instance] = time.time()
instance = vm.instance
if instance not in list(counter.keys()):
counter[instance] = 0
if instance not in list(inactivity.keys()):
inactivity[instance] = time.time()
if not vm.is_alive():
continue
vm_pid = vm.get_pid()
Expand All @@ -1525,13 +1526,13 @@ def _take_screendumps(test, params, env):
os.makedirs(screendump_dir)
except OSError:
pass
counter[vm.instance] += 1
filename = "%04d.jpg" % counter[vm.instance]
counter[instance] += 1
filename = "%04d.jpg" % counter[instance]
Copy link
Contributor

Choose a reason for hiding this comment

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

if vm.instance changes, counter[instance] will starts from 1, so all previous image files will be overwritten. I believe it is better to relate vm.instance with screendump_dir.

screendump_filename = os.path.join(screendump_dir, filename)
vm.verify_bsod(screendump_filename)
image_hash = crypto.hash_file(temp_filename)
if image_hash in cache:
time_inactive = time.time() - inactivity[vm.instance]
time_inactive = time.time() - inactivity[instance]
if time_inactive > inactivity_treshold:
msg = (
"%s screen is inactive for more than %d s (%d min)" %
Expand All @@ -1543,12 +1544,12 @@ def _take_screendumps(test, params, env):
except virt_vm.VMScreenInactiveError:
logging.error(msg)
# Let's reset the counter
inactivity[vm.instance] = time.time()
inactivity[instance] = time.time()
test.background_errors.put(sys.exc_info())
elif inactivity_watcher == 'log':
logging.debug(msg)
else:
inactivity[vm.instance] = time.time()
inactivity[instance] = time.time()
cache[image_hash] = screendump_filename
try:
try:
Expand All @@ -1562,7 +1563,7 @@ def _take_screendumps(test, params, env):
"screendump: %s", vm.name, error_detail)
# Decrement the counter as we in fact failed to
# produce a converted screendump
counter[vm.instance] -= 1
counter[instance] -= 1
except NameError:
pass
os.unlink(temp_filename)
Expand Down