qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: zhanghailiang <zhang.zhanghailiang@huawei.com>
To: qemu-devel@nongnu.org
Cc: zhanghailiang <zhang.zhanghailiang@huawei.com>,
	luonengjun@huawei.com, peter.huangpeng@huawei.com,
	lcapitulino@redhat.com, hani@linux.com, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH] hmp: Add info machines
Date: Wed, 27 Aug 2014 17:24:12 +0800	[thread overview]
Message-ID: <1409131452-11064-1-git-send-email-zhang.zhanghailiang@huawei.com> (raw)

This is the hmp counterpart of qmp query_machines

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
---
 hmp-commands.hx |  2 ++
 hmp.c           | 22 ++++++++++++++++++++++
 hmp.h           |  1 +
 monitor.c       |  7 +++++++
 4 files changed, 32 insertions(+)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index d0943b1..1d04235 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1780,6 +1780,8 @@ show qdev device model list
 show roms
 @item info tpm
 show the TPM device
+@item info machines
+show supported machines information
 @end table
 ETEXI
 
diff --git a/hmp.c b/hmp.c
index 4d1838e..603f2f5 100644
--- a/hmp.c
+++ b/hmp.c
@@ -725,6 +725,28 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict)
     qapi_free_TPMInfoList(info_list);
 }
 
+void hmp_info_machines(Monitor *mon, const QDict *qdict)
+{
+    MachineInfoList *mach_list = NULL, *cur_item = NULL;
+
+    mach_list = qmp_query_machines(NULL);
+    for (cur_item = mach_list; cur_item; cur_item = cur_item->next) {
+        MachineInfo *machine;
+        char default_chr = ' ';
+
+        machine = cur_item->value;
+        if (machine->is_default) {
+            default_chr = '*';
+        }
+        monitor_printf(mon, "%c %s:\n", default_chr, machine->name);
+        monitor_printf(mon, "    max_cpus: %" PRId64 "\n", machine->cpu_max);
+        if (machine->has_alias) {
+            monitor_printf(mon, "    alias: %s\n", machine->alias);
+        }
+    }
+    qapi_free_MachineInfoList(mach_list);
+}
+
 void hmp_quit(Monitor *mon, const QDict *qdict)
 {
     monitor_suspend(mon);
diff --git a/hmp.h b/hmp.h
index 4fd3c4a..374e841 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_machines(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 34cee74..adc3645 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2921,6 +2921,13 @@ static mon_cmd_t info_cmds[] = {
         .mhandler.cmd = hmp_info_memdev,
     },
     {
+        .name       = "machines",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show supported machines information",
+        .mhandler.cmd = hmp_info_machines,
+    },
+    {
         .name       = NULL,
     },
 };
-- 
1.7.12.4

             reply	other threads:[~2014-08-27  9:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-27  9:24 zhanghailiang [this message]
2014-08-27 10:00 ` [Qemu-devel] [PATCH] hmp: Add info machines Paolo Bonzini
2014-08-28  1:44   ` zhanghailiang
2014-08-28  2:43     ` Amos Kong
2014-08-28  4:56       ` zhanghailiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1409131452-11064-1-git-send-email-zhang.zhanghailiang@huawei.com \
    --to=zhang.zhanghailiang@huawei.com \
    --cc=hani@linux.com \
    --cc=lcapitulino@redhat.com \
    --cc=luonengjun@huawei.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).