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

libvirt-vm:Add support for cmdline parameter for --boot #3977

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

misanjumn
Copy link

libvirt-vm: Add support for cmdline parameter for --boot

Currently, kernel_args is not present in the output of "virt-install --boot help" as "--boot cmdline=%s" is the recommended way of passing kernel command line parameters. As a result, the import/install test is failiing since kernel and initrd parameter is being passed without kernel_args

But --boot option supports both kernel_args and cmdline parameter for passing kernel arguments to the guest, i.e,
--boot kernel=<vmlinuz>,initrd=<initrd>,cmdline=<kernel-cmdline> (recommended way)
(or)
--boot kernel=<vmlinuz>,initrd=<initrd>,kernel_args= <kernel-cmdline>

This patch adds support of reading both cmdline and kernel_args parameter and passes whichever is available from config to the virt-install --boot option

Signed-off-by: Misbah Anjum N [email protected]

Currently, kernel_args is not present in the output
of "virt-install --boot help" as "--boot cmdline=%s"
is the recommended way of passing kernel command line
parameters. As a result, the import/install test is
failiing since kernel and initrd parameter is being
passed without kernel_args

But --boot option supports both kernel_args
and cmdline parameter for passing kernel arguments
to the guest, i.e,
--boot kernel=<vmlinuz>,initrd=<initrd>,cmdline=<kernel
-cmdline>
(or)
--boot kernel=<vmlinuz>,initrd=<initrd>,kernel_args=
<kernel-cmdline>

This patch adds support of reading both cmdline and
kernel_args parameter and passes whichever is available
from config to the virt-install --boot option

Signed-off-by: Misbah Anjum N <[email protected]>
@misanjumn
Copy link
Author

Explanation

This particular piece of code checks the presence of "kernel_args" parameter in the output of virt-install --boot help

if has_sub_option("boot", "kernel_args") and kernel_args:
      result += 'kernel_args="%s",' % kernel_args

But the output of virt-install --boot help does not contain "kernel_args" as sub option. Hence the above check is not satisfied even if the "kernel_args" parameter is being passed in the config file

# virt-install --boot help
--boot options:
  clearxml
  xpath[0-9]*.create
  xpath[0-9]*.delete
  xpath[0-9]*.set
  xpath[0-9]*.value
  acpi.table
  acpi.table.type
  arch
  bios.rebootTimeout
  bios.useserial
  boot[0-9]*.dev
  bootloader
  bootloader_args
  bootmenu.enable
  bootmenu.timeout
  cdrom
  cmdline
  domain_type
  dtb
  emulator
  fd
  firmware
  firmware.feature[0-9]*.enabled
  firmware.feature[0-9]*.name
  hd
  init
  initarg[0-9]*
  initargs
  initdir
  initenv[0-9]*
  initenv[0-9]*.name
  initgroup
  initrd
  inituser
  kernel
  loader
  loader.readonly
  loader.secure
  loader.type
  machine
  network
  nvram
  nvram.template
  os_type
  refresh-machine-type

This is because, "cmdline" is the recommended way of passing the kernel command line parameters
Reference: virt-manager/virt-manager@d85a9a4#diff-a207f1f755d446ad85f8fc53a1a14646999f56c7be124b356c78d601aea62429

@misanjumn
Copy link
Author

misanjumn commented Aug 23, 2024

Config file

create_vm_libvirt = yes
kernel_args = "root=/dev/sda2 console=hvc0,ttyS0,115200"
kernel = "/boot/vmlinuz-6.11.0-rc3-gd7a5aa4b3c00"
initrd = "/boot/initramfs-6.11.0-rc3-gd7a5aa4b3c00.img"

Before patch

kernel_args is not passed in --boot

INFO | Running libvirt command (reformatted):
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO | /usr/bin/virt-install
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --connect=qemu:///system
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --hvm
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --accelerate
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --name 'vm1'
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --machine pseries
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --memory=10000
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --vcpu=8,maxvcpus=8,sockets=4,cores=1,threads=2
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --import
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --nographics
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --os-variant rhel8.0
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --serial pty
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --memballoon model=virtio
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --controller type=scsi,model=virtio-scsi
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --disk path=/home/kvmci/tests/data/avocado-vt/images/rhel8.0devel-ppc64le_vm1.qcow2,bus=scsi,size=10,format=qcow2
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --network=bridge=virbr0,model=virtio,mac=***
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --mac=***
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --boot emulator=/usr/bin/qemu-system-ppc64,kernel=/boot/vmlinuz-6.11.0-rc3-gd7a5aa4b3c00,initrd=/boot/initramfs-6.11.0-rc3-gd7a5aa4b3c00.img
[stdlog] 2024-08-21 02:38:38,913 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --noautoconsole

....

2024-08-21 02:38:46: ^[[0;21;39m sda: sda1 sda2 sda3^[[0m
2024-08-21 02:38:46: ^[[0;21;32msd 0:0:0:0: [sda] Attached SCSI disk^[[0m
2024-08-21 02:38:46: [^[[0;32m  OK  ^[[0m] Finished ^[[0;1;39minitrd-udevadm-cleanup-db.service^[[0m - Cleanup udev Database.
2024-08-21 02:38:46: [^[[0;32m  OK  ^[[0m] Reached target ^[[0;1;39minitrd-switch-root.target^[[0m - Switch Root.
2024-08-21 02:38:46:          Starting ^[[0;1;39minitrd-switch-root.service^[[0m - Switch Root...
2024-08-21 02:38:46: [^[[0;1;31mFAILED^[[0m] Failed to start ^[[0;1;39minitrd-switch-root.service^[[0m - Switch Root.
2024-08-21 02:38:46: See 'systemctl status initrd-switch-root.service' for details.
2024-08-21 02:38:47:
2024-08-21 02:38:47: Generating "/run/initramfs/rdsosreport.txt"
2024-08-21 02:38:47:
2024-08-21 02:38:47:
2024-08-21 02:38:47: Entering emergency mode. Exit the shell to continue.
2024-08-21 02:38:47: Type "journalctl" to view system logs.
2024-08-21 02:38:47: You might want to save "/run/initramfs/rdsosreport.txt" to a USB stick or /boot
2024-08-21 02:38:47: after mounting them and attach it to a bug report.
2024-08-21 02:38:47:
2024-08-21 02:38:47:
2024-08-21 02:38:47: Press Enter for maintenance
2024-08-21 02:38:47: (or press Control-D to continue):

After patch

kernel_args is being passed in --boot

INFO | Running libvirt command (reformatted): 
[stdlog] 2024-08-23 03:21:19,802 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO | /usr/bin/virt-install 
[stdlog] 2024-08-23 03:21:19,802 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --connect=qemu:///system 
[stdlog] 2024-08-23 03:21:19,802 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --hvm 
[stdlog] 2024-08-23 03:21:19,802 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --accelerate 
[stdlog] 2024-08-23 03:21:19,802 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --name 'vm1' 
[stdlog] 2024-08-23 03:21:19,802 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --machine pseries 
[stdlog] 2024-08-23 03:21:19,802 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --memory=10000 
[stdlog] 2024-08-23 03:21:19,803 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --vcpu=8,maxvcpus=16,sockets=8,cores=2,threads=1    
[stdlog] 2024-08-23 03:21:19,803 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --import 
[stdlog] 2024-08-23 03:21:19,803 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --nographics
[stdlog] 2024-08-23 03:21:19,803 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --os-variant rhel8.0
[stdlog] 2024-08-23 03:21:19,803 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --serial pty
[stdlog] 2024-08-23 03:21:19,803 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --memballoon model=virtio
[stdlog] 2024-08-23 03:21:19,803 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --controller type=scsi,model=virtio-scsi
[stdlog] 2024-08-23 03:21:19,803 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --disk path=/home/kvmci/tests/data/avocado-vt/images/rhel8.0devel-ppc64le_vm1.qcow2,bus=scsi,size=10,format=qcow2
[stdlog] 2024-08-23 03:21:19,803 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --network=bridge=virbr0,model=virtio,mac=***
[stdlog] 2024-08-23 03:21:19,803 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --mac=***
[stdlog] 2024-08-23 03:21:19,803 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --boot emulator=/usr/bin/qemu-system-ppc64,kernel=/boot/vmlinuz-6.11.0-rc3-gd7a5aa4b3c00,initrd=/boot/initramfs-6.11.0-rc3-gd7a5aa4b3c00.img,cmdline="root=/dev/sda2 console=hvc0,ttyS0,115200 "
[stdlog] 2024-08-23 03:21:19,803 avocado.virttest.libvirt_vm libvirt_vm       L2181 INFO |     --noautoconsole

....

2024-08-23 03:23:36: Fedora Linux 40 (Server Edition)
2024-08-23 03:23:36: Kernel 6.11.0-rc3-gd7a5aa4b3c00 on an ppc64le (hvc0)
2024-08-23 03:23:36:
2024-08-23 03:23:36: Web console: https://localhost:***/ or https://***:***
2024-08-23 03:23:36:
2024-08-23 03:23:36: localhost login:

@harihare
Copy link
Contributor

Please check the after patch output and confirm.

@misanjumn
Copy link
Author

Please check the after patch output and confirm.

The following is the updated output after patch

[stdlog] 2024-08-26 01:56:40,570 avocado.virttest.libvirt_vm libvirt_vm       L2183 INFO | Running libvirt command (reformatted):
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO | /usr/bin/virt-install
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO |     --connect=qemu:///system
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO |     --hvm
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO |     --accelerate
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO |     --name 'vm1'
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO |     --machine pseries
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO |     --memory=10000
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO |     --vcpu=8,maxvcpus=16,sockets=8,cores=2,threads=1
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO |     --import
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO |     --nographics
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO |     --os-variant rhel8.0
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO |     --serial pty
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO |     --memballoon model=virtio
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO |     --controller type=scsi,model=virtio-scsi
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO |     --disk path=/home/kvmci/tests/data/avocado-vt/images/rhel8.0devel-ppc64le_vm1.qcow2,bus=scsi,size=10,format=qcow2
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO |     --network=bridge=virbr0,model=virtio,mac=***
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO |     --mac=***
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO |     --boot emulator=/usr/bin/qemu-system-ppc64,kernel=/boot/vmlinuz-6.11.0-rc3-gd7a5aa4b3c00,initrd=/boot/initramfs-6.11.0-rc3-gd7a5aa4b3c00.img,cmdline="root=/dev/sda2 console=hvc0,ttyS0,115200"
[stdlog] 2024-08-26 01:56:40,571 avocado.virttest.libvirt_vm libvirt_vm       L2185 INFO |     --noautoconsole

Pointing to the specific line where cmdline is being used:
--boot emulator=/usr/bin/qemu-system-ppc64,kernel=/boot/vmlinuz-6.11.0-rc3-gd7a5aa4b3c00,initrd=/boot/initramfs-6.11.0-rc3-gd7a5aa4b3c00.img,cmdline="root=/dev/sda2 console=hvc0,ttyS0,115200"

@@ -986,6 +986,8 @@ def add_kernel(
result += "initrd=%s," % initrd_path
if has_sub_option("boot", "kernel_args") and kernel_args:
result += 'kernel_args="%s",' % kernel_args
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that kernel_args is not part of virt_install shall we remove the check.

Copy link
Author

Choose a reason for hiding this comment

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

@harihare
I kept that for people still using the older virt-install tool which has kernel_args parameter listed in virt-install --boot help
If that is not required, then I can remove that check

@PraveenPenguin
Copy link

@clebergnu can you please help us to trigger CI for this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants