Received: from eggs.gnu.org ([2001:4830:134:3::10]:56416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAabt-0001Gx-Ri for qemu-devel@nongnu.org; Fri, 25 Jul 2014 04:12:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XAabn-0006h3-Mb for qemu-devel@nongnu.org; Fri, 25 Jul 2014 04:12:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18217) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAabn-0006gp-GA for qemu-devel@nongnu.org; Fri, 25 Jul 2014 04:12:07 -0400 From: Markus Armbruster References: <1406219965-13214-1-git-send-email-stefanha@redhat.com> <1406219965-13214-3-git-send-email-stefanha@redhat.com> Date: Fri, 25 Jul 2014 10:12:01 +0200 In-Reply-To: <1406219965-13214-3-git-send-email-stefanha@redhat.com> (Stefan Hajnoczi's message of "Thu, 24 Jul 2014 17:39:24 +0100") Message-ID: <87ppgtvovi.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 2/3] qemu-char: add -chardev exit-on-eof option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org, Anthony Liguori , Andreas Faerber Stefan Hajnoczi 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 > --- > 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.