qemu-system-x86_64, I want QEMU to start a virtual machine with a drive and a few virtual cdrom drives and floppy drives attached.
I need it to automatically boot from the first virtual cdrom drive without me having to "press any key to boot from cd/dvd".
I have specified the cdrom drive like this:
But no matter what I do with the
-boot parameter, it always displays this "Press any key to boot from cd/dvd now..." for about 5 seconds and then it doesn't boot from that cd. I have tried various things like:
-boot order=d -boot menu=on
I also tried using the boot index:
Which results in an error:
Block format 'raw' does not support the option 'bootindex'
The cdrom drive that I want to boot from contains a Windows 10 installation image which I have configured to install itself automatically without user interaction. My goal is to have a bash script which automatically creates a Windows VM and automatically installs Windows without any user interaction. So I really just need QEMU to automatically boot into that Windows installation.
I managed to reproduce the the behavior like this:
sudo qemu-system-x86_64 \ -smp 4 \ -m 4G \ -drive "file=/home/fedora/vm/windows10.iso,index=1,media=cdrom" \ -boot order=d \ -drive id=disk0,if=virtio,cache.direct=on,if=virtio,aio=native,format=raw,file=/home/fedora/Projects/misc/MobilePassThrough/vm-files/WindowsVM.img \ -drive "if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE.fd" \ -drive "if=pflash,format=raw,file=/home/fedora/vm/WindowsVM_VARS.fd"
If I remove the last 2 lines (which are responsible for booting in UEFI (OVMF) mode instead of in BIOS (SeaBIOS) mode), then it actually respects the
But I have to boot the VM in UEFI mode, otherwise it would be useless to me.
Edit2: If I understood this correctly, in the UEFI world, the boot order is determined by a variable that is kept in a non-volitile storage (in my case "home/fedora/vm/WindowsVM_VARS.fd"). Now when the boot fails I think I drop into the "UEFI shell". And after doing some research, it appears that this shell is exposed via QEMU's serial port and in theory it would have to be possible to set the variable via 'setvar' and 'expect'. But neither do I have a clue what the name if that variable would be nor what the value would look like or how I would even specify my CD drive in it. I don't even know how 'setvar' and 'expect' work at all.