aboutsummaryrefslogtreecommitdiffstats
path: root/block
AgeCommit message (Collapse)AuthorFilesLines
2009-11-29Add support for GNU/kFreeBSDAurelien Jarno1-8/+8
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-11-12Fix 32-bit overflow in parallels image supportDavid Woodhouse1-2/+3
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09qcow2: Allow qcow2 disk images with size zeroStefan Weil2-9/+13
Images with disk size 0 may be used for VM snapshots, but not to save normal block data. It is possible to create such images using qemu-img, but opening them later fails. So even "qemu-img info image.qcow2" is not possible for an image created with "qemu-img create -f qcow2 image.qcow2 0". This is fixed here. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30Remove aio_ctx from paio_* interfaceKevin Wolf2-8/+6
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 is unused, but it is highly confusing). Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27Revert "qcow2: Bring synchronous read/write back to life"Kevin Wolf3-55/+5
It was merely a workaround and the real fix is done now. This reverts commit ef845c3bf421290153154635dc18eaa677cecb43. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27Add qemu_aio_process_queue()Kevin Wolf1-4/+4
We'll leave some AIO completions unhandled when we can't call the callback. qemu_aio_process_queue() is used later to run any callbacks that are left and can be run then. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27raw/linux-aio: Also initialize POSIX AIOKevin Wolf1-0/+4
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 luck (e.g. it doesn't seem to happen any more with qcow2 since we have re-added synchronous qcow2 functions). Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27qcow2: Fix grow_refcount_table error handlingKevin Wolf1-1/+0
In case of failure, we haven't increased the refcount for the newly allocated cluster yet. Therefore we must not free the cluster or its refcount will become negative (and endless recursion is possible). Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15qcow2: Bring synchronous read/write back to lifeKevin Wolf3-5/+55
When the synchronous read and write functions were dropped, they were replaced by generic emulation functions. Unfortunately, these emulation functions don't provide the same semantics as the original functions did. The original bdrv_read would mean that we read some data synchronously and that we won't be interrupted during this read. The latter assumption is no longer true with the emulation function which needs to use qemu_aio_poll and therefore allows the callback of any other concurrent AIO request to be run during the read. Which in turn means that (meta)data read earlier could have changed and be invalid now. qcow2 is not prepared to work in this way and it's just scary how many places there are where other requests could run. I'm not sure yet where exactly it breaks, but you'll see breakage with virtio on qcow2 with a backing file. Providing synchronous functions again fixes the problem for me. Patchworks-ID: 35437 Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05block/raw: Add create_options for host_deviceKevin Wolf1-6/+10
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 <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05qcow2: Increase maximum cluster size to 2 MBKevin Wolf3-8/+11
This patch increases the maximum qcow2 cluster size to 2 MB. Starting with 128k clusters, L2 tables span 2 GB or more of virtual disk space, causing 32 bit truncation and wraparound of signed integers. Therefore some variables need to use a larger data type. While being at reviewing data types, change some integers that are used for array indices to unsigned. In some places they were checked against some upper limit but not for negative values. This could avoid potential segfaults with corrupted qcow2 images. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-04Check availability of uuid header / libraryStefan Weil1-2/+2
If available, the Universally Unique Identifier library is used by the vdi block driver. Other parts of QEMU (vl.c) could also use it. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-10-01Revert "Get rid of _t suffix"Anthony Liguori1-144/+144
In the very least, a change like this requires discussion on the list. The naming convention is goofy and it causes a massive merge problem. Something like this _must_ be presented on the list first so people can provide input and cope with it. This reverts commit 99a0949b720a0936da2052cb9a46db04ffc6db29. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-01Get rid of _t suffixmalc1-144/+144
Some not so obvious bits, slirp and Xen were left alone for the time being. Signed-off-by: malc <av1474@comtv.ru>
2009-09-30vvfat: fix coding style nitMichael S. Tsirkin1-2/+2
Put space between = and & when taking a pointer, to avoid confusion with old-style "&=". Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-12Fix signedness warnings on OpenSolarisBlue Swirl1-4/+4
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-12Fix sys-queue.h conflict for goodBlue Swirl3-13/+13
Problem: Our file sys-queue.h is a copy of the BSD file, but there are some additions and it's not entirely compatible. Because of that, there have been conflicts with system headers on BSD systems. Some hacks have been introduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896, f40d753718c72693c5f520f0d9899f6e50395e94, 96555a96d724016e13190b28cffa3bc929ac60dc and 3990d09adf4463eca200ad964cc55643c33feb50 but the fixes were fragile. Solution: Avoid the conflict entirely by renaming the functions and the file. Revert the previous hacks. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-11block: add aio_flush operationChristoph Hellwig2-1/+19
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 it isn't actually implement in asynchronous fashion. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-11block: use fdatasync instead of fsync if possibleChristoph Hellwig2-2/+2
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 implement the flush operations. Unfortunately many operating systems still do not support fdatasync, so we add a qemu_fdatasync wrapper that uses fdatasync if available as per the _POSIX_SYNCHRONIZED_IO feature macro or fsync otherwise. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-09qcow2: Order concurrent AIO requests on the same unallocated clusterKevin Wolf3-5/+96
When two AIO requests write to the same cluster, and this cluster is unallocated, currently both requests allocate a new cluster and the second one merges the first one when it is completed. This means an cluster allocation, a read and a cluster deallocation which cause some overhead. If we simply let the second request wait until the first one is done, we improve overall performance with AIO requests (specifially, qcow2/virtio combinations). This patch maintains a list of in-flight requests that have allocated new clusters. A second request touching the same cluster is limited so that it either doesn't touch the allocation of the first request (so it can have a non-overlapping allocation) or it waits for the first request to complete. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-09qcow2: Fix metadata preallocationKevin Wolf1-1/+3
The wrong version of the preallocation patch has been applied, so this is the remaining diff. We can't use truncate to grow the image file to the right size because we don't know if metadata has been written after the last data cluster. In this case truncate would shrink the file and destroy its metadata. Write a zero sector at the end of the virtual disk instead to ensure that the file is big enough. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-09Fix spelling in comment.Stefan Weil1-1/+1
The company which made Virtual PC was Connectix. They use the magic string "conectix" in their disk images. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-29Fix gcc 3 warning about uninitialized variableBlue Swirl1-1/+1
If nb_sectors is 0, cluster_offset will not be initialized. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-08-28Don't compile aio code if CONFIG_LINUX_AIO is undefinedStefan Weil1-1/+7
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 <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27raw-posix: add Linux native AIO supportChristoph Hellwig2-5/+31
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 eventfd with the qemu poll handler to do complete the iocbs directly from there. This started out based on Anthony's earlier AIO patch, but after estimated 42,000 rewrites and just as many build system changes there's not much left of it. To enable native kernel aio use the aio=native sub-command on the drive command line. I have also added an option to qemu-io to test the aio support without needing a guest. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27raw-posix: refactor AIO supportChristoph Hellwig2-236/+75
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. So instead move all the guts of the AIO implementation into posix-aio-compat.c (which might need a better name, btw). There's now a very small interface between the AIO providers and raw-posix.c: - an init routine is called from raw_open_common to return an AIO context for this drive. An AIO implementation may either re-use one context for all drives, or use a different one for each as the Linux native AIO support will do. - an submit routine is called from the aio_reav/writev methods to submit an AIO request There are no indirect calls involved in this interface as we need to decide which one to call manually. We will only call the Linux AIO native init function if we were requested to by vl.c, and we will only call the native submit function if we are asked to and the request is properly aligned. That's also the reason why the alignment check actually does the inverse move and now goes into raw-posix.c. The old posix-aio-compat.h headers is removed now that most of it's content is private to posix-aio-compat.c, and instead we add a new block/raw-posix-aio.h headers is created containing only the tiny interface between raw-posix.c and the AIO implementation. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27qcow2: Metadata preallocationKevin Wolf1-2/+79
This introduces a qemu-img create option for qcow2 which allows the metadata to be preallocated, i.e. clusters are reserved in the refcount table and L1/L2 tables, but no data is written to them. Metadata is quite small, so this happens in almost no time. Especially with qcow2 on virtio this helps to gain a bit of performance during the initial writes. However, as soon as create a snapshot, we're back to the normal slow speed, obviously. So this isn't the real fix, but kind of a cheat while we're still having trouble with qcow2 on virtio. Note that the option is disabled by default and needs to be specified explicitly using qemu-img create -f qcow2 -o preallocation=metadata. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27block/vdi.c: Fix several bugsStefan Weil1-4/+9
* The code for option '-static' was wrong, so image creation always created static images. * Static images created with qemu-img did not set header entry blocks_allocated. * The size of the block map must be rounded to the next multiple of SECTOR_SIZE, otherwise the block map is only read partially for block map sizes which are not a multiple of SECTOR_SIZE. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-24eliminate errors about unused results in block/vpc.cNathan Froyd1-4/+4
These errors come up when compiling with gcc-4.3.3 and some older headers: /scratch/froydnj/qemu.git/block/vpc.c: In function 'vpc_create': /scratch/froydnj/qemu.git/block/vpc.c:514: error: value computed is not used /scratch/froydnj/qemu.git/block/vpc.c:516: error: value computed is not used /scratch/froydnj/qemu.git/block/vpc.c:517: error: value computed is not used /scratch/froydnj/qemu.git/block/vpc.c:566: error: value computed is not used Use memcpy to copy the strings instead of strncpy. Signed-off-by: Nathan Froyd <froydnj@codesourcery.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-24make pthreads mandatoryChristoph Hellwig1-27/+1
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 <hch@lst.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-15Use pstrcpy to avoid OpenBSD linker warningsBlue Swirl1-1/+1
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-08-10Add new block driver for the VDI format (only aio supported)Stefan Weil1-0/+951
This is a new block driver written from scratch to support the VDI format in QEMU. VDI is the native format used by Innotek / SUN VirtualBox. Latest changes: * stripped down version (code for synchronous operations and experimental code removed) * don't open VDI snapshot images (with uuid_link or uuid_parent) * modified vdi_aio_cancel Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Message-Id:
2009-08-01Fix Sparse warning about "expression using sizeof on a function"Blue Swirl1-3/+3
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-07-27rename HOST_BSD to CONFIG_BSDJuan Quintela1-2/+2
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-22vmdk: Fix backing file handlingKevin Wolf1-14/+15
Instead of storing the backing file in its own BlockDriverState, VMDK uses the BlockDriverState of the raw image file it opened. This is wrong and breaks functions that access the backing file or protocols. This fix replaces all occurrences of s->hd->backing_* with bs->backing_*. This fixes qemu-iotests failure in 020 (Commit changes to backing file). Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-20Fix most warnings (errors with -Werror) when debugging is enabledBlue Swirl2-2/+3
I used the following command to enable debugging: perl -p -i -e 's/^\/\/#define DEBUG/#define DEBUG/g' * */* */*/* Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-07-16raw-posix: Handle errors in raw_createStefan Weil1-5/+12
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 and reported. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-16replace bdrv_{get, put}_buffer with bdrv_{load, save}_vmstateChristoph Hellwig1-8/+14
The VM state offset is a concept internal to the image format. Replace the old bdrv_{get,put}_buffer method that require an index into the image file that is constructed from the VM state offset and an offset into the vmstate with the bdrv_{load,save}_vmstate that just take an offset into the VM state. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-10qcow2: Fix L1 table memory allocationKevin Wolf3-3/+4
Contrary to what one could expect, the size of L1 tables is not cluster aligned. So as we're writing whole sectors now instead of single entries, we need to ensure that the L1 table in memory is large enough; otherwise write would access memory after the end of the L1 table. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-10qcow1: Fix qcow_aio_writevKevin Wolf1-1/+1
Pass is_write = 1 to qcow_aio_setup when writing. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-09Substitute O_DSYNC with O_SYNC or O_FSYNC when needed.G 31-0/+4
Signed-off-by: John Arbuckle <programmingkidx@gmail.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-09Allow adjustment of http block device's readahead size, via a newNolan1-3/+47
":readahead=###:" suffix. Signed-off-by: Nolan Leake <nolan <at> sigbus.net> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-09Revert "support colon in filenames"Anthony Liguori2-2/+1
This reverts commit 707c0dbc97cddfe8d2441b8259c6c526d99f2dd8. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-09qcow2: Make cache=writethrough defaultKevin Wolf1-8/+0
The performance of qcow2 has improved meanwhile, so we don't need to special-case it any more. Switch the default to write-through caching like all other block drivers. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29qcow2: Cache refcount blocks during snapshot creationKevin Wolf1-0/+40
The really time consuming part of snapshotting is to adjust the reference count of all clusters. Currently after each adjusted cluster the refcount block is written to disk. Don't write each single byte immediately to disk but cache all writes to the refcount block and write them out once we're done with the block. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29block-raw: Allow pread beyond the end of growable imagesKevin Wolf1-0/+11
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 image file. Now pwrite tries to align things and reads the old contents of the file, read returns 0 because there is nothing to read after the end of file and pwrite is stuck in an endless loop. This patch allows to pread beyond the end of an image file. Whenever the given offset is after the end of the image file, the read succeeds and fills the buffer with zeros. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29support colon in filenamesRam Pai2-1/+2
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 filename can now be expressed either as 'scsi\:0' or as file:scsi:0 anything following the "file:" tag is interpreted verbatin. However if "file:" tag is omitted then any colon characters in the string must be escaped using backslash. Here are couple of examples: scsi\:0\:abc is a local file scsi:0:abc http\://myweb is a local file by name http://myweb file:scsi:0:abc is a local file scsi:0:abc file:http://myweb is a local file by name http://myweb Signed-off-by: Ram Pai <linuxram@us.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29Fix QCOW2 debugging code to compile againFilip Navara3-8/+8
Updated to use C99 comments. Signed-off-by: Filip Navara <filip.navara@gmail.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-17Fix opening of read only raw imagesBlue Swirl1-16/+15
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-06-16update_refcount: Write complete sectorsKevin Wolf1-8/+26
When updating the refcount blocks in update_refcount(), write complete sectors instead of updating single entries. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>