From nobody Sat Oct 25 23:33:53 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 152151690790327.711963011112175; Mon, 19 Mar 2018 20:35:07 -0700 (PDT) Received: from localhost ([::1]:45290 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ey83B-0004Sh-0f for importer@patchew.org; Mon, 19 Mar 2018 23:35:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ey7m8-0006Wg-Lg for qemu-devel@nongnu.org; Mon, 19 Mar 2018 23:17:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ey7m7-000835-Gp for qemu-devel@nongnu.org; Mon, 19 Mar 2018 23:17:24 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:56984 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ey7m7-00082o-Aw for qemu-devel@nongnu.org; Mon, 19 Mar 2018 23:17:23 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F29CE8182D38; Tue, 20 Mar 2018 03:17:22 +0000 (UTC) Received: from redhat.com (ovpn-121-0.rdu2.redhat.com [10.10.121.0]) by smtp.corp.redhat.com (Postfix) with SMTP id A51132024CA6; Tue, 20 Mar 2018 03:17:22 +0000 (UTC) Date: Tue, 20 Mar 2018 05:17:22 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1521515720-612046-18-git-send-email-mst@redhat.com> References: <1521515720-612046-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1521515720-612046-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 20 Mar 2018 03:17:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 20 Mar 2018 03:17:23 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mst@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL v2 17/50] qmp: distinguish PC-DIMM and NVDIMM in MemoryDeviceInfoList 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: Peter Maydell , Eduardo Habkost , Haozhong Zhang , "Dr. David Alan Gilbert" , Markus Armbruster , Igor Mammedov 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 Content-Type: text/plain; charset="utf-8" From: Haozhong Zhang It may need to treat PC-DIMM and NVDIMM differently, e.g., when deciding the necessity of non-volatile flag bit in SRAT memory affinity structures. A new field 'nvdimm' is added to the union type MemoryDeviceInfo for such purpose. Its type is currently PCDIMMDeviceInfo and will be updated when necessary in the future. It also fixes "info memory-devices"/query-memory-devices which currently show nvdimm devices as dimm devices since object_dynamic_cast(obj, TYPE_PC_DIMM) happily cast nvdimm to TYPE_PC_DIMM which it's been inherited from. Signed-off-by: Haozhong Zhang Reviewed-by: Eric Blake Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/misc.json | 6 +++++- hmp.c | 14 +++++++++++--- hw/mem/pc-dimm.c | 10 +++++++++- numa.c | 19 +++++++++++++------ 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/qapi/misc.json b/qapi/misc.json index bcd5d10..6bf082f 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -2852,7 +2852,11 @@ # # Since: 2.1 ## -{ 'union': 'MemoryDeviceInfo', 'data': {'dimm': 'PCDIMMDeviceInfo'} } +{ 'union': 'MemoryDeviceInfo', + 'data': { 'dimm': 'PCDIMMDeviceInfo', + 'nvdimm': 'PCDIMMDeviceInfo' + } +} =20 ## # @query-memory-devices: diff --git a/hmp.c b/hmp.c index ba9e299..a277517 100644 --- a/hmp.c +++ b/hmp.c @@ -2423,7 +2423,18 @@ void hmp_info_memory_devices(Monitor *mon, const QDi= ct *qdict) switch (value->type) { case MEMORY_DEVICE_INFO_KIND_DIMM: di =3D value->u.dimm.data; + break; + + case MEMORY_DEVICE_INFO_KIND_NVDIMM: + di =3D value->u.nvdimm.data; + break; + + default: + di =3D NULL; + break; + } =20 + if (di) { monitor_printf(mon, "Memory device [%s]: \"%s\"\n", MemoryDeviceInfoKind_str(value->type), di->id ? di->id : ""); @@ -2436,9 +2447,6 @@ void hmp_info_memory_devices(Monitor *mon, const QDic= t *qdict) di->hotplugged ? "true" : "false"); monitor_printf(mon, " hotpluggable: %s\n", di->hotpluggable ? "true" : "false"); - break; - default: - break; } } } diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 4d050fe..51350d9 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -20,6 +20,7 @@ =20 #include "qemu/osdep.h" #include "hw/mem/pc-dimm.h" +#include "hw/mem/nvdimm.h" #include "qapi/error.h" #include "qemu/config-file.h" #include "qapi/visitor.h" @@ -250,6 +251,7 @@ MemoryDeviceInfoList *qmp_pc_dimm_device_list(void) MemoryDeviceInfoList *elem =3D g_new0(MemoryDeviceInfoList, 1); MemoryDeviceInfo *info =3D g_new0(MemoryDeviceInfo, 1); PCDIMMDeviceInfo *di =3D g_new0(PCDIMMDeviceInfo, 1); + bool is_nvdimm =3D object_dynamic_cast(obj, TYPE_NVDIMM); DeviceClass *dc =3D DEVICE_GET_CLASS(obj); DeviceState *dev =3D DEVICE(obj); =20 @@ -265,7 +267,13 @@ MemoryDeviceInfoList *qmp_pc_dimm_device_list(void) di->size =3D object_property_get_uint(obj, PC_DIMM_SIZE_PROP, NULL= ); di->memdev =3D object_get_canonical_path(OBJECT(dimm->hostmem)); =20 - info->u.dimm.data =3D di; + if (!is_nvdimm) { + info->u.dimm.data =3D di; + info->type =3D MEMORY_DEVICE_INFO_KIND_DIMM; + } else { + info->u.nvdimm.data =3D di; + info->type =3D MEMORY_DEVICE_INFO_KIND_NVDIMM; + } elem->value =3D info; elem->next =3D NULL; if (prev) { diff --git a/numa.c b/numa.c index 9442704..1116c90 100644 --- a/numa.c +++ b/numa.c @@ -529,18 +529,25 @@ static void numa_stat_memory_devices(NumaNodeMem node= _mem[]) =20 if (value) { switch (value->type) { - case MEMORY_DEVICE_INFO_KIND_DIMM: { + case MEMORY_DEVICE_INFO_KIND_DIMM: pcdimm_info =3D value->u.dimm.data; + break; + + case MEMORY_DEVICE_INFO_KIND_NVDIMM: + pcdimm_info =3D value->u.nvdimm.data; + break; + + default: + pcdimm_info =3D NULL; + break; + } + + if (pcdimm_info) { node_mem[pcdimm_info->node].node_mem +=3D pcdimm_info->siz= e; if (pcdimm_info->hotpluggable && pcdimm_info->hotplugged) { node_mem[pcdimm_info->node].node_plugged_mem +=3D pcdimm_info->size; } - break; - } - - default: - break; } } } --=20 MST