From patchwork Thu Mar 26 09:02:47 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Han, Weidong" X-Patchwork-Id: 14495 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2Q93lxH031285 for ; Thu, 26 Mar 2009 09:03:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753628AbZCZJDq (ORCPT ); Thu, 26 Mar 2009 05:03:46 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753798AbZCZJDq (ORCPT ); Thu, 26 Mar 2009 05:03:46 -0400 Received: from mga02.intel.com ([134.134.136.20]:4668 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753579AbZCZJDp (ORCPT ); Thu, 26 Mar 2009 05:03:45 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 26 Mar 2009 01:56:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.38,425,1233561600"; d="scan'208,223";a="397688321" Received: from pgsmsx602.gar.corp.intel.com ([10.221.43.81]) by orsmga002.jf.intel.com with ESMTP; 26 Mar 2009 02:12:04 -0700 Received: from pdsmsx602.ccr.corp.intel.com (172.16.12.184) by pgsmsx602.gar.corp.intel.com (10.221.43.81) with Microsoft SMTP Server (TLS) id 8.1.340.0; Thu, 26 Mar 2009 17:02:50 +0800 Received: from pdsmsx503.ccr.corp.intel.com ([172.16.12.95]) by pdsmsx602.ccr.corp.intel.com ([172.16.12.184]) with mapi; Thu, 26 Mar 2009 17:02:49 +0800 From: "Han, Weidong" To: "'Avi Kivity'" CC: "'kvm@vger.kernel.org'" Date: Thu, 26 Mar 2009 17:02:47 +0800 Subject: [PATCH 1/2] kvm: qemu: add warning message when assign device without IOMMU Thread-Topic: [PATCH 1/2] kvm: qemu: add warning message when assign device without IOMMU Thread-Index: Acmt8aI57Dlr5FJPS3SWvhb0TJynKA== Message-ID: <715D42877B251141A38726ABF5CABF2C01A11B66ED@pdsmsx503.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- 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);