Stefan Hajnoczi <stefa...@redhat.com> writes: > When QEMU is executed as part of a test case or from a script, it is > usually desirable to exit if the parent process terminates. This > ensures that "leaked" QEMU processes do not continue consuming resources > after their parent has died. > > This patch adds the -chardev exit-on-eof option causing socket and pipe > chardevs to exit QEMU upon close. This happens when a parent process > deliberately closes its file descriptor but also when the kernel cleans > up a crashed process. > > Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com> > --- > include/sysemu/char.h | 1 + > qapi-schema.json | 23 ++++++++++++++++------- > qemu-char.c | 34 ++++++++++++++++++++++++++++------ > qemu-options.hx | 19 +++++++++++++------ > 4 files changed, 58 insertions(+), 19 deletions(-) > > diff --git a/include/sysemu/char.h b/include/sysemu/char.h > index 0bbd631..382b320 100644 > --- a/include/sysemu/char.h > +++ b/include/sysemu/char.h > @@ -86,6 +86,7 @@ struct CharDriverState { > guint fd_in_tag; > QemuOpts *opts; > QTAILQ_ENTRY(CharDriverState) next; > + bool exit_on_eof; > }; > > /** > diff --git a/qapi-schema.json b/qapi-schema.json > index b11aad2..9b13da1 100644 > --- a/qapi-schema.json > +++ b/qapi-schema.json > @@ -2630,10 +2630,13 @@ > # @device: The name of the special file for the device, > # i.e. /dev/ttyS0 on Unix or COM1: on Windows > # @type: What kind of device this is. > +# @exit-on-eof: #optional terminate when other side closes the pipe > +# (default: false, since: 2.2) > # > # Since: 1.4 > ## > -{ 'type': 'ChardevHostdev', 'data': { 'device' : 'str' } } > +{ 'type': 'ChardevHostdev', 'data': { 'device' : 'str', > + '*exit-on-eof' : 'bool' } } > > ## > # @ChardevSocket:
Any use cases beyond libqtest? If no, should this be x-exit-on-eof? Hmm, looks like there's no precedence for x- in QAPI.