aboutsummaryrefslogtreecommitdiff
path: root/samples/client.c
diff options
context:
space:
mode:
authorThanos Makatos <thanos.makatos@nutanix.com>2020-10-22 11:05:36 -0400
committerThanos Makatos <thanos.makatos@nutanix.com>2020-10-22 11:11:37 -0400
commit11daed97e8751b123897030e331ee49aad6c34ba (patch)
treea0793b4286702dafc1faa39072acdb8fbbea7dde /samples/client.c
parenta7c7d91429f3f00122ae06852730a8d514d518f6 (diff)
downloadlibvfio-user-11daed97e8751b123897030e331ee49aad6c34ba.zip
libvfio-user-11daed97e8751b123897030e331ee49aad6c34ba.tar.gz
libvfio-user-11daed97e8751b123897030e331ee49aad6c34ba.tar.bz2
samples/client: also receive region_access response for region write
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'samples/client.c')
-rw-r--r--samples/client.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/samples/client.c b/samples/client.c
index 7daa209..9a793dd 100644
--- a/samples/client.c
+++ b/samples/client.c
@@ -296,19 +296,23 @@ access_bar0(int sock)
.t = time(NULL)
};
uint16_t msg_id = 1;
+ const int sleep_time = 1;
+ struct vfio_user_region_access region_access = {};
int ret = send_recv_vfio_user_msg(sock, msg_id, VFIO_USER_REGION_WRITE,
- &data, sizeof data, NULL, 0, NULL, NULL, 0);
+ &data, sizeof data, NULL, 0, NULL,
+ &region_access, sizeof region_access);
if (ret < 0) {
fprintf(stderr, "failed to write to BAR0: %s\n", strerror(-ret));
return ret;
}
+ assert(region_access.count == sizeof data.t);
printf("wrote to BAR0: %ld\n", data.t);
- sleep(2);
-
msg_id++;
+ sleep(sleep_time);
+
ret = send_recv_vfio_user_msg(sock, msg_id, VFIO_USER_REGION_READ,
&data.region_access, sizeof data.region_access,
NULL, 0, NULL, &data, sizeof data);
@@ -320,6 +324,8 @@ access_bar0(int sock)
printf("read from BAR0: %ld\n", data.t);
+ assert(data.t >= sleep_time);
+
return 0;
}