Skip to content

Commit

Permalink
Make qemu-io commands available in HMP
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Kevin Wolf <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
  • Loading branch information
kevmw authored and stefanhaRH committed Jun 6, 2013
1 parent 02da386 commit 587da2c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions Makefile.objs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions hmp-commands.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,22 @@ STEXI

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

{
Expand Down
18 changes: 18 additions & 0 deletions hmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}
1 change: 1 addition & 0 deletions hmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 587da2c

Please sign in to comment.