qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH for-2.7] wxx: Truncate files used for character


From: Stefan Weil
Subject: Re: [Qemu-devel] [PATCH for-2.7] wxx: Truncate files used for character devices
Date: Tue, 2 Aug 2016 07:10:20 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.1.0

Am 01.08.2016 um 10:31 schrieb Paolo Bonzini:
> On 26/07/2016 19:11, Stefan Weil wrote:
>> On Windows, such files were not truncated like on all other hosts.
>> Now we also test whether truncation is needed when running on Windows.
>>
>> Reported-by: Benjamin David Lunt <address@hidden>
>> Signed-off-by: Stefan Weil <address@hidden>
>> ---
>>  qemu-char.c | 11 ++++++++++-
>>  1 file changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/qemu-char.c b/qemu-char.c
>> index e4b8448..7de63c8 100644
>> --- a/qemu-char.c
>> +++ b/qemu-char.c
>> @@ -4197,14 +4197,23 @@ static CharDriverState *qmp_chardev_open_file(const 
>> char *id,
>>      ChardevFile *file = backend->u.file.data;
>>      ChardevCommon *common = qapi_ChardevFile_base(file);
>>      HANDLE out;
>> +    DWORD flags;
>>  
>>      if (file->has_in) {
>>          error_setg(errp, "input file not supported");
>>          return NULL;
>>      }
>>  
>> +    if (file->has_append && file->append) {
>> +        /* Append to file if it already exists. */
>> +        flags = OPEN_ALWAYS;
>> +    } else {
>> +        /* Truncate file if it already exists. */
>> +        flags = CREATE_ALWAYS;
>> +    }
>> +
>>      out = CreateFile(file->out, GENERIC_WRITE, FILE_SHARE_READ, NULL,
> 
> GENERIC_WRITE does not include FILE_APPEND_DATA.  You should also change
> the access rights to FILE_GENERIC_WRITE & ~FILE_WRITE_DATA in the append
> case; see commit 52074d0f662fc51293d4cde8077631f754784405 for a similar
> case in qemu-ga.
> 
> Thanks,
> 
> Paolo

Thanks for the hint.

That's a second problem of the old code. I'll send a new patch which
addresses both problems.

Stefan


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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