qemu-cr16/block
Richard W.M. Jones 73ba05d936 block/raw-posix: Open file descriptor O_RDWR to work around glibc posix_fallocate emulation issue.
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)).

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 <rjones@redhat.com>
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1265196
Reviewed-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-10-02 13:48:29 +02:00
..
accounting.c
archipelago.c
backup.c Backup: don't do copy-on-read in before_write_notifier 2015-09-25 08:37:07 -04:00
blkdebug.c
blkverify.c
block-backend.c
bochs.c
cloop.c
commit.c block: Allow specifying driver-specific options to reopen 2015-09-14 16:51:36 +02:00
curl.c
dmg.c
gluster.c
io.c block: Introduce a new API bdrv_co_no_copy_on_readv() 2015-09-25 08:37:07 -04:00
iscsi.c
linux-aio.c
Makefile.objs
mirror.c block: mirror - fix full sync mode when target does not support zero init 2015-10-01 15:02:21 -04:00
nbd-client.c
nbd-client.h
nbd.c nbd: convert to use the QAPI SocketAddress object 2015-09-25 12:04:40 +02:00
nfs.c block/nfs: cache allocated filesize for read-only files 2015-09-25 08:37:07 -04:00
null.c
parallels.c
qapi.c
qcow.c
qcow2-cache.c
qcow2-cluster.c qcow2: Make size_to_clusters() return uint64_t 2015-09-14 16:51:37 +02:00
qcow2-refcount.c qcow2: Make qcow2_alloc_bytes() more explicit 2015-09-14 16:51:37 +02:00
qcow2-snapshot.c
qcow2.c qcow2: Support updating driver-specific options in reopen 2015-09-14 16:51:37 +02:00
qcow2.h qcow2: Make size_to_clusters() return uint64_t 2015-09-14 16:51:37 +02:00
qed-check.c
qed-cluster.c
qed-gencb.c
qed-l2-cache.c
qed-table.c
qed.c
qed.h
quorum.c
raw-aio.h
raw-posix.c block/raw-posix: Open file descriptor O_RDWR to work around glibc posix_fallocate emulation issue. 2015-10-02 13:48:29 +02:00
raw-win32.c raw-win32: Fix write request error handling 2015-10-02 13:48:29 +02:00
raw_bsd.c
rbd.c
sheepdog.c sheepdog: refine discard support 2015-09-25 10:25:19 -04:00
snapshot.c
ssh.c
stream.c
throttle-groups.c
vdi.c
vhdx-endian.c
vhdx-log.c
vhdx.c
vhdx.h
vmdk.c vmdk: Fix next_cluster_sector for compressed write 2015-09-14 16:51:37 +02:00
vpc.c
vvfat.c
win32-aio.c
write-threshold.c