[Top][All Lists]
[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 14:31:53 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120911 Thunderbird/15.0.1 |
Il 21/09/2012 14:17, Jeff Cody ha scritto:
> On 09/21/2012 04:43 AM, Paolo Bonzini wrote:
>> 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".
>
> Yes, I think this is by far the most common case.
Actually ReOpenFile probably only takes into account _other_ sharing
modes, not the one for hFile, so it may even be unnecessary.
But...
>> I would change it to FILE_SHARE_READ|FILE_SHARE_WRITE and remove this code.
>
> I contemplated doing that, but I wasn't sure if there was any particular
> reason it was originally done with FILE_SHARE_READ only in the first
> place (security, etc..). I was hesitant to override that behaviour as
> the new default under w32. Do we know if this is acceptable / safe?
... let's just make things work the same as in Unix.
Paolo
- [Qemu-devel] [PATCH v4 08/19] block: purge s->aligned_buf and s->aligned_buf_size from raw-posix.c, (continued)
- [Qemu-devel] [PATCH v4 08/19] block: purge s->aligned_buf and s->aligned_buf_size from raw-posix.c, Jeff Cody, 2012/09/20
- [Qemu-devel] [PATCH v4 12/19] block: qcow2 image file reopen, Jeff Cody, 2012/09/20
- [Qemu-devel] [PATCH v4 19/19] block: remove keep_read_only flag from BlockDriverState struct, Jeff Cody, 2012/09/20
- [Qemu-devel] [PATCH v4 10/19] block: raw image file reopen, Jeff Cody, 2012/09/20
- [Qemu-devel] [PATCH v4 17/19] block: vpc image file reopen, Jeff Cody, 2012/09/20
- [Qemu-devel] [PATCH v4 18/19] block: convert bdrv_commit() to use bdrv_reopen(), Jeff Cody, 2012/09/20
- [Qemu-devel] [PATCH v4 15/19] block: raw-win32 driver reopen support, Jeff Cody, 2012/09/20
[Qemu-devel] [PATCH v4 16/19] block: vdi image file reopen, Jeff Cody, 2012/09/20
[Qemu-devel] [PATCH v4 11/19] block: qed image file reopen, Jeff Cody, 2012/09/20
[Qemu-devel] [PATCH v4 13/19] block: qcow image file reopen, Jeff Cody, 2012/09/20
[Qemu-devel] [PATCH v4 14/19] block: vmdk image file reopen, Jeff Cody, 2012/09/20
Re: [Qemu-devel] [PATCH v4 00/19] block: bdrv_reopen() patches, Kevin Wolf, 2012/09/21