aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThanos Makatos <thanos.makatos@nutanix.com>2021-02-15 10:22:54 +0000
committerGitHub <noreply@github.com>2021-02-15 10:22:54 +0000
commit59029a593c5ed606ee7fd674d5c7d7d265dc5970 (patch)
treed2a53253209e8da2c6ac80dd0533e9d2895bdf45 /lib
parentc08ce6363b1d3487f330a542ed5273f5d055d3bc (diff)
downloadlibvfio-user-59029a593c5ed606ee7fd674d5c7d7d265dc5970.zip
libvfio-user-59029a593c5ed606ee7fd674d5c7d7d265dc5970.tar.gz
libvfio-user-59029a593c5ed606ee7fd674d5c7d7d265dc5970.tar.bz2
handle VFIO_USER_DIRTY_PAGES in stopped and stop-and-copy states (#335)
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/libvfio-user.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c
index fb94b23..c36a4da 100644
--- a/lib/libvfio-user.c
+++ b/lib/libvfio-user.c
@@ -760,11 +760,19 @@ exec_command(vfu_ctx_t *vfu_ctx, struct vfio_user_header *hdr, size_t size,
}
if (device_is_stopped_and_copying(vfu_ctx->migration)
- && !(hdr->cmd == VFIO_USER_REGION_READ || hdr->cmd == VFIO_USER_REGION_WRITE)) {
+ && !(hdr->cmd == VFIO_USER_REGION_READ ||
+ hdr->cmd == VFIO_USER_REGION_WRITE ||
+ hdr->cmd == VFIO_USER_DIRTY_PAGES)) {
vfu_log(vfu_ctx, LOG_ERR,
"bad command %d while device in stop-and-copy state", hdr->cmd);
ret = -EINVAL;
goto out;
+ } else if (device_is_stopped(vfu_ctx->migration) &&
+ hdr->cmd != VFIO_USER_DIRTY_PAGES) {
+ vfu_log(vfu_ctx, LOG_ERR,
+ "bad command %d while device in stopped state", hdr->cmd);
+ ret = -EINVAL;
+ goto out;
}
switch (hdr->cmd) {
@@ -882,10 +890,6 @@ process_request(vfu_ctx_t *vfu_ctx)
assert(vfu_ctx != NULL);
- if (device_is_stopped(vfu_ctx->migration)) {
- return -ESHUTDOWN;
- }
-
/*
* FIXME if migration device state is VFIO_DEVICE_STATE_STOP then only
* migration-related operations should execute. However, some operations