Skip to content

Commit

Permalink
qemu: add option microvm.qemu.machine to opt back for q35
Browse files Browse the repository at this point in the history
  • Loading branch information
astro committed Mar 19, 2024
1 parent 0e2223d commit 45b22ec
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
18 changes: 11 additions & 7 deletions lib/runners/qemu.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let
pkgs.qemu_kvm else pkgs.buildPackages.qemu_full);

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

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

Expand Down Expand Up @@ -75,18 +75,22 @@ let
shares != [] ||
pciInDevices;

machine = {
x86_64-linux = builtins.concatStringsSep "," [
"microvm"
machineConfig = builtins.concatStringsSep "," {
x86_64-linux = [
machine
accel
"mem-merge=on"
"acpi=on"
] ++ lib.optionals (machine == "microvm") [
"pit=off"
"pic=off"
"acpi=on"
"pcie=${if requirePci then "on" else "off"}"
"usb=${if requireUsb then "on" else "off"}"
];
aarch64-linux = "virt,gic-version=max,${accel}";
aarch64-linux = [
"virt"
"gic-version=max,${accel}"
];
}.${system};

devType =
Expand Down Expand Up @@ -139,7 +143,7 @@ in {
[
"${qemu}/bin/qemu-system-${arch}"
"-name" hostName
"-M" machine
"-M" machineConfig
"-m" (toString (mem + balloonMem))
"-smp" (toString vcpu)
"-nodefaults" "-no-user-config"
Expand Down
15 changes: 14 additions & 1 deletion nixos-modules/microvm/options.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, options, lib, ... }:
{ config, options, lib, pkgs, ... }:
let
self-lib = import ../../lib {
nixpkgs-lib = lib;
Expand Down Expand Up @@ -393,6 +393,19 @@ in
'';
};

qemu.machine = mkOption {
type = types.str;
default = {
x86_64-linux = "microvm";
aarch64-linux = "virt";
}.${pkgs.system};
description = ''
QEMU machine model, eg. `microvm`, or `q35`
Get a full list with `qemu-system-x86_64 -M help`
'';
};

qemu.extraArgs = mkOption {
type = with types; listOf str;
default = [];
Expand Down

0 comments on commit 45b22ec

Please sign in to comment.