diff --git a/chv.nix b/chv.nix index f266595..9e5f69b 100644 --- a/chv.nix +++ b/chv.nix @@ -14,9 +14,16 @@ let # Crane lib with proper Rust toolchain craneLib' = craneLib.overrideToolchain rustToolchain; + jsonFilter = path: _type: builtins.match ".*json$" path != null; + sourceFilter = path: type: (jsonFilter path type) || (craneLib.filterCargoSources path type); + commonArgs = let - src = craneLib'.cleanCargoSource cloud-hypervisor-src; + src = lib.cleanSourceWith { + src = cloud-hypervisor-src; + filter = sourceFilter; + name = "source"; + }; in { inherit src; diff --git a/flake.lock b/flake.lock index 1b0721a..6cd361e 100644 --- a/flake.lock +++ b/flake.lock @@ -3,16 +3,16 @@ "cloud-hypervisor-src": { "flake": false, "locked": { - "lastModified": 1768228722, - "narHash": "sha256-FKhFxeCULCsirfH9W/lQtHOWOxpcMOY5a8sfyEB++m0=", - "owner": "cyberus-technology", + "lastModified": 1768575885, + "narHash": "sha256-r8aeWxuofPQprvHQjwey6aQxspm2GNPAfomqXeMFtNw=", + "owner": "amphi", "repo": "cloud-hypervisor", - "rev": "75efbe171ae8de4e8724b2c83d0754e7aaf04efe", + "rev": "f2e10ba3884de1149d80b2cc27e132f7fcea48a9", "type": "github" }, "original": { - "owner": "cyberus-technology", - "ref": "gardenlinux", + "owner": "amphi", + "ref": "migration-rarp", "repo": "cloud-hypervisor", "type": "github" } diff --git a/flake.nix b/flake.nix index c2a335b..865459c 100644 --- a/flake.nix +++ b/flake.nix @@ -15,7 +15,7 @@ }; cloud-hypervisor-src = { # url = "git+file:"; - url = "github:cyberus-technology/cloud-hypervisor?ref=gardenlinux"; + url = "github:amphi/cloud-hypervisor?ref=migration-rarp"; flake = false; }; edk2-src = { diff --git a/tests/testscript.py b/tests/testscript.py index 6564df3..00efd81 100644 --- a/tests/testscript.py +++ b/tests/testscript.py @@ -494,6 +494,9 @@ def test_live_migration(self): want to test. We also hot-attach some devices before migrating, in order to cover proper migration of those devices. + + This test also checks that the destination host sends out RARP packets + to announce its new location to the network. """ controllerVM.succeed("virsh define /etc/domain-chv.xml") @@ -509,16 +512,42 @@ def test_live_migration(self): "virsh attach-disk --domain testvm --target vdb --persistent --source /var/lib/libvirt/storage-pools/nfs-share/disk.img", ) - for i in range(2): + # We use tcpdump and tshark to check for the RARP packets. + def start_capture(machine): + machine.succeed( + "systemd-run --unit tcpdump-mig -- bash -lc 'tcpdump -i any -w /tmp/rarp.pcap \"ether proto 0x8035\" 2> /tmp/rarp.log'" + ) + machine.wait_until_succeeds("grep -q 'listening on any' /tmp/rarp.log") + + def stop_capture_and_count_packets(machine): + machine.succeed("systemctl stop tcpdump-mig") + rarps = ( + machine.succeed( + 'tshark -r /tmp/rarp.pcap -Y "sll.etype == 0x8035" -T fields -e sll.src.eth' + ) + .strip() + .split("\n") + ) + + # We only check whether we got rarp packets for both NICs, by + # looking at the source MAC addresses. + self.assertEqual(len(set(rarps)), 2) + + for _ in range(2): + start_capture(computeVM) # Explicitly use IP in desturi as this was already a problem in the past controllerVM.succeed( "virsh migrate --domain testvm --desturi ch+tcp://192.168.100.2/session --persistent --live --p2p" ) wait_for_ssh(computeVM) + stop_capture_and_count_packets(computeVM) + + start_capture(controllerVM) computeVM.succeed( "virsh migrate --domain testvm --desturi ch+tcp://controllerVM/session --persistent --live --p2p" ) wait_for_ssh(controllerVM) + stop_capture_and_count_packets(controllerVM) def test_live_migration_with_hotplug(self): """