qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v4 15/19] block: raw-win32 driver reopen support


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v4 15/19] block: raw-win32 driver reopen support
Date: Fri, 21 Sep 2012 10:43:45 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120911 Thunderbird/15.0.1

Il 21/09/2012 10:33, Kevin Wolf ha scritto:
>> > +    /* could not reopen the file handle, so fall back to opening
>> > +     * new file (CreateFile) */
>> > +    if (raw_s->hfile == INVALID_HANDLE_VALUE) {
>> > +        raw_s->hfile = CreateFile(state->bs->filename, access_flags,
>> > +                                  FILE_SHARE_READ, NULL, OPEN_EXISTING,
>> > +                                  overlapped, NULL);
>> > +        if (raw_s->hfile == INVALID_HANDLE_VALUE) {
>> > +            /* this could happen because the access_flags requested are
>> > +             * incompatible with the existing share mode of s->hfile,
>> > +             * so our only option now is to close s->hfile, and try again.
>> > +             * This could end badly */
>> > +            CloseHandle(s->hfile);
> How common is this case?
> 
> We do have another option, namely not reopen at all and return an error.
> Of course, this only makes sense if it doesn't mean that we almost never
> succeed.

Probably pretty common since we specify FILE_SHARE_READ for the sharing
mode, meaning that "subsequent open operations on a file or device are
only able to request read access".

I would change it to FILE_SHARE_READ|FILE_SHARE_WRITE and remove this code.

Paolo



reply via email to

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