aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Henderson <william.henderson@nutanix.com>2023-08-01 09:38:48 +0000
committerJohn Levon <john.levon@nutanix.com>2023-09-15 12:59:39 +0100
commit108932d519afd1b91d067f1ef0e237abdcc4e856 (patch)
tree0010bc95b4826054ed822d4c9d6ec57f59bef19d
parentc7210ef1816e68857186cfc43d623b366cb7c5ca (diff)
downloadlibvfio-user-108932d519afd1b91d067f1ef0e237abdcc4e856.zip
libvfio-user-108932d519afd1b91d067f1ef0e237abdcc4e856.tar.gz
libvfio-user-108932d519afd1b91d067f1ef0e237abdcc4e856.tar.bz2
fix: conflict with kernel definitions
Signed-off-by: William Henderson <william.henderson@nutanix.com>
-rw-r--r--include/libvfio-user.h28
-rw-r--r--include/vfio-user.h25
-rw-r--r--lib/libvfio-user.c3
-rw-r--r--lib/migration.c28
-rw-r--r--lib/migration.h2
-rw-r--r--lib/migration_priv.h4
6 files changed, 32 insertions, 58 deletions
diff --git a/include/libvfio-user.h b/include/libvfio-user.h
index e0a452c..bb015c2 100644
--- a/include/libvfio-user.h
+++ b/include/libvfio-user.h
@@ -628,34 +628,6 @@ typedef struct {
} vfu_migration_callbacks_t;
-/**
- * The definition for VFIO_DEVICE_STATE_XXX differs with the version of vfio
- * header file used. Some old systems wouldn't have these definitions. Some
- * other newer systems would be using region based migration, and not
- * have VFIO_DEVICE_STATE_V1_XXXX defined. The latest ones have
- * VFIO_DEVICE_STATE_V1_XXXX defined. The following addresses all
- * these scenarios.
- */
-#if defined(VFIO_DEVICE_STATE_STOP)
-
-_Static_assert(VFIO_DEVICE_STATE_STOP == 0,
- "incompatible VFIO_DEVICE_STATE_STOP definition");
-
-#define VFIO_DEVICE_STATE_V1_STOP VFIO_DEVICE_STATE_STOP
-#define VFIO_DEVICE_STATE_V1_RUNNING VFIO_DEVICE_STATE_RUNNING
-#define VFIO_DEVICE_STATE_V1_SAVING VFIO_DEVICE_STATE_SAVING
-#define VFIO_DEVICE_STATE_V1_RESUMING VFIO_DEVICE_STATE_RESUMING
-
-#elif !defined(VFIO_REGION_TYPE_MIGRATION_DEPRECATED) /* VFIO_DEVICE_STATE_STOP */
-
-#define VFIO_DEVICE_STATE_V1_STOP (0)
-#define VFIO_DEVICE_STATE_V1_RUNNING (1 << 0)
-#define VFIO_DEVICE_STATE_V1_SAVING (1 << 1)
-#define VFIO_DEVICE_STATE_V1_RESUMING (1 << 2)
-#define VFIO_DEVICE_STATE_MASK ((1 << 3) - 1)
-
-#endif /* VFIO_REGION_TYPE_MIGRATION_DEPRECATED */
-
int
vfu_setup_device_migration_callbacks(vfu_ctx_t *vfu_ctx, uint64_t flags,
const vfu_migration_callbacks_t
diff --git a/include/vfio-user.h b/include/vfio-user.h
index aec5c06..1652a84 100644
--- a/include/vfio-user.h
+++ b/include/vfio-user.h
@@ -225,7 +225,7 @@ struct vfio_user_device_feature_dma_logging_report {
uint8_t bitmap[];
} __attribute__((packed));
-#ifndef VFIO_REGION_TYPE_MIGRATION_DEPRECATED
+#ifndef VFIO_DEVICE_FEATURE_DMA_LOGGING_START
#define VFIO_DEVICE_FEATURE_DMA_LOGGING_START 6
#define VFIO_DEVICE_FEATURE_DMA_LOGGING_STOP 7
#define VFIO_DEVICE_FEATURE_DMA_LOGGING_REPORT 8
@@ -250,6 +250,8 @@ struct vfio_user_device_feature_migration {
#ifndef VFIO_REGION_TYPE_MIGRATION_DEPRECATED
#define VFIO_MIGRATION_STOP_COPY (1 << 0)
#define VFIO_MIGRATION_P2P (1 << 1)
+#endif
+#ifndef VFIO_MIGRATION_PRE_COPY
#define VFIO_MIGRATION_PRE_COPY (1 << 2)
#endif
} __attribute__((packed));
@@ -270,18 +272,17 @@ struct vfio_user_device_feature_mig_state {
_Static_assert(sizeof(struct vfio_user_device_feature_migration) == 8,
"bad vfio_user_device_feature_mig_state size");
-#ifndef VFIO_REGION_TYPE_MIGRATION_DEPRECATED
-enum vfio_device_mig_state {
- VFIO_DEVICE_STATE_ERROR = 0,
- VFIO_DEVICE_STATE_STOP = 1,
- VFIO_DEVICE_STATE_RUNNING = 2,
- VFIO_DEVICE_STATE_STOP_COPY = 3,
- VFIO_DEVICE_STATE_RESUMING = 4,
- VFIO_DEVICE_STATE_RUNNING_P2P = 5,
- VFIO_DEVICE_STATE_PRE_COPY = 6,
- VFIO_DEVICE_STATE_PRE_COPY_P2P = 7,
+/* Analogous to vfio_device_mig_state */
+enum vfio_user_device_mig_state {
+ VFIO_USER_DEVICE_STATE_ERROR = 0,
+ VFIO_USER_DEVICE_STATE_STOP = 1,
+ VFIO_USER_DEVICE_STATE_RUNNING = 2,
+ VFIO_USER_DEVICE_STATE_STOP_COPY = 3,
+ VFIO_USER_DEVICE_STATE_RESUMING = 4,
+ VFIO_USER_DEVICE_STATE_RUNNING_P2P = 5,
+ VFIO_USER_DEVICE_STATE_PRE_COPY = 6,
+ VFIO_USER_DEVICE_STATE_PRE_COPY_P2P = 7,
};
-#endif
struct vfio_user_mig_data {
uint32_t argsz;
diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c
index ec79657..2834456 100644
--- a/lib/libvfio-user.c
+++ b/lib/libvfio-user.c
@@ -901,7 +901,8 @@ device_reset(vfu_ctx_t *vfu_ctx, vfu_reset_type_t reason)
}
if (vfu_ctx->migration != NULL) {
- migr_state_transition(vfu_ctx->migration, VFIO_DEVICE_STATE_RUNNING);
+ migr_state_transition(vfu_ctx->migration,
+ VFIO_USER_DEVICE_STATE_RUNNING);
}
return 0;
}
diff --git a/lib/migration.c b/lib/migration.c
index 2f80ac0..7b55813 100644
--- a/lib/migration.c
+++ b/lib/migration.c
@@ -72,9 +72,9 @@ init_migration(const vfu_migration_callbacks_t *callbacks,
/* FIXME this should be done in vfu_ctx_realize */
if (flags & LIBVFIO_USER_MIG_FLAG_START_RESUMING) {
- migr->state = VFIO_DEVICE_STATE_RESUMING;
+ migr->state = VFIO_USER_DEVICE_STATE_RESUMING;
} else {
- migr->state = VFIO_DEVICE_STATE_RUNNING;
+ migr->state = VFIO_USER_DEVICE_STATE_RUNNING;
}
migr->callbacks = *callbacks;
@@ -91,7 +91,7 @@ init_migration(const vfu_migration_callbacks_t *callbacks,
void
MOCK_DEFINE(migr_state_transition)(struct migration *migr,
- enum vfio_device_mig_state state)
+ enum vfio_user_device_mig_state state)
{
assert(migr != NULL);
/* FIXME validate that state transition */
@@ -99,18 +99,18 @@ MOCK_DEFINE(migr_state_transition)(struct migration *migr,
}
vfu_migr_state_t
-MOCK_DEFINE(migr_state_vfio_to_vfu)(enum vfio_device_mig_state state)
+MOCK_DEFINE(migr_state_vfio_to_vfu)(enum vfio_user_device_mig_state state)
{
switch (state) {
- case VFIO_DEVICE_STATE_STOP:
+ case VFIO_USER_DEVICE_STATE_STOP:
return VFU_MIGR_STATE_STOP;
- case VFIO_DEVICE_STATE_RUNNING:
+ case VFIO_USER_DEVICE_STATE_RUNNING:
return VFU_MIGR_STATE_RUNNING;
- case VFIO_DEVICE_STATE_STOP_COPY:
+ case VFIO_USER_DEVICE_STATE_STOP_COPY:
return VFU_MIGR_STATE_STOP_AND_COPY;
- case VFIO_DEVICE_STATE_RESUMING:
+ case VFIO_USER_DEVICE_STATE_RESUMING:
return VFU_MIGR_STATE_RESUME;
- case VFIO_DEVICE_STATE_PRE_COPY:
+ case VFIO_USER_DEVICE_STATE_PRE_COPY:
return VFU_MIGR_STATE_PRE_COPY;
default:
return -1;
@@ -240,8 +240,8 @@ handle_mig_data_read(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg)
return -EINVAL;
}
- if (migr->state != VFIO_DEVICE_STATE_PRE_COPY
- && migr->state != VFIO_DEVICE_STATE_STOP_COPY) {
+ if (migr->state != VFIO_USER_DEVICE_STATE_PRE_COPY
+ && migr->state != VFIO_USER_DEVICE_STATE_STOP_COPY) {
vfu_log(vfu_ctx, LOG_ERR, "bad migration state to read data: %d",
migr->state);
return -EINVAL;
@@ -287,7 +287,7 @@ handle_mig_data_write(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg)
return -EINVAL;
}
- if (migr->state != VFIO_DEVICE_STATE_RESUMING) {
+ if (migr->state != VFIO_USER_DEVICE_STATE_RESUMING) {
vfu_log(vfu_ctx, LOG_ERR, "bad migration state to write data: %d",
migr->state);
return -EINVAL;
@@ -299,13 +299,13 @@ handle_mig_data_write(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg)
bool
MOCK_DEFINE(device_is_stopped_and_copying)(struct migration *migr)
{
- return migr != NULL && migr->state == VFIO_DEVICE_STATE_STOP_COPY;
+ return migr != NULL && migr->state == VFIO_USER_DEVICE_STATE_STOP_COPY;
}
bool
MOCK_DEFINE(device_is_stopped)(struct migration *migr)
{
- return migr != NULL && migr->state == VFIO_DEVICE_STATE_STOP;
+ return migr != NULL && migr->state == VFIO_USER_DEVICE_STATE_STOP;
}
size_t
diff --git a/lib/migration.h b/lib/migration.h
index 221a345..d164a3a 100644
--- a/lib/migration.h
+++ b/lib/migration.h
@@ -80,7 +80,7 @@ uint64_t
migration_get_flags(struct migration *migr);
MOCK_DECLARE(void, migr_state_transition, struct migration *migr,
- enum vfio_device_mig_state state);
+ enum vfio_user_device_mig_state state);
MOCK_DECLARE(bool, vfio_migr_state_transition_is_valid, uint32_t from,
uint32_t to);
diff --git a/lib/migration_priv.h b/lib/migration_priv.h
index 20f1fad..2566b39 100644
--- a/lib/migration_priv.h
+++ b/lib/migration_priv.h
@@ -35,7 +35,7 @@
struct migration {
uint64_t flags;
- enum vfio_device_mig_state state;
+ enum vfio_user_device_mig_state state;
size_t pgsize;
vfu_migration_callbacks_t callbacks;
};
@@ -43,7 +43,7 @@ struct migration {
/* valid migration state transitions
each number corresponds to a FROM state and each bit a TO state
if the bit is set then the transition is allowed
- the indices of each state are those in the vfio_device_mig_state enum */
+ the indices of each state are those in the vfio_user_device_mig_state enum */
static const char transitions[8] = {
0b00000000, // ERROR -> {}
0b00011100, // STOP -> {RUNNING, STOP_COPY, RESUMING}