summary refs log tree commit diff
path: root/nixos/modules/virtualisation/qemu-vm.nix
diff options
context:
space:
mode:
authorGraham Christensen <graham@tumblr.com>2017-04-10 10:50:05 -0400
committerGraham Christensen <graham@tumblr.com>2017-04-24 15:23:46 -0400
commit4585fdb9d462d8f91ca819f7c0b398cfc47745db (patch)
treeec8f20f2747702bbbe994f740bd5e8c7cf020708 /nixos/modules/virtualisation/qemu-vm.nix
parent91ad6b35970b1378ac99de209b4ec48318704b07 (diff)
downloadnixlib-4585fdb9d462d8f91ca819f7c0b398cfc47745db.tar
nixlib-4585fdb9d462d8f91ca819f7c0b398cfc47745db.tar.gz
nixlib-4585fdb9d462d8f91ca819f7c0b398cfc47745db.tar.bz2
nixlib-4585fdb9d462d8f91ca819f7c0b398cfc47745db.tar.lz
nixlib-4585fdb9d462d8f91ca819f7c0b398cfc47745db.tar.xz
nixlib-4585fdb9d462d8f91ca819f7c0b398cfc47745db.tar.zst
nixlib-4585fdb9d462d8f91ca819f7c0b398cfc47745db.zip
qemu module: add virtualisation.cores option
QEMU can allow guests to access more than one host core at a time.
Previously, this had to be done via ad-hoc arguments:

    virtualisation.qemu.options = ["-smp 12"];

Now you can simply specify:

    virtualisation.cores = 12;
Diffstat (limited to 'nixos/modules/virtualisation/qemu-vm.nix')
-rw-r--r--nixos/modules/virtualisation/qemu-vm.nix13
1 files changed, 13 insertions, 0 deletions
diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix
index 1933f11d1fff..c75edfcd8cf6 100644
--- a/nixos/modules/virtualisation/qemu-vm.nix
+++ b/nixos/modules/virtualisation/qemu-vm.nix
@@ -75,6 +75,7 @@ let
       exec ${qemu}/bin/qemu-kvm \
           -name ${vmName} \
           -m ${toString config.virtualisation.memorySize} \
+          -smp ${toString config.virtualisation.cores} \
           ${optionalString (pkgs.stdenv.system == "x86_64-linux") "-cpu kvm64"} \
           ${concatStringsSep " " config.virtualisation.qemu.networkingOptions} \
           -virtfs local,path=/nix/store,security_model=none,mount_tag=store \
@@ -244,6 +245,18 @@ in
           '';
       };
 
+    virtualisation.cores =
+      mkOption {
+        default = 1;
+        type = types.int;
+        description =
+          ''
+            Specify the number of cores the guest is permitted to use.
+            The number can be higher than the available cores on the
+            host system.
+          '';
+      };
+
     virtualisation.pathsInNixDB =
       mkOption {
         default = [];