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

Add timeout for "qemu-img convert" #3521

Merged
merged 1 commit into from
Feb 7, 2023
Merged
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
10 changes: 7 additions & 3 deletions virttest/qemu_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,9 +986,13 @@ def convert(self, params, root_dir, cache_mode=None,
convert_cmd = self.image_cmd + " " + \
self._cmd_formatter.format(self.convert_cmd, **cmd_dict)

LOG.info("Convert image %s from %s to %s", self.image_filename,
self.image_format, convert_image.image_format)
process.run(convert_cmd)
timeout = convert_params.get_numeric("image_conversion_timeout", -1)
timeout = None if timeout == -1 else timeout
Comment on lines +989 to +990
Copy link
Contributor

Choose a reason for hiding this comment

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

Then maybe it seems to be the time to introduce a dedicated method to Param for getting timeouts, how does that sound? And later we may consider to add more features to support:

  • setting timeouts in different units of time (e.g. 5m, 1h)
  • basic calculations (with constants, e.g. TEST_TIMEOUT * 0.8)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I am not sure how Params object enhancements relates to the current pull request which aims specifically at qemu-img but bringing myself to talk about this new topic I would still say I am not sure whether introducing such methods in Params is not too data specific. The current type-handling methods are general enough and a small easy to maintain selection. Returning -1 is a very easy way to handle not just timeouts but various numeric parameters that might end up including infinity and the above is a simple solution that only uses -1 default value, something I hardly see as needing an entire new method with lots of added assumptions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Returning -1 is a very easy way to handle not just timeouts but various numeric parameters that might end up including infinity and the above is a simple solution that only uses -1 default value, something I hardly see as needing an entire new method with lots of added assumptions.

Then, almost all the cases of handling timeouts may just have like this two lines approach (let's recall the situation of handling numerics before having get_numeric). Anyway, I understand that it's not a must to this PR, so I'd leave the proposal for future discussion, thanks.


LOG.info("Convert image %s from %s to %s with timeout %s",
self.image_filename, self.image_format,
convert_image.image_format, timeout)
process.run(convert_cmd, timeout=timeout)
pevogam marked this conversation as resolved.
Show resolved Hide resolved
if convert_image.encryption_config.key_secret:
convert_image.encryption_config.key_secret.save_to_file()

Expand Down