diff options
author | William Henderson <william.henderson@nutanix.com> | 2023-08-04 11:17:31 +0000 |
---|---|---|
committer | John Levon <john.levon@nutanix.com> | 2023-09-15 12:59:39 +0100 |
commit | e00dc35f5da630282f9bafb169270e703977a248 (patch) | |
tree | b2a5d73d0859bb1d7cf58f9ea8cc87c24620e6bf | |
parent | 5002b8a08501942e34c0176ebc1f2238c2d7c49f (diff) | |
download | libvfio-user-e00dc35f5da630282f9bafb169270e703977a248.zip libvfio-user-e00dc35f5da630282f9bafb169270e703977a248.tar.gz libvfio-user-e00dc35f5da630282f9bafb169270e703977a248.tar.bz2 |
fix: make state transitions idempotent
Signed-off-by: William Henderson <william.henderson@nutanix.com>
-rw-r--r-- | lib/migration.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/migration.c b/lib/migration.c index 8abe6c2..e0cecfe 100644 --- a/lib/migration.c +++ b/lib/migration.c @@ -217,9 +217,9 @@ migration_feature_set(vfu_ctx_t *vfu_ctx, uint32_t feature, void *buf) struct vfio_user_device_feature_mig_state *res = buf; struct migration *migr = vfu_ctx->migration; uint32_t state; - ssize_t ret; + ssize_t ret = 0; - do { + while (migr->state != res->device_state && ret == 0) { state = next_state[migr->state][res->device_state]; if (state == VFIO_USER_DEVICE_STATE_ERROR) { @@ -227,7 +227,7 @@ migration_feature_set(vfu_ctx_t *vfu_ctx, uint32_t feature, void *buf) } ret = handle_device_state(vfu_ctx, migr, state, true); - } while (migr->state != res->device_state && ret == 0); + }; return ret; } |