From b52bff72d4eb646a453d19e19ddbd13ed6111a09 Mon Sep 17 00:00:00 2001 From: Jag Raman Date: Mon, 23 May 2022 08:15:47 -0400 Subject: libvfio-user.h: sync VFIO_DEVICE_STATE_XXXX definitions with upstream (#690) Rename VFIO_DEVICE_STATE_XXXX defines as VFIO_DEVICE_STATE_V1_XXXX. Upstream renamed these variable to be of the XXXX_V1_XXXX format and switched an enum for VFIO_DEVICE_STATE_XXXX. Signed-off-by: Jagannathan Raman Reviewed-by: John Levon Reviewed-by: Thanos Makatos --- lib/libvfio-user.c | 2 +- lib/migration.c | 28 ++++++++++++++-------------- lib/migration_priv.h | 50 +++++++++++++++++++++++++------------------------- 3 files changed, 40 insertions(+), 40 deletions(-) (limited to 'lib') diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c index fd2465d..a666316 100644 --- a/lib/libvfio-user.c +++ b/lib/libvfio-user.c @@ -861,7 +861,7 @@ do_device_reset(vfu_ctx_t *vfu_ctx, vfu_reset_type_t reason) } if (vfu_ctx->migration != NULL) { return handle_device_state(vfu_ctx, vfu_ctx->migration, - VFIO_DEVICE_STATE_RUNNING, false); + VFIO_DEVICE_STATE_V1_RUNNING, false); } return 0; } diff --git a/lib/migration.c b/lib/migration.c index fc5bb39..2936768 100644 --- a/lib/migration.c +++ b/lib/migration.c @@ -81,7 +81,7 @@ init_migration(const vfu_migration_callbacks_t * callbacks, migr->pgsize = sysconf(_SC_PAGESIZE); /* FIXME this should be done in vfu_ctx_realize */ - migr->info.device_state = VFIO_DEVICE_STATE_RUNNING; + migr->info.device_state = VFIO_DEVICE_STATE_V1_RUNNING; migr->data_offset = data_offset; migr->callbacks = *callbacks; @@ -111,11 +111,11 @@ vfu_migr_state_t MOCK_DEFINE(migr_state_vfio_to_vfu)(uint32_t device_state) { switch (device_state) { - case VFIO_DEVICE_STATE_STOP: + case VFIO_DEVICE_STATE_V1_STOP: return VFU_MIGR_STATE_STOP; - case VFIO_DEVICE_STATE_RUNNING: + case VFIO_DEVICE_STATE_V1_RUNNING: return VFU_MIGR_STATE_RUNNING; - case VFIO_DEVICE_STATE_SAVING: + case VFIO_DEVICE_STATE_V1_SAVING: /* * FIXME How should the device operate during the stop-and-copy * phase? Should we only allow the migration data to be read from @@ -123,9 +123,9 @@ MOCK_DEFINE(migr_state_vfio_to_vfu)(uint32_t device_state) * failed? This might be a good question to send to LKML. */ return VFU_MIGR_STATE_STOP_AND_COPY; - case VFIO_DEVICE_STATE_RUNNING | VFIO_DEVICE_STATE_SAVING: + case VFIO_DEVICE_STATE_V1_RUNNING | VFIO_DEVICE_STATE_V1_SAVING: return VFU_MIGR_STATE_PRE_COPY; - case VFIO_DEVICE_STATE_RESUMING: + case VFIO_DEVICE_STATE_V1_RESUMING: return VFU_MIGR_STATE_RESUME; } return -1; @@ -301,14 +301,14 @@ handle_data_offset(vfu_ctx_t *vfu_ctx, struct migration *migr, assert(offset != NULL); switch (migr->info.device_state) { - case VFIO_DEVICE_STATE_SAVING: - case VFIO_DEVICE_STATE_RUNNING | VFIO_DEVICE_STATE_SAVING: + case VFIO_DEVICE_STATE_V1_SAVING: + case VFIO_DEVICE_STATE_V1_RUNNING | VFIO_DEVICE_STATE_V1_SAVING: ret = handle_data_offset_when_saving(vfu_ctx, migr, is_write); if (ret == 0 && !is_write) { *offset = migr->iter.offset + migr->data_offset; } return ret; - case VFIO_DEVICE_STATE_RESUMING: + case VFIO_DEVICE_STATE_V1_RESUMING: if (is_write) { /* TODO writing to read-only registers should be simply ignored */ vfu_log(vfu_ctx, LOG_ERR, "bad write to migration data_offset"); @@ -380,14 +380,14 @@ handle_data_size(vfu_ctx_t *vfu_ctx, struct migration *migr, assert(size != NULL); switch (migr->info.device_state){ - case VFIO_DEVICE_STATE_SAVING: - case VFIO_DEVICE_STATE_RUNNING | VFIO_DEVICE_STATE_SAVING: + case VFIO_DEVICE_STATE_V1_SAVING: + case VFIO_DEVICE_STATE_V1_RUNNING | VFIO_DEVICE_STATE_V1_SAVING: ret = handle_data_size_when_saving(vfu_ctx, migr, is_write); if (ret == 0 && !is_write) { *size = migr->iter.size; } return ret; - case VFIO_DEVICE_STATE_RESUMING: + case VFIO_DEVICE_STATE_V1_RESUMING: return handle_data_size_when_resuming(vfu_ctx, migr, *size, is_write); } /* TODO improve error message */ @@ -535,13 +535,13 @@ migration_region_access(vfu_ctx_t *vfu_ctx, char *buf, size_t count, bool MOCK_DEFINE(device_is_stopped_and_copying)(struct migration *migr) { - return migr != NULL && migr->info.device_state == VFIO_DEVICE_STATE_SAVING; + return migr != NULL && migr->info.device_state == VFIO_DEVICE_STATE_V1_SAVING; } bool MOCK_DEFINE(device_is_stopped)(struct migration *migr) { - return migr != NULL && migr->info.device_state == VFIO_DEVICE_STATE_STOP; + return migr != NULL && migr->info.device_state == VFIO_DEVICE_STATE_V1_STOP; } size_t diff --git a/lib/migration_priv.h b/lib/migration_priv.h index bf7c7b0..d5643af 100644 --- a/lib/migration_priv.h +++ b/lib/migration_priv.h @@ -70,47 +70,47 @@ struct migr_state_data { const char *name; }; -#define VFIO_DEVICE_STATE_ERROR (VFIO_DEVICE_STATE_SAVING | VFIO_DEVICE_STATE_RESUMING) +#define VFIO_DEVICE_STATE_V1_ERROR (VFIO_DEVICE_STATE_V1_SAVING | VFIO_DEVICE_STATE_V1_RESUMING) /* valid migration state transitions */ static const struct migr_state_data migr_states[(VFIO_DEVICE_STATE_MASK + 1)] = { - [VFIO_DEVICE_STATE_STOP] = { + [VFIO_DEVICE_STATE_V1_STOP] = { .state = - (1 << VFIO_DEVICE_STATE_STOP) | - (1 << VFIO_DEVICE_STATE_RUNNING), + (1 << VFIO_DEVICE_STATE_V1_STOP) | + (1 << VFIO_DEVICE_STATE_V1_RUNNING), .name = "stopped" }, - [VFIO_DEVICE_STATE_RUNNING] = { + [VFIO_DEVICE_STATE_V1_RUNNING] = { .state = - (1 << VFIO_DEVICE_STATE_STOP) | - (1 << VFIO_DEVICE_STATE_RUNNING) | - (1 << VFIO_DEVICE_STATE_SAVING) | - (1 << (VFIO_DEVICE_STATE_RUNNING | VFIO_DEVICE_STATE_SAVING)) | - (1 << VFIO_DEVICE_STATE_RESUMING) | - (1 << VFIO_DEVICE_STATE_ERROR), + (1 << VFIO_DEVICE_STATE_V1_STOP) | + (1 << VFIO_DEVICE_STATE_V1_RUNNING) | + (1 << VFIO_DEVICE_STATE_V1_SAVING) | + (1 << (VFIO_DEVICE_STATE_V1_RUNNING | VFIO_DEVICE_STATE_V1_SAVING)) | + (1 << VFIO_DEVICE_STATE_V1_RESUMING) | + (1 << VFIO_DEVICE_STATE_V1_ERROR), .name = "running" }, - [VFIO_DEVICE_STATE_SAVING] = { + [VFIO_DEVICE_STATE_V1_SAVING] = { .state = - (1 << VFIO_DEVICE_STATE_STOP) | - (1 << VFIO_DEVICE_STATE_RUNNING) | - (1 << VFIO_DEVICE_STATE_SAVING) | - (1 << VFIO_DEVICE_STATE_ERROR), + (1 << VFIO_DEVICE_STATE_V1_STOP) | + (1 << VFIO_DEVICE_STATE_V1_RUNNING) | + (1 << VFIO_DEVICE_STATE_V1_SAVING) | + (1 << VFIO_DEVICE_STATE_V1_ERROR), .name = "stop-and-copy" }, - [VFIO_DEVICE_STATE_RUNNING | VFIO_DEVICE_STATE_SAVING] = { + [VFIO_DEVICE_STATE_V1_RUNNING | VFIO_DEVICE_STATE_V1_SAVING] = { .state = - (1 << VFIO_DEVICE_STATE_STOP) | - (1 << VFIO_DEVICE_STATE_SAVING) | - (1 << VFIO_DEVICE_STATE_RUNNING | VFIO_DEVICE_STATE_SAVING) | - (1 << VFIO_DEVICE_STATE_ERROR), + (1 << VFIO_DEVICE_STATE_V1_STOP) | + (1 << VFIO_DEVICE_STATE_V1_SAVING) | + (1 << VFIO_DEVICE_STATE_V1_RUNNING | VFIO_DEVICE_STATE_V1_SAVING) | + (1 << VFIO_DEVICE_STATE_V1_ERROR), .name = "pre-copy" }, - [VFIO_DEVICE_STATE_RESUMING] = { + [VFIO_DEVICE_STATE_V1_RESUMING] = { .state = - (1 << VFIO_DEVICE_STATE_RUNNING) | - (1 << VFIO_DEVICE_STATE_RESUMING) | - (1 << VFIO_DEVICE_STATE_ERROR), + (1 << VFIO_DEVICE_STATE_V1_RUNNING) | + (1 << VFIO_DEVICE_STATE_V1_RESUMING) | + (1 << VFIO_DEVICE_STATE_V1_ERROR), .name = "resuming" } }; -- cgit v1.1