From adf3cc2bc84d78664d6152596a4ac6f1b1c4badd Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 1 Jun 2017 18:12:29 -0700 Subject: [PATCH] vhost: add fallback if linux/vfio.h is missing On older kernels that don't have VFIO, stub out the vhost IOMMU functions. Fixes build on older distributions (e.g. CentOS 6). Change-Id: Icda9998e494c24d252511a4da93ecb56502fe5a7 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/363473 Tested-by: SPDK Automated Test System Reviewed-by: Pawel Wodkowski Reviewed-by: Ben Walker --- lib/vhost/vhost_iommu.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/vhost/vhost_iommu.c b/lib/vhost/vhost_iommu.c index 8b50e7922..a785e3316 100644 --- a/lib/vhost/vhost_iommu.c +++ b/lib/vhost/vhost_iommu.c @@ -33,6 +33,12 @@ #include "spdk/stdinc.h" +#include "vhost_iommu.h" + +#include + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) + #include #include "spdk/env.h" @@ -40,8 +46,6 @@ #include "spdk_internal/log.h" -#include "vhost_iommu.h" - struct vfio_map { uint64_t iova; uint64_t size; @@ -303,3 +307,19 @@ int spdk_iommu_mem_unregister(uint64_t addr, uint64_t len) } SPDK_LOG_REGISTER_TRACE_FLAG("vhost_vfio", SPDK_TRACE_VHOST_VFIO) + +#else + +/* linux/vfio.h not available */ + +int spdk_iommu_mem_register(uint64_t addr, uint64_t len) +{ + return 0; +} + +int spdk_iommu_mem_unregister(uint64_t addr, uint64_t len) +{ + return 0; +} + +#endif