vmspawn: add disk type selection for root and extra drives (#41301)

vmspawn previously hardcoded virtio-blk for all drives. This adds
  --image-disk-type= to select the root disk type (virtio-blk,
  virtio-scsi, or nvme) and allows per-drive overrides via a
  colon-separated prefix on --extra-drive=. The format and disk type
  prefixes can appear in any order since their value sets don't overlap.

  For virtio-scsi, a single shared controller is created with drives
  attached as scsi-hd devices. For nvme, each drive gets its own
controller. Both have serial number length limits (30 and 20 characters
  respectively), so long filenames are replaced with a truncated SHA-256
  hex digest.
This commit is contained in:
Lennart Poettering
2026-03-24 21:48:00 +01:00
committed by GitHub
5 changed files with 173 additions and 20 deletions
+3
View File
@@ -38,6 +38,7 @@ _systemd_vmspawn() {
[CONSOLE]='--console'
[ARG]='--cpus --ram --vsock-cid -M --machine --uuid --private-users --background --set-credential --load-credential'
[IMAGE_FORMAT]='--image-format'
[IMAGE_DISK_TYPE]='--image-disk-type'
)
_init_completion || return
@@ -59,6 +60,8 @@ _systemd_vmspawn() {
comps='interactive native gui read-only headless'
elif __contains_word "$prev" ${OPTS[IMAGE_FORMAT]}; then
comps='raw qcow2'
elif __contains_word "$prev" ${OPTS[IMAGE_DISK_TYPE]}; then
comps='virtio-blk virtio-scsi nvme'
elif __contains_word "$prev" ${OPTS[ARG]}; then
comps=''
else