qmp: distinguish PC-DIMM and NVDIMM in MemoryDeviceInfoList

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 <haozhong.zhang@intel.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Haozhong Zhang 2018-03-11 11:02:12 +08:00 committed by Michael S. Tsirkin
parent 52c95cae4e
commit 6388e18de9
4 changed files with 38 additions and 11 deletions

19
numa.c
View file

@ -529,18 +529,25 @@ static void numa_stat_memory_devices(NumaNodeMem node_mem[])
if (value) {
switch (value->type) {
case MEMORY_DEVICE_INFO_KIND_DIMM: {
case MEMORY_DEVICE_INFO_KIND_DIMM:
pcdimm_info = value->u.dimm.data;
break;
case MEMORY_DEVICE_INFO_KIND_NVDIMM:
pcdimm_info = value->u.nvdimm.data;
break;
default:
pcdimm_info = NULL;
break;
}
if (pcdimm_info) {
node_mem[pcdimm_info->node].node_mem += pcdimm_info->size;
if (pcdimm_info->hotpluggable && pcdimm_info->hotplugged) {
node_mem[pcdimm_info->node].node_plugged_mem +=
pcdimm_info->size;
}
break;
}
default:
break;
}
}
}