diff options
author | Thanos Makatos <thanos.makatos@nutanix.com> | 2021-01-26 14:35:07 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-26 14:35:07 +0000 |
commit | ae3aa60d6676f656f80dc293644f681bdbac5eb6 (patch) | |
tree | ded95e34d3442c6191ac01e532b6d5902f8b2098 /lib/migration.c | |
parent | 4cb7d591301bc082f8f6414b1a8e7957c72971a6 (diff) | |
download | libvfio-user-ae3aa60d6676f656f80dc293644f681bdbac5eb6.zip libvfio-user-ae3aa60d6676f656f80dc293644f681bdbac5eb6.tar.gz libvfio-user-ae3aa60d6676f656f80dc293644f681bdbac5eb6.tar.bz2 |
don't return wrong data_offset in resuming state (#253)
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'lib/migration.c')
-rw-r--r-- | lib/migration.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/lib/migration.c b/lib/migration.c index a27245d..f4e6931 100644 --- a/lib/migration.c +++ b/lib/migration.c @@ -343,28 +343,24 @@ handle_data_offset(vfu_ctx_t *vfu_ctx, struct migration *migr, case VFIO_DEVICE_STATE_SAVING: case VFIO_DEVICE_STATE_RUNNING | VFIO_DEVICE_STATE_SAVING: ret = handle_data_offset_when_saving(vfu_ctx, migr, is_write); - break; + if (ret == 0 && !is_write) { + *offset = migr->iter.offset + sizeof(struct vfio_device_migration_info); + } + return ret; case VFIO_DEVICE_STATE_RESUMING: if (is_write) { vfu_log(vfu_ctx, LOG_ERR, "bad write to migration data_offset"); - ret = -EINVAL; + return -EINVAL; } else { - ret = 0; + *offset = migr->info.data_offset + sizeof(struct vfio_device_migration_info); + return 0; } - break; - default: - /* TODO improve error message */ - vfu_log(vfu_ctx, LOG_ERR, - "bad access to migration data_offset in state %d", - migr->info.device_state); - ret = -EINVAL; - } - - if (ret == 0 && !is_write) { - *offset = migr->iter.offset + sizeof(struct vfio_device_migration_info); } - - return ret; + /* TODO improve error message */ + vfu_log(vfu_ctx, LOG_ERR, + "bad access to migration data_offset in state %s", + migr_states[migr->info.device_state].name); + return -EINVAL; } static ssize_t |