Skip to content

Commit eb1539b

Browse files
Hu Taomstsirkin
Hu Tao
authored andcommitted
hmp: add info memdev
This is the hmp counterpart of qmp query-memdev. Signed-off-by: Hu Tao <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> MST: fix build on 32 bit
1 parent 76b5d85 commit eb1539b

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

Diff for: hmp.c

+36
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "qemu/sockets.h"
2323
#include "monitor/monitor.h"
2424
#include "qapi/opts-visitor.h"
25+
#include "qapi/string-output-visitor.h"
26+
#include "qapi-visit.h"
2527
#include "ui/console.h"
2628
#include "block/qapi.h"
2729
#include "qemu-io.h"
@@ -1676,3 +1678,37 @@ void hmp_object_del(Monitor *mon, const QDict *qdict)
16761678
qmp_object_del(id, &err);
16771679
hmp_handle_error(mon, &err);
16781680
}
1681+
1682+
void hmp_info_memdev(Monitor *mon, const QDict *qdict)
1683+
{
1684+
Error *err = NULL;
1685+
MemdevList *memdev_list = qmp_query_memdev(&err);
1686+
MemdevList *m = memdev_list;
1687+
StringOutputVisitor *ov;
1688+
int i = 0;
1689+
1690+
1691+
while (m) {
1692+
ov = string_output_visitor_new(false);
1693+
visit_type_uint16List(string_output_get_visitor(ov),
1694+
&m->value->host_nodes, NULL, NULL);
1695+
monitor_printf(mon, "memory device %d\n", i);
1696+
monitor_printf(mon, " size: %" PRId64 "\n", m->value->size);
1697+
monitor_printf(mon, " merge: %s\n",
1698+
m->value->merge ? "true" : "false");
1699+
monitor_printf(mon, " dump: %s\n",
1700+
m->value->dump ? "true" : "false");
1701+
monitor_printf(mon, " prealloc: %s\n",
1702+
m->value->prealloc ? "true" : "false");
1703+
monitor_printf(mon, " policy: %s\n",
1704+
HostMemPolicy_lookup[m->value->policy]);
1705+
monitor_printf(mon, " host nodes: %s\n",
1706+
string_output_get_string(ov));
1707+
1708+
string_output_visitor_cleanup(ov);
1709+
m = m->next;
1710+
i++;
1711+
}
1712+
1713+
monitor_printf(mon, "\n");
1714+
}

Diff for: hmp.h

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict);
9393
void hmp_cpu_add(Monitor *mon, const QDict *qdict);
9494
void hmp_object_add(Monitor *mon, const QDict *qdict);
9595
void hmp_object_del(Monitor *mon, const QDict *qdict);
96+
void hmp_info_memdev(Monitor *mon, const QDict *qdict);
9697
void object_add_completion(ReadLineState *rs, int nb_args, const char *str);
9798
void object_del_completion(ReadLineState *rs, int nb_args, const char *str);
9899
void device_add_completion(ReadLineState *rs, int nb_args, const char *str);

Diff for: monitor.c

+7
Original file line numberDiff line numberDiff line change
@@ -2963,6 +2963,13 @@ static mon_cmd_t info_cmds[] = {
29632963
.help = "show the TPM device",
29642964
.mhandler.cmd = hmp_info_tpm,
29652965
},
2966+
{
2967+
.name = "memdev",
2968+
.args_type = "",
2969+
.params = "",
2970+
.help = "show the memory device",
2971+
.mhandler.cmd = hmp_info_memdev,
2972+
},
29662973
{
29672974
.name = NULL,
29682975
},

0 commit comments

Comments
 (0)