Skip to content

Commit

Permalink
hmp: Handle virtio-pmem when printing memory device infos
Browse files Browse the repository at this point in the history
Print the memory device info just like for PCDIMM/NVDIMM.

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20190619094907.10131-6-pagupta@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
davidhildenbrand authored and mstsirkin committed Jul 4, 2019
1 parent adf0748 commit d766b22
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions monitor/hmp-cmds.c
Expand Up @@ -2653,6 +2653,7 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
Error *err = NULL;
MemoryDeviceInfoList *info_list = qmp_query_memory_devices(&err);
MemoryDeviceInfoList *info;
VirtioPMEMDeviceInfo *vpi;
MemoryDeviceInfo *value;
PCDIMMDeviceInfo *di;

Expand All @@ -2662,19 +2663,9 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
if (value) {
switch (value->type) {
case MEMORY_DEVICE_INFO_KIND_DIMM:
di = value->u.dimm.data;
break;

case MEMORY_DEVICE_INFO_KIND_NVDIMM:
di = value->u.nvdimm.data;
break;

default:
di = NULL;
break;
}

if (di) {
di = value->type == MEMORY_DEVICE_INFO_KIND_DIMM ?
value->u.dimm.data : value->u.nvdimm.data;
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
MemoryDeviceInfoKind_str(value->type),
di->id ? di->id : "");
Expand All @@ -2687,6 +2678,18 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
di->hotplugged ? "true" : "false");
monitor_printf(mon, " hotpluggable: %s\n",
di->hotpluggable ? "true" : "false");
break;
case MEMORY_DEVICE_INFO_KIND_VIRTIO_PMEM:
vpi = value->u.virtio_pmem.data;
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
MemoryDeviceInfoKind_str(value->type),
vpi->id ? vpi->id : "");
monitor_printf(mon, " memaddr: 0x%" PRIx64 "\n", vpi->memaddr);
monitor_printf(mon, " size: %" PRIu64 "\n", vpi->size);
monitor_printf(mon, " memdev: %s\n", vpi->memdev);
break;
default:
g_assert_not_reached();
}
}
}
Expand Down

0 comments on commit d766b22

Please sign in to comment.