[PATCH v5 00/10] Introduce the microvm machine type

Sergio Lopez posted 10 patches 4 years, 6 months ago
Test checkpatch failed
Test docker-mingw@fedora passed
Test docker-quick@centos7 failed
Test docker-clang@ubuntu failed
Test asan failed
Test FreeBSD passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20191002113103.45023-1-slp@redhat.com
Maintainers: Eduardo Habkost <ehabkost@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Richard Henderson <rth@twiddle.net>, "Philippe Mathieu-Daudé" <philmd@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Michael S. Tsirkin" <mst@redhat.com>, Laszlo Ersek <lersek@redhat.com>
There is a newer version of this series
.gitmodules                      |   3 +
default-configs/i386-softmmu.mak |   1 +
docs/microvm.rst                 |  98 ++++
hw/acpi/cpu_hotplug.c            |  10 +-
hw/i386/Kconfig                  |   4 +
hw/i386/Makefile.objs            |   2 +
hw/i386/acpi-build.c             |  29 +-
hw/i386/amd_iommu.c              |   3 +-
hw/i386/intel_iommu.c            |   3 +-
hw/i386/microvm.c                | 574 ++++++++++++++++++++++
hw/i386/pc.c                     | 779 +++---------------------------
hw/i386/pc_piix.c                |  46 +-
hw/i386/pc_q35.c                 |  38 +-
hw/i386/pc_sysfw.c               |  58 +--
hw/i386/x86.c                    | 789 +++++++++++++++++++++++++++++++
hw/intc/apic.c                   |   2 +-
hw/intc/ioapic.c                 |   2 +-
hw/nvram/fw_cfg.c                |  29 ++
hw/virtio/virtio-mmio.c          |  48 +-
include/hw/i386/microvm.h        |  83 ++++
include/hw/i386/pc.h             |  28 +-
include/hw/i386/x86.h            |  93 ++++
include/hw/nvram/fw_cfg.h        |  42 ++
include/hw/virtio/virtio-mmio.h  |  73 +++
pc-bios/bios-microvm.bin         | Bin 0 -> 65536 bytes
roms/Makefile                    |   6 +
roms/qboot                       |   1 +
27 files changed, 1948 insertions(+), 896 deletions(-)
create mode 100644 docs/microvm.rst
create mode 100644 hw/i386/microvm.c
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
[PATCH v5 00/10] Introduce the microvm machine type
Posted by Sergio Lopez 4 years, 6 months ago
Microvm is a machine type inspired by Firecracker and constructed
after the its machine model.

It's a minimalist machine type without PCI nor ACPI support, designed
for short-lived guests. Microvm also establishes a baseline for
benchmarking and optimizing both QEMU and guest operating systems,
since it is optimized for both boot time and footprint.

---

Changelog
v5:
 - Drop unneeded "[PATCH v4 2/8] hw/i386: Factorize e820 related
   functions" (Philippe Mathieu-Daudé)
 - Drop unneeded "[PATCH v4 1/8] hw/i386: Factorize PVH related
   functions" (Stefano Garzarella)
 - Split X86MachineState introduction into smaller patches (Philippe
   Mathieu-Daudé)
 - Change option-roms to x-option-roms and kernel-cmdline to
   auto-kernel-cmdline (Paolo Bonzini)
 - Make i8259 PIT and i8254 PIC optional (Paolo Bonzini)
 - Some fixes to the documentation (Paolo Bonzini)
 - Switch documentation format from txt to rst (Peter Maydell)
 - Move NMI interface to X86_MACHINE (Philippe Mathieu-Daudé, Paolo
   Bonzini)

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 (10):
  hw/virtio: Factorize virtio-mmio headers
  hw/i386/pc: rename functions shared with non-PC machines
  hw/i386/pc: move shared x86 functions to x86.c and export them
  hw/i386: split PCMachineState deriving X86MachineState from it
  hw/i386: make x86.c independent from PCMachineState
  fw_cfg: add "modify" functions for all types
  hw/intc/apic: reject pic ints if isa_pic == NULL
  roms: add microvm-bios (qboot) as binary and git submodule
  docs/microvm.rst: document the new microvm machine type
  hw/i386: Introduce the microvm machine type

 .gitmodules                      |   3 +
 default-configs/i386-softmmu.mak |   1 +
 docs/microvm.rst                 |  98 ++++
 hw/acpi/cpu_hotplug.c            |  10 +-
 hw/i386/Kconfig                  |   4 +
 hw/i386/Makefile.objs            |   2 +
 hw/i386/acpi-build.c             |  29 +-
 hw/i386/amd_iommu.c              |   3 +-
 hw/i386/intel_iommu.c            |   3 +-
 hw/i386/microvm.c                | 574 ++++++++++++++++++++++
 hw/i386/pc.c                     | 779 +++---------------------------
 hw/i386/pc_piix.c                |  46 +-
 hw/i386/pc_q35.c                 |  38 +-
 hw/i386/pc_sysfw.c               |  58 +--
 hw/i386/x86.c                    | 789 +++++++++++++++++++++++++++++++
 hw/intc/apic.c                   |   2 +-
 hw/intc/ioapic.c                 |   2 +-
 hw/nvram/fw_cfg.c                |  29 ++
 hw/virtio/virtio-mmio.c          |  48 +-
 include/hw/i386/microvm.h        |  83 ++++
 include/hw/i386/pc.h             |  28 +-
 include/hw/i386/x86.h            |  93 ++++
 include/hw/nvram/fw_cfg.h        |  42 ++
 include/hw/virtio/virtio-mmio.h  |  73 +++
 pc-bios/bios-microvm.bin         | Bin 0 -> 65536 bytes
 roms/Makefile                    |   6 +
 roms/qboot                       |   1 +
 27 files changed, 1948 insertions(+), 896 deletions(-)
 create mode 100644 docs/microvm.rst
 create mode 100644 hw/i386/microvm.c
 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


Re: [PATCH v5 00/10] Introduce the microvm machine type
Posted by no-reply@patchew.org 4 years, 6 months ago
Patchew URL: https://patchew.org/QEMU/20191002113103.45023-1-slp@redhat.com/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1
=== TEST SCRIPT END ===

  CC      aarch64-softmmu/hw/arm/virt.o
  CC      aarch64-softmmu/hw/arm/virt-acpi-build.o
/tmp/qemu-test/src/hw/i386/xen/xen-hvm.c: In function 'xen_ram_init':
/tmp/qemu-test/src/hw/i386/xen/xen-hvm.c:203:53: error: 'PC_MACHINE_MAX_RAM_BELOW_4G' undeclared (first use in this function)
                                                     PC_MACHINE_MAX_RAM_BELOW_4G,
                                                     ^
/tmp/qemu-test/src/hw/i386/xen/xen-hvm.c:203:53: note: each undeclared identifier is reported only once for each function it appears in
/tmp/qemu-test/src/hw/i386/xen/xen-hvm.c:217:13: error: 'PCMachineState' has no member named 'above_4g_mem_size'
         pcms->above_4g_mem_size = ram_size - user_lowmem;
             ^
/tmp/qemu-test/src/hw/i386/xen/xen-hvm.c:218:13: error: 'PCMachineState' has no member named 'below_4g_mem_size'
         pcms->below_4g_mem_size = user_lowmem;
             ^
/tmp/qemu-test/src/hw/i386/xen/xen-hvm.c:220:13: error: 'PCMachineState' has no member named 'above_4g_mem_size'
         pcms->above_4g_mem_size = 0;
             ^
/tmp/qemu-test/src/hw/i386/xen/xen-hvm.c:221:13: error: 'PCMachineState' has no member named 'below_4g_mem_size'
         pcms->below_4g_mem_size = ram_size;
             ^
/tmp/qemu-test/src/hw/i386/xen/xen-hvm.c:223:14: error: 'PCMachineState' has no member named 'above_4g_mem_size'
     if (!pcms->above_4g_mem_size) {
              ^
/tmp/qemu-test/src/hw/i386/xen/xen-hvm.c:230:40: error: 'PCMachineState' has no member named 'above_4g_mem_size'
         block_len = (1ULL << 32) + pcms->above_4g_mem_size;
                                        ^
/tmp/qemu-test/src/hw/i386/xen/xen-hvm.c:247:34: error: 'PCMachineState' has no member named 'below_4g_mem_size'
                              pcms->below_4g_mem_size - 0xc0000);
                                  ^
/tmp/qemu-test/src/hw/i386/xen/xen-hvm.c:249:13: error: 'PCMachineState' has no member named 'above_4g_mem_size'
     if (pcms->above_4g_mem_size > 0) {
             ^
/tmp/qemu-test/src/hw/i386/xen/xen-hvm.c:252:38: error: 'PCMachineState' has no member named 'above_4g_mem_size'
                                  pcms->above_4g_mem_size);
                                      ^
make[1]: *** [hw/i386/xen/xen-hvm.o] Error 1
make[1]: *** Waiting for unfinished jobs....
  CC      x86_64-softmmu/target/i386/translate.o
  CC      aarch64-softmmu/hw/arm/digic_boards.o
---
  CC      aarch64-softmmu/hw/arm/realview.o
  CC      aarch64-softmmu/hw/arm/sbsa-ref.o
  CC      aarch64-softmmu/hw/arm/stellaris.o
make: *** [x86_64-softmmu/all] Error 2
make: *** Waiting for unfinished jobs....
  CC      aarch64-softmmu/hw/arm/collie.o
  CC      aarch64-softmmu/hw/arm/versatilepb.o
---
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=f1c2f7c4cc1b4d368566f09386dc38ef', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-yoe776nw/src/docker-src.2019-10-02-08.00.47.19037:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2.
filter=--filter=label=com.qemu.instance.uuid=f1c2f7c4cc1b4d368566f09386dc38ef
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-yoe776nw/src'
make: *** [docker-run-test-quick@centos7] Error 2

real    2m25.365s
user    0m7.863s


The full log is available at
http://patchew.org/logs/20191002113103.45023-1-slp@redhat.com/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Re: [PATCH v5 00/10] Introduce the microvm machine type
Posted by no-reply@patchew.org 4 years, 6 months ago
Patchew URL: https://patchew.org/QEMU/20191002113103.45023-1-slp@redhat.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20191002113103.45023-1-slp@redhat.com
Subject: [PATCH v5 00/10] Introduce the microvm machine type

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Switched to a new branch 'test'
7b4ed4b hw/i386: Introduce the microvm machine type
e5bff45 docs/microvm.rst: document the new microvm machine type
5d497ed roms: add microvm-bios (qboot) as binary and git submodule
de77277 hw/intc/apic: reject pic ints if isa_pic == NULL
5e6a3a1 fw_cfg: add "modify" functions for all types
adb0c9b hw/i386: make x86.c independent from PCMachineState
4d909dc hw/i386: split PCMachineState deriving X86MachineState from it
cdb8355 hw/i386/pc: move shared x86 functions to x86.c and export them
f591a05 hw/i386/pc: rename functions shared with non-PC machines
1051f6f hw/virtio: Factorize virtio-mmio headers

=== OUTPUT BEGIN ===
1/10 Checking commit 1051f6fcc0c0 (hw/virtio: Factorize virtio-mmio headers)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#77: 
new file mode 100644

total: 0 errors, 1 warnings, 131 lines checked

Patch 1/10 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
2/10 Checking commit f591a05ac797 (hw/i386/pc: rename functions shared with non-PC machines)
3/10 Checking commit cdb83552a361 (hw/i386/pc: move shared x86 functions to x86.c and export them)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#749: 
new file mode 100644

WARNING: Block comments use a leading /* on a separate line
#809: FILE: hw/i386/x86.c:56:
+/* Calculates initial APIC ID for a specific CPU index

WARNING: Block comments use a leading /* on a separate line
#866: FILE: hw/i386/x86.c:113:
+    /* Calculates the limit to CPU APIC ID values

WARNING: Block comments should align the * on each line
#913: FILE: hw/i386/x86.c:160:
+         * -smp hasn't been parsed after it
+        */

WARNING: line over 80 characters
#926: FILE: hw/i386/x86.c:173:
+        ms->possible_cpus->cpus[i].arch_id = x86_cpu_apic_id_from_index(pcms, i);

ERROR: spaces required around that '+' (ctx:VxV)
#1087: FILE: hw/i386/x86.c:334:
+    cmdline_size = (strlen(kernel_cmdline)+16) & ~15;
                                           ^

ERROR: do not use assignment in if condition
#1091: FILE: hw/i386/x86.c:338:
+    if (!f || !(kernel_size = get_file_size(f)) ||

ERROR: if this code is redundant consider removing it
#1100: FILE: hw/i386/x86.c:347:
+#if 0

ERROR: spaces required around that '+' (ctx:VxV)
#1101: FILE: hw/i386/x86.c:348:
+    fprintf(stderr, "header magic: %#x\n", ldl_p(header+0x202));
                                                        ^

ERROR: spaces required around that '+' (ctx:VxV)
#1103: FILE: hw/i386/x86.c:350:
+    if (ldl_p(header+0x202) == 0x53726448) {
                     ^

ERROR: spaces required around that '+' (ctx:VxV)
#1104: FILE: hw/i386/x86.c:351:
+        protocol = lduw_p(header+0x206);
                                 ^

ERROR: if this code is redundant consider removing it
#1194: FILE: hw/i386/x86.c:441:
+#if 0

ERROR: spaces required around that '+' (ctx:VxV)
#1206: FILE: hw/i386/x86.c:453:
+        lduw_p(header+0x236) & XLF_CAN_BE_LOADED_ABOVE_4G) {
                      ^

ERROR: spaces required around that '+' (ctx:VxV)
#1225: FILE: hw/i386/x86.c:472:
+        initrd_max = ldl_p(header+0x22c);
                                  ^

ERROR: spaces required around that '+' (ctx:VxV)
#1235: FILE: hw/i386/x86.c:482:
+    fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(kernel_cmdline)+1);
                                                                       ^

ERROR: spaces required around that '+' (ctx:VxV)
#1239: FILE: hw/i386/x86.c:486:
+        stl_p(header+0x228, cmdline_addr);
                     ^

ERROR: spaces required around that '+' (ctx:VxV)
#1241: FILE: hw/i386/x86.c:488:
+        stw_p(header+0x20, 0xA33F);
                     ^

ERROR: spaces required around that '+' (ctx:VxV)
#1242: FILE: hw/i386/x86.c:489:
+        stw_p(header+0x22, cmdline_addr-real_addr);
                     ^

ERROR: spaces required around that '-' (ctx:VxV)
#1242: FILE: hw/i386/x86.c:489:
+        stw_p(header+0x22, cmdline_addr-real_addr);
                                        ^

ERROR: consider using qemu_strtol in preference to strtol
#1258: FILE: hw/i386/x86.c:505:
+            video_mode = strtol(vmode, NULL, 0);

ERROR: spaces required around that '+' (ctx:VxV)
#1260: FILE: hw/i386/x86.c:507:
+        stw_p(header+0x1fa, video_mode);
                     ^

WARNING: Block comments use a leading /* on a separate line
#1264: FILE: hw/i386/x86.c:511:
+    /* High nybble = B reserved for QEMU; low nybble is revision number.

WARNING: Block comments use * on subsequent lines
#1265: FILE: hw/i386/x86.c:512:
+    /* High nybble = B reserved for QEMU; low nybble is revision number.
+       If this code is substantially changed, you may want to consider

WARNING: Block comments use a trailing */ on a separate line
#1266: FILE: hw/i386/x86.c:513:
+       incrementing the revision. */

ERROR: code indent should never use tabs
#1272: FILE: hw/i386/x86.c:519:
+        header[0x211] |= 0x80;^I/* CAN_USE_HEAP */$

ERROR: spaces required around that '+' (ctx:VxV)
#1273: FILE: hw/i386/x86.c:520:
+        stw_p(header+0x224, cmdline_addr-real_addr-0x200);
                     ^

ERROR: spaces required around that '-' (ctx:VxV)
#1273: FILE: hw/i386/x86.c:520:
+        stw_p(header+0x224, cmdline_addr-real_addr-0x200);
                                         ^

ERROR: spaces required around that '-' (ctx:VxV)
#1273: FILE: hw/i386/x86.c:520:
+        stw_p(header+0x224, cmdline_addr-real_addr-0x200);
                                                   ^

ERROR: spaces required around that '-' (ctx:VxV)
#1305: FILE: hw/i386/x86.c:552:
+        initrd_addr = (initrd_max-initrd_size) & ~4095;
                                  ^

ERROR: spaces required around that '+' (ctx:VxV)
#1311: FILE: hw/i386/x86.c:558:
+        stl_p(header+0x218, initrd_addr);
                     ^

ERROR: spaces required around that '+' (ctx:VxV)
#1312: FILE: hw/i386/x86.c:559:
+        stl_p(header+0x21c, initrd_size);
                     ^

ERROR: spaces required around that '+' (ctx:VxV)
#1320: FILE: hw/i386/x86.c:567:
+    setup_size = (setup_size+1)*512;
                             ^

ERROR: spaces required around that '*' (ctx:VxV)
#1320: FILE: hw/i386/x86.c:567:
+    setup_size = (setup_size+1)*512;
                                ^

ERROR: spaces required around that '+' (ctx:VxV)
#1358: FILE: hw/i386/x86.c:605:
+        stq_p(header+0x250, prot_addr + setup_data_offset);
                     ^

total: 26 errors, 8 warnings, 1430 lines checked

Patch 3/10 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

4/10 Checking commit 4d909dcf38f6 (hw/i386: split PCMachineState deriving X86MachineState from it)
WARNING: Block comments use a leading /* on a separate line
#880: FILE: hw/i386/pc_q35.c:158:
+        x86ms->max_ram_below_4g = 1ULL << 32; /* default: 4G */;

WARNING: line over 80 characters
#1103: FILE: hw/i386/x86.c:420:
+                initrd_max = x86ms->below_4g_mem_size - pcmc->acpi_data_size - 1;

WARNING: Block comments use a leading /* on a separate line
#1366: FILE: include/hw/i386/x86.h:61:
+    /* Address space used by IOAPIC device. All IOAPIC interrupts

WARNING: Block comments use a trailing */ on a separate line
#1367: FILE: include/hw/i386/x86.h:62:
+     * will be translated to MSI messages in the address space. */

total: 0 errors, 4 warnings, 1235 lines checked

Patch 4/10 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
5/10 Checking commit adb0c9bd5e70 (hw/i386: make x86.c independent from PCMachineState)
WARNING: line over 80 characters
#176: FILE: hw/i386/x86.c:172:
+        ms->possible_cpus->cpus[i].arch_id = x86_cpu_apic_id_from_index(x86ms, i);

total: 0 errors, 1 warnings, 217 lines checked

Patch 5/10 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
6/10 Checking commit 5e6a3a1d589a (fw_cfg: add "modify" functions for all types)
7/10 Checking commit de7727755ee9 (hw/intc/apic: reject pic ints if isa_pic == NULL)
8/10 Checking commit 5d497ed4b132 (roms: add microvm-bios (qboot) as binary and git submodule)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#29: 
new file mode 100755

total: 0 errors, 1 warnings, 28 lines checked

Patch 8/10 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
9/10 Checking commit e5bff45525b6 (docs/microvm.rst: document the new microvm machine type)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#13: 
new file mode 100644

total: 0 errors, 1 warnings, 98 lines checked

Patch 9/10 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
10/10 Checking commit 7b4ed4bfb853 (hw/i386: Introduce the microvm machine type)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#55: 
new file mode 100644

total: 0 errors, 1 warnings, 678 lines checked

Patch 10/10 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20191002113103.45023-1-slp@redhat.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com