at 23.11-pre 2.6 kB view raw
1import ./make-test-python.nix ({ pkgs, ... }: { 2 name = "libvirtd"; 3 meta.maintainers = with pkgs.lib.maintainers; [ fpletz ]; 4 5 nodes = { 6 virthost = 7 { pkgs, ... }: 8 { 9 virtualisation = { 10 cores = 2; 11 memorySize = 2048; 12 13 libvirtd.enable = true; 14 }; 15 boot.supportedFilesystems = [ "zfs" ]; 16 networking.hostId = "deadbeef"; # needed for zfs 17 networking.nameservers = [ "192.168.122.1" ]; 18 security.polkit.enable = true; 19 environment.systemPackages = with pkgs; [ virt-manager ]; 20 }; 21 }; 22 23 testScript = let 24 nixosInstallISO = (import ../release.nix {}).iso_minimal.${pkgs.stdenv.hostPlatform.system}; 25 virshShutdownCmd = if pkgs.stdenv.isx86_64 then "shutdown" else "destroy"; 26 in '' 27 start_all() 28 29 virthost.wait_for_unit("multi-user.target") 30 31 with subtest("enable default network"): 32 virthost.succeed("virsh net-start default") 33 virthost.succeed("virsh net-autostart default") 34 virthost.succeed("virsh net-info default") 35 36 with subtest("check if partition disk pools works with parted"): 37 virthost.succeed("fallocate -l100m /tmp/foo; losetup /dev/loop0 /tmp/foo; echo 'label: dos' | sfdisk /dev/loop0") 38 virthost.succeed("virsh pool-create-as foo disk --source-dev /dev/loop0 --target /dev") 39 virthost.succeed("virsh vol-create-as foo loop0p1 25MB") 40 virthost.succeed("virsh vol-create-as foo loop0p2 50MB") 41 42 with subtest("check if virsh zfs pools work"): 43 virthost.succeed("fallocate -l100m /tmp/zfs; losetup /dev/loop1 /tmp/zfs;") 44 virthost.succeed("zpool create zfs_loop /dev/loop1") 45 virthost.succeed("virsh pool-define-as --name zfs_storagepool --source-name zfs_loop --type zfs") 46 virthost.succeed("virsh pool-start zfs_storagepool") 47 virthost.succeed("virsh vol-create-as zfs_storagepool disk1 25MB") 48 49 with subtest("check if nixos install iso boots, network and autostart works"): 50 virthost.succeed( 51 "virt-install -n nixos --osinfo nixos-unstable --memory 1024 --graphics none --disk `find ${nixosInstallISO}/iso -type f | head -n1`,readonly=on --import --noautoconsole --autostart" 52 ) 53 virthost.succeed("virsh domstate nixos | grep running") 54 virthost.wait_until_succeeds("ping -c 1 nixos") 55 virthost.succeed("virsh ${virshShutdownCmd} nixos") 56 virthost.wait_until_succeeds("virsh domstate nixos | grep 'shut off'") 57 virthost.shutdown() 58 virthost.wait_for_unit("multi-user.target") 59 virthost.wait_until_succeeds("ping -c 1 nixos") 60 ''; 61})