Skip to content

Commit

Permalink
hmp: add info memdev
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Hu Tao authored and mstsirkin committed Jun 19, 2014
1 parent 76b5d85 commit eb1539b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
36 changes: 36 additions & 0 deletions hmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "qemu/sockets.h"
#include "monitor/monitor.h"
#include "qapi/opts-visitor.h"
#include "qapi/string-output-visitor.h"
#include "qapi-visit.h"
#include "ui/console.h"
#include "block/qapi.h"
#include "qemu-io.h"
Expand Down Expand Up @@ -1676,3 +1678,37 @@ void hmp_object_del(Monitor *mon, const QDict *qdict)
qmp_object_del(id, &err);
hmp_handle_error(mon, &err);
}

void hmp_info_memdev(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
MemdevList *memdev_list = qmp_query_memdev(&err);
MemdevList *m = memdev_list;
StringOutputVisitor *ov;
int i = 0;


while (m) {
ov = string_output_visitor_new(false);
visit_type_uint16List(string_output_get_visitor(ov),
&m->value->host_nodes, NULL, NULL);
monitor_printf(mon, "memory device %d\n", i);
monitor_printf(mon, " size: %" PRId64 "\n", m->value->size);
monitor_printf(mon, " merge: %s\n",
m->value->merge ? "true" : "false");
monitor_printf(mon, " dump: %s\n",
m->value->dump ? "true" : "false");
monitor_printf(mon, " prealloc: %s\n",
m->value->prealloc ? "true" : "false");
monitor_printf(mon, " policy: %s\n",
HostMemPolicy_lookup[m->value->policy]);
monitor_printf(mon, " host nodes: %s\n",
string_output_get_string(ov));

string_output_visitor_cleanup(ov);
m = m->next;
i++;
}

monitor_printf(mon, "\n");
}
1 change: 1 addition & 0 deletions hmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict);
void hmp_cpu_add(Monitor *mon, const QDict *qdict);
void hmp_object_add(Monitor *mon, const QDict *qdict);
void hmp_object_del(Monitor *mon, const QDict *qdict);
void hmp_info_memdev(Monitor *mon, const QDict *qdict);
void object_add_completion(ReadLineState *rs, int nb_args, const char *str);
void object_del_completion(ReadLineState *rs, int nb_args, const char *str);
void device_add_completion(ReadLineState *rs, int nb_args, const char *str);
Expand Down
7 changes: 7 additions & 0 deletions monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -2963,6 +2963,13 @@ static mon_cmd_t info_cmds[] = {
.help = "show the TPM device",
.mhandler.cmd = hmp_info_tpm,
},
{
.name = "memdev",
.args_type = "",
.params = "",
.help = "show the memory device",
.mhandler.cmd = hmp_info_memdev,
},
{
.name = NULL,
},
Expand Down

0 comments on commit eb1539b

Please sign in to comment.