2
0

microvm.rst 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. ====================
  2. microvm Machine Type
  3. ====================
  4. ``microvm`` is a machine type inspired by ``Firecracker`` and
  5. constructed after its machine model.
  6. It's a minimalist machine type without ``PCI`` nor ``ACPI`` support,
  7. designed for short-lived guests. microvm also establishes a baseline
  8. for benchmarking and optimizing both QEMU and guest operating systems,
  9. since it is optimized for both boot time and footprint.
  10. Supported devices
  11. -----------------
  12. The microvm machine type supports the following devices:
  13. - ISA bus
  14. - i8259 PIC (optional)
  15. - i8254 PIT (optional)
  16. - MC146818 RTC (optional)
  17. - One ISA serial port (optional)
  18. - LAPIC
  19. - IOAPIC (with kernel-irqchip=split by default)
  20. - kvmclock (if using KVM)
  21. - fw_cfg
  22. - Up to eight virtio-mmio devices (configured by the user)
  23. Limitations
  24. -----------
  25. Currently, microvm does *not* support the following features:
  26. - PCI-only devices.
  27. - Hotplug of any kind.
  28. - Live migration across QEMU versions.
  29. Using the microvm machine type
  30. ------------------------------
  31. Machine-specific options
  32. ~~~~~~~~~~~~~~~~~~~~~~~~
  33. It supports the following machine-specific options:
  34. - microvm.x-option-roms=bool (Set off to disable loading option ROMs)
  35. - microvm.pit=OnOffAuto (Enable i8254 PIT)
  36. - microvm.isa-serial=bool (Set off to disable the instantiation an ISA serial port)
  37. - microvm.pic=OnOffAuto (Enable i8259 PIC)
  38. - microvm.rtc=OnOffAuto (Enable MC146818 RTC)
  39. - microvm.auto-kernel-cmdline=bool (Set off to disable adding virtio-mmio devices to the kernel cmdline)
  40. Boot options
  41. ~~~~~~~~~~~~
  42. By default, microvm uses ``qboot`` as its BIOS, to obtain better boot
  43. times, but it's also compatible with ``SeaBIOS``.
  44. As no current FW is able to boot from a block device using
  45. ``virtio-mmio`` as its transport, a microvm-based VM needs to be run
  46. using a host-side kernel and, optionally, an initrd image.
  47. Running a microvm-based VM
  48. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  49. By default, microvm aims for maximum compatibility, enabling both
  50. legacy and non-legacy devices. In this example, a VM is created
  51. without passing any additional machine-specific option, using the
  52. legacy ``ISA serial`` device as console::
  53. $ qemu-system-x86_64 -M microvm \
  54. -enable-kvm -cpu host -m 512m -smp 2 \
  55. -kernel vmlinux -append "earlyprintk=ttyS0 console=ttyS0 root=/dev/vda" \
  56. -nodefaults -no-user-config -nographic \
  57. -serial stdio \
  58. -drive id=test,file=test.img,format=raw,if=none \
  59. -device virtio-blk-device,drive=test \
  60. -netdev tap,id=tap0,script=no,downscript=no \
  61. -device virtio-net-device,netdev=tap0
  62. While the example above works, you might be interested in reducing the
  63. footprint further by disabling some legacy devices. If you're using
  64. ``KVM``, you can disable the ``RTC``, making the Guest rely on
  65. ``kvmclock`` exclusively. Additionally, if your host's CPUs have the
  66. ``TSC_DEADLINE`` feature, you can also disable both the i8259 PIC and
  67. the i8254 PIT (make sure you're also emulating a CPU with such feature
  68. in the guest).
  69. This is an example of a VM with all optional legacy features
  70. disabled::
  71. $ qemu-system-x86_64 \
  72. -M microvm,x-option-roms=off,pit=off,pic=off,isa-serial=off,rtc=off \
  73. -enable-kvm -cpu host -m 512m -smp 2 \
  74. -kernel vmlinux -append "console=hvc0 root=/dev/vda" \
  75. -nodefaults -no-user-config -nographic \
  76. -chardev stdio,id=virtiocon0 \
  77. -device virtio-serial-device \
  78. -device virtconsole,chardev=virtiocon0 \
  79. -drive id=test,file=test.img,format=raw,if=none \
  80. -device virtio-blk-device,drive=test \
  81. -netdev tap,id=tap0,script=no,downscript=no \
  82. -device virtio-net-device,netdev=tap0
  83. Triggering a guest-initiated shut down
  84. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  85. As the microvm machine type includes just a small set of system
  86. devices, some x86 mechanisms for rebooting or shutting down the
  87. system, like sending a key sequence to the keyboard or writing to an
  88. ACPI register, doesn't have any effect in the VM.
  89. The recommended way to trigger a guest-initiated shut down is by
  90. generating a ``triple-fault``, which will cause the VM to initiate a
  91. reboot. Additionally, if the ``-no-reboot`` argument is present in the
  92. command line, QEMU will detect this event and terminate its own
  93. execution gracefully.
  94. Linux does support this mechanism, but by default will only be used
  95. after other options have been tried and failed, causing the reboot to
  96. be delayed by a small number of seconds. It's possible to instruct it
  97. to try the triple-fault mechanism first, by adding ``reboot=t`` to the
  98. kernel's command line.