aboutsummaryrefslogtreecommitdiffstats
path: root/tools/blktap/drivers/block-qcow.c
Commit message (Collapse)AuthorAgeFilesLines
* blktap: Fix old QCow tapdisk image handlingKeir Fraser2010-05-041-10/+9
| | | | | | | | | | When I tried to use QCow image, I found that only each second boot is successful. As I discovered, this is caused by wrong handling old qcow tapdisk images. Extended header flag is not stored correctly so the blktap tries to change endian fo L1 table on each startup. From: Miroslav Rezanina <mrezanin@redhat.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* blktap: fix empty QCOW images (bug 1430 part 2)Keir Fraser2009-06-031-2/+3
| | | | | | | | | | | | Empty QCOW images consist of only the L1 table, this results in a file size which is not sector-aligned. Since blktap uses O_DIRECT, the block aligned read of the L1 table will go beyond the end of file and thus returns the actual file size and not the expected length. This patch checks whether at least the L1 table has been read. This should fix bug 1430. Signed-off-by: Andre Przywara <andre.przywara@amd.com>
* blktap: fix and use ROUNDUP macro (bug 1430 part 1)Keir Fraser2009-06-031-6/+6
| | | | | | | | | As pointed out in Xen Bugzilla 1430 in the blktap QCOW driver the rounding function is wrong in line 824 of block-qcow.c. This patch replaces this (and other roundings) with the already existing ROUNDUP macro (and fixes the usual macro pitfall). Signed-off-by: Andre Przywara <andre.przywara@amd.com>
* blktap: re-enable O_DIRECT in block_qcow.cKeir Fraser2008-10-221-9/+15
| | | | | | | Turns out that only two reads and writes in block-qcow.c need to be fixed to work correctly with O_DIRECT. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
* blktap: Handle qcow backing files correctly.Keir Fraser2008-10-201-9/+7
| | | | Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
* blktap: cleanupKeir Fraser2008-07-111-11/+11
| | | | | | | Make functions w/o a prototype static and remove redundant declaration of xs_fire_next_watch(). Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
* blktap: Fall back to libcrypto if libgcrypt is not installed.Keir Fraser2008-06-301-1/+39
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* blktap: link against libgcrypt rather than libcryptoKeir Fraser2008-06-301-13/+4
| | | | | | | | | | tapdisk, part of blktap, links against libcrypto. tapdisk includes GPLv2 (tapaio.c) and other licensed code (block-qcow.c). The license of OpenSSL is considered incompatible with the GPL by many people. This patch changes them to link against libgcrypt, which is LGPL. Signed-off-by: Bastian Blank <waldi@debian.org>
* tools: Use PATH_MAX for pathname char arrays.Keir Fraser2008-04-041-1/+1
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* tapdisk: Fix L1 table endianess of qcow imagesKeir Fraser2008-03-271-6/+56
| | | | | | | | Fix tapdisk to use big endian L1 tables as used by qemu/ioemu. Old tapdisk images with native endianess are automagically converted to big endian when the image file is opened for the first time. Signed-off-by: Kevin Wolf <kwolf@suse.de>
* blktap: Remove some code duplicationKeir Fraser2008-02-251-211/+34
| | | | | | | | With my qcow2 patch to blktap I contributed a bit to the mess, so here an attempt to clean up and remove at least some of the code duplication in the functions dealing with aio operations. Signed-off-by: Kevin Wolf <kwolf@suse.de>
* blktap: qcow2 image format supportKeir Fraser2008-02-211-1/+13
| | | | | | | | | | | | This patch adds support for the qcow2 image format to blktap. It consists mostly of qemu code, adapted to the blktap interfaces. Snapshots and compressed images are supported. The qcow2 driver may be used by either specifying tap:qcow2 or by using tap:qcow which will detect that you have a version 2 image and will call the qcow2 driver. Signed-off-by: Kevin Wolf <kwolf@suse.de>
* blktap: factor out linux specific codeKeir Fraser2008-01-151-6/+10
| | | | Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
* blktap: Add fallback code to blktap for missing poll-on-aio support.kfraser@localhost.localdomain2007-06-191-24/+22
| | | | | | | | | | | | | | | | | | | | | blktap requires a xen specific kernel AIO ABI which has been vetoed by upstream in favour of another approach. Rather than include this ABI, Fedora has been carrying a patch which makes tap:aio use a thread to poll for aio events and notify the main thread via a pipe. The upstream approach of allowing io_getevents() poll normal file descriptors via epoll is still progressing: http://lkml.org/lkml/2007/1/3/16 but when that does make it upstream, blktap will require significant re-working to use that approach. In the meantime, here's a patch which uses the poll-in-a-thread approach only if AIO poll support isn't available. It also hides the details behind a simple abstraction and makes both tap:aio and tap:qcow use it. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
* tools: warn_unused_result build fixes.kfraser@localhost.localdomain2007-06-121-2/+5
| | | | | | | | | | | | Note that some of the existing error checking for asprintf was wrong for Linux. asprintf in glibc returns -1 on error, but leaves the pointer uninitialized. Only the BSDs zero out the pointer on error. Also, while fixing these warnings I saw several error paths that were incorrect. This patch minimally fixes the warn_unused_result; more complete error path cleanup will be a later patch. Signed-off-by: Charles Coffing <ccoffing@novell.com>
* blktap: Fix compile errorskfraser@localhost.localdomain2007-05-241-3/+6
| | | | | | | When compiling the various blktap drivers with warnings cranked up, I get errors that return values are not checked. Signed-off-by: Charles Coffing <ccoffing@novell.com>
* blktap: Fix qcow max_aio_reqs calculation.kfraser@localhost.localdomain2007-05-031-1/+2
| | | | Signed-off-by: Keir Fraser <keir@xensource.com>
* blktap: Segments can span multiple clusters with tap:qcow.kfraser@localhost.localdomain2007-04-261-14/+53
| | | | | | | | | | | | | In blktap's qcow we need split up read/write requests if the requests span multiple clusters. However, with our MAX_AIO_REQUESTS define we assume that there is only ever a single aio request per tapdisk request and under heavy i/o we can run out of room causing us to cancel requests. Dynamically allocate (based on cluster_bits) the various io request queues the driver maintains. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
* [TAPDISK] Fix qcow initialization bug.Jake Wires2007-04-101-2/+8
| | | | | | fd_end was being incorrectly initialized upon open, leading to data corruption. Signed-off-by: Jake Wires <jwires@xensource.com>
* [TAPDISK] unlock sector on error caseJake Wires2007-03-161-0/+1
| | | | Signed-off-by: Jake Wires <jwires@xensource.com>
* [TAPDISK] honor read-only attributes when creating tap-based VBDsJake Wires2007-02-231-1/+1
| | | | Signed-off-by: Jake Wires <jwires@xensource.com>
* [TAPDISK] minor changes to tapdisk and pluginsJake Wires2007-02-221-38/+43
| | | | | | * open all parent images read-only * expose parent image names to tapdisk (needed for locking api) Signed-off-by: Jake Wires <jwires@xensource.com>
* [TAPDISK] add tapdisk support for image chainingJake Wires2007-02-161-281/+246
| | | | | | | | Enables tapdisk to chain an arbitrary number of VDIs, propagating reads of holes in children to their parent images. Introduces two new functions to the tapdisk interface to facilitate this. Modifies the QCoW plugin to take advantage of these changes, thus providing support for arbitrarily long chains of QCoW image types.
* [BLTAP] Use getpagesize() for portability.kfraser@localhost.localdomain2006-12-201-2/+3
| | | | Signed-off-by: Alex Williamson <alex.williamson@hp.com>
* Qcow driver code cleanup:Julian Chesterfield2006-12-191-41/+83
| | | | | | | | | | | - Remove global QCOW flags - rename sparseness flag to -r fore 'reserve' - Add ROUNDUP macro - Check for qtruncate failures Signed-off-by: Julian Chesterfield <julian@xensource.com>
* Fix 64-bit build with a PRIu64.Ewan Mellor2006-12-151-1/+1
| | | | Signed-off-by: Ewan Mellor <ewan@xensource.com>
* Add sparseness flag to qcow-create.Julian Chesterfield2006-12-141-33/+87
| | | | | | | | For environments where space must be guaranteed in advance use the -p flag to remove sparseness from the qcow file. Signed-off-by: Julian Chesterfield <julian@xensource.com>
* Fix a number of flaws in the blktap userspace daemon when dealingAndrew Warfield2006-12-011-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with I/O errors. There are a number of flaws in the blktap userspace daemon when dealing with I/O errors. - The backends which use AIO check the io_events.res member to determine if an I/O error occurred. Which is good. But when calling the callback to signal completion of the I/O, they pass the io_events.res2 member Now this seems fine at first glance[1] "res is the usual result of an I/O operation: the number of bytes transfered, or a negative error code. res2 is a second status value which will be returned to the user" Except that "currently (2.6.0-test9), callers of aio_complete() within the kernel always set res2 to zero." And this hasn't changed anytime since 2.6.0, so by passing through the status from 'res2', the callback thinks the I/O operation succeeded even when it failed :-( The fix is simple instead of passing 'res2', just pass ep->res == io->u.c.nbytes ? 0 : 1 This would solve the error reporting to the guest, except that there is a second flaw... - The tapdisk I/O completion callback checks the status parameter passed in, syslog's it and then returns. It never bothers to send the I/O completion response back to the blktap kernel driver when a failure occurrs. Fortunately the fix for this is also simple. Instead of returning from the callback when dealing with an error, we simply toggle the status field for the pending response to BLKIF_RSP_ERROR and then continue with the normal codepath. So the error eventually gets back to the guest. The scenario I used to discover the problem and test the patch is thus: - In dom0 create a filesystem with only 200 MB of free space - Create a 1 GB sparse file on this volume. - Configure the guest so this sparse file appears as /dev/xvdb - In the domU create a single partition on /dev/xvdb and format it with ext3. - In the DomU, mount /dev/xvdb1 on /mnt and then run dd if=/dev/zero of=/mnt/data.bin bs=1GB count=1 Without this patch, the 'dd' command would succeed in writing 1 GB of data even though the underlying disk in Dom0 was only 200 MB in size. More complex tests of copying a whole directory heirarchy across resulted in catastrophic data corruption of the filessytem itself. Manual fsck was needed to fixup the filesystem & there were many very bad errors needing fixing. With this patch applied the DomU sees the I/O failures and kernel logs messages Dec 1 11:02:53 dhcp-5-203 kernel: end_request: I/O error, dev xvdc, sector 722127 Dec 1 11:02:53 dhcp-5-203 kernel: end_request: I/O error, dev xvdc, sector 730327 Dec 1 11:02:53 dhcp-5-203 kernel: end_request: I/O error, dev xvdc, sector 738527 Dec 1 11:02:53 dhcp-5-203 kernel: end_request: I/O error, dev xvdc, sector 746727 Dec 1 11:02:53 dhcp-5-203 kernel: end_request: I/O error, dev xvdc, sector 754927 Dec 1 11:02:53 dhcp-5-203 kernel: end_request: I/O error, dev xvdc, sector 763127 Dec 1 11:02:53 dhcp-5-203 kernel: end_request: I/O error, dev xvdc, sector 771327 Dec 1 11:02:53 dhcp-5-203 kernel: end_request: I/O error, dev xvdc, sector 779527 Dec 1 11:02:53 dhcp-5-203 kernel: end_request: I/O error, dev xvdc, sector 792399 It will retry the I/O operation until it runs out of sectors to try, and then fail the operation. The filesystem is not seriously damaged - ext3 journal recovery will trivially cleanup if the guest is rebooted after the disk in Dom0 is enlarged. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> [1] http://lwn.net/Articles/24366/
* [blktap] Fix block device getsize bug in qcow when backing_filename is a ↵jchesterfield@dhcp92.uk.xensource.com2006-09-051-4/+25
| | | | block device.
* Small blktap cleanups.akw@devbox.site2006-08-291-1/+1
| | | | Signed-off-by: Andrew Warfield <andy@xensource.com>
* Reduce AIO context allocations in blktap.akw@devbox.site2006-08-291-4/+15
| | | | Signed-off-by: Andrew Warfield <andy@xensource.com>
* Added blktap support. Includes kernel driver (enabled as ↵jchesterfield@dhcp92.uk.xensource.com2006-07-131-0/+1369
CONFIG_XEN_BLKDEV_TAP=y) and userspace tools. The userspace deamon (blktapctrl) is enabled by default when xend is activated. For further information on using and configuring blktap see tools/blktap/README.