[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] block/raw-posix: Open file descriptor O_RDWR to
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH] block/raw-posix: Open file descriptor O_RDWR to work around glibc posix_fallocate emulation issue. |
Date: |
Wed, 30 Sep 2015 21:36:26 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
On 09/29/2015 09:54 AM, Richard W.M. Jones wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=1265196
>
> The following command fails on an NFS mountpoint:
>
> $ qemu-img create -f qcow2 -o preallocation=falloc disk.img 262144
> Formatting 'disk.img', fmt=qcow2 size=262144 encryption=off
> cluster_size=65536 preallocation='falloc' lazy_refcounts=off
> qemu-img: disk.img: Could not preallocate data for the new file: Bad file
> descriptor
>
> The reason turns out to be because NFS doesn't support the
> posix_fallocate call. glibc emulates it instead. However glibc's
> emulation involves using the pread(2) syscall. The pread syscall
> fails with EBADF if the file descriptor is opened without the read
> open-flag (ie. open (..., O_WRONLY)).
>
Failing with EBADF feels fishy (POSIX requests EINVAL in that case) -
but that's an upstream glibc discussion that has forked from this thread
and doesn't hold up the qemu fix.
> I contacted glibc upstream about this, and their response is here:
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1265196#c9
>
> There are two possible fixes: Use Linux fallocate directly, or (this
> fix) work around the problem in qemu by opening the file with O_RDWR
> instead of O_WRONLY.
>
> Signed-off-by: Richard W.M. Jones <address@hidden>
> BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1265196
> ---
> block/raw-posix.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature