aboutsummaryrefslogtreecommitdiff
path: root/chardev
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2023-04-13 16:07:24 +0100
committerThomas Huth <thuth@redhat.com>2023-04-20 06:50:11 +0200
commit5b18a6bf44b93122ba6638d227153cd146a68973 (patch)
tree27b3f75564fcaab8338c00e9d3c6489b7023ee60 /chardev
parent537a1388e65a784ac21eaf1639222e6332357b2f (diff)
chardev: Allow setting file chardev input file on the command line
Our 'file' chardev backend supports both "output from this chardev is written to a file" and "input from this chardev should be read from a file" (except on Windows). However, you can only set up the input file if you're using the QMP interface -- there is no command line syntax to do it. Add command line syntax to allow specifying an input file as well as an output file, using a new 'input-path' suboption. The specific use case I have is that I'd like to be able to feed fuzzer reproducer input into qtest without having to use '-qtest stdio' and put the input onto stdin. Being able to use a file chardev like this: -chardev file,id=repro,path=/dev/null,input-path=repro.txt -qtest chardev:repro means that stdio is free for use by gdb. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20230413150724.404304-3-peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> [thuth: Replace "input-file=" typo with "input-path="] Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'chardev')
-rw-r--r--chardev/char-file.c8
-rw-r--r--chardev/char.c3
2 files changed, 11 insertions, 0 deletions
diff --git a/chardev/char-file.c b/chardev/char-file.c
index 3a7b9caf6f..263e6da563 100644
--- a/chardev/char-file.c
+++ b/chardev/char-file.c
@@ -100,6 +100,7 @@ static void qemu_chr_parse_file_out(QemuOpts *opts, ChardevBackend *backend,
Error **errp)
{
const char *path = qemu_opt_get(opts, "path");
+ const char *inpath = qemu_opt_get(opts, "input-path");
ChardevFile *file;
backend->type = CHARDEV_BACKEND_KIND_FILE;
@@ -107,9 +108,16 @@ static void qemu_chr_parse_file_out(QemuOpts *opts, ChardevBackend *backend,
error_setg(errp, "chardev: file: no filename given");
return;
}
+#ifdef _WIN32
+ if (inpath) {
+ error_setg(errp, "chardev: file: input-path not supported on Windows");
+ return;
+ }
+#endif
file = backend->u.file.data = g_new0(ChardevFile, 1);
qemu_chr_parse_common(opts, qapi_ChardevFile_base(file));
file->out = g_strdup(path);
+ file->in = g_strdup(inpath);
file->has_append = true;
file->append = qemu_opt_get_bool(opts, "append", false);
diff --git a/chardev/char.c b/chardev/char.c
index e69390601f..661ad8176a 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -806,6 +806,9 @@ QemuOptsList qemu_chardev_opts = {
.name = "path",
.type = QEMU_OPT_STRING,
},{
+ .name = "input-path",
+ .type = QEMU_OPT_STRING,
+ },{
.name = "host",
.type = QEMU_OPT_STRING,
},{