xref: /openbmc/qemu/docs/system/bootindex.rst (revision 2c471a8291c182130a77702d9bd4c910d987c6a9)
1bd77bc8bSPeter MaydellManaging device boot order with bootindex properties
2bd77bc8bSPeter Maydell====================================================
3bd77bc8bSPeter Maydell
4bd77bc8bSPeter MaydellQEMU can tell QEMU-aware guest firmware (like the x86 PC BIOS)
5bd77bc8bSPeter Maydellwhich order it should look for a bootable OS on which devices.
6bd77bc8bSPeter MaydellA simple way to set this order is to use the ``-boot order=`` option,
7bd77bc8bSPeter Maydellbut you can also do this more flexibly, by setting a ``bootindex``
8bd77bc8bSPeter Maydellproperty on the individual block or net devices you specify
9bd77bc8bSPeter Maydellon the QEMU command line.
10bd77bc8bSPeter Maydell
11bd77bc8bSPeter MaydellThe ``bootindex`` properties are used to determine the order in which
12bd77bc8bSPeter Maydellfirmware will consider devices for booting the guest OS. If the
13bd77bc8bSPeter Maydell``bootindex`` property is not set for a device, it gets the lowest
14bd77bc8bSPeter Maydellboot priority. There is no particular order in which devices with no
15bd77bc8bSPeter Maydell``bootindex`` property set will be considered for booting, but they
16bd77bc8bSPeter Maydellwill still be bootable.
17bd77bc8bSPeter Maydell
18bd77bc8bSPeter MaydellSome guest machine types (for instance the s390x machines) do
19bd77bc8bSPeter Maydellnot support ``-boot order=``; on those machines you must always
20bd77bc8bSPeter Maydelluse ``bootindex`` properties.
21bd77bc8bSPeter Maydell
22bd77bc8bSPeter MaydellThere is no way to set a ``bootindex`` property if you are using
23bd77bc8bSPeter Maydella short-form option like ``-hda`` or ``-cdrom``, so to use
24bd77bc8bSPeter Maydell``bootindex`` properties you will need to expand out those options
25bd77bc8bSPeter Maydellinto long-form ``-drive`` and ``-device`` option pairs.
26bd77bc8bSPeter Maydell
27bd77bc8bSPeter MaydellExample
28bd77bc8bSPeter Maydell-------
29bd77bc8bSPeter Maydell
30bd77bc8bSPeter MaydellLet's assume we have a QEMU machine with two NICs (virtio, e1000) and two
31bd77bc8bSPeter Maydelldisks (IDE, virtio):
32bd77bc8bSPeter Maydell
33bd77bc8bSPeter Maydell.. parsed-literal::
34bd77bc8bSPeter Maydell
35bd77bc8bSPeter Maydell  |qemu_system| -drive file=disk1.img,if=none,id=disk1 \\
36bd77bc8bSPeter Maydell                -device ide-hd,drive=disk1,bootindex=4 \\
37bd77bc8bSPeter Maydell                -drive file=disk2.img,if=none,id=disk2 \\
38bd77bc8bSPeter Maydell                -device virtio-blk-pci,drive=disk2,bootindex=3 \\
39bd77bc8bSPeter Maydell                -netdev type=user,id=net0 \\
40bd77bc8bSPeter Maydell                -device virtio-net-pci,netdev=net0,bootindex=2 \\
41bd77bc8bSPeter Maydell                -netdev type=user,id=net1 \\
42bd77bc8bSPeter Maydell                -device e1000,netdev=net1,bootindex=1
43bd77bc8bSPeter Maydell
44bd77bc8bSPeter MaydellGiven the command above, firmware should try to boot from the e1000 NIC
45bd77bc8bSPeter Maydellfirst.  If this fails, it should try the virtio NIC next; if this fails
46bd77bc8bSPeter Maydelltoo, it should try the virtio disk, and then the IDE disk.
47bd77bc8bSPeter Maydell
48bd77bc8bSPeter MaydellLimitations
49bd77bc8bSPeter Maydell-----------
50bd77bc8bSPeter Maydell
51bd77bc8bSPeter MaydellSome firmware has limitations on which devices can be considered for
520bd10713SJared Rossibooting.  For instance, the x86 PC BIOS boot specification allows only one
530bd10713SJared Rossidisk to be bootable.  If boot from disk fails for some reason, the x86 BIOS
54bd77bc8bSPeter Maydellwon't retry booting from other disk.  It can still try to boot from
550bd10713SJared Rossifloppy or net, though. In the case of s390x BIOS, the BIOS will try up to
56*b8c5fdc6SThomas Huth8 total devices, any number of which may be disks or virtio-net devices.
57bd77bc8bSPeter Maydell
58bd77bc8bSPeter MaydellSometimes, firmware cannot map the device path QEMU wants firmware to
59bd77bc8bSPeter Maydellboot from to a boot method.  It doesn't happen for devices the firmware
60bd77bc8bSPeter Maydellcan natively boot from, but if firmware relies on an option ROM for
61bd77bc8bSPeter Maydellbooting, and the same option ROM is used for booting from more then one
62bd77bc8bSPeter Maydelldevice, the firmware may not be able to ask the option ROM to boot from
63bd77bc8bSPeter Maydella particular device reliably.  For instance with the PC BIOS, if a SCSI HBA
64bd77bc8bSPeter Maydellhas three bootable devices target1, target3, target5 connected to it,
65bd77bc8bSPeter Maydellthe option ROM will have a boot method for each of them, but it is not
66bd77bc8bSPeter Maydellpossible to map from boot method back to a specific target.  This is a
67bd77bc8bSPeter Maydellshortcoming of the PC BIOS boot specification.
68bd77bc8bSPeter Maydell
69bd77bc8bSPeter MaydellMixing bootindex and boot order parameters
70bd77bc8bSPeter Maydell------------------------------------------
71bd77bc8bSPeter Maydell
72bd77bc8bSPeter MaydellNote that it does not make sense to use the bootindex property together
73bd77bc8bSPeter Maydellwith the ``-boot order=...`` (or ``-boot once=...``) parameter. The guest
74bd77bc8bSPeter Maydellfirmware implementations normally either support the one or the other,
75bd77bc8bSPeter Maydellbut not both parameters at the same time. Mixing them will result in
76bd77bc8bSPeter Maydellundefined behavior, and thus the guest firmware will likely not boot
77bd77bc8bSPeter Maydellfrom the expected devices.
78