1{ pkgs, lib, ... }:
2{
3 name = "kexec";
4 meta = with lib.maintainers; {
5 maintainers = [
6 flokli
7 lassulus
8 ];
9 };
10
11 nodes = {
12 node1 =
13 { ... }:
14 {
15 virtualisation.vlans = [ ];
16 virtualisation.memorySize = 4 * 1024;
17 };
18
19 node2 =
20 { modulesPath, ... }:
21 {
22 virtualisation.vlans = [ ];
23 environment.systemPackages = [ pkgs.hello ];
24 imports = [
25 "${modulesPath}/installer/netboot/netboot-minimal.nix"
26 "${modulesPath}/testing/test-instrumentation.nix"
27 "${modulesPath}/profiles/qemu-guest.nix"
28 ];
29 };
30 };
31
32 testScript =
33 { nodes, ... }:
34 ''
35 # Test whether reboot via kexec works.
36 node1.wait_for_unit("multi-user.target")
37 node1.succeed('kexec --load /run/current-system/kernel --initrd /run/current-system/initrd --command-line "$(</proc/cmdline)"')
38 node1.execute("systemctl kexec >&2 &", check_return=False)
39 node1.connected = False
40 node1.connect()
41 node1.wait_for_unit("multi-user.target")
42
43 # Check if the machine with netboot-minimal.nix profile boots up
44 node2.wait_for_unit("multi-user.target")
45 node2.shutdown()
46
47 # Kexec node1 to the toplevel of node2 via the kexec-boot script
48 node1.succeed('touch /run/foo')
49 node1.fail('hello')
50 node1.execute('${nodes.node2.system.build.kexecTree}/kexec-boot', check_output=False)
51 node1.connected = False
52 node1.connect()
53 node1.wait_for_unit("multi-user.target")
54 node1.succeed('! test -e /run/foo')
55 node1.succeed('hello')
56 node1.succeed('[ "$(hostname)" = "node2" ]')
57
58 node1.shutdown()
59 '';
60}