qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] Safely reopening image files by stashing fds


From: Paolo Bonzini
Subject: Re: [Qemu-devel] Safely reopening image files by stashing fds
Date: Fri, 05 Aug 2011 11:55:24 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20110707 Thunderbird/5.0

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? :)

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).

Paolo



reply via email to

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