All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/8] Introduce the microvm machine type
@ 2019-09-24 12:44 ` Sergio Lopez
  0 siblings, 0 replies; 133+ messages in thread
From: Sergio Lopez @ 2019-09-24 12:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: mst, imammedo, marcel.apfelbaum, pbonzini, rth, ehabkost, philmd,
	lersek, kraxel, mtosatti, kvm, Sergio Lopez

Microvm is a machine type inspired by both NEMU and Firecracker, and
constructed after the machine model implemented by the latter.

It's main purpose is providing users a minimalist machine type free
from the burden of legacy compatibility, serving as a stepping stone
for future projects aiming at improving boot times, reducing the
attack surface and slimming down QEMU's footprint.

The microvm machine type supports the following devices:

 - ISA bus
 - i8259 PIC
 - LAPIC (implicit if using KVM)
 - IOAPIC (defaults to kernel_irqchip_split = true)
 - i8254 PIT
 - MC146818 RTC (optional)
 - kvmclock (if using KVM)
 - fw_cfg
 - One ISA serial port (optional)
 - Up to eight virtio-mmio devices (configured by the user)

It supports the following machine-specific options:

microvm.option-roms=bool (Set off to disable loading option ROMs)
microvm.isa-serial=bool (Set off to disable the instantiation an ISA serial port)
microvm.rtc=bool (Set off to disable the instantiation of an MC146818 RTC)
microvm.kernel-cmdline=bool (Set off to disable adding virtio-mmio devices to the kernel cmdline)

By default, microvm uses qboot as its BIOS, to obtain better boot
times, but it's also compatible with SeaBIOS.

As no current FW is able to boot from a block device using virtio-mmio
as its transport, a microvm-based VM needs to be run using a host-side
kernel and, optionally, an initrd image.

This is an example of instantiating a microvm VM with a virtio-mmio
based console:

qemu-system-x86_64 -M microvm
 -enable-kvm -cpu host -m 512m -smp 2 \
 -kernel vmlinux -append "console=hvc0 root=/dev/vda" \
 -nodefaults -no-user-config -nographic \
 -chardev stdio,id=virtiocon0,server \
 -device virtio-serial-device \
 -device virtconsole,chardev=virtiocon0 \
 -drive id=test,file=test.img,format=raw,if=none \
 -device virtio-blk-device,drive=test \
 -netdev tap,id=tap0,script=no,downscript=no \
 -device virtio-net-device,netdev=tap0

This is another example, this time using an ISA serial port, useful
for debugging purposes:

qemu-system-x86_64 -M microvm \
 -enable-kvm -cpu host -m 512m -smp 2 \
 -kernel vmlinux -append "earlyprintk=ttyS0 console=ttyS0 root=/dev/vda" \
 -nodefaults -no-user-config -nographic \
 -serial stdio \
 -drive id=test,file=test.img,format=raw,if=none \
 -device virtio-blk-device,drive=test \
 -netdev tap,id=tap0,script=no,downscript=no \
 -device virtio-net-device,netdev=tap0

Finally, in this example a microvm VM is instantiated without RTC,
without an ISA serial port and without loading the option ROMs,
obtaining the smallest configuration:

qemu-system-x86_64 -M microvm,rtc=off,isa-serial=off,option-roms=off \
 -enable-kvm -cpu host -m 512m -smp 2 \
 -kernel vmlinux -append "console=hvc0 root=/dev/vda" \
 -nodefaults -no-user-config -nographic \
 -chardev stdio,id=virtiocon0,server \
 -device virtio-serial-device \
 -device virtconsole,chardev=virtiocon0 \
 -drive id=test,file=test.img,format=raw,if=none \
 -device virtio-blk-device,drive=test \
 -netdev tap,id=tap0,script=no,downscript=no \
 -device virtio-net-device,netdev=tap0

---

Changelog
v4:
 - This is a complete rewrite of the whole patchset, with a focus on
   reusing as much existing code as possible to ease the maintenance burden
   and making the machine type as compatible as possible by default. As
   a result, the number of lines dedicated specifically to microvm is
   383 (code lines measured by "cloc") and, with the default
   configuration, it's now able to boot both PVH ELF images and
   bzImages with either SeaBIOS or qboot.

v3:
  - Add initrd support (thanks Stefano).

v2:
  - Drop "[PATCH 1/4] hw/i386: Factorize CPU routine".
  - Simplify machine definition (thanks Eduardo).
  - Remove use of unneeded NUMA-related callbacks (thanks Eduardo).
  - Add a patch to factorize PVH-related functions.
  - Replace use of Linux's Zero Page with PVH (thanks Maran and Paolo).
  
---
Sergio Lopez (8):
  hw/i386: Factorize PVH related functions
  hw/i386: Factorize e820 related functions
  hw/virtio: Factorize virtio-mmio headers
  hw/i386: split PCMachineState deriving X86MachineState from it
  fw_cfg: add "modify" functions for all types
  roms: add microvm-bios (qboot) as binary and git submodule
  docs/microvm.txt: document the new microvm machine type
  hw/i386: Introduce the microvm machine type

 .gitmodules                      |   3 +
 default-configs/i386-softmmu.mak |   1 +
 docs/microvm.txt                 |  78 +++
 hw/acpi/cpu_hotplug.c            |  10 +-
 hw/i386/Kconfig                  |   4 +
 hw/i386/Makefile.objs            |   4 +
 hw/i386/acpi-build.c             |  31 +-
 hw/i386/amd_iommu.c              |   4 +-
 hw/i386/e820.c                   |  99 ++++
 hw/i386/e820.h                   |  11 +
 hw/i386/intel_iommu.c            |   4 +-
 hw/i386/microvm.c                | 512 +++++++++++++++++
 hw/i386/pc.c                     | 960 +++----------------------------
 hw/i386/pc_piix.c                |  48 +-
 hw/i386/pc_q35.c                 |  38 +-
 hw/i386/pc_sysfw.c               |  60 +-
 hw/i386/pvh.c                    | 113 ++++
 hw/i386/pvh.h                    |  10 +
 hw/i386/x86.c                    | 788 +++++++++++++++++++++++++
 hw/intc/ioapic.c                 |   3 +-
 hw/nvram/fw_cfg.c                |  29 +
 hw/virtio/virtio-mmio.c          |  35 +-
 include/hw/i386/microvm.h        |  80 +++
 include/hw/i386/pc.h             |  40 +-
 include/hw/i386/x86.h            |  97 ++++
 include/hw/nvram/fw_cfg.h        |  42 ++
 include/hw/virtio/virtio-mmio.h  |  60 ++
 pc-bios/bios-microvm.bin         | Bin 0 -> 65536 bytes
 roms/Makefile                    |   6 +
 roms/qboot                       |   1 +
 target/i386/kvm.c                |   1 +
 31 files changed, 2102 insertions(+), 1070 deletions(-)
 create mode 100644 docs/microvm.txt
 create mode 100644 hw/i386/e820.c
 create mode 100644 hw/i386/e820.h
 create mode 100644 hw/i386/microvm.c
 create mode 100644 hw/i386/pvh.c
 create mode 100644 hw/i386/pvh.h
 create mode 100644 hw/i386/x86.c
 create mode 100644 include/hw/i386/microvm.h
 create mode 100644 include/hw/i386/x86.h
 create mode 100644 include/hw/virtio/virtio-mmio.h
 create mode 100755 pc-bios/bios-microvm.bin
 create mode 160000 roms/qboot

-- 
2.21.0


^ permalink raw reply	[flat|nested] 133+ messages in thread

end of thread, other threads:[~2019-10-01  9:03 UTC | newest]

Thread overview: 133+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-24 12:44 [PATCH v4 0/8] Introduce the microvm machine type Sergio Lopez
2019-09-24 12:44 ` Sergio Lopez
2019-09-24 12:44 ` [PATCH v4 1/8] hw/i386: Factorize PVH related functions Sergio Lopez
2019-09-24 12:44   ` Sergio Lopez
2019-09-24 13:18   ` Philippe Mathieu-Daudé
2019-09-24 13:18     ` Philippe Mathieu-Daudé
2019-09-25  6:03     ` Sergio Lopez
2019-09-25  6:03       ` Sergio Lopez
2019-09-25  8:36   ` Stefano Garzarella
2019-09-25  8:36     ` Stefano Garzarella
2019-09-25  9:00     ` Sergio Lopez
2019-09-25  9:00       ` Sergio Lopez
2019-09-25  9:29       ` Stefano Garzarella
2019-09-25  9:29         ` Stefano Garzarella
2019-09-24 12:44 ` [PATCH v4 2/8] hw/i386: Factorize e820 " Sergio Lopez
2019-09-24 12:44   ` Sergio Lopez
2019-09-24 13:20   ` Philippe Mathieu-Daudé
2019-09-24 13:20     ` Philippe Mathieu-Daudé
2019-09-24 14:12     ` Sergio Lopez
2019-09-24 14:12       ` Sergio Lopez
2019-09-24 12:44 ` [PATCH v4 3/8] hw/virtio: Factorize virtio-mmio headers Sergio Lopez
2019-09-24 12:44   ` Sergio Lopez
2019-09-24 12:44 ` [PATCH v4 4/8] hw/i386: split PCMachineState deriving X86MachineState from it Sergio Lopez
2019-09-24 13:40   ` Philippe Mathieu-Daudé
2019-09-25 15:39     ` Philippe Mathieu-Daudé
2019-09-24 12:44 ` [PATCH v4 5/8] fw_cfg: add "modify" functions for all types Sergio Lopez
2019-09-24 12:44   ` Sergio Lopez
2019-09-24 12:44 ` [PATCH v4 6/8] roms: add microvm-bios (qboot) as binary and git submodule Sergio Lopez
2019-09-24 12:44   ` Sergio Lopez
2019-09-24 13:31   ` Philippe Mathieu-Daudé
2019-09-24 13:31     ` Philippe Mathieu-Daudé
2019-09-25  6:09     ` Sergio Lopez
2019-09-25  6:09       ` Sergio Lopez
2019-09-24 12:44 ` [PATCH v4 7/8] docs/microvm.txt: document the new microvm machine type Sergio Lopez
2019-09-24 12:44   ` Sergio Lopez
2019-09-24 13:10   ` Paolo Bonzini
2019-09-24 13:10     ` Paolo Bonzini
2019-09-25  5:49     ` Sergio Lopez
2019-09-25  5:49       ` Sergio Lopez
2019-09-25  7:57       ` Paolo Bonzini
2019-09-25  7:57         ` Paolo Bonzini
2019-09-25  8:40         ` Sergio Lopez
2019-09-25  8:40           ` Sergio Lopez
2019-09-25  9:22           ` Paolo Bonzini
2019-09-25  9:22             ` Paolo Bonzini
2019-09-25 11:04             ` Sergio Lopez
2019-09-25 11:04               ` Sergio Lopez
2019-09-25 11:20               ` Paolo Bonzini
2019-09-25 11:20                 ` Paolo Bonzini
2019-09-25 15:04     ` Sergio Lopez
2019-09-25 15:04       ` Sergio Lopez
2019-09-25 16:46       ` Paolo Bonzini
2019-09-25 16:46         ` Paolo Bonzini
2019-09-26  6:23         ` Sergio Lopez
2019-09-26  6:23           ` Sergio Lopez
2019-09-26  8:58           ` Paolo Bonzini
2019-09-26  8:58             ` Paolo Bonzini
2019-09-26 10:16             ` Sergio Lopez
2019-09-26 10:16               ` Sergio Lopez
2019-09-26 10:21               ` Paolo Bonzini
2019-09-26 10:21                 ` Paolo Bonzini
2019-09-26 12:12                 ` Sergio Lopez
2019-09-26 12:12                   ` Sergio Lopez
2019-09-25  5:06   ` Gerd Hoffmann
2019-09-25  5:06     ` Gerd Hoffmann
2019-09-25  7:33     ` Sergio Lopez
2019-09-25  7:33       ` Sergio Lopez
2019-09-25  8:51       ` Gerd Hoffmann
2019-09-25  8:51         ` Gerd Hoffmann
2019-09-24 12:44 ` [PATCH v4 8/8] hw/i386: Introduce the " Sergio Lopez
2019-09-24 12:44   ` Sergio Lopez
2019-09-24 13:12   ` Paolo Bonzini
2019-09-24 13:12     ` Paolo Bonzini
2019-09-24 13:24     ` Michael S. Tsirkin
2019-09-24 13:24       ` Michael S. Tsirkin
2019-09-24 13:34       ` Paolo Bonzini
2019-09-24 13:34         ` Paolo Bonzini
2019-09-25  5:53     ` Sergio Lopez
2019-09-25  5:53       ` Sergio Lopez
2019-09-24 13:28   ` Michael S. Tsirkin
2019-09-24 13:28     ` Michael S. Tsirkin
2019-09-25  5:59     ` Sergio Lopez
2019-09-25  5:59       ` Sergio Lopez
2019-10-01  8:56       ` Sergio Lopez
2019-10-01  8:56         ` Sergio Lopez
2019-09-25 15:40   ` Philippe Mathieu-Daudé
2019-09-25 15:40     ` Philippe Mathieu-Daudé
2019-09-26  6:34     ` Sergio Lopez
2019-09-26  6:34       ` Sergio Lopez
2019-09-26  8:59       ` Paolo Bonzini
2019-09-26  8:59         ` Paolo Bonzini
2019-09-24 13:57 ` [PATCH v4 0/8] " Peter Maydell
2019-09-24 13:57   ` Peter Maydell
2019-09-25  5:51   ` Sergio Lopez
2019-09-25  5:51     ` Sergio Lopez
2019-09-25 11:33     ` Philippe Mathieu-Daudé
2019-09-25 11:33       ` Philippe Mathieu-Daudé
2019-09-25 12:39       ` Peter Maydell
2019-09-25 12:39         ` Peter Maydell
2019-09-25  7:41 ` David Hildenbrand
2019-09-25  7:41   ` David Hildenbrand
2019-09-25  7:58   ` Pankaj Gupta
2019-09-25  7:58     ` Pankaj Gupta
2019-09-25  8:10   ` Sergio Lopez
2019-09-25  8:10     ` Sergio Lopez
2019-09-25  8:16     ` David Hildenbrand
2019-09-25  8:16       ` David Hildenbrand
2019-09-25  8:37       ` Pankaj Gupta
2019-09-25  8:37         ` Pankaj Gupta
2019-09-25  8:26     ` Paolo Bonzini
2019-09-25  8:26       ` Paolo Bonzini
2019-09-25  8:42       ` Sergio Lopez
2019-09-25  8:42         ` Sergio Lopez
2019-09-25  8:44       ` David Hildenbrand
2019-09-25  8:44         ` David Hildenbrand
2019-09-25 10:19         ` when to use virtio (was Re: [PATCH v4 0/8] Introduce the microvm machine type) Paolo Bonzini
2019-09-25 10:19           ` Paolo Bonzini
2019-09-25 10:50           ` David Hildenbrand
2019-09-25 10:50             ` David Hildenbrand
2019-09-25 11:24             ` Paolo Bonzini
2019-09-25 11:24               ` Paolo Bonzini
2019-09-25 11:32               ` David Hildenbrand
2019-09-25 11:32                 ` David Hildenbrand
2019-09-25  9:12       ` [PATCH v4 0/8] Introduce the microvm machine type Gerd Hoffmann
2019-09-25  9:12         ` Gerd Hoffmann
2019-09-25  9:29         ` Paolo Bonzini
2019-09-25  9:29           ` Paolo Bonzini
2019-09-25  9:47         ` David Hildenbrand
2019-09-25  9:47           ` David Hildenbrand
2019-09-26  7:48 ` Christian Borntraeger
2019-09-26  7:48   ` Christian Borntraeger
2019-09-26  8:22   ` Sergio Lopez
2019-09-26  8:22     ` Sergio Lopez

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.