diff options
author | Thanos Makatos <thanos.makatos@nutanix.com> | 2021-01-26 11:00:26 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-26 11:00:26 +0000 |
commit | 863cef18e7debf782afb6b66ebcb55a5ee139389 (patch) | |
tree | 9743e237a8930fe450a2356a4d93e33c8e29cbfc /lib | |
parent | f2fe9d8e4fc4c5eb80dc61cc243a18087cc12ca3 (diff) | |
download | libvfio-user-863cef18e7debf782afb6b66ebcb55a5ee139389.zip libvfio-user-863cef18e7debf782afb6b66ebcb55a5ee139389.tar.gz libvfio-user-863cef18e7debf782afb6b66ebcb55a5ee139389.tar.bz2 |
introduce function for transitioning vfio-user migration iteration states (#263)
This makes it easier to tell where we change the migration iteration state. In
the future we might also perform additional validations.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/migration.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/migration.c b/lib/migration.c index c4eb6f6..489a6fc 100644 --- a/lib/migration.c +++ b/lib/migration.c @@ -131,6 +131,14 @@ vfio_migr_state_transition_is_valid(__u32 from, __u32 to) return migr_states[from] & (1 << to); } +static void +migr_state_transition(struct migration *migr, enum migr_iter_state state) +{ + assert(migr != NULL); + /* FIXME validate that state transition */ + migr->iter.state = state; +} + static ssize_t handle_device_state(vfu_ctx_t *vfu_ctx, struct migration *migr, __u32 *device_state, bool is_write) { @@ -223,9 +231,9 @@ handle_pending_bytes(vfu_ctx_t *vfu_ctx, struct migration *migr, * iteration? Check https://www.spinics.net/lists/kvm/msg228608.html. */ if (*pending_bytes == 0) { - migr->iter.state = VFIO_USER_MIGR_ITER_STATE_FINISHED; + migr_state_transition(migr, VFIO_USER_MIGR_ITER_STATE_FINISHED); } else { - migr->iter.state = VFIO_USER_MIGR_ITER_STATE_STARTED; + migr_state_transition(migr, VFIO_USER_MIGR_ITER_STATE_STARTED); } break; case VFIO_USER_MIGR_ITER_STATE_STARTED: |