diff mbox

[v4,8/8] qemu-monitor: add HMP "info-bootindex" command

Message ID 1406800053-6480-9-git-send-email-arei.gonglei@huawei.com
State New
Headers show

Commit Message

Gonglei (Arei) July 31, 2014, 9:47 a.m. UTC
From: Gonglei <arei.gonglei@huawei.com>

Add HMP info-bootindex command to getting
devcie's bootindex via monitor.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Chenliang <chenliang88@huawei.com>
---
 hmp-commands.hx |  2 ++
 hmp.c           | 20 ++++++++++++++++++++
 hmp.h           |  1 +
 monitor.c       |  7 +++++++
 4 files changed, 30 insertions(+)
diff mbox

Patch

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 31ef24e..bc1b982 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1795,6 +1795,8 @@  show qdev device model list
 show roms
 @item info tpm
 show the TPM device
+@item info bootindex
+show the current VM bootindex information
 @end table
 ETEXI
 
diff --git a/hmp.c b/hmp.c
index 95f7eeb..1688e02 100644
--- a/hmp.c
+++ b/hmp.c
@@ -725,6 +725,26 @@  void hmp_info_tpm(Monitor *mon, const QDict *qdict)
     qapi_free_TPMInfoList(info_list);
 }
 
+void hmp_info_bootindex(Monitor *mon, const QDict *qdict)
+{
+    BootindexInfoList *bootindex_list, *info;
+
+    bootindex_list = qmp_query_bootindex(NULL);
+    if (!bootindex_list) {
+        monitor_printf(mon, "No bootindex was configured\n");
+        return;
+    }
+
+    monitor_printf(mon, "id \t bootindex \t suffix\n");
+    for (info = bootindex_list; info; info = info->next) {
+        monitor_printf(mon, "\"%s\"\t %"PRId64"\t\"%s\"\n",
+                       info->value->id, info->value->bootindex,
+                       info->value->suffix);
+    }
+
+    qapi_free_BootindexInfoList(bootindex_list);
+}
+
 void hmp_quit(Monitor *mon, const QDict *qdict)
 {
     monitor_suspend(mon);
diff --git a/hmp.h b/hmp.h
index eb2641a..5899537 100644
--- a/hmp.h
+++ b/hmp.h
@@ -38,6 +38,7 @@  void hmp_info_balloon(Monitor *mon, const QDict *qdict);
 void hmp_info_pci(Monitor *mon, const QDict *qdict);
 void hmp_info_block_jobs(Monitor *mon, const QDict *qdict);
 void hmp_info_tpm(Monitor *mon, const QDict *qdict);
+void hmp_info_bootindex(Monitor *mon, const QDict *qdict);
 void hmp_quit(Monitor *mon, const QDict *qdict);
 void hmp_stop(Monitor *mon, const QDict *qdict);
 void hmp_system_reset(Monitor *mon, const QDict *qdict);
diff --git a/monitor.c b/monitor.c
index 5bc70a6..8158ddb 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2918,6 +2918,13 @@  static mon_cmd_t info_cmds[] = {
         .mhandler.cmd = hmp_info_memdev,
     },
     {
+        .name       = "bootindex",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show the current VM bootindex information",
+        .mhandler.cmd = hmp_info_bootindex,
+    },
+    {
         .name       = NULL,
     },
 };