From: Luiz Capitulino <lcapitulino@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, aliguori@us.ibm.com, mdroth@linux.vnet.ibm.com,
armbru@redhat.com
Subject: [Qemu-devel] [PATCH 14/21] qapi: Convert query-status
Date: Wed, 28 Sep 2011 11:44:38 -0300 [thread overview]
Message-ID: <1317221085-5825-15-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1317221085-5825-1-git-send-email-lcapitulino@redhat.com>
The original conversion was done by Anthony Liguori. This commit
is just a rebase.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
hmp.c | 19 +++++++++++++++
hmp.h | 1 +
monitor.c | 41 +--------------------------------
qapi-schema.json | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
qmp-commands.hx | 6 +++++
vl.c | 12 +++++++++
6 files changed, 106 insertions(+), 40 deletions(-)
diff --git a/hmp.c b/hmp.c
index 94a7f74..9e7f07e 100644
--- a/hmp.c
+++ b/hmp.c
@@ -53,3 +53,22 @@ void hmp_info_kvm(Monitor *mon)
qapi_free_KvmInfo(info);
}
+void hmp_info_status(Monitor *mon)
+{
+ StatusInfo *info;
+
+ info = qmp_query_status(NULL);
+
+ monitor_printf(mon, "VM status: %s%s",
+ info->running ? "running" : "paused",
+ info->singlestep ? " (single step mode)" : "");
+
+ if (!info->running && info->status != VM_RUN_STATUS_PAUSED) {
+ monitor_printf(mon, " (%s)", VmRunStatus_lookup[info->status]);
+ }
+
+ monitor_printf(mon, "\n");
+
+ qapi_free_StatusInfo(info);
+}
+
diff --git a/hmp.h b/hmp.h
index a93ac1f..df4242f 100644
--- a/hmp.h
+++ b/hmp.h
@@ -20,5 +20,6 @@
void hmp_info_name(Monitor *mon);
void hmp_info_version(Monitor *mon);
void hmp_info_kvm(Monitor *mon);
+void hmp_info_status(Monitor *mon);
#endif
diff --git a/monitor.c b/monitor.c
index edb56b9..f641504 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2544,36 +2544,6 @@ static int do_inject_nmi(Monitor *mon, const QDict *qdict, QObject **ret_data)
}
#endif
-static void do_info_status_print(Monitor *mon, const QObject *data)
-{
- QDict *qdict;
- const char *status;
-
- qdict = qobject_to_qdict(data);
-
- monitor_printf(mon, "VM status: ");
- if (qdict_get_bool(qdict, "running")) {
- monitor_printf(mon, "running");
- if (qdict_get_bool(qdict, "singlestep")) {
- monitor_printf(mon, " (single step mode)");
- }
- } else {
- monitor_printf(mon, "paused");
- }
-
- status = qdict_get_str(qdict, "status");
- if (strcmp(status, "paused") && strcmp(status, "running")) {
- monitor_printf(mon, " (%s)", status);
- }
-
- monitor_printf(mon, "\n");
-}
-
-static void do_info_status(Monitor *mon, QObject **ret_data)
-{
- *ret_data = qobject_from_jsonf("{ 'running': %i, 'singlestep': %i, 'status': %s }", runstate_is_running(), singlestep, runstate_as_string());
-}
-
static qemu_acl *find_acl(Monitor *mon, const char *name)
{
qemu_acl *acl = qemu_acl_find(name);
@@ -2966,8 +2936,7 @@ static const mon_cmd_t info_cmds[] = {
.args_type = "",
.params = "",
.help = "show the current VM status (running|paused)",
- .user_print = do_info_status_print,
- .mhandler.info_new = do_info_status,
+ .mhandler.info = hmp_info_status,
},
{
.name = "pcmcia",
@@ -3149,14 +3118,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
.mhandler.info_new = do_pci_info,
},
{
- .name = "status",
- .args_type = "",
- .params = "",
- .help = "show the current VM status (running|paused)",
- .user_print = do_info_status_print,
- .mhandler.info_new = do_info_status,
- },
- {
.name = "mice",
.args_type = "",
.params = "",
diff --git a/qapi-schema.json b/qapi-schema.json
index 641f12d..de0f807 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -85,3 +85,70 @@
##
{ 'command': 'query-kvm', 'returns': 'KvmInfo' }
+##
+# @VmRunStatus
+#
+# An enumation of VM run status.
+#
+# @debug: QEMU is running on a debugger
+#
+# @inmigrate: guest is paused waiting for an incoming migration
+#
+# @internal-error: An internal error that prevents further guest execution
+# has occurred
+#
+# @io-error: the last IOP has failed and the device is configured to pause
+# on I/O errors
+#
+# @paused: guest has been paused via the 'stop' command
+#
+# @postmigrate: guest is paused following a successful 'migrate'
+#
+# @prelaunch: QEMU was started with -S and guest has not started
+#
+# @finish-migrate: guest is paused to finish the migration process
+#
+# @restore-vm: guest is paused to restore VM state
+#
+# @running: guest is actively running
+#
+# @save-vm: guest is paused to save the VM state
+#
+# @shutdown: guest is shut down (and -no-shutdown is in use)
+#
+# @watchdog: the watchdog action is configured to pause and has been triggered
+##
+{ 'enum': 'VmRunStatus',
+ 'data': [ 'no-status', 'debug', 'inmigrate', 'internal-error', 'io-error',
+ 'paused', 'postmigrate', 'prelaunch', 'finish-migrate',
+ 'restore-vm', 'running', 'save-vm', 'shutdown', 'watchdog' ] }
+
+##
+# @StatusInfo:
+#
+# Information about VCPU run state
+#
+# @running: true if all VCPUs are runnable, false if not runnable
+#
+# @singlestep: true if VCPUs are in single-step mode
+#
+# @status: the @VmRunStatus
+#
+# Since: 0.14.0
+#
+# Notes: @singlestep is enabled through the GDB stub
+##
+{ 'type': 'StatusInfo',
+ 'data': {'running': 'bool', 'singlestep': 'bool', 'status': 'VmRunStatus'} }
+
+##
+# @query-status:
+#
+# Query the run status of all VCPUs
+#
+# Returns: @StatusInfo reflecting all VCPUs
+#
+# Since: 0.14.0
+##
+{ 'command': 'query-status', 'returns': 'StatusInfo' }
+
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 9f9751d..afa95bd 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -1609,6 +1609,12 @@ Example:
<- { "return": { "running": true, "singlestep": false, "status": "running" } }
EQMP
+
+ {
+ .name = "query-status",
+ .args_type = "",
+ .mhandler.cmd_new = qmp_marshal_input_query_status,
+ },
SQMP
query-mice
diff --git a/vl.c b/vl.c
index bd4a5ce..b7bef59 100644
--- a/vl.c
+++ b/vl.c
@@ -147,6 +147,7 @@ int main(int argc, char **argv)
#include "qemu-config.h"
#include "qemu-objects.h"
#include "qemu-options.h"
+#include "qmp-commands.h"
#ifdef CONFIG_VIRTFS
#include "fsdev/qemu-fsdev.h"
#endif
@@ -434,6 +435,17 @@ int runstate_is_running(void)
return runstate_check(RSTATE_RUNNING);
}
+StatusInfo *qmp_query_status(Error **errp)
+{
+ StatusInfo *info = g_malloc0(sizeof(*info));
+
+ info->running = runstate_is_running();
+ info->singlestep = singlestep;
+ info->status = current_run_state;
+
+ return info;
+}
+
/***********************************************************/
/* real time host monotonic timer */
--
1.7.7.rc0.72.g4b5ea
next prev parent reply other threads:[~2011-09-28 14:45 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-28 14:44 [Qemu-devel] [PATCH v1 00/21]: First round of QAPI conversions Luiz Capitulino
2011-09-28 14:44 ` [Qemu-devel] [PATCH 01/21] error: let error_is_type take a NULL error Luiz Capitulino
2011-09-28 14:44 ` [Qemu-devel] [PATCH 02/21] qerror: add qerror_report_err() Luiz Capitulino
2011-09-28 14:44 ` [Qemu-devel] [PATCH 03/21] qapi: add code generation support for middle mode Luiz Capitulino
2011-09-28 14:44 ` [Qemu-devel] [PATCH 04/21] qapi: use middle mode in QMP server Luiz Capitulino
2011-09-28 14:44 ` [Qemu-devel] [PATCH 05/21] qapi: fixup command generation for functions that return list types Luiz Capitulino
2011-09-28 14:44 ` [Qemu-devel] [PATCH 06/21] qapi: dealloc visitor, fix premature free and iteration logic Luiz Capitulino
2011-09-29 12:49 ` Anthony Liguori
2011-09-28 14:44 ` [Qemu-devel] [PATCH 07/21] qapi: generate qapi_free_* functions for *List types Luiz Capitulino
2011-09-29 12:50 ` Anthony Liguori
2011-09-28 14:44 ` [Qemu-devel] [PATCH 08/21] qapi: add test cases for generated free functions Luiz Capitulino
2011-09-29 12:51 ` Anthony Liguori
2011-09-28 14:44 ` [Qemu-devel] [PATCH 09/21] qapi: dealloc visitor, support freeing of nested lists Luiz Capitulino
2011-09-29 12:51 ` Anthony Liguori
2011-09-28 14:44 ` [Qemu-devel] [PATCH 10/21] qapi: modify visitor code generation for list iteration Luiz Capitulino
2011-09-29 12:53 ` Anthony Liguori
2011-09-28 14:44 ` [Qemu-devel] [PATCH 11/21] qapi: convert query-name Luiz Capitulino
2011-09-28 14:44 ` [Qemu-devel] [PATCH 12/21] qapi: Convert query-version Luiz Capitulino
2011-09-29 12:54 ` Anthony Liguori
2011-09-29 14:32 ` Luiz Capitulino
2011-09-29 14:42 ` Anthony Liguori
2011-09-28 14:44 ` [Qemu-devel] [PATCH 13/21] qapi: Convert query-kvm Luiz Capitulino
2011-09-28 14:44 ` Luiz Capitulino [this message]
2011-09-29 20:11 ` [Qemu-devel] [PATCH 14/21] qapi: Convert query-status Michael Roth
2011-09-28 14:44 ` [Qemu-devel] [PATCH 15/21] qapi: Convert query-uuid Luiz Capitulino
2011-09-28 14:44 ` [Qemu-devel] [PATCH 16/21] qapi: Convert query-chardev Luiz Capitulino
2011-09-29 19:17 ` Michael Roth
2011-09-28 14:44 ` [Qemu-devel] [PATCH 17/21] qapi: Convert query-commands Luiz Capitulino
2011-09-29 19:25 ` Michael Roth
2011-09-28 14:44 ` [Qemu-devel] [PATCH 18/21] qapi: Convert quit Luiz Capitulino
2011-09-28 14:44 ` [Qemu-devel] [PATCH 19/21] qapi: Convert stop Luiz Capitulino
2011-09-28 14:44 ` [Qemu-devel] [PATCH 20/21] qapi: Convert system_reset Luiz Capitulino
2011-09-28 14:44 ` [Qemu-devel] [PATCH 21/21] qapi: Convert system_powerdown Luiz Capitulino
2011-09-29 12:55 ` [Qemu-devel] [PATCH v1 00/21]: First round of QAPI conversions Anthony Liguori
2011-09-29 13:52 ` Luiz Capitulino
2011-09-29 20:15 ` Michael Roth
2011-09-29 20:57 ` Luiz Capitulino
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=1317221085-5825-15-git-send-email-lcapitulino@redhat.com \
--to=lcapitulino@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/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).