From: Andrey Drobyshev <[email protected]> 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]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Message-ID: <[email protected]> --- hw/virtio/vhost-vsock.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 503d248a61..c582ac9fcc 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -20,6 +20,7 @@ #include "hw/core/qdev-properties.h" #include "hw/virtio/vhost-vsock.h" #include "monitor/monitor.h" +#include "migration/cpr.h" #include "migration/blocker.h" #include "migration/misc.h" @@ -110,6 +111,20 @@ 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) +{ + /* + * Only reset vsock connections for non-CPR migration. For CPR the + * guest cid is unchanged, and the cid-change reset would otherwise + * tear the vsock connections down. + */ + if (!cpr_is_incoming()) { + return vhost_vsock_common_post_load(opaque, version_id); + } + + return 0; +} + static const VMStateDescription vmstate_virtio_vhost_vsock = { .name = "virtio-vhost_vsock", .minimum_version_id = VHOST_VSOCK_SAVEVM_VERSION, @@ -119,7 +134,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) -- MST
