When user wants to assign device with IOMMU, but IOMMU is not
enabled, add warning messages to prompt user this situation, and
return error. Or device will be assigned but it cannot work.

Signed-off-by: Weidong Han <weidong....@intel.com>
---
 qemu/hw/device-assignment.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/qemu/hw/device-assignment.c b/qemu/hw/device-assignment.c
index b7f9fa6..cef7c8a 100644
--- a/qemu/hw/device-assignment.c
+++ b/qemu/hw/device-assignment.c
@@ -616,6 +616,11 @@ static int assign_device(AssignedDevInfo *adev)
     r = kvm_check_extension(kvm_context, KVM_CAP_IOMMU);
     if (r && !adev->disable_iommu)
        assigned_dev_data.flags |= KVM_DEV_ASSIGN_ENABLE_IOMMU;
+    else if (!adev->disable_iommu && r == 0) {
+       fprintf(stderr, "IOMMU is not enabled. You cannot use "
+                "it to assign device!\n");
+       return -EINVAL;
+    }
 #endif
 
     r = kvm_assign_pci_device(kvm_context, &assigned_dev_data);
-- 
1.6.0.4

Attachment: 0001-kvm-qemu-add-warning-message-when-assign-device-wi.patch
Description: 0001-kvm-qemu-add-warning-message-when-assign-device-wi.patch

Reply via email to