aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJag Raman <jag.raman@oracle.com>2022-05-23 08:15:47 -0400
committerGitHub <noreply@github.com>2022-05-23 13:15:47 +0100
commitb52bff72d4eb646a453d19e19ddbd13ed6111a09 (patch)
tree493045e75edc44a0696dfaffd84896a8e0cdaf7f /include
parentb427c6084311f0c620bf4afe7746739e8c887977 (diff)
downloadlibvfio-user-b52bff72d4eb646a453d19e19ddbd13ed6111a09.zip
libvfio-user-b52bff72d4eb646a453d19e19ddbd13ed6111a09.tar.gz
libvfio-user-b52bff72d4eb646a453d19e19ddbd13ed6111a09.tar.bz2
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 <jag.raman@oracle.com> Reviewed-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'include')
-rw-r--r--include/libvfio-user.h32
1 files changed, 25 insertions, 7 deletions
diff --git a/include/libvfio-user.h b/include/libvfio-user.h
index e95c26a..629727f 100644
--- a/include/libvfio-user.h
+++ b/include/libvfio-user.h
@@ -671,15 +671,33 @@ typedef struct {
} vfu_migration_callbacks_t;
-#ifndef VFIO_DEVICE_STATE_STOP
+/**
+ * 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_STOP (0)
-#define VFIO_DEVICE_STATE_RUNNING (1 << 0)
-#define VFIO_DEVICE_STATE_SAVING (1 << 1)
-#define VFIO_DEVICE_STATE_RESUMING (1 << 2)
-#define VFIO_DEVICE_STATE_MASK ((1 << 3) - 1)
+#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_DEVICE_STATE_STOP */
+#endif /* VFIO_REGION_TYPE_MIGRATION_DEPRECATED */
/*
* The currently defined migration registers; if using migration callbacks,