Skip to content

Commit 6533956

Browse files
committed
qemu: add option microvm.qemu.machine to opt back for q35
1 parent 1b26257 commit 6533956

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
Generator** instead of KVM.
1010
* **SSH deployment scripts** are added as
1111
`config.microvm.deploy.rebuild`
12-
* **qemu** gets rid of the *q35* machine model entirely as the
13-
*microvm* model supports PCI, USB, and ACPI by now.
12+
* **qemu** defaults to the *microvm* machine model now as it supports
13+
PCI, USB, and ACPI by now. Set `microvm.qemu.machine = "q35"` if
14+
this breaks for you.
1415
* The NixOS **hardened** profile can be used by falling back to
1516
*squashfs*.
1617
* Runners execute the hypervisor with a process name of

lib/runners/qemu.nix

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ let
3939
pkgs.qemu_kvm else pkgs.buildPackages.qemu_full);
4040

4141
inherit (microvmConfig) hostName cpu vcpu mem balloonMem user interfaces shares socket forwardPorts devices vsock graphics storeOnDisk kernel initrdPath storeDisk;
42-
inherit (microvmConfig.qemu) extraArgs serialConsole;
42+
inherit (microvmConfig.qemu) machine extraArgs serialConsole;
4343

4444
inherit (import ../. { nixpkgs-lib = pkgs.lib; }) withDriveLetters;
4545

@@ -75,18 +75,22 @@ let
7575
shares != [] ||
7676
pciInDevices;
7777

78-
machine = {
79-
x86_64-linux = builtins.concatStringsSep "," [
80-
"microvm"
78+
machineConfig = builtins.concatStringsSep "," {
79+
x86_64-linux = [
80+
machine
8181
accel
8282
"mem-merge=on"
83+
"acpi=on"
84+
] ++ lib.optionals (machine == "microvm") [
8385
"pit=off"
8486
"pic=off"
85-
"acpi=on"
8687
"pcie=${if requirePci then "on" else "off"}"
8788
"usb=${if requireUsb then "on" else "off"}"
8889
];
89-
aarch64-linux = "virt,gic-version=max,${accel}";
90+
aarch64-linux = [
91+
"virt"
92+
"gic-version=max,${accel}"
93+
];
9094
}.${system};
9195

9296
devType =
@@ -139,7 +143,7 @@ in {
139143
[
140144
"${qemu}/bin/qemu-system-${arch}"
141145
"-name" hostName
142-
"-M" machine
146+
"-M" machineConfig
143147
"-m" (toString (mem + balloonMem))
144148
"-smp" (toString vcpu)
145149
"-nodefaults" "-no-user-config"

nixos-modules/microvm/options.nix

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ config, options, lib, ... }:
1+
{ config, options, lib, pkgs, ... }:
22
let
33
self-lib = import ../../lib {
44
nixpkgs-lib = lib;
@@ -393,6 +393,19 @@ in
393393
'';
394394
};
395395

396+
qemu.machine = mkOption {
397+
type = types.str;
398+
default = {
399+
x86_64-linux = "microvm";
400+
aarch64-linux = "virt";
401+
}.${pkgs.system};
402+
description = ''
403+
QEMU machine model, eg. `microvm`, or `q35`
404+
405+
Get a full list with `qemu-system-x86_64 -M help`
406+
'';
407+
};
408+
396409
qemu.extraArgs = mkOption {
397410
type = with types; listOf str;
398411
default = [];

0 commit comments

Comments
 (0)