mirror of
https://gitlab.com/qemu-project/qemu.git
synced 2026-10-28 14:04:39 +08:00
qtest: add qemu-io command to the qtest protocol
Add a "qemu-io" command to the qtest protocol so that tests can issue block layer I/O commands without going through the HMP monitor's "human-monitor-command" QMP, or use QMP at all. Unfortunately, many tests will prefer to use QMP as they also monitor and log other events. It's easier if it is pipelined in the same stream. Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20260828-qemu-no-hmp-v5-23-9227de146347@redhat.com>
This commit is contained in:
1 parent
1f8d06ef42
commit
4440cc2fe9
3 files changed
+39
No files matched your search
@@ -33,6 +33,7 @@
|
||||
#include "qom/object_interfaces.h"
|
||||
#include "qom/qom-qobject.h"
|
||||
#include "qobject/qobject.h"
|
||||
#include "qapi-commands-block.h"
|
||||
|
||||
#define MAX_IRQ 256
|
||||
|
||||
@@ -797,6 +798,19 @@ static void qtest_process_command(CharFrontend *chr, gchar **words)
|
||||
}
|
||||
g_slist_free(list);
|
||||
qtest_send(chr, "OK\n");
|
||||
} else if (strcmp(words[0], "qemu-io") == 0) {
|
||||
const char *io_dev;
|
||||
g_autofree char *io_cmd = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
g_assert(words[1] && words[2]);
|
||||
io_dev = words[1];
|
||||
io_cmd = g_strjoinv(" ", &words[2]);
|
||||
|
||||
qmp_x_qemu_io(io_dev, NULL, io_cmd, &err);
|
||||
qtest_sendf(chr, err ? "FAIL %s\n" : "OK\n",
|
||||
err ? error_get_pretty(err) : NULL);
|
||||
error_free(err);
|
||||
} else if (process_command_cb && process_command_cb(chr, words)) {
|
||||
/* Command got consumed by the callback handler */
|
||||
} else {
|
||||
|
||||
@@ -1012,6 +1012,20 @@ char *qtest_hmp(QTestState *s, const char *fmt, ...)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void qtest_qemu_io(QTestState *s, const char *device,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
g_autofree char *cmd = NULL;
|
||||
|
||||
va_start(ap, fmt);
|
||||
cmd = g_strdup_vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
qtest_sendf(s, "qemu-io %s %s\n", device, cmd);
|
||||
qtest_rsp(s);
|
||||
}
|
||||
|
||||
const char *qtest_get_arch(void)
|
||||
{
|
||||
/*
|
||||
|
||||
@@ -424,6 +424,17 @@ char *qtest_hmp(QTestState *s, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
|
||||
char *qtest_vhmp(QTestState *s, const char *fmt, va_list ap)
|
||||
G_GNUC_PRINTF(2, 0);
|
||||
|
||||
/**
|
||||
* qtest_qemu_io:
|
||||
* @s: #QTestState instance to operate on.
|
||||
* @device: block device node-name or BlockBackend name.
|
||||
* @fmt: qemu-io command to send, formats arguments like sprintf().
|
||||
*
|
||||
* Send a qemu-io command via the qtest protocol.
|
||||
*/
|
||||
void qtest_qemu_io(QTestState *s, const char *device,
|
||||
const char *fmt, ...) G_GNUC_PRINTF(3, 4);
|
||||
|
||||
void qtest_module_load(QTestState *s, const char *prefix, const char *libname);
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user