From 5ee64f8fbf04bf73ebe0abe28bdf45096edcb0e8 Mon Sep 17 00:00:00 2001 From: Astro Date: Sat, 10 Apr 2021 21:59:14 +0200 Subject: [PATCH] install and use virtio drivers (virtio disk, qxl vga, virtio net) fixes Gitea issue #7 --- wfvm/autounattend.nix | 16 ++++++++++++++-- wfvm/utils.nix | 3 ++- wfvm/win.nix | 12 ++++++++++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/wfvm/autounattend.nix b/wfvm/autounattend.nix index 6033b21..94bf34a 100644 --- a/wfvm/autounattend.nix +++ b/wfvm/autounattend.nix @@ -124,6 +124,9 @@ let # Windows expects a flat list of users while we want to manage them as a set flatUsers = builtins.attrValues (builtins.mapAttrs (name: s: s // { inherit name; }) users); + diskId = + if efi then 2 else 1; + autounattendXML = pkgs.writeText "autounattend.xml" '' @@ -136,6 +139,15 @@ let E:\ + + C:\virtio\amd64\w10 + + + C:\virtio\NetKVM\w10\amd64 + + + C:\virtio\qxldod\w10\amd64 + @@ -178,7 +190,7 @@ let 3 - 0 + ${toString diskId} true @@ -186,7 +198,7 @@ let - 0 + ${toString diskId} 3 diff --git a/wfvm/utils.nix b/wfvm/utils.nix index de605ac..42866b5 100644 --- a/wfvm/utils.nix +++ b/wfvm/utils.nix @@ -10,9 +10,10 @@ rec { "-smp ${cores}" "-m ${qemuMem}" "-M q35" + "-vga qxl" "-rtc base=${baseRtc}" "-device qemu-xhci" - "-device e1000,netdev=n1" + "-device virtio-net-pci,netdev=n1" ] ++ pkgs.lib.optionals efi [ "-bios ${pkgs.OVMF.fd}/FV/OVMF.fd" ] ++ extraFlags; diff --git a/wfvm/win.nix b/wfvm/win.nix index 9ee442b..5dab9ba 100644 --- a/wfvm/win.nix +++ b/wfvm/win.nix @@ -41,6 +41,12 @@ let sha256 = "668fe1af70c2f7416328aee3a0bb066b12dc6bbd2576f40f812b95741e18bc3a"; }; + # stable as of 2021-04-08 + virtioWinIso = pkgs.fetchurl { + url = "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.185-2/virtio-win-0.1.185.iso"; + sha256 = "11n3kjyawiwacmi3jmfmn311g9xvfn6m0ccdwnjxw1brzb4kqaxg"; + }; + openSshServerPackage = ./openssh/server-package.cab; autounattend = import ./autounattend.nix ( @@ -65,6 +71,8 @@ let runQemuCommand "bootstrap-win-pkgs.img" '' mkdir -p pkgs/fod + 7z x -y ${virtioWinIso} -opkgs/virtio + cp ${bundleInstaller} pkgs/"$(stripHash "${bundleInstaller}")" # Install optional windows features @@ -91,7 +99,7 @@ let "usb-storage,drive=win-install" # Output image "-drive" - "file=c.img,index=0,media=disk,cache=unsafe" + "file=c.img,index=0,media=disk,if=virtio,cache=unsafe" # Network "-netdev user,id=n1,net=192.168.1.0/24,restrict=on" ]); @@ -152,7 +160,7 @@ let qemuParams = utils.mkQemuFlags (lib.optional (!impureMode) "-display none" ++ [ # Output image "-drive" - "file=c.img,index=0,media=disk,cache=unsafe" + "file=c.img,index=0,media=disk,if=virtio,cache=unsafe" # Network - enable SSH forwarding "-netdev user,id=n1,net=192.168.1.0/24,restrict=on,hostfwd=tcp::2022-:22" ]); -- 2.42.0