From: Anthony Liguori <anthony@codemonkey.ws>
To: Luiz Capitulino <lcapitulino@redhat.com>
Cc: kwolf@redhat.com, jan.kiszka@siemens.com, qemu-devel@nongnu.org,
armbru@redhat.com, avi@redhat.com, amit.shah@redhat.com
Subject: Re: [Qemu-devel] [PATCH 7/8] QMP: query-status: Introduce 'status' key
Date: Sun, 14 Aug 2011 11:44:22 -0500 [thread overview]
Message-ID: <4E47FB66.7070509@codemonkey.ws> (raw)
In-Reply-To: <1313008408-23161-8-git-send-email-lcapitulino@redhat.com>
On 08/10/2011 03:33 PM, Luiz Capitulino wrote:
> This new key reports the current VM status to clients. Please, check
> the documentation being added in this commit for more details.
>
> Signed-off-by: Luiz Capitulino<lcapitulino@redhat.com>
> ---
> monitor.c | 3 +--
> qmp-commands.hx | 21 ++++++++++++++++++++-
> sysemu.h | 1 +
> vl.c | 24 ++++++++++++++++++++++++
> 4 files changed, 46 insertions(+), 3 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index 82d19c0..c9e65fa 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -2622,8 +2622,7 @@ static void do_info_status_print(Monitor *mon, const QObject *data)
>
> static void do_info_status(Monitor *mon, QObject **ret_data)
> {
> - *ret_data = qobject_from_jsonf("{ 'running': %i, 'singlestep': %i }",
> - vm_is_running(), singlestep);
> + *ret_data = qobject_from_jsonf("{ 'running': %i, 'singlestep': %i, 'status': %s }", vm_is_running(), singlestep, runstate_get_name());
> }
>
> static qemu_acl *find_acl(Monitor *mon, const char *name)
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index 03f67da..cb73706 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -1547,11 +1547,30 @@ Return a json-object with the following information:
> - "running": true if the VM is running, or false if it is paused (json-bool)
> - "singlestep": true if the VM is in single step mode,
> false otherwise (json-bool)
> +- "status": one of the following values (json-string)
> + "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
> + "restore-vm-failed" - guest is paused following a failed attempt to
> + restore the 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
>
> Example:
>
> -> { "execute": "query-status" }
> -<- { "return": { "running": true, "singlestep": false } }
> +<- { "return": { "running": true, "singlestep": false, "status": "running" } }
>
> EQMP
>
> diff --git a/sysemu.h b/sysemu.h
> index 9a8ea78..60d882d 100644
> --- a/sysemu.h
> +++ b/sysemu.h
> @@ -38,6 +38,7 @@ int qemu_uuid_parse(const char *str, uint8_t *uuid);
>
> int vm_is_running(void);
> RunState runstate_get(void);
> +const char *runstate_get_name(void);
> void runstate_set(RunState state);
> typedef struct vm_change_state_entry VMChangeStateEntry;
> typedef void VMChangeStateHandler(void *opaque, int running, RunState state);
> diff --git a/vl.c b/vl.c
> index 537c5fb..61c3743 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -321,6 +321,23 @@ static int default_driver_check(QemuOpts *opts, void *opaque)
> /***********************************************************/
> /* QEMU state */
>
> +static const char *const runstate_name_tbl[RSTATE_MAX] = {
> + [RSTATE_DEBUG] = "debug",
> + [RSTATE_IN_MIGRATE] = "incoming-migration",
> + [RSTATE_PANICKED] = "internal-error",
> + [RSTATE_IO_ERROR] = "io-error",
> + [RSTATE_PAUSED] = "paused",
> + [RSTATE_POST_MIGRATE] = "post-migrate",
> + [RSTATE_PRE_LAUNCH] = "prelaunch",
> + [RSTATE_PRE_MIGRATE] = "finish-migrate",
> + [RSTATE_RESTORE] = "restore-vm",
> + [RSTATE_RESTORE_FAILED] = "restore-vm-failed",
> + [RSTATE_RUNNING] = "running",
> + [RSTATE_SAVEVM] = "save-vm",
> + [RSTATE_SHUTDOWN] = "shutdown",
> + [RSTATE_WATCHDOG] = "watchdog",
> +};
> +
> static RunState current_run_state = RSTATE_NO_STATE;
>
> RunState runstate_get(void)
> @@ -334,6 +351,13 @@ void runstate_set(RunState state)
> current_run_state = state;
> }
>
> +const char *runstate_get_name(void)
> +{
> + assert(current_run_state> RSTATE_NO_STATE&&
> + current_run_state< RSTATE_MAX);
> + return runstate_name_tbl[current_run_state];
> +}
> +
Minor suggestion:
const char *runstate_as_string(void);
Regards,
Anthony Liguori
> int vm_is_running(void)
> {
> return current_run_state == RSTATE_RUNNING;
next prev parent reply other threads:[~2011-08-14 18:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-10 20:33 [Qemu-devel] [PATCH v2 0/8]: Introduce the RunState type Luiz Capitulino
2011-08-10 20:33 ` [Qemu-devel] [PATCH 1/8] Move vm_state_notify() prototype from cpus.h to sysemu.h Luiz Capitulino
2011-08-10 20:33 ` [Qemu-devel] [PATCH 2/8] Replace the VMSTOP macros with a proper state type Luiz Capitulino
2011-08-10 20:33 ` [Qemu-devel] [PATCH 3/8] RunState: Add additional states Luiz Capitulino
2011-08-10 20:33 ` [Qemu-devel] [PATCH 4/8] Drop the incoming_expected global variable Luiz Capitulino
2011-08-14 16:42 ` Anthony Liguori
2011-08-10 20:33 ` [Qemu-devel] [PATCH 5/8] Drop the vm_running " Luiz Capitulino
2011-08-14 16:43 ` Anthony Liguori
2011-08-10 20:33 ` [Qemu-devel] [PATCH 6/8] Monitor: Don't allow cont on bad VM state Luiz Capitulino
2011-08-10 20:33 ` [Qemu-devel] [PATCH 7/8] QMP: query-status: Introduce 'status' key Luiz Capitulino
2011-08-14 16:44 ` Anthony Liguori [this message]
2011-08-10 20:33 ` [Qemu-devel] [PATCH 8/8] HMP: info status: Print the VM state Luiz Capitulino
2011-08-14 16:45 ` [Qemu-devel] [PATCH v2 0/8]: Introduce the RunState type Anthony Liguori
2011-08-15 21:44 ` Luiz Capitulino
-- strict thread matches above, loose matches on Subject: below --
2011-09-01 18:12 [Qemu-devel] [PATCH v3 " Luiz Capitulino
2011-09-01 18:12 ` [Qemu-devel] [PATCH 7/8] QMP: query-status: Introduce 'status' key 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=4E47FB66.7070509@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=amit.shah@redhat.com \
--cc=armbru@redhat.com \
--cc=avi@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.