From nobody Thu Nov 6 06:14:52 2025 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153928608530151.67249755631997; Thu, 11 Oct 2018 12:28:05 -0700 (PDT) Received: from localhost ([::1]:36298 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAgcl-00068N-CW for importer@patchew.org; Thu, 11 Oct 2018 15:27:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44876) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAgaa-0004vg-CK for qemu-devel@nongnu.org; Thu, 11 Oct 2018 15:25:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAgaV-0001dz-Hu for qemu-devel@nongnu.org; Thu, 11 Oct 2018 15:25:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58834) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gAgaV-0001cc-3i for qemu-devel@nongnu.org; Thu, 11 Oct 2018 15:25:35 -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 13668C034DED; Thu, 11 Oct 2018 19:25:34 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-217.ams2.redhat.com [10.36.117.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2D308543D; Thu, 11 Oct 2018 19:25:32 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com Date: Thu, 11 Oct 2018 20:25:12 +0100 Message-Id: <20181011192513.63634-7-dgilbert@redhat.com> In-Reply-To: <20181011192513.63634-1-dgilbert@redhat.com> References: <20181011192513.63634-1-dgilbert@redhat.com> MIME-Version: 1.0 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.32]); Thu, 11 Oct 2018 19:25:34 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 6/7] qmp, hmp: make subsystem/system-vendor identities optional 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: wei@redhat.com, i.maximets@samsung.com, thuth@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: "Denis V. Lunev" According to PCI specification, subsystem id and subsystem vendor id are present only in type 0 and type 2 headers (at different offsets), but not in type 1 headers. Thus we should make this data optional in struct PciDeviceId and skip reporting them via HMP if the information is not available. Additional (wrong information) about PCI bridges (Type1 devices) has been added in 5383a705 and fortunately not released. This patch fixes that problem. The problem was spotted by Markus. Signed-off-by: Denis V. Lunev CC: "Dr. David Alan Gilbert" CC: Eric Blake CC: Markus Armbruster Message-Id: <20181002135538.12113-1-den@openvz.org> Reported-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Markus Armbruster Signed-off-by: Dr. David Alan Gilbert --- hmp.c | 6 ++++-- hw/pci/pci.c | 13 ++++++++++--- qapi/misc.json | 4 ++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/hmp.c b/hmp.c index 61ef120423..7828f93a39 100644 --- a/hmp.c +++ b/hmp.c @@ -837,8 +837,10 @@ static void hmp_info_pci_device(Monitor *mon, const Pc= iDeviceInfo *dev) =20 monitor_printf(mon, ": PCI device %04" PRIx64 ":%04" PRIx64 "\n", dev->id->vendor, dev->id->device); - monitor_printf(mon, " PCI subsystem %04" PRIx64 ":%04" PRIx64 "\n= ", - dev->id->subsystem_vendor, dev->id->subsystem); + if (dev->id->has_subsystem_vendor && dev->id->has_subsystem) { + monitor_printf(mon, " PCI subsystem %04" PRIx64 ":%04" PRIx64= "\n", + dev->id->subsystem_vendor, dev->id->subsystem); + } =20 if (dev->has_irq) { monitor_printf(mon, " IRQ %" PRId64 ".\n", dev->irq); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 51d0dec466..b937f0dc0a 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1737,9 +1737,6 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevice = *dev, PCIBus *bus, info->id =3D g_new0(PciDeviceId, 1); info->id->vendor =3D pci_get_word(dev->config + PCI_VENDOR_ID); info->id->device =3D pci_get_word(dev->config + PCI_DEVICE_ID); - info->id->subsystem =3D pci_get_word(dev->config + PCI_SUBSYSTEM_ID); - info->id->subsystem_vendor =3D - pci_get_word(dev->config + PCI_SUBSYSTEM_VENDOR_ID); info->regions =3D qmp_query_pci_regions(dev); info->qdev_id =3D g_strdup(dev->qdev.id ? dev->qdev.id : ""); =20 @@ -1752,6 +1749,16 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevice= *dev, PCIBus *bus, if (type =3D=3D PCI_HEADER_TYPE_BRIDGE) { info->has_pci_bridge =3D true; info->pci_bridge =3D qmp_query_pci_bridge(dev, bus, bus_num); + } else if (type =3D=3D PCI_HEADER_TYPE_NORMAL) { + info->id->has_subsystem =3D info->id->has_subsystem_vendor =3D tru= e; + info->id->subsystem =3D pci_get_word(dev->config + PCI_SUBSYSTEM_I= D); + info->id->subsystem_vendor =3D + pci_get_word(dev->config + PCI_SUBSYSTEM_VENDOR_ID); + } else if (type =3D=3D PCI_HEADER_TYPE_CARDBUS) { + info->id->has_subsystem =3D info->id->has_subsystem_vendor =3D tru= e; + info->id->subsystem =3D pci_get_word(dev->config + PCI_CB_SUBSYSTE= M_ID); + info->id->subsystem_vendor =3D + pci_get_word(dev->config + PCI_CB_SUBSYSTEM_VENDOR_ID); } =20 return info; diff --git a/qapi/misc.json b/qapi/misc.json index f98de3a58c..3a68af9ca3 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -839,8 +839,8 @@ # Since: 2.4 ## { 'struct': 'PciDeviceId', - 'data': {'device': 'int', 'vendor': 'int', 'subsystem': 'int', - 'subsystem-vendor': 'int'} } + 'data': {'device': 'int', 'vendor': 'int', '*subsystem': 'int', + '*subsystem-vendor': 'int'} } =20 ## # @PciDeviceInfo: --=20 2.19.0