From: Luiz Capitulino <lcapitulino@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 16/16] Make qemu-io commands available in HMP
Date: Fri, 7 Jun 2013 10:17:15 -0400 [thread overview]
Message-ID: <20130607101715.1d97ac22@redhat.com> (raw)
In-Reply-To: <1370434781-28570-17-git-send-email-kwolf@redhat.com>
On Wed, 5 Jun 2013 14:19:41 +0200
Kevin Wolf <kwolf@redhat.com> wrote:
> It was decided to not make this command available in QMP in order to
> make clear that this is not supposed to be a stable API and should be
> used only for testing and debugging purposes.
I like this as a temporary solution.
But I also see that commands seem to print to stderr, so this needs
work before being available in QMP. Even for HMP or the -debug
extension this is not desirable.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> Makefile | 2 +-
> Makefile.objs | 1 +
> hmp-commands.hx | 16 ++++++++++++++++
> hmp.c | 18 ++++++++++++++++++
> hmp.h | 1 +
> 5 files changed, 37 insertions(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index 87298e5..9a77ae0 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -186,7 +186,7 @@ qemu-img.o: qemu-img-cmds.h
>
> qemu-img$(EXESUF): qemu-img.o $(block-obj-y) libqemuutil.a libqemustub.a
> qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) libqemuutil.a libqemustub.a
> -qemu-io$(EXESUF): qemu-io.o qemu-io-cmds.o $(block-obj-y) libqemuutil.a libqemustub.a
> +qemu-io$(EXESUF): qemu-io.o $(block-obj-y) libqemuutil.a libqemustub.a
>
> qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o
>
> diff --git a/Makefile.objs b/Makefile.objs
> index 286ce06..5b288ba 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -13,6 +13,7 @@ block-obj-$(CONFIG_POSIX) += aio-posix.o
> block-obj-$(CONFIG_WIN32) += aio-win32.o
> block-obj-y += block/
> block-obj-y += qapi-types.o qapi-visit.o
> +block-obj-y += qemu-io-cmds.o
>
> block-obj-y += qemu-coroutine.o qemu-coroutine-lock.o qemu-coroutine-io.o
> block-obj-y += qemu-coroutine-sleep.o
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index 9cea415..a6167bd 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -1551,6 +1551,22 @@ Removes the chardev @var{id}.
> ETEXI
>
> {
> + .name = "qemu-io",
> + .args_type = "device:B,command:s",
> + .params = "[device] \"[command]\"",
> + .help = "run a qemu-io command on a block device",
> + .mhandler.cmd = hmp_qemu_io,
> + },
> +
> +STEXI
> +@item qemu-io @var{device} @var{command}
> +@findex qemu-io
> +
> +Executes a qemu-io command on the given block device.
> +
> +ETEXI
> +
> + {
> .name = "info",
> .args_type = "item:s?",
> .params = "[subcommand]",
> diff --git a/hmp.c b/hmp.c
> index 4fb76ec..64e0baa 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -22,6 +22,7 @@
> #include "qemu/sockets.h"
> #include "monitor/monitor.h"
> #include "ui/console.h"
> +#include "qemu-io.h"
>
> static void hmp_handle_error(Monitor *mon, Error **errp)
> {
> @@ -1425,3 +1426,20 @@ void hmp_chardev_remove(Monitor *mon, const QDict *qdict)
> qmp_chardev_remove(qdict_get_str(qdict, "id"), &local_err);
> hmp_handle_error(mon, &local_err);
> }
> +
> +void hmp_qemu_io(Monitor *mon, const QDict *qdict)
> +{
> + BlockDriverState *bs;
> + const char* device = qdict_get_str(qdict, "device");
> + const char* command = qdict_get_str(qdict, "command");
> + Error *err = NULL;
> +
> + bs = bdrv_find(device);
> + if (bs) {
> + qemuio_command(bs, command);
> + } else {
> + error_set(&err, QERR_DEVICE_NOT_FOUND, device);
> + }
> +
> + hmp_handle_error(mon, &err);
> +}
> diff --git a/hmp.h b/hmp.h
> index 95fe76e..56d2e92 100644
> --- a/hmp.h
> +++ b/hmp.h
> @@ -85,5 +85,6 @@ void hmp_nbd_server_add(Monitor *mon, const QDict *qdict);
> void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
> void hmp_chardev_add(Monitor *mon, const QDict *qdict);
> void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
> +void hmp_qemu_io(Monitor *mon, const QDict *qdict);
>
> #endif
next prev parent reply other threads:[~2013-06-07 14:17 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-05 12:19 [Qemu-devel] [PATCH v2 00/16] Make qemu-io commands available in the monitor Kevin Wolf
2013-06-05 12:19 ` [Qemu-devel] [PATCH v2 01/16] qemu-io: Remove unused args_command Kevin Wolf
2013-06-05 12:19 ` [Qemu-devel] [PATCH v2 02/16] cutils: Support 'P' and 'E' suffixes in strtosz() Kevin Wolf
2013-06-05 12:19 ` [Qemu-devel] [PATCH v2 03/16] qemu-io: Make cvtnum() a wrapper around strtosz_suffix() Kevin Wolf
2013-06-05 12:19 ` [Qemu-devel] [PATCH v2 04/16] qemu-io: Handle cvtnum() errors in 'alloc' Kevin Wolf
2013-06-05 12:19 ` [Qemu-devel] [PATCH v2 05/16] qemu-io: Don't use global bs in command implementations Kevin Wolf
2013-06-05 12:19 ` [Qemu-devel] [PATCH v2 06/16] qemu-io: Split off commands to qemu-io-cmds.c Kevin Wolf
2013-06-05 12:19 ` [Qemu-devel] [PATCH v2 07/16] qemu-io: Factor out qemuio_command Kevin Wolf
2013-06-05 12:19 ` [Qemu-devel] [PATCH v2 08/16] qemu-io: Move 'help' function Kevin Wolf
2013-06-05 12:19 ` [Qemu-devel] [PATCH v2 09/16] qemu-io: Move 'quit' function Kevin Wolf
2013-06-05 12:19 ` [Qemu-devel] [PATCH v2 10/16] qemu-io: Move qemu_strsep() to cutils.c Kevin Wolf
2013-06-05 12:19 ` [Qemu-devel] [PATCH v2 11/16] qemu-io: Move functions for registering and running commands Kevin Wolf
2013-06-05 12:19 ` [Qemu-devel] [PATCH v2 12/16] qemu-io: Move command_loop() and friends Kevin Wolf
2013-06-05 12:19 ` [Qemu-devel] [PATCH v2 13/16] qemu-io: Move remaining helpers from cmd.c Kevin Wolf
2013-06-05 12:19 ` [Qemu-devel] [PATCH v2 14/16] qemu-io: Interface cleanup Kevin Wolf
2013-06-05 12:19 ` [Qemu-devel] [PATCH v2 15/16] qemu-io: Use the qemu version for -V Kevin Wolf
2013-06-05 12:19 ` [Qemu-devel] [PATCH v2 16/16] Make qemu-io commands available in HMP Kevin Wolf
2013-06-07 14:17 ` Luiz Capitulino [this message]
2013-06-06 9:46 ` [Qemu-devel] [PATCH v2 00/16] Make qemu-io commands available in the monitor Stefan Hajnoczi
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=20130607101715.1d97ac22@redhat.com \
--to=lcapitulino@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.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 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.