Skip to content

Simplify and improve flatcar_production_qemu*.sh script#2846

Merged
krnowak merged 5 commits intomainfrom
krnowak/qemu-script
Apr 23, 2025
Merged

Simplify and improve flatcar_production_qemu*.sh script#2846
krnowak merged 5 commits intomainfrom
krnowak/qemu-script

Conversation

@krnowak
Copy link
Copy Markdown
Member

@krnowak krnowak commented Apr 23, 2025

How disk and network devices are set up for the machine need not to be arch-specific any more. We can use virtio-blk-pci and virtio-net-pci on both arches.

This PR also adds two options:

  • -D or -image-disk-opts for adding options to primary disk (I used it mostly to add "serial=foo", so primary disk is available under /dev/disk/by-id/virtio-foo and its partitions as /dev/disk/by-id/virtio-foo-partN)
  • -d or -disk for adding extra disks - you can do qemu-img create -f qcow2 extradisk 1G, and then invoke the script with -d extradisk,serial=my-extra-disk to have it available under /dev/disk/by-id/virtio-my-extra-disk

Tested locally on both amd64 and arm64.

krnowak added 5 commits April 22, 2025 17:19
There's no need to differentiate between amd64 and arm64 boards here
any more. This also adds bootindex=1 option to the -device flag, so we
can pass more secondary disks without affecting the boot order.
The final part of the script differed only the name of the qemu binary
to execute and in network device driver (virtio-net-pci on amd64 vs
virtio-net-device on arm64). virtio-net-pci seems to be working also
on arm64, so simplify the code to avoid repetition.
Copy link
Copy Markdown
Contributor

@chewi chewi left a comment

Choose a reason for hiding this comment

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

I love it! ❤️

@krnowak
Copy link
Copy Markdown
Member Author

krnowak commented Apr 23, 2025

Thanks! Merging it - no point in running the CI, as no parts of CI are using the script.

@krnowak krnowak merged commit fb2682d into main Apr 23, 2025
2 of 4 checks passed
@krnowak krnowak deleted the krnowak/qemu-script branch April 23, 2025 13:15
@github-project-automation github-project-automation bot moved this from ✅ Testing / in Review to Implemented in Flatcar tactical, release planning, and roadmap Apr 23, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 23, 2025

Build action triggered: https://github.com/flatcar/scripts/actions/runs/14639292341

@tormath1
Copy link
Copy Markdown
Contributor

Maybe we could add a changelog entry in the changes section to mention the two new options?

@krnowak
Copy link
Copy Markdown
Member Author

krnowak commented Apr 24, 2025

Maybe we could add a changelog entry in the changes section to mention the two new options?

Good idea, will file a follow-up.

@krnowak
Copy link
Copy Markdown
Member Author

krnowak commented Apr 24, 2025

Filed here: #2847

@danzatt
Copy link
Copy Markdown
Contributor

danzatt commented Apr 24, 2025

I've actually just run an NVIDIA sysext build based on main (including this PR) and the vms job failed with

12:01:05  INFO    image_to_vm.sh: Writing pxe configuration
12:01:05  possible bashism in /mnt/host/source/src/build/images/amd64-usr/latest/flatcar_production_pxe.sh line 96 (should be VAR="${VAR}foo"):
12:01:05              DISKS+=( "$2" )
12:01:05  possible bashism in /mnt/host/source/src/build/images/amd64-usr/latest/flatcar_production_pxe.sh line 276 (alternative test command ([[ foo ]] should be [ foo ])):
12:01:05      if [[ ,${PRIMARY_DISK_OPTS}, = *,drive=* || ,${PRIMARY_DISK_OPTS}, = *,bootindex=* ]]; then
12:01:05  possible bashism in /mnt/host/source/src/build/images/amd64-usr/latest/flatcar_production_pxe.sh line 283 (declare):
12:01:05  declare -i id_counter=1
12:01:05  possible bashism in /mnt/host/source/src/build/images/amd64-usr/latest/flatcar_production_pxe.sh line 285 (bash arrays, ${name[0|*|@]}):
12:01:05  for disk in "${DISKS[@]}"; do
12:01:05  possible bashism in /mnt/host/source/src/build/images/amd64-usr/latest/flatcar_production_pxe.sh line 286 ('$((n++))' should be '$n; $((n=n+1))'):
12:01:05      disk_id="flatcar-extra-disk-$((id_counter++))"
12:01:05  possible bashism in /mnt/host/source/src/build/images/amd64-usr/latest/flatcar_production_pxe.sh line 287 (alternative test command ([[ foo ]] should be [ foo ])):
12:01:05      if [[ ${disk} = *,* ]]; then
12:01:05  ERROR   image_to_vm.sh: script called: image_to_vm.sh '--format' 'pxe' '--board=amd64-usr' '--from' '/home/sdk/trunk/src/build/images/amd64-usr/latest-input' '--to' '/home/sdk/trunk/src/build/images/amd64-usr/latest' '--image_compression_formats=bz2' '--only_store_compressed'
12:01:05  ERROR   image_to_vm.sh: Backtrace:  (most recent call is last)
12:01:05  ERROR   image_to_vm.sh:   file image_to_vm.sh, line 123, called: write_vm_conf '1024'
12:01:05  ERROR   image_to_vm.sh:   file vm_image_util.sh, line 785, called: _write_pxe_conf '1024'
12:01:05  ERROR   image_to_vm.sh:   file vm_image_util.sh, line 901, called: _write_qemu_common '/mnt/host/source/src/build/images/amd64-usr/latest/flatcar_production_pxe.sh'
12:01:05  ERROR   image_to_vm.sh:   file vm_image_util.sh, line 797, called: die 

Do you think this could be related?

@chewi
Copy link
Copy Markdown
Contributor

chewi commented Apr 24, 2025

It is. See #2848.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants