From f2fe9d8e4fc4c5eb80dc61cc243a18087cc12ca3 Mon Sep 17 00:00:00 2001 From: Thanos Makatos Date: Mon, 25 Jan 2021 17:39:35 +0000 Subject: add pre-copy phase in live migration example (#247) This patch adds a simplistic pre-copy phase in the live migration sample. The end goal is have a separate thread in the client to modify device state while the device is in the pre-copy phase. This will be done in later patches. BAR1 is saved during the pre-copy phase and BAR0 is saved during the stop-and-copy phase. This is purely for convenience. There are quite a few assumptions and FIXMEs, even in the client code. We plan to address them in future patches. Signed-off-by: Thanos Makatos --- lib/migration.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/migration.c') diff --git a/lib/migration.c b/lib/migration.c index 31a8d9d..c4eb6f6 100644 --- a/lib/migration.c +++ b/lib/migration.c @@ -450,6 +450,12 @@ migration_region_access(vfu_ctx_t *vfu_ctx, char *buf, size_t count, assert(migr != NULL); assert(buf != NULL); + /* + * FIXME don't call the device callback if the migration state is in not in + * pre-copy/stop-and-copy/resuming state, since the behavior is undefined + * in that case. + */ + if (pos + count <= sizeof(struct vfio_device_migration_info)) { ret = migration_region_access_registers(vfu_ctx, buf, count, pos, is_write); -- cgit v1.1