From nobody Fri May 3 07:35:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1490945910415299.889314665348; Fri, 31 Mar 2017 00:38:30 -0700 (PDT) Received: from localhost ([::1]:39348 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctr8e-00021Q-LZ for importer@patchew.org; Fri, 31 Mar 2017 03:38:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctr7M-0001DD-2s for qemu-devel@nongnu.org; Fri, 31 Mar 2017 03:37:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctr7I-0006wR-W6 for qemu-devel@nongnu.org; Fri, 31 Mar 2017 03:37:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49554) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ctr7I-0006vk-RA for qemu-devel@nongnu.org; Fri, 31 Mar 2017 03:37:04 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CAE9C804ED; Fri, 31 Mar 2017 07:37:03 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-8-59.pek2.redhat.com [10.72.8.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2154D18E21; Fri, 31 Mar 2017 07:36:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CAE9C804ED Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CAE9C804ED From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 31 Mar 2017 15:36:29 +0800 Message-Id: <1490945793-21276-2-git-send-email-peterx@redhat.com> In-Reply-To: <1490945793-21276-1-git-send-email-peterx@redhat.com> References: <1490945793-21276-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 31 Mar 2017 07:37:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.10 1/5] QemuOpts: introduce qemu_opts_extract() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tianyu.lan@intel.com, kevin.tian@intel.com, yi.l.liu@intel.com, "\\ Michael S . Tsirkin \\ " , Jason Wang , Markus Armbruster , peterx@redhat.com, Marcel Apfelbaum , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This helper function is used to extract specific QemuOpts item from an existing QemuOptsList which matches specific patterns. Signed-off-by: Peter Xu --- include/qemu/option.h | 2 ++ util/qemu-option.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/qemu/option.h b/include/qemu/option.h index f7338db..355cee8 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -136,6 +136,8 @@ void qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdic= t, Error **errp); typedef int (*qemu_opts_loopfunc)(void *opaque, QemuOpts *opts, Error **er= rp); int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque, Error **errp); +QemuOpts *qemu_opts_extract(QemuOptsList *list, qemu_opts_loopfunc func, + void *opaque, Error **errp); void qemu_opts_print(QemuOpts *opts, const char *sep); void qemu_opts_print_help(QemuOptsList *list); void qemu_opts_free(QemuOptsList *list); diff --git a/util/qemu-option.c b/util/qemu-option.c index 5ce1b5c..7c34d88 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -1121,6 +1121,30 @@ int qemu_opts_foreach(QemuOptsList *list, qemu_opts_= loopfunc func, return rc; } =20 +/* + * Extract specific QemuOpts from a QemuOptsList. For each QemuOpts + * item, if checks against func() returns zero, it'll be picked out + * from current QemuOptsList, then returned. If there are more than + * one QemuOpts that match the check, will only return the first one + * found. + */ +QemuOpts *qemu_opts_extract(QemuOptsList *list, qemu_opts_loopfunc func, + void *opaque, Error **errp) +{ + QemuOpts *opts, *next_opts; + + assert(list && func); + + QTAILQ_FOREACH_SAFE(opts, &list->head, next, next_opts) { + if (func(opaque, opts, errp) =3D=3D 0) { + QTAILQ_REMOVE(&list->head, opts, next); + return opts; + } + } + + return NULL; +} + static size_t count_opts_list(QemuOptsList *list) { QemuOptDesc *desc =3D NULL; --=20 2.7.4 From nobody Fri May 3 07:35:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1490946001580751.7606551623369; Fri, 31 Mar 2017 00:40:01 -0700 (PDT) Received: from localhost ([::1]:39354 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctrA8-00032H-Bj for importer@patchew.org; Fri, 31 Mar 2017 03:40:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39173) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctr7X-0001LQ-CA for qemu-devel@nongnu.org; Fri, 31 Mar 2017 03:37:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctr7U-0006xw-AQ for qemu-devel@nongnu.org; Fri, 31 Mar 2017 03:37:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38206) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ctr7U-0006xl-40 for qemu-devel@nongnu.org; Fri, 31 Mar 2017 03:37:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 21BC83D958; Fri, 31 Mar 2017 07:37:15 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-8-59.pek2.redhat.com [10.72.8.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id BED6518146; Fri, 31 Mar 2017 07:37:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 21BC83D958 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 21BC83D958 From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 31 Mar 2017 15:36:30 +0800 Message-Id: <1490945793-21276-3-git-send-email-peterx@redhat.com> In-Reply-To: <1490945793-21276-1-git-send-email-peterx@redhat.com> References: <1490945793-21276-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 31 Mar 2017 07:37:15 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.10 2/5] util: export device_init_func() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tianyu.lan@intel.com, kevin.tian@intel.com, yi.l.liu@intel.com, "\\ Michael S . Tsirkin \\ " , Jason Wang , Markus Armbruster , peterx@redhat.com, Marcel Apfelbaum , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This general routine is used to create most of the "-device" objects. Export it so that other modules can use it as well. Signed-off-by: Peter Xu --- include/qemu-common.h | 1 + vl.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/qemu-common.h b/include/qemu-common.h index d218821..0e6bb3b 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -125,6 +125,7 @@ const char *qemu_get_vm_name(void); #define QEMU_FILE_TYPE_BIOS 0 #define QEMU_FILE_TYPE_KEYMAP 1 char *qemu_find_file(int type, const char *name); +int device_init_func(void *opaque, QemuOpts *opts, Error **errp); =20 /* OS specific functions */ void os_setup_early_signal_handling(void); diff --git a/vl.c b/vl.c index 0b4ed52..b97b32a 100644 --- a/vl.c +++ b/vl.c @@ -2297,7 +2297,7 @@ static int device_help_func(void *opaque, QemuOpts *o= pts, Error **errp) return qdev_device_help(opts); } =20 -static int device_init_func(void *opaque, QemuOpts *opts, Error **errp) +int device_init_func(void *opaque, QemuOpts *opts, Error **errp) { Error *err =3D NULL; DeviceState *dev; --=20 2.7.4 From nobody Fri May 3 07:35:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1490946069925977.8802341536143; Fri, 31 Mar 2017 00:41:09 -0700 (PDT) Received: from localhost ([::1]:39362 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctrBE-0003pR-LF for importer@patchew.org; Fri, 31 Mar 2017 03:41:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctr7b-0001N3-LW for qemu-devel@nongnu.org; Fri, 31 Mar 2017 03:37:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctr7a-0006zG-Rv for qemu-devel@nongnu.org; Fri, 31 Mar 2017 03:37:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49184) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ctr7a-0006z6-MV for qemu-devel@nongnu.org; Fri, 31 Mar 2017 03:37:22 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A477B61B93; Fri, 31 Mar 2017 07:37:21 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-8-59.pek2.redhat.com [10.72.8.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8D0618E21; Fri, 31 Mar 2017 07:37:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A477B61B93 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A477B61B93 From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 31 Mar 2017 15:36:31 +0800 Message-Id: <1490945793-21276-4-git-send-email-peterx@redhat.com> In-Reply-To: <1490945793-21276-1-git-send-email-peterx@redhat.com> References: <1490945793-21276-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 31 Mar 2017 07:37:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.10 3/5] util: propagate error for device_func_init() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tianyu.lan@intel.com, kevin.tian@intel.com, yi.l.liu@intel.com, "\\ Michael S . Tsirkin \\ " , Jason Wang , Markus Armbruster , peterx@redhat.com, Marcel Apfelbaum , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We have error_propagate(). Use it. Signed-off-by: Peter Xu --- vl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vl.c b/vl.c index b97b32a..b18bde7 100644 --- a/vl.c +++ b/vl.c @@ -2304,7 +2304,7 @@ int device_init_func(void *opaque, QemuOpts *opts, Er= ror **errp) =20 dev =3D qdev_device_add(opts, &err); if (!dev) { - error_report_err(err); + error_propagate(errp, err); return -1; } object_unref(OBJECT(dev)); --=20 2.7.4 From nobody Fri May 3 07:35:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1490945980109847.4965923290756; Fri, 31 Mar 2017 00:39:40 -0700 (PDT) Received: from localhost ([::1]:39353 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctr9m-0002ms-NQ for importer@patchew.org; Fri, 31 Mar 2017 03:39:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctr7j-0001Sq-AM for qemu-devel@nongnu.org; Fri, 31 Mar 2017 03:37:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctr7i-00073T-Gb for qemu-devel@nongnu.org; Fri, 31 Mar 2017 03:37:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17342) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ctr7i-000731-8n for qemu-devel@nongnu.org; Fri, 31 Mar 2017 03:37:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3E9AE15552; Fri, 31 Mar 2017 07:37:29 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-8-59.pek2.redhat.com [10.72.8.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6563A18146; Fri, 31 Mar 2017 07:37:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3E9AE15552 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3E9AE15552 From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 31 Mar 2017 15:36:32 +0800 Message-Id: <1490945793-21276-5-git-send-email-peterx@redhat.com> In-Reply-To: <1490945793-21276-1-git-send-email-peterx@redhat.com> References: <1490945793-21276-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 31 Mar 2017 07:37:29 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.10 4/5] q35: init vIOMMU during machine init X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tianyu.lan@intel.com, kevin.tian@intel.com, yi.l.liu@intel.com, "\\ Michael S . Tsirkin \\ " , Jason Wang , Markus Armbruster , peterx@redhat.com, Marcel Apfelbaum , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Now x86 vIOMMUs are init along with all the rest of "-devices". That may not be sufficient since some devices' realization will depend on the vIOMMU object. Let's move the vIOMMU init back to machine init, so that'll be far earlier than all the rest of devices. Signed-off-by: Peter Xu --- hw/pci-host/q35.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index 344f77b..c5becea 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -28,6 +28,8 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "hw/hw.h" #include "hw/pci-host/q35.h" #include "qapi/error.h" @@ -460,6 +462,26 @@ static void mch_reset(DeviceState *qdev) mch_update(mch); } =20 +static int x86_iommu_detecter(void *opaque, QemuOpts *opts, Error **errp) +{ + const char *driver =3D qemu_opt_get(opts, "driver"); + + if (!driver) { + /* + * We don't need to set any error here. It'll be invoked later + * when init all the devices. Here we can just concentrate on + * the IOMMU device. + */ + return -1; + } + + if (!strcmp(driver, "intel-iommu") || !strcmp(driver, "amd-iommu")) { + return 0; + } + + return -1; +} + static void mch_realize(PCIDevice *d, Error **errp) { int i; @@ -518,6 +540,29 @@ static void mch_realize(PCIDevice *d, Error **errp) mch->pci_address_space, &mch->pam_regions[i+1], PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE); } + + /* + * Initialize vIOMMUs during machine init. Now we have vIOMMUs + * configured with "-device", let's try to pick them out in the + * device list, and init them before the rest of the devices (some + * device will depend on the vIOMMU during its realization). + * + * TODO: support multiple vIOMMUs. This loop prepares for that. + */ + while (1) { + QemuOpts *iommu_opts; + + iommu_opts =3D qemu_opts_extract(qemu_find_opts("device"), + x86_iommu_detecter, NULL, errp); + if (!iommu_opts) { + break; + } + + /* Found one IOMMU device, init it */ + if (device_init_func(NULL, iommu_opts, errp)) { + return; + } + } } =20 uint64_t mch_mcfg_base(void) --=20 2.7.4 From nobody Fri May 3 07:35:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1490946141232500.8484135309218; Fri, 31 Mar 2017 00:42:21 -0700 (PDT) Received: from localhost ([::1]:39365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctrCO-0004Y7-2B for importer@patchew.org; Fri, 31 Mar 2017 03:42:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctr7z-0001fc-46 for qemu-devel@nongnu.org; Fri, 31 Mar 2017 03:37:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctr7w-0007Db-19 for qemu-devel@nongnu.org; Fri, 31 Mar 2017 03:37:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60902) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ctr7v-0007DD-Pj for qemu-devel@nongnu.org; Fri, 31 Mar 2017 03:37:43 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BB03080463; Fri, 31 Mar 2017 07:37:42 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-8-59.pek2.redhat.com [10.72.8.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2E1B18146; Fri, 31 Mar 2017 07:37:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BB03080463 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BB03080463 From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 31 Mar 2017 15:36:33 +0800 Message-Id: <1490945793-21276-6-git-send-email-peterx@redhat.com> In-Reply-To: <1490945793-21276-1-git-send-email-peterx@redhat.com> References: <1490945793-21276-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 31 Mar 2017 07:37:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.10 5/5] pci: move dma_as init back to bus realize X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tianyu.lan@intel.com, kevin.tian@intel.com, yi.l.liu@intel.com, "\\ Michael S . Tsirkin \\ " , Jason Wang , Markus Armbruster , peterx@redhat.com, Marcel Apfelbaum , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch partly reverted commit b86eacb ("hw/pci: delay bus_master_enable_region initialization"). In that patch, we postponed pci DMA address space initialization to support the new "-device" interface for "intel-iommu" device. Now since we have vIOMMUs inited back during machine init phase, we won't need this notifier mechanism any more. This brings us a benefit that all device realization will be able to have a valid bus_master_as now. Signed-off-by: Peter Xu --- hw/pci/pci.c | 21 +-------------------- include/hw/pci/pci_bus.h | 2 -- include/sysemu/sysemu.h | 1 - vl.c | 5 ----- 4 files changed, 1 insertion(+), 28 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index bd8043c..dd32ddf 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -94,25 +94,10 @@ static void pci_init_bus_master(PCIDevice *pci_dev) &pci_dev->bus_master_enable_region); } =20 -static void pcibus_machine_done(Notifier *notifier, void *data) -{ - PCIBus *bus =3D container_of(notifier, PCIBus, machine_done); - int i; - - for (i =3D 0; i < ARRAY_SIZE(bus->devices); ++i) { - if (bus->devices[i]) { - pci_init_bus_master(bus->devices[i]); - } - } -} - static void pci_bus_realize(BusState *qbus, Error **errp) { PCIBus *bus =3D PCI_BUS(qbus); =20 - bus->machine_done.notify =3D pcibus_machine_done; - qemu_add_machine_init_done_notifier(&bus->machine_done); - vmstate_register(NULL, -1, &vmstate_pcibus, bus); } =20 @@ -120,8 +105,6 @@ static void pci_bus_unrealize(BusState *qbus, Error **e= rrp) { PCIBus *bus =3D PCI_BUS(qbus); =20 - qemu_remove_machine_init_done_notifier(&bus->machine_done); - vmstate_unregister(NULL, &vmstate_pcibus, bus); } =20 @@ -1004,9 +987,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pc= i_dev, PCIBus *bus, address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_container_region, pci_dev->nam= e); =20 - if (qdev_hotplug) { - pci_init_bus_master(pci_dev); - } + pci_init_bus_master(pci_dev); pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); pci_dev->irq_state =3D 0; pci_config_alloc(pci_dev); diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h index 5484a9b..403fec6 100644 --- a/include/hw/pci/pci_bus.h +++ b/include/hw/pci/pci_bus.h @@ -39,8 +39,6 @@ struct PCIBus { Keep a count of the number of devices with raised IRQs. */ int nirq; int *irq_count; - - Notifier machine_done; }; =20 typedef struct PCIBridgeWindows PCIBridgeWindows; diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 576c7ce..8b686b5 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -73,7 +73,6 @@ void qemu_add_exit_notifier(Notifier *notify); void qemu_remove_exit_notifier(Notifier *notify); =20 void qemu_add_machine_init_done_notifier(Notifier *notify); -void qemu_remove_machine_init_done_notifier(Notifier *notify); =20 void hmp_savevm(Monitor *mon, const QDict *qdict); int save_vmstate(Monitor *mon, const char *name); diff --git a/vl.c b/vl.c index b18bde7..3786a08 100644 --- a/vl.c +++ b/vl.c @@ -2660,11 +2660,6 @@ void qemu_add_machine_init_done_notifier(Notifier *n= otify) } } =20 -void qemu_remove_machine_init_done_notifier(Notifier *notify) -{ - notifier_remove(notify); -} - static void qemu_run_machine_init_done_notifiers(void) { notifier_list_notify(&machine_init_done_notifiers, NULL); --=20 2.7.4