aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJag Raman <jraman567@gmail.com>2021-07-13 12:18:33 -0400
committerGitHub <noreply@github.com>2021-07-13 17:18:33 +0100
commite0c15dfd087f8093ee6aab697e9ac2a252ab42bb (patch)
treef853f527ae541c03b16055cc1efc5c53e3382ec2 /lib
parentf44091db918d54211cb43683b091c61a6177d450 (diff)
downloadlibvfio-user-e0c15dfd087f8093ee6aab697e9ac2a252ab42bb.zip
libvfio-user-e0c15dfd087f8093ee6aab697e9ac2a252ab42bb.tar.gz
libvfio-user-e0c15dfd087f8093ee6aab697e9ac2a252ab42bb.tar.bz2
add VFU_REGION_FLAG_ALWAYS_CB to receive callback always (#583)
Diffstat (limited to 'lib')
-rw-r--r--lib/libvfio-user.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c
index a90d9c2..1ee4026 100644
--- a/lib/libvfio-user.c
+++ b/lib/libvfio-user.c
@@ -208,7 +208,8 @@ region_access(vfu_ctx_t *vfu_ctx, size_t region_index, char *buf,
dump_buffer("buffer write", buf, count);
}
- if (region_index == VFU_PCI_DEV_CFG_REGION_IDX) {
+ if ((region_index == VFU_PCI_DEV_CFG_REGION_IDX) &&
+ !(vfu_ctx->reg_info[region_index].flags & VFU_REGION_FLAG_ALWAYS_CB)) {
ret = pci_config_space_access(vfu_ctx, buf, count, offset, is_write);
if (ret == -1) {
return ret;
@@ -1445,7 +1446,13 @@ vfu_setup_region(vfu_ctx_t *vfu_ctx, int region_idx, size_t size,
* PCI config space is never mappable or of type mem.
*/
if (region_idx == VFU_PCI_DEV_CFG_REGION_IDX &&
- flags != VFU_REGION_FLAG_RW) {
+ (((flags & VFU_REGION_FLAG_RW) != VFU_REGION_FLAG_RW) ||
+ (flags & VFU_REGION_FLAG_MEM))) {
+ return ERROR_INT(EINVAL);
+ }
+
+ if ((flags & VFU_REGION_FLAG_ALWAYS_CB) && (cb == NULL)) {
+ vfu_log(vfu_ctx, LOG_ERR, "VFU_REGION_FLAG_ALWAYS_CB needs callback");
return ERROR_INT(EINVAL);
}