From patchwork Wed Feb 4 15:43:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcel Apfelbaum X-Patchwork-Id: 436407 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8D5D1140190 for ; Thu, 5 Feb 2015 02:45:24 +1100 (AEDT) Received: from localhost ([::1]:37001 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJ28o-0004R8-Cv for incoming@patchwork.ozlabs.org; Wed, 04 Feb 2015 10:45:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44988) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJ28D-0003dC-US for qemu-devel@nongnu.org; Wed, 04 Feb 2015 10:44:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJ287-0004a6-Gj for qemu-devel@nongnu.org; Wed, 04 Feb 2015 10:44:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46588) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJ287-0004Y1-8w for qemu-devel@nongnu.org; Wed, 04 Feb 2015 10:44:39 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t14Fi6BA026738 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 4 Feb 2015 10:44:06 -0500 Received: from work.redhat.com (vpn1-7-196.ams2.redhat.com [10.36.7.196]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t14Fhu8Z010817; Wed, 4 Feb 2015 10:44:01 -0500 From: Marcel Apfelbaum To: qemu-devel@nongnu.org Date: Wed, 4 Feb 2015 17:43:48 +0200 Message-Id: <1423064635-19045-2-git-send-email-marcel@redhat.com> In-Reply-To: <1423064635-19045-1-git-send-email-marcel@redhat.com> References: <1423064635-19045-1-git-send-email-marcel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, james.hogan@imgtec.com, mst@redhat.com, marcel@redhat.com, jan.kiszka@siemens.com, cornelia.huck@de.ibm.com, agraf@suse.de, borntraeger@de.ibm.com, scottwood@freescale.com, pbonzini@redhat.com, leon.alrae@imgtec.com, aurelien@aurel32.net Subject: [Qemu-devel] [PATCH 1/8] machine: query iommu machine property rather than qemu opts X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Fixes a QEMU crash when passing iommu parameter in command line. Signed-off-by: Marcel Apfelbaum Signed-off-by: Marcel Apfelbaum --- hw/core/machine.c | 5 +++++ hw/pci-host/q35.c | 2 +- include/hw/boards.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index fbd91be..096eb10 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -403,6 +403,11 @@ bool machine_usb(MachineState *machine) return machine->usb; } +bool machine_iommu(MachineState *machine) +{ + return machine->iommu; +} + static const TypeInfo machine_info = { .name = TYPE_MACHINE, .parent = TYPE_OBJECT, diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index b20bad8..dfd8bbf 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -415,7 +415,7 @@ static int mch_init(PCIDevice *d) PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE); } /* Intel IOMMU (VT-d) */ - if (qemu_opt_get_bool(qemu_get_machine_opts(), "iommu", false)) { + if (machine_iommu(current_machine)) { mch_init_dmar(mch); } return 0; diff --git a/include/hw/boards.h b/include/hw/boards.h index 3ddc449..a12f041 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -66,6 +66,7 @@ MachineClass *find_default_machine(void); extern MachineState *current_machine; bool machine_usb(MachineState *machine); +bool machine_iommu(MachineState *machine); /** * MachineClass: