On Fri, Aug 5, 2011 at 10:55 AM, Paolo Bonzini <pbonz...@redhat.com> wrote:
> On 08/05/2011 11:27 AM, Stefan Hajnoczi wrote:
>>>>
>>>> First call bdrv_extract_fds() to stash the file descriptors, then close
>>>> the block device.  Try opening the new image but if that fails, reopen
>>>> using
>>>> the stashed file descriptors.
>>>
>>> Why not do the latter unconditionally?
>>
>> Because you cannot change O_DIRECT on an open fd:(.  This is why
>> we're going through this pain.
>>
>> The only method I've found that works is to open("/proc/self/fd/X",
>> new_flags) but that's non-portable.
>
> Maybe I'm missing something obvious, but so is O_DIRECT, no? :)

http://www.freebsd.org/cgi/man.cgi?query=open&apropos=0&sektion=0&manpath=FreeBSD+8.1-RELEASE&format=html

> So for Linux you can dup the stashed file descriptors using /proc/self/fd
> and change flags directly, and for other OSes you can dup them using dup2
> and change flags with F_SETFL.  In any case, reopening can always be done
> using the stashed descriptors (or BlockDriverStates).

F_SETFL doesn't let you change arbitrary flags.

Stefan

Reply via email to