During switchover there is a period during which both source and destination side VMs are paused. During this period, all network packets are still routed to the source side, but it will never process them. Once the destination resumes, it is not aware of these packets and they are lost. This can cause packet loss in unreliable protocols and extended delays due to retransmission in reliable protocols.
This series resolves this problem by caching packets received once the source VM pauses and then passing and injecting them on the destination side. This feature is implemented in the last patch. The caching and injecting is implemented using network filter interface and should work with any backend with vhost=off, but only TAP network backend was explicitly tested. This series also introduces an RP_VM_STARTED message on the return-path channel, which is used to correctly calculate downtime for both precopy and postcopy, and also as a trigger for netpass to forward packets to the destination. With more data sent through the migration channel after the destination VM starts, using RP_SHUT wouldn't be accurate anymore, and in postcopy the downtime calculation was always incorrect. As netpass requires return-path capability, its capability is also off by default, but I am open for discussion about making it on by default, as long as return-path is enabled (i.e. enabling return-path would also enable netpass unless it is explicitly disabled). Juraj Marcin (4): migration/qemu-file: Add ability to clear error migration: Introduce VM_STARTED return-path message migration: Convert VMSD early_setup into VMStateSavePhase enum migration: Pass network packets received during switchover to dest VM hw/core/machine.c | 4 +- hw/virtio/virtio-mem.c | 2 +- include/migration/vmstate.h | 33 +++-- include/net/net.h | 5 + migration/meson.build | 1 + migration/migration.c | 83 +++++++++++- migration/migration.h | 11 ++ migration/netpass.c | 246 ++++++++++++++++++++++++++++++++++++ migration/netpass.h | 14 ++ migration/options.c | 29 +++++ migration/options.h | 2 + migration/qemu-file.c | 6 + migration/qemu-file.h | 1 + migration/savevm.c | 44 ++++++- migration/savevm.h | 2 + migration/trace-events | 9 ++ net/net.c | 11 ++ net/tap.c | 11 +- qapi/migration.json | 7 +- 19 files changed, 501 insertions(+), 20 deletions(-) create mode 100644 migration/netpass.c create mode 100644 migration/netpass.h -- 2.52.0
