|
|
9ae3a8 |
From 6b7e23d3e8ff46e638c9dcd769681b2e1b9da08e Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 23 Nov 2015 17:38:35 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 16/27] Make qemu-io commands available in HMP
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1448300320-7772-17-git-send-email-jsnow@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 68443
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.3 qemu-kvm PATCH v2 16/21] Make qemu-io commands available in HMP
|
|
|
9ae3a8 |
Bugzilla: 1272523
|
|
|
9ae3a8 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
It was decided to not make this command available in QMP in order to
|
|
|
9ae3a8 |
make clear that this is not supposed to be a stable API and should be
|
|
|
9ae3a8 |
used only for testing and debugging purposes.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 587da2c39c9ace168f4d01fa446a54ae998a2553)
|
|
|
9ae3a8 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
Makefile | 2 +-
|
|
|
9ae3a8 |
Makefile.objs | 1 +
|
|
|
9ae3a8 |
hmp-commands.hx | 16 ++++++++++++++++
|
|
|
9ae3a8 |
hmp.c | 18 ++++++++++++++++++
|
|
|
9ae3a8 |
hmp.h | 1 +
|
|
|
9ae3a8 |
5 files changed, 37 insertions(+), 1 deletion(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/Makefile b/Makefile
|
|
|
9ae3a8 |
index f403057..76eb694 100644
|
|
|
9ae3a8 |
--- a/Makefile
|
|
|
9ae3a8 |
+++ b/Makefile
|
|
|
9ae3a8 |
@@ -205,7 +205,7 @@ qemu-img.o: qemu-img-cmds.h
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
qemu-img$(EXESUF): qemu-img.o $(block-obj-y) libqemuutil.a libqemustub.a
|
|
|
9ae3a8 |
qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) libqemuutil.a libqemustub.a
|
|
|
9ae3a8 |
-qemu-io$(EXESUF): qemu-io.o qemu-io-cmds.o $(block-obj-y) libqemuutil.a libqemustub.a
|
|
|
9ae3a8 |
+qemu-io$(EXESUF): qemu-io.o $(block-obj-y) libqemuutil.a libqemustub.a
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/Makefile.objs b/Makefile.objs
|
|
|
9ae3a8 |
index f83a5b2..74f722e 100644
|
|
|
9ae3a8 |
--- a/Makefile.objs
|
|
|
9ae3a8 |
+++ b/Makefile.objs
|
|
|
9ae3a8 |
@@ -13,6 +13,7 @@ block-obj-$(CONFIG_POSIX) += aio-posix.o
|
|
|
9ae3a8 |
block-obj-$(CONFIG_WIN32) += aio-win32.o
|
|
|
9ae3a8 |
block-obj-y += block/
|
|
|
9ae3a8 |
block-obj-y += qapi-types.o qapi-visit.o
|
|
|
9ae3a8 |
+block-obj-y += qemu-io-cmds.o
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
block-obj-y += qemu-coroutine.o qemu-coroutine-lock.o qemu-coroutine-io.o
|
|
|
9ae3a8 |
block-obj-y += qemu-coroutine-sleep.o
|
|
|
9ae3a8 |
diff --git a/hmp-commands.hx b/hmp-commands.hx
|
|
|
9ae3a8 |
index 58498f7..7e1855a 100644
|
|
|
9ae3a8 |
--- a/hmp-commands.hx
|
|
|
9ae3a8 |
+++ b/hmp-commands.hx
|
|
|
9ae3a8 |
@@ -1592,6 +1592,22 @@ Removes the chardev @var{id}.
|
|
|
9ae3a8 |
ETEXI
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
+ .name = "qemu-io",
|
|
|
9ae3a8 |
+ .args_type = "device:B,command:s",
|
|
|
9ae3a8 |
+ .params = "[device] \"[command]\"",
|
|
|
9ae3a8 |
+ .help = "run a qemu-io command on a block device",
|
|
|
9ae3a8 |
+ .mhandler.cmd = hmp_qemu_io,
|
|
|
9ae3a8 |
+ },
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+STEXI
|
|
|
9ae3a8 |
+@item qemu-io @var{device} @var{command}
|
|
|
9ae3a8 |
+@findex qemu-io
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+Executes a qemu-io command on the given block device.
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ETEXI
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ {
|
|
|
9ae3a8 |
.name = "info",
|
|
|
9ae3a8 |
.args_type = "item:s?",
|
|
|
9ae3a8 |
.params = "[subcommand]",
|
|
|
9ae3a8 |
diff --git a/hmp.c b/hmp.c
|
|
|
9ae3a8 |
index 1805926..e1d92f4 100644
|
|
|
9ae3a8 |
--- a/hmp.c
|
|
|
9ae3a8 |
+++ b/hmp.c
|
|
|
9ae3a8 |
@@ -22,6 +22,7 @@
|
|
|
9ae3a8 |
#include "qemu/sockets.h"
|
|
|
9ae3a8 |
#include "monitor/monitor.h"
|
|
|
9ae3a8 |
#include "ui/console.h"
|
|
|
9ae3a8 |
+#include "qemu-io.h"
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static void hmp_handle_error(Monitor *mon, Error **errp)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
@@ -1448,3 +1449,20 @@ void hmp_chardev_remove(Monitor *mon, const QDict *qdict)
|
|
|
9ae3a8 |
qmp_chardev_remove(qdict_get_str(qdict, "id"), &local_err);
|
|
|
9ae3a8 |
hmp_handle_error(mon, &local_err);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+void hmp_qemu_io(Monitor *mon, const QDict *qdict)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ BlockDriverState *bs;
|
|
|
9ae3a8 |
+ const char* device = qdict_get_str(qdict, "device");
|
|
|
9ae3a8 |
+ const char* command = qdict_get_str(qdict, "command");
|
|
|
9ae3a8 |
+ Error *err = NULL;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ bs = bdrv_find(device);
|
|
|
9ae3a8 |
+ if (bs) {
|
|
|
9ae3a8 |
+ qemuio_command(bs, command);
|
|
|
9ae3a8 |
+ } else {
|
|
|
9ae3a8 |
+ error_set(&err, QERR_DEVICE_NOT_FOUND, device);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ hmp_handle_error(mon, &err;;
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
diff --git a/hmp.h b/hmp.h
|
|
|
9ae3a8 |
index 9b2c9ce..b27ef3d 100644
|
|
|
9ae3a8 |
--- a/hmp.h
|
|
|
9ae3a8 |
+++ b/hmp.h
|
|
|
9ae3a8 |
@@ -86,5 +86,6 @@ void hmp_nbd_server_add(Monitor *mon, const QDict *qdict);
|
|
|
9ae3a8 |
void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
|
|
|
9ae3a8 |
void hmp_chardev_add(Monitor *mon, const QDict *qdict);
|
|
|
9ae3a8 |
void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
|
|
|
9ae3a8 |
+void hmp_qemu_io(Monitor *mon, const QDict *qdict);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#endif
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|