qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/3] qemu-char: add -chardev exit-on-eof option


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH 2/3] qemu-char: add -chardev exit-on-eof option
Date: Fri, 25 Jul 2014 10:39:44 +0100

On Fri, Jul 25, 2014 at 9:12 AM, Markus Armbruster <address@hidden> wrote:
> Stefan Hajnoczi <address@hidden> 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 <address@hidden>
>> ---
>>  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?

qemu-iotests should use it too.  Basically any script that drives QEMU
directly will need to clean up the QEMU process.

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]