diff mbox

[1/2] kvm: qemu: add warning message when assign device without IOMMU

Message ID 715D42877B251141A38726ABF5CABF2C01A11B66ED@pdsmsx503.ccr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Han, Weidong March 26, 2009, 9:02 a.m. UTC
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.han@intel.com>
---
 qemu/hw/device-assignment.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

Comments

Avi Kivity March 26, 2009, noon UTC | #1
Han, Weidong wrote:
> 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.
>   

If the device has does not do DMA (say a serial port) then it can be 
assigned.  Can we check the device for dma capability and allow this 
special case?
Han, Weidong March 27, 2009, 3:38 a.m. UTC | #2
Avi Kivity wrote:
> Han, Weidong wrote:
>> 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.
>> 
> 
> If the device has does not do DMA (say a serial port) then it can be
> assigned.  Can we check the device for dma capability and allow this
> special case?

Do you have any hint to check it? This warning be triggered only when user wants to assign device with IOMMU. If user doesn't want to use IOMMU to assign device, he can use "-pcidevice host=xx:yy.z,dma=none". 

Regards,
Weidong

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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);