Statistics
| Branch: | Revision:

root / block / raw-posix.c @ a74cdab4

History | View | Annotate | Download (37.2 kB)

# Date Author Comment
dce512de 12/17/2010 05:11 pm Christoph Hellwig

raw-posix: add discard support

Add support to discard blocks in a raw image residing on an XFS filesystem
by calling the XFS_IOC_UNRESVSP64 ioctl to punch holes. Support for other
hole punching mechanisms can be added when they become available.

Signed-off-by: Christoph Hellwig <>...

11a3cb81 11/26/2010 08:02 pm Christoph Hellwig

raw-posix: raw_pwrite comment fixup

Signed-off-by: Christoph Hellwig <>
Signed-off-by: Kevin Wolf <>

205ef796 11/04/2010 01:52 pm Kevin Wolf

block: Allow bdrv_flush to return errors

This changes bdrv_flush to return 0 on success and -errno in case of failure.
It's a requirement for implementing proper error handle in users of bdrv_flush.

Signed-off-by: Kevin Wolf <>
Reviewed-by: Stefan Hajnoczi <>

c57c846a 10/23/2010 06:24 pm Blue Swirl

qemu-timer: move commonly used timer code to qemu-timer-common

Move timer init functions to a new file, qemu-timer-common.c. Make other
critical timer functions inlined to preserve performance in
qemu-timer.c, also move muldiv64() (used by the inline functions)...

581b9e29 09/21/2010 04:39 pm Christoph Hellwig

raw-posix: handle > 512 byte alignment correctly

Replace the hardcoded handling of 512 byte alignment with bs->buffer_alignment
to handle larger sector size devices correctly.

Note that we can not rely on it to be initialize in bdrv_open, so deal
with the worst case there....

05acda4d 09/08/2010 01:39 pm Bernhard Kohl

raw-posix: improve detection of scsi-generic devices

Allow symbolic links which point to /dev/sgX devices.

Signed-off-by: Bernhard Kohl <>
Signed-off-by: Kevin Wolf <>

897804d6 09/08/2010 01:39 pm Kevin Wolf

raw-posix: Don't use file name for host_cdrom detection on Linux

On Linux, we have code to detect CD-ROMs using an ioctl. We shouldn't lose
anything but false positives by removing the check for a /dev/cd* path.

Signed-off-by: Kevin Wolf <>

336c1c12 08/03/2010 04:57 pm Kevin Wolf

block: Fix bdrv_has_zero_init

Assuming that any image on a block device is not properly zero-initialized is
actually wrong: Only raw images have this problem. Any other image format
shouldn't care about it, they initialize everything properly themselves....

2ee9fb48 07/25/2010 05:59 pm Stefan Weil

block: Replace u_int8_t, u_int16_t, u_int32_t, u_int64_t by standard int types

There is no need to have a second set of integral types.
Replace them by the standard types from stdint.h.

Signed-off-by: Stefan Weil <>
Signed-off-by: Aurelien Jarno <>

65d21bc7 07/06/2010 06:05 pm Markus Armbruster

raw-posix: Fix test for host CD-ROM

raw_pread_aligned() retries up to two times if the block device backs
a virtual CD-ROM (a drive with media=cdrom and if=ide, scsi, xen or
none). This makes no sense. Whether retrying reads can correct read
errors can only depend on what we're reading, not on how the result...

9040385d 06/04/2010 12:43 pm Jes Sorensen

Cleanup: raw-posix.c: Be more consistent using BDRV_SECTOR_SIZE instead of 512

Clean up raw-posix.c to be more consistent using BDRV_SECTOR_SIZE
instead of hard coded 512 values.

Signed-off-by: Jes Sorensen <>
Signed-off-by: Kevin Wolf <>

4899d10d 05/03/2010 11:07 am Stefan Hajnoczi

raw-posix: Use pread/pwrite instead of lseek+read/write

This patch combines the lseek+read/write calls to use pread/pwrite
instead. This will result in fewer system calls and is already used by
AIO.

Thanks to Jan Kiszka <> for identifying excessive...

84a12e66 05/03/2010 11:07 am Christoph Hellwig

block: separate raw images from the file protocol

We're running into various problems because the "raw" file access, which
is used internally by the various image formats is entangled with the
"raw" image format, which maps the VM view 1:1 to a file system....

66f82cee 05/03/2010 11:07 am Kevin Wolf

block: Open the underlying image file in generic code

Format drivers shouldn't need to bother with things like file names, but rather
just get an open BlockDriverState for the underlying protocol. This patch
introduces this behaviour for bdrv_open implementation. For protocols which...

50779cc2 04/23/2010 05:08 pm Christoph Hellwig

block: split raw_getlength

Split up the raw_getlength into separate generic, solaris and BSD
versions to reduce the ifdef maze a bit. The BSD variant still
is a complete maze, but to clean it up properly we'd need some
people using the BSD variants to figure out what code is used...

6e0a47aa 04/10/2010 03:22 am Christoph Hellwig

raw-posix: don't assign bs->read_only

bdrv_open already takes care of this for us.

Signed-off-by: Christoph Hellwig <>
Acked-by: Kevin Wolf <>
Signed-off-by: Aurelien Jarno <>

57e69b7d 03/27/2010 01:00 pm Kevin Wolf

raw-posix: Better error return values for hdev_create

Now that we output an error message according to the returned error code in
qemu-img, let's return the real error codes. "Input/output error" for
everything isn't helpful.

Signed-off-by: Kevin Wolf <>...

053965c7 01/27/2010 12:41 am Kevin Wolf

block/raw-posix: Abort on pread beyond end of non-growable file

This shouldn't happen under any normal circumstances. However, it looks like
it's possible to achieve this with corrupted images. Without this patch
raw_pread is hanging in an endless loop in such cases....

f8a83245 01/27/2010 12:41 am Herve Poussineau

win32: pair qemu_memalign() with qemu_vfree()

Win32 suffers from a very big memory leak when dealing with SCSI devices.
Each read/write request allocates memory with qemu_memalign (ie
VirtualAlloc) but frees it with qemu_free (ie free).
Pair all qemu_memalign() calls with qemu_vfree() to prevent such leaks....

9a2d77ad 01/26/2010 11:42 pm Christoph Hellwig

block: kill BDRV_O_CREAT

The BDRV_O_CREAT option is unused inside qemu and partially duplicates
the bdrv_create method. Remove it, and the -C option to qemu-io which
isn't used in qemu-iotests anyway.

Signed-off-by: Christoph Hellwig <>
Signed-off-by: Anthony Liguori <>

f5edb014 01/20/2010 04:25 pm Naphtali Sprei

Clean-up a little bit the RW related bits of BDRV_O_FLAGS. BDRV_O_RDONLY gone (and so is BDRV_O_ACCESS). Default value for bdrv_flags (0/zero) is READ-ONLY. Need to explicitly request READ-WRITE.

Instead of using the field 'readonly' of the BlockDriverState struct for passing the request,...

3baf720e 01/20/2010 12:31 am Cole Robinson

raw-posix: Detect CDROM via ioctl on linux

Current CDROM detection is hardcoded based on source file name.
Make this smarter on linux by attempting a CDROM specific ioctl.

This makes '-cdrom /dev/sr0' succeed with no media present.

v2:
Give ioctl check higher priority than filename check....

2ebf7c4b 01/20/2010 12:31 am Cole Robinson

raw-posix: Detect legacy floppy via ioctl on linux

Current legacy floppy detection is hardcoded based on source file
name. Make this smarter on linux by attempting a floppy specific
ioctl.

v2:
Give ioctl check higher priority than filename check
s/IDE/legacy/...

12c09b8c 12/03/2009 07:45 pm Kevin Wolf

qemu-img: There is more than one host device driver

I haven't heard yet of anyone using qemu-img to copy an image to a real floppy,
but it's a valid use case.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

40ff6d7e 12/03/2009 07:45 pm Kevin Wolf

Don't leak file descriptors

We're leaking file descriptors to child processes. Set FD_CLOEXEC on file
descriptors that don't need to be passed to children to stop this misbehaviour.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

a167ba50 11/29/2009 07:00 pm Aurelien Jarno

Add support for GNU/kFreeBSD

Signed-off-by: Aurelien Jarno <>

1e5b9d2f 10/30/2009 03:39 pm Kevin Wolf

Remove aio_ctx from paio_* interface

The context parameter in paio_submit isn't used anyway, so there is no reason
why block drivers should need to remember it. This also avoids passing a Linux
AIO context to paio_submit (which doesn't do any harm as long as the parameter...

d2e46345 10/27/2009 07:28 pm Kevin Wolf

raw/linux-aio: Also initialize POSIX AIO

When using Linux AIO raw still falls back to POSIX AIO sometimes, so we should
initialize it.

Not initializing it happens to work if POSIX AIO is used by another drive, or
if the format is not specified (probing the format uses POSIX AIO) or by pure...

0b4ce02e 10/05/2009 10:20 pm Kevin Wolf

block/raw: Add create_options for host_device

Today host_devices have a create function, so they also need a create_options
field to prevent qemu-img from complaining.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

6f1953c4 09/11/2009 06:19 pm Christoph Hellwig

block: use fdatasync instead of fsync if possible

If we are flushing the caches for our image files we only care about the
data (including the metadata required for accessing it) but not things
like timestamp updates. So try to use fdatasync instead of fsync to...

b2e12bc6 09/11/2009 06:19 pm Christoph Hellwig

block: add aio_flush operation

Instead stalling the VCPU while serving a cache flush try to do it
asynchronously. Use our good old helper thread pool to issue an
asynchronous fdatasync for raw-posix. Note that while Linux AIO
implements a fdatasync operation it is not useful for us because...

e44bd6fc 08/28/2009 04:57 pm Stefan Weil

Don't compile aio code if CONFIG_LINUX_AIO is undefined

This patch fixes linker errors when building QEMU without Linux AIO support.

It is based on suggestions from malc and Kevin Wolf.

Signed-off-by: Stefan Weil <>
Signed-off-by: Anthony Liguori <>

9ef91a67 08/28/2009 04:30 am Christoph Hellwig

raw-posix: refactor AIO support

Currently the raw-posix.c code contains a lot of knowledge about the
asynchronous I/O scheme that is mostly implemented in posix-aio-compat.c.
All this code does not really belong here and is getting a bit in the
way of implementing native AIO on Linux....

5c6c3a6c 08/28/2009 04:30 am Christoph Hellwig

raw-posix: add Linux native AIO support

Now that do have a nicer interface to work against we can add Linux native
AIO support. It's an extremly thing layer just setting up an iocb for
the io_submit system call in the submission path, and registering an...

4dd75c70 08/24/2009 04:46 pm Christoph Hellwig

make pthreads mandatory

As requested by Anthony make pthreads mandatory. This means we will always
have AIO available on posix hosts, and it will also allow enabling the I/O
thread unconditionally once it's ready.

Signed-off-by: Christoph Hellwig <>...

71e72a19 07/27/2009 10:09 pm Juan Quintela

rename HOST_BSD to CONFIG_BSD

Signed-off-by: Juan Quintela <>
Signed-off-by: Anthony Liguori <>

0bf9e31a 07/20/2009 08:19 pm Blue Swirl

Fix most warnings (errors with -Werror) when debugging is enabled

I used the following command to enable debugging:
perl -p -i -e 's/^\/\/#define DEBUG/#define DEBUG/g' * /* *//*

Signed-off-by: Blue Swirl <>

1e37d059 07/17/2009 01:28 am Stefan Weil

raw-posix: Handle errors in raw_create

In qemu-iotests, some large images are created using qemu-img.

Without checks for errors, qemu-img will just create an
empty image, and later read / write tests will fail.

With the patch, failures during image creation are detected...

1c27a8b3 07/10/2009 12:58 am G 3

Substitute O_DSYNC with O_SYNC or O_FSYNC when needed.

Signed-off-by: John Arbuckle <>
Signed-off-by: Anthony Liguori <>

1cec71e3 07/10/2009 12:06 am Anthony Liguori

Revert "support colon in filenames"

This reverts commit 707c0dbc97cddfe8d2441b8259c6c526d99f2dd8.

Signed-off-by: Anthony Liguori <>

22afa7b5 06/29/2009 10:18 pm Kevin Wolf

block-raw: Allow pread beyond the end of growable images

When using O_DIRECT, qcow2 snapshots didn't work any more for me. In the
process of creating the snapshot, qcow2 tries to pwrite some new information
(e.g. new L1 table) which will often end up being after the old end of the...

707c0dbc 06/29/2009 09:50 pm Ram Pai

support colon in filenames

Problem: It is impossible to feed filenames with the character colon because
qemu interprets such names as a protocol. For example filename scsi:0, is
interpreted as a protocol by name "scsi".

This patch allows user to espace colon characters. For example the above...

19a3da7f 06/17/2009 06:27 pm Blue Swirl

Fix opening of read only raw images

Signed-off-by: Blue Swirl <>

736d0c25 06/16/2009 11:18 pm Avi Kivity

raw-posix: open flags use BDRV_ namespace, not posix namespace

The flags argument to raw_common_open() contain bits defined by the BDRV_O_*
namespace, not the posix O_* namespace.

Adjust to use the correct constants.

Signed-off-by: Avi Kivity <>...

11a1feb6 06/16/2009 11:18 pm Avi Kivity

raw-posix: Remove O_RDWR when attempting to open a file read-only

When we open a file, we first attempt to open it read-write, then fall back
to read-only. Unfortunately we reuse the flags from the previous attempt,
so both attempts try to open the file with write permissions, and fail....

63ec93db 06/15/2009 03:04 pm Christoph Hellwig

raw-posix: cleanup ioctl methods

Rename raw_ioctl and raw_aio_ioctl to hdev_ioctl and hdev_aio_ioctl as they
are only used for the host device. Also only add them to the method table
for the cases where we need them (generic hdev if linux and linux CDROM)...

508c7cb3 06/15/2009 03:04 pm Christoph Hellwig

block: add bdrv_probe_device method

Add a bdrv_probe_device method to all BlockDriver instances implementing
host devices to move matching of host device types into the actual drivers.
For now we keep exacly the old matching behaviour based on the devices names,...

f3a5d3f8 06/15/2009 02:55 pm Christoph Hellwig

raw-posix: split hdev drivers

Instead of declaring one BlockDriver for all host devices declared one
for each type: a generic one for normal disk devices, a Linux floppy
driver and a CDROM driver for Linux and FreeBSD. This gets rid of a lot
of messy ifdefs and switching based on the type in the various removal...

90babde0 06/15/2009 02:53 pm Christoph Hellwig

raw-posix: add a raw_open_common helper

raw_open and hdev_open contain the same basic logic. Add a new
raw_open_common helper containing the guts of the open routine
and call it from raw_open and hdev_open.

We use the new open_flags field in BDRVRawState to allow passing...

0e1d8f4c 06/15/2009 02:53 pm Christoph Hellwig

raw-posix: always store open flags

Both the Linux floppy and the FreeBSD CDROM host device need to store
the open flags so that they can re-open the device later. Store the
open flags unconditionally to remove the ifdef mess and simply the
calling conventions for the later patches in the series....

db08adf5 06/06/2009 06:38 pm Kevin Wolf

qemu-img: Print available options with -o ?

This patch adds a small help text to each of the options in the block drivers
which can be displayed by using qemu-img create -f fmt -o ?

Signed-off-by: Kevin Wolf <>

c16b5a2c 05/27/2009 05:46 pm Christoph Hellwig

fully split aio_pool from BlockDriver

Now that we have a separate aio pool structure we can remove those
aio pool details from BlockDriver.

Every driver supporting AIO now needs to declare a static AIOPool
with the aiocb size and the cancellation method. This cleans up the...

4099df58 05/27/2009 05:45 pm Christoph Hellwig

raw-posix: fix hdev_create

We do need hdev_create unconditionally on all platforms so that qemu-img
create support for host device works on all platforms.

Also relax the check to allow character devices in addition to block
devices. On many Unix platforms block devices have buffered block...

94c6d6d8 05/27/2009 05:45 pm Christoph Hellwig

fix raw_pread_aligned return value

raw_pread_aligned currently returns the raw return value from
lseek/read, which is always -1 in case of an error. But the
callers higher up the stack expect it to return the negated
errno just like raw_pwrite_aligned.
...

0e7e1989 05/22/2009 06:50 pm Kevin Wolf

Convert all block drivers to new bdrv_create

Now we can make use of the newly introduced option structures. Instead of
having bdrv_create carry more and more parameters (which are format specific in
most cases), just pass a option structure as defined by the driver itself....

019d6b8f 05/15/2009 12:13 am Anthony Liguori

Move block drivers into their own directory

Signed-off-by: Anthony Liguori <>