-
Notifications
You must be signed in to change notification settings - Fork 263
avocado-vt: add support for shim parameter #4355
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -183,6 +183,8 @@ def __init__(self, test, params, vm): | |||||||||||||||||||||||||||||||||
| "driver_in_floppy", | ||||||||||||||||||||||||||||||||||
| "vga", | ||||||||||||||||||||||||||||||||||
| "unattended_file_kernel_param_name", | ||||||||||||||||||||||||||||||||||
| "shim_target_efi_path", | ||||||||||||||||||||||||||||||||||
| "shim", | ||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| for a in self.attributes: | ||||||||||||||||||||||||||||||||||
|
|
@@ -266,6 +268,8 @@ def get_unattended_file(backend): | |||||||||||||||||||||||||||||||||
| self.kernel = os.path.join(root_dir, self.kernel) | ||||||||||||||||||||||||||||||||||
| if getattr(self, "initrd"): | ||||||||||||||||||||||||||||||||||
| self.initrd = os.path.join(root_dir, self.initrd) | ||||||||||||||||||||||||||||||||||
| if getattr(self, "shim"): | ||||||||||||||||||||||||||||||||||
| self.shim = os.path.join(root_dir, self.shim) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if self.medium == "nfs": | ||||||||||||||||||||||||||||||||||
| self.nfs_mount = tempfile.mkdtemp(prefix="nfs_", dir=self.tmpdir) | ||||||||||||||||||||||||||||||||||
|
|
@@ -984,6 +988,11 @@ def setup_cdrom(self): | |||||||||||||||||||||||||||||||||
| assert os.path.getsize(self.kernel) > 0 | ||||||||||||||||||||||||||||||||||
| i.copy(os.path.join(self.boot_path, os.path.basename(self.initrd)), self.initrd) | ||||||||||||||||||||||||||||||||||
| assert os.path.getsize(self.initrd) > 0 | ||||||||||||||||||||||||||||||||||
| i.copy( | ||||||||||||||||||||||||||||||||||
| os.path.join(self.shim_target_efi_path, os.path.basename(self.shim)), | ||||||||||||||||||||||||||||||||||
| self.shim, | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
| assert os.path.getsize(self.shim) > 0 | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if self.unattended_file.endswith(".preseed"): | ||||||||||||||||||||||||||||||||||
| self.preseed_initrd() | ||||||||||||||||||||||||||||||||||
|
|
@@ -1063,6 +1072,7 @@ def setup_url(self): | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| kernel_basename = os.path.basename(self.kernel) | ||||||||||||||||||||||||||||||||||
| initrd_basename = os.path.basename(self.initrd) | ||||||||||||||||||||||||||||||||||
| shim_basename = os.path.basename(self.shim) | ||||||||||||||||||||||||||||||||||
| sha1sum_kernel_cmd = "sha1sum %s" % kernel_basename | ||||||||||||||||||||||||||||||||||
| sha1sum_kernel_output = process.run( | ||||||||||||||||||||||||||||||||||
| sha1sum_kernel_cmd, ignore_status=True, verbose=DEBUG | ||||||||||||||||||||||||||||||||||
|
|
@@ -1081,12 +1091,24 @@ def setup_url(self): | |||||||||||||||||||||||||||||||||
| except IndexError: | ||||||||||||||||||||||||||||||||||
| sha1sum_initrd = "" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| sha1sum_shim_cmd = "sha1sum %s" % shim_basename | ||||||||||||||||||||||||||||||||||
| sha1sum_shim_output = process.run( | ||||||||||||||||||||||||||||||||||
| sha1sum_shim_cmd, ignore_status=True, verbose=DEBUG | ||||||||||||||||||||||||||||||||||
| ).stdout_text | ||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||
| sha1sum_shim = sha1sum_shim_output.split()[0] | ||||||||||||||||||||||||||||||||||
| except IndexError: | ||||||||||||||||||||||||||||||||||
| sha1sum_shim = "" | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+1094
to
+1101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The sha1sum calculation for the shim should only occur if
Suggested change
References
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| url_kernel = os.path.join( | ||||||||||||||||||||||||||||||||||
| self.url, self.boot_path, os.path.basename(self.kernel) | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
| url_initrd = os.path.join( | ||||||||||||||||||||||||||||||||||
| self.url, self.boot_path, os.path.basename(self.initrd) | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
| url_shim = os.path.join( | ||||||||||||||||||||||||||||||||||
| self.url, self.shim_target_efi_path, os.path.basename(self.shim) | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+1109
to
+1111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if not sha1sum_kernel == self.params.get("sha1sum_vmlinuz", None): | ||||||||||||||||||||||||||||||||||
| if os.path.isfile(self.kernel): | ||||||||||||||||||||||||||||||||||
|
|
@@ -1106,6 +1128,15 @@ def setup_url(self): | |||||||||||||||||||||||||||||||||
| os.path.join(self.image_path, os.path.basename(self.initrd)), | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if not sha1sum_shim == self.params.get("sha1sum_shim", None): | ||||||||||||||||||||||||||||||||||
| if os.path.isfile(self.shim): | ||||||||||||||||||||||||||||||||||
| os.remove(self.shim) | ||||||||||||||||||||||||||||||||||
| LOG.info("Downloading %s -> %s", url_shim, self.image_path) | ||||||||||||||||||||||||||||||||||
| download.get_file( | ||||||||||||||||||||||||||||||||||
| url_shim, | ||||||||||||||||||||||||||||||||||
| os.path.join(self.image_path, os.path.basename(self.shim)), | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+1131
to
+1138
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The download logic for the shim must be guarded to avoid errors when
Suggested change
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if "repo=cdrom" in self.kernel_params: | ||||||||||||||||||||||||||||||||||
| # Red Hat | ||||||||||||||||||||||||||||||||||
| self.kernel_params = re.sub( | ||||||||||||||||||||||||||||||||||
|
|
@@ -1154,6 +1185,13 @@ def setup_nfs(self): | |||||||||||||||||||||||||||||||||
| self.image_path, | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
| process.run(initrd_fetch_cmd, verbose=DEBUG) | ||||||||||||||||||||||||||||||||||
| shim_fetch_cmd = "cp %s/%s/%s %s" % ( | ||||||||||||||||||||||||||||||||||
| self.nfs_mount, | ||||||||||||||||||||||||||||||||||
| self.shim_target_efi_path, | ||||||||||||||||||||||||||||||||||
| os.path.basename(self.shim), | ||||||||||||||||||||||||||||||||||
| self.image_path, | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
| process.run(shim_fetch_cmd, verbose=DEBUG) | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+1188
to
+1194
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fetching the shim via NFS should be conditional on
Suggested change
|
||||||||||||||||||||||||||||||||||
| finally: | ||||||||||||||||||||||||||||||||||
| utils_disk.cleanup(self.nfs_mount) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessing
self.shimhere without checking if it's set can lead to issues if the parameter is missing or empty. It should be guarded to avoid errors in subsequent logic.