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
2015-07-08 13:11:01 +02:00
2015-10-01 17:24:02 -07:00
2015-09-11 10:45:43 +03:00
2015-09-11 10:21:38 +03:00
2015-09-11 10:45:43 +03:00
2015-09-19 11:53:15 +02:00
2015-09-25 23:14:00 +01:00
2014-06-16 13:24:35 +02:00
2013-09-05 09:40:31 -05:00
2013-10-11 09:34:56 -07:00
2015-09-30 09:42:04 +02:00
2015-07-27 22:44:47 +03:00
2015-04-30 16:05:48 +03:00
2013-07-23 02:41:31 +02:00
2015-09-04 13:26:26 +02:00
2015-09-07 18:14:03 +02:00
2015-09-07 18:14:03 +02:00
2015-09-01 13:16:26 -05:00
2014-05-24 00:07:29 +04:00
2015-05-11 08:59:07 -04:00
2015-09-29 11:33:02 +05:30
2013-10-11 09:34:56 -07:00
2015-09-16 17:33:33 +02:00
2015-08-19 16:29:53 +01:00
2015-08-11 23:15:55 +01:00
2013-10-11 09:34:56 -07:00

Read the documentation in qemu-doc.html or on http://wiki.qemu-project.org

- QEMU team
Description
No description provided
Readme 569 MiB
Languages
C 83%
C++ 6.3%
Python 3.2%
Dylan 2.9%
Shell 1.6%
Other 2.8%