On 19.06.2026 12:55, Andrey Drobyshev wrote:
Migration target with a vhost-vsock device in the .post_load() hook issues
VIRTIO_VSOCK_EVENT_TRANSPORT_RESET event to the guest. This results into
the guest tearing down all its vsock connections. That reset exists
because after a normal migration the cid may change.
However it's not true for CPR-style migration. In this case cid remains
the same, and we want the connections to persist. Thus, let's customize
the .post_load() hook to skip the common transport reset part in this case.
Signed-off-by: Andrey Drobyshev <[email protected]>
---
hw/virtio/vhost-vsock.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c
index ea9a7d2149d..8b033426296 100644
--- a/hw/virtio/vhost-vsock.c
+++ b/hw/virtio/vhost-vsock.c
@@ -109,6 +109,19 @@ static uint64_t vhost_vsock_get_features(VirtIODevice
*vdev,
return vhost_vsock_common_get_features(vdev, requested_features, errp);
}
+static int vhost_vsock_post_load(void *opaque, int version_id)
+{
+ /*
+ * For CPR the guest cid is unchanged, so don't reset vsock connections
+ * (the cid-change reset would otherwise tear them all down).
+ */
+ if (cpr_is_incoming()) {
+ return 0;
+ }
+
+ return vhost_vsock_common_post_load(opaque, version_id);
+}
+
static const VMStateDescription vmstate_virtio_vhost_vsock = {
.name = "virtio-vhost_vsock",
.minimum_version_id = VHOST_VSOCK_SAVEVM_VERSION,
@@ -118,7 +131,7 @@ static const VMStateDescription vmstate_virtio_vhost_vsock
= {
VMSTATE_END_OF_LIST()
},
.pre_save = vhost_vsock_common_pre_save,
- .post_load = vhost_vsock_common_post_load,
+ .post_load = vhost_vsock_post_load,
};
static void vhost_vsock_device_realize(DeviceState *dev, Error **errp)
Looks okay on the CPR-side but I will defer to vsock reviewers to check if this
is safe from the vhost-vsock side.
Thanks,
Maciej