* [PATCH 0/2] chardev/char-file: Allow setting input file on command line
@ 2023-04-13 15:07 Peter Maydell
2023-04-13 15:07 ` [PATCH 1/2] qtest: Don't assert on "-qtest chardev:myid" Peter Maydell
2023-04-13 15:07 ` [PATCH 2/2] chardev: Allow setting file chardev input file on the command line Peter Maydell
0 siblings, 2 replies; 9+ messages in thread
From: Peter Maydell @ 2023-04-13 15:07 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Thomas Huth, Laurent Vivier, Marc-André Lureau
Our 'file' chardev backend supports specifying both an
input and an output file, but only if you create it via
the QMP interface -- there is no command-line syntax
support for setting the input file. This patchset adds
an extra 'input-path' option to the chardev.
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.
The first patch in the series fixes an assertion failure
in the qtest code if you try to pass it a named chardev;
the second patch adds the new option to the file backend.
thanks
-- PMM
Peter Maydell (2):
qtest: Don't assert on "-qtest chardev:myid"
chardev: Allow setting file chardev input file on the command line
chardev/char-file.c | 8 ++++++++
chardev/char.c | 3 +++
softmmu/qtest.c | 2 +-
qemu-options.hx | 10 ++++++++--
4 files changed, 20 insertions(+), 3 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] qtest: Don't assert on "-qtest chardev:myid"
2023-04-13 15:07 [PATCH 0/2] chardev/char-file: Allow setting input file on command line Peter Maydell
@ 2023-04-13 15:07 ` Peter Maydell
2023-04-14 14:50 ` Thomas Huth
2023-04-14 19:01 ` Marc-André Lureau
2023-04-13 15:07 ` [PATCH 2/2] chardev: Allow setting file chardev input file on the command line Peter Maydell
1 sibling, 2 replies; 9+ messages in thread
From: Peter Maydell @ 2023-04-13 15:07 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Thomas Huth, Laurent Vivier, Marc-André Lureau
If the -qtest command line argument is passed a string that says
"use this chardev for I/O", then it will assert:
$ ./build/clang/qemu-system-i386 -chardev file,path=/dev/null,id=myid -qtest chardev:myid
Unexpected error in qtest_set_chardev() at ../../softmmu/qtest.c:1011:
qemu-system-i386: Cannot find character device 'qtest'
Aborted (core dumped)
This is because in qtest_server_init() we assume that when we create
the chardev with qemu_chr_new() it will always have the name "qtest".
This is true if qemu_chr_new() had to create a new chardev, but not
true if one already existed and is being referred to with
"chardev:myid".
Use the name of the chardev we get back from qemu_chr_new() as the
string to set the qtest 'chardev' property to, instead of hardcoding
it to "qtest".
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
softmmu/qtest.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/softmmu/qtest.c b/softmmu/qtest.c
index 34bd2a33a76..26852996b5b 100644
--- a/softmmu/qtest.c
+++ b/softmmu/qtest.c
@@ -867,7 +867,7 @@ void qtest_server_init(const char *qtest_chrdev, const char *qtest_log, Error **
}
qtest = object_new(TYPE_QTEST);
- object_property_set_str(qtest, "chardev", "qtest", &error_abort);
+ object_property_set_str(qtest, "chardev", chr->label, &error_abort);
if (qtest_log) {
object_property_set_str(qtest, "log", qtest_log, &error_abort);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] chardev: Allow setting file chardev input file on the command line
2023-04-13 15:07 [PATCH 0/2] chardev/char-file: Allow setting input file on command line Peter Maydell
2023-04-13 15:07 ` [PATCH 1/2] qtest: Don't assert on "-qtest chardev:myid" Peter Maydell
@ 2023-04-13 15:07 ` Peter Maydell
2023-04-14 14:03 ` Philippe Mathieu-Daudé
` (2 more replies)
1 sibling, 3 replies; 9+ messages in thread
From: Peter Maydell @ 2023-04-13 15:07 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Thomas Huth, Laurent Vivier, Marc-André Lureau
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>
---
The "not on Windows" ifdeffery is because qmp_chardev_open_file()
does something similar; it seems likely to produce a nicer
error message to catch it at parse time rather than open time.
---
chardev/char-file.c | 8 ++++++++
chardev/char.c | 3 +++
qemu-options.hx | 10 ++++++++--
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/chardev/char-file.c b/chardev/char-file.c
index 3a7b9caf6f0..263e6da5636 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 e69390601fc..661ad8176a9 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -805,6 +805,9 @@ QemuOptsList qemu_chardev_opts = {
},{
.name = "path",
.type = QEMU_OPT_STRING,
+ },{
+ .name = "input-path",
+ .type = QEMU_OPT_STRING,
},{
.name = "host",
.type = QEMU_OPT_STRING,
diff --git a/qemu-options.hx b/qemu-options.hx
index 59bdf67a2c5..31d08c60264 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3360,7 +3360,7 @@ DEF("chardev", HAS_ARG, QEMU_OPTION_chardev,
"-chardev vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]]\n"
" [,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
"-chardev ringbuf,id=id[,size=size][,logfile=PATH][,logappend=on|off]\n"
- "-chardev file,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
+ "-chardev file,id=id,path=path[,input-file=input-file][,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
"-chardev pipe,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
#ifdef _WIN32
"-chardev console,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
@@ -3563,13 +3563,19 @@ The available backends are:
Create a ring buffer with fixed size ``size``. size must be a power
of two and defaults to ``64K``.
-``-chardev file,id=id,path=path``
+``-chardev file,id=id,path=path[,input-path=input-path]``
Log all traffic received from the guest to a file.
``path`` specifies the path of the file to be opened. This file will
be created if it does not already exist, and overwritten if it does.
``path`` is required.
+ If ``input-path`` is specified, this is the path of a second file
+ which will be used for input. If ``input-path`` is not specified,
+ no input will be available from the chardev.
+
+ Note that ``input-path`` is not supported on Windows hosts.
+
``-chardev pipe,id=id,path=path``
Create a two-way connection to the guest. The behaviour differs
slightly between Windows hosts and other hosts:
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] chardev: Allow setting file chardev input file on the command line
2023-04-13 15:07 ` [PATCH 2/2] chardev: Allow setting file chardev input file on the command line Peter Maydell
@ 2023-04-14 14:03 ` Philippe Mathieu-Daudé
2023-04-14 14:21 ` Peter Maydell
2023-04-14 14:52 ` Thomas Huth
2023-04-14 19:33 ` Marc-André Lureau
2 siblings, 1 reply; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-04-14 14:03 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
Cc: Paolo Bonzini, Thomas Huth, Laurent Vivier, Marc-André Lureau
On 13/4/23 17:07, Peter Maydell wrote:
> 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>
> ---
> The "not on Windows" ifdeffery is because qmp_chardev_open_file()
> does something similar; it seems likely to produce a nicer
> error message to catch it at parse time rather than open time.
> ---
> chardev/char-file.c | 8 ++++++++
> chardev/char.c | 3 +++
> qemu-options.hx | 10 ++++++++--
> 3 files changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/chardev/char-file.c b/chardev/char-file.c
> index 3a7b9caf6f0..263e6da5636 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");
> file->out = g_strdup(path);
> + file->in = g_strdup(inpath);
> diff --git a/chardev/char.c b/chardev/char.c
> index e69390601fc..661ad8176a9 100644
> --- a/chardev/char.c
> +++ b/chardev/char.c
> @@ -805,6 +805,9 @@ QemuOptsList qemu_chardev_opts = {
> },{
> .name = "path",
> .type = QEMU_OPT_STRING,
> + },{
> + .name = "input-path",
> + .type = QEMU_OPT_STRING,
> },{
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 59bdf67a2c5..31d08c60264 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> -``-chardev file,id=id,path=path``
> +``-chardev file,id=id,path=path[,input-path=input-path]``
> Log all traffic received from the guest to a file.
>
> ``path`` specifies the path of the file to be opened. This file will
> be created if it does not already exist, and overwritten if it does.
> ``path`` is required.
I find "path" vs. "input-path" confusing and would rather rename it as
"output-path" for consistency; or at least add an alias.
Possibly deprecating the "path" alias. Maybe matter of taste...
Can be done as follow-up, so:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> + If ``input-path`` is specified, this is the path of a second file
> + which will be used for input. If ``input-path`` is not specified,
> + no input will be available from the chardev.
> +
> + Note that ``input-path`` is not supported on Windows hosts.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] chardev: Allow setting file chardev input file on the command line
2023-04-14 14:03 ` Philippe Mathieu-Daudé
@ 2023-04-14 14:21 ` Peter Maydell
0 siblings, 0 replies; 9+ messages in thread
From: Peter Maydell @ 2023-04-14 14:21 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Paolo Bonzini, Thomas Huth, Laurent Vivier,
Marc-André Lureau
On Fri, 14 Apr 2023 at 15:03, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> On 13/4/23 17:07, Peter Maydell wrote:
> > --- a/qemu-options.hx
> > +++ b/qemu-options.hx
>
>
> > -``-chardev file,id=id,path=path``
> > +``-chardev file,id=id,path=path[,input-path=input-path]``
> > Log all traffic received from the guest to a file.
> >
> > ``path`` specifies the path of the file to be opened. This file will
> > be created if it does not already exist, and overwritten if it does.
> > ``path`` is required.
>
> I find "path" vs. "input-path" confusing and would rather rename it as
> "output-path" for consistency; or at least add an alias.
> Possibly deprecating the "path" alias. Maybe matter of taste...
The much more common use is the preexisting one of "write the
output to the file". I don't particularly want to break all
the uses of that just because we added this option.
thanks
-- PMM
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] qtest: Don't assert on "-qtest chardev:myid"
2023-04-13 15:07 ` [PATCH 1/2] qtest: Don't assert on "-qtest chardev:myid" Peter Maydell
@ 2023-04-14 14:50 ` Thomas Huth
2023-04-14 19:01 ` Marc-André Lureau
1 sibling, 0 replies; 9+ messages in thread
From: Thomas Huth @ 2023-04-14 14:50 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
Cc: Paolo Bonzini, Laurent Vivier, Marc-André Lureau
On 13/04/2023 17.07, Peter Maydell wrote:
> If the -qtest command line argument is passed a string that says
> "use this chardev for I/O", then it will assert:
>
> $ ./build/clang/qemu-system-i386 -chardev file,path=/dev/null,id=myid -qtest chardev:myid
> Unexpected error in qtest_set_chardev() at ../../softmmu/qtest.c:1011:
> qemu-system-i386: Cannot find character device 'qtest'
> Aborted (core dumped)
>
> This is because in qtest_server_init() we assume that when we create
> the chardev with qemu_chr_new() it will always have the name "qtest".
> This is true if qemu_chr_new() had to create a new chardev, but not
> true if one already existed and is being referred to with
> "chardev:myid".
>
> Use the name of the chardev we get back from qemu_chr_new() as the
> string to set the qtest 'chardev' property to, instead of hardcoding
> it to "qtest".
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> softmmu/qtest.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/softmmu/qtest.c b/softmmu/qtest.c
> index 34bd2a33a76..26852996b5b 100644
> --- a/softmmu/qtest.c
> +++ b/softmmu/qtest.c
> @@ -867,7 +867,7 @@ void qtest_server_init(const char *qtest_chrdev, const char *qtest_log, Error **
> }
>
> qtest = object_new(TYPE_QTEST);
> - object_property_set_str(qtest, "chardev", "qtest", &error_abort);
> + object_property_set_str(qtest, "chardev", chr->label, &error_abort);
> if (qtest_log) {
> object_property_set_str(qtest, "log", qtest_log, &error_abort);
> }
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] chardev: Allow setting file chardev input file on the command line
2023-04-13 15:07 ` [PATCH 2/2] chardev: Allow setting file chardev input file on the command line Peter Maydell
2023-04-14 14:03 ` Philippe Mathieu-Daudé
@ 2023-04-14 14:52 ` Thomas Huth
2023-04-14 19:33 ` Marc-André Lureau
2 siblings, 0 replies; 9+ messages in thread
From: Thomas Huth @ 2023-04-14 14:52 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
Cc: Paolo Bonzini, Laurent Vivier, Marc-André Lureau
On 13/04/2023 17.07, Peter Maydell wrote:
> 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>
> ---
...
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 59bdf67a2c5..31d08c60264 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -3360,7 +3360,7 @@ DEF("chardev", HAS_ARG, QEMU_OPTION_chardev,
> "-chardev vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]]\n"
> " [,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
> "-chardev ringbuf,id=id[,size=size][,logfile=PATH][,logappend=on|off]\n"
> - "-chardev file,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
> + "-chardev file,id=id,path=path[,input-file=input-file][,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
s/input-file=/input-path=/
Thomas
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] qtest: Don't assert on "-qtest chardev:myid"
2023-04-13 15:07 ` [PATCH 1/2] qtest: Don't assert on "-qtest chardev:myid" Peter Maydell
2023-04-14 14:50 ` Thomas Huth
@ 2023-04-14 19:01 ` Marc-André Lureau
1 sibling, 0 replies; 9+ messages in thread
From: Marc-André Lureau @ 2023-04-14 19:01 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, Paolo Bonzini, Thomas Huth, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 1732 bytes --]
On Thu, Apr 13, 2023 at 7:07 PM Peter Maydell <peter.maydell@linaro.org>
wrote:
> If the -qtest command line argument is passed a string that says
> "use this chardev for I/O", then it will assert:
>
> $ ./build/clang/qemu-system-i386 -chardev file,path=/dev/null,id=myid
> -qtest chardev:myid
> Unexpected error in qtest_set_chardev() at ../../softmmu/qtest.c:1011:
> qemu-system-i386: Cannot find character device 'qtest'
> Aborted (core dumped)
>
> This is because in qtest_server_init() we assume that when we create
> the chardev with qemu_chr_new() it will always have the name "qtest".
> This is true if qemu_chr_new() had to create a new chardev, but not
> true if one already existed and is being referred to with
> "chardev:myid".
>
> Use the name of the chardev we get back from qemu_chr_new() as the
> string to set the qtest 'chardev' property to, instead of hardcoding
> it to "qtest".
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> softmmu/qtest.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/softmmu/qtest.c b/softmmu/qtest.c
> index 34bd2a33a76..26852996b5b 100644
> --- a/softmmu/qtest.c
> +++ b/softmmu/qtest.c
> @@ -867,7 +867,7 @@ void qtest_server_init(const char *qtest_chrdev, const
> char *qtest_log, Error **
> }
>
> qtest = object_new(TYPE_QTEST);
> - object_property_set_str(qtest, "chardev", "qtest", &error_abort);
> + object_property_set_str(qtest, "chardev", chr->label, &error_abort);
> if (qtest_log) {
> object_property_set_str(qtest, "log", qtest_log, &error_abort);
> }
> --
> 2.34.1
>
>
[-- Attachment #2: Type: text/html, Size: 2531 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] chardev: Allow setting file chardev input file on the command line
2023-04-13 15:07 ` [PATCH 2/2] chardev: Allow setting file chardev input file on the command line Peter Maydell
2023-04-14 14:03 ` Philippe Mathieu-Daudé
2023-04-14 14:52 ` Thomas Huth
@ 2023-04-14 19:33 ` Marc-André Lureau
2 siblings, 0 replies; 9+ messages in thread
From: Marc-André Lureau @ 2023-04-14 19:33 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, Paolo Bonzini, Thomas Huth, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 4997 bytes --]
On Thu, Apr 13, 2023 at 7:07 PM Peter Maydell <peter.maydell@linaro.org>
wrote:
> 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>
>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> The "not on Windows" ifdeffery is because qmp_chardev_open_file()
> does something similar; it seems likely to produce a nicer
> error message to catch it at parse time rather than open time.
>
(I wonder if we could actually reduce the win32-specific code, I'll have a
look eventually)
---
> chardev/char-file.c | 8 ++++++++
> chardev/char.c | 3 +++
> qemu-options.hx | 10 ++++++++--
> 3 files changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/chardev/char-file.c b/chardev/char-file.c
> index 3a7b9caf6f0..263e6da5636 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 e69390601fc..661ad8176a9 100644
> --- a/chardev/char.c
> +++ b/chardev/char.c
> @@ -805,6 +805,9 @@ QemuOptsList qemu_chardev_opts = {
> },{
> .name = "path",
> .type = QEMU_OPT_STRING,
> + },{
> + .name = "input-path",
> + .type = QEMU_OPT_STRING,
> },{
> .name = "host",
> .type = QEMU_OPT_STRING,
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 59bdf67a2c5..31d08c60264 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -3360,7 +3360,7 @@ DEF("chardev", HAS_ARG, QEMU_OPTION_chardev,
> "-chardev
> vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]]\n"
> " [,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
> "-chardev
> ringbuf,id=id[,size=size][,logfile=PATH][,logappend=on|off]\n"
> - "-chardev
> file,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
> + "-chardev
> file,id=id,path=path[,input-file=input-file][,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
> "-chardev
> pipe,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
> #ifdef _WIN32
> "-chardev
> console,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
> @@ -3563,13 +3563,19 @@ The available backends are:
> Create a ring buffer with fixed size ``size``. size must be a power
> of two and defaults to ``64K``.
>
> -``-chardev file,id=id,path=path``
> +``-chardev file,id=id,path=path[,input-path=input-path]``
> Log all traffic received from the guest to a file.
>
> ``path`` specifies the path of the file to be opened. This file will
> be created if it does not already exist, and overwritten if it does.
> ``path`` is required.
>
> + If ``input-path`` is specified, this is the path of a second file
> + which will be used for input. If ``input-path`` is not specified,
> + no input will be available from the chardev.
> +
> + Note that ``input-path`` is not supported on Windows hosts.
> +
> ``-chardev pipe,id=id,path=path``
> Create a two-way connection to the guest. The behaviour differs
> slightly between Windows hosts and other hosts:
> --
> 2.34.1
>
>
[-- Attachment #2: Type: text/html, Size: 6386 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-04-14 19:34 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13 15:07 [PATCH 0/2] chardev/char-file: Allow setting input file on command line Peter Maydell
2023-04-13 15:07 ` [PATCH 1/2] qtest: Don't assert on "-qtest chardev:myid" Peter Maydell
2023-04-14 14:50 ` Thomas Huth
2023-04-14 19:01 ` Marc-André Lureau
2023-04-13 15:07 ` [PATCH 2/2] chardev: Allow setting file chardev input file on the command line Peter Maydell
2023-04-14 14:03 ` Philippe Mathieu-Daudé
2023-04-14 14:21 ` Peter Maydell
2023-04-14 14:52 ` Thomas Huth
2023-04-14 19:33 ` Marc-André Lureau
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.