When run job with initramfs, there is a default combination of kernel, modules and headers, and I add a key "kernel_version" to make it optional.
Signed-off-by: Xu Xijian xuxijian@huawei.com --- doc/job/kernel_version.md | 19 +++++++++++++++++++ src/lib/job.cr | 14 +++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 doc/job/kernel_version.md
diff --git a/doc/job/kernel_version.md b/doc/job/kernel_version.md new file mode 100644 index 0000000..bd02cd1 --- /dev/null +++ b/doc/job/kernel_version.md @@ -0,0 +1,19 @@ +# kernel_version + +Meaning: +- Every os has its kernel, however an os can start with different kernels according to different need. +- kernel_version is a key for users to specify a kernel version. +- If kernel_version is not given by users, it will use the default one. + +Related files: +- $os_dir/vmlinuz => boot/vmlinuz-$kernel_version + - default kernel file(vmlinuz) is a soft link +- $os_dir/boot/vmlinuz-$kernel_version + - real kernel path +- $os_dir/boot/modules-$kernel_version.cgz +- $os_dir/boot/headers-$kernel_version.cgz + +A example $os_dir can be "/srv/os/openeuler/aarch64/20.03" + +usage example: +- submit iperf.yaml testbox=vm-hi1620-2p8g--xxj os=openeuler os_arch=aarch64 os_version=20.03 runtime=20 kernel_version=4.19.90-2003 diff --git a/src/lib/job.cr b/src/lib/job.cr index 7fbc414..88f64ab 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -86,6 +86,7 @@ class Job kernel_append_root kernel_params docker_image + kernel_version )
macro method_missing(call) @@ -134,6 +135,7 @@ class Job set_result_service() set_os_mount() set_depends_initrd() + set_kernel_version() set_initrds_uri() set_kernel_uri() set_kernel_append_root() @@ -293,8 +295,9 @@ class Job end
private def set_kernel_uri + vmlinuz_sub_path = (("#{kernel_version}" == "default") ? "vmlinuz" : "boot/vmlinuz-#{kernel_version}") self["kernel_uri"] = "kernel #{OS_HTTP_PREFIX}" + - "#{JobHelper.service_path("#{SRV_OS}/#{os_dir}/vmlinuz")}" + "#{JobHelper.service_path("#{SRV_OS}/#{os_dir}/#{vmlinuz_sub_path}")}" end
private def kernel_common_params @@ -315,10 +318,15 @@ class Job temp_initrds = [] of String
osimage_dir = "#{SRV_INITRD}/osimage/#{os_dir}" + boot_dir = "#{SRV_OS}/#{os_dir}/boot" temp_initrds << "#{INITRD_HTTP_PREFIX}" + "#{JobHelper.service_path("#{osimage_dir}/current")}" temp_initrds << "#{INITRD_HTTP_PREFIX}" + "#{JobHelper.service_path("#{osimage_dir}/run-ipconfig.cgz")}" + temp_initrds << "#{OS_HTTP_PREFIX}" + + "#{JobHelper.service_path("#{boot_dir}/modules-#{kernel_version}.cgz")}" + temp_initrds << "#{OS_HTTP_PREFIX}" + + "#{JobHelper.service_path("#{boot_dir}/headers-#{kernel_version}.cgz")}"
temp_initrds.concat(initrd_deps.split(/ /)) unless initrd_deps.empty? temp_initrds.concat(initrd_pkg.split(/ /)) unless initrd_pkg.empty? @@ -359,6 +367,10 @@ class Job return basenames end
+ private def set_kernel_version + self["kernel_version"] ||= "default" + end + private def set_initrds_uri uris = ""
On Thu, Oct 29, 2020 at 03:55:48PM +0800, Wu Fengguang wrote:
- private def set_kernel_version
- self["kernel_version"] ||= "default"
- end
It might be easier to just leave it empty if user want the default kernel. What do you think?
if $kernel_version not set or empty vmlinuz else vmlinuz-$kernel_version
Thanks, Fengguang
If just use "$kernel_version" with vmlinuz, it will be easier. But there are "modules-$kernel_version.cgz" and "headers-$kernel_version.cgz" that need "$kernel_version" too, so I think to keep "default" may be better. Otherwise, they will be "modules-.cgz" and "headers-.cgz", or to adapt them additionally, it will make code more complex.
Thanks, Xijian
On Thu, Oct 29, 2020 at 07:51:24PM +0800, Xu Xijian wrote:
On Thu, Oct 29, 2020 at 03:55:48PM +0800, Wu Fengguang wrote:
- private def set_kernel_version
- self["kernel_version"] ||= "default"
- end
It might be easier to just leave it empty if user want the default kernel. What do you think?
if $kernel_version not set or empty vmlinuz else vmlinuz-$kernel_version
Thanks, Fengguang
If just use "$kernel_version" with vmlinuz, it will be easier. But there are "modules-$kernel_version.cgz" and "headers-$kernel_version.cgz" that need "$kernel_version" too, so I think to keep "default" may be better. Otherwise, they will be "modules-.cgz" and "headers-.cgz", or to adapt them additionally, it will make code more complex.
Just one line of code..
Do you consider complexity in USER POV?
Thanks, Fengguang