aboutsummaryrefslogtreecommitdiffstats
path: root/block
AgeCommit message (Collapse)AuthorFilesLines
2011-09-06VMDK: bugfix, opening vSphere 4 exported imageFam Zheng1-2/+7
The vSphere 4 exported image is streamOptimized extent, which is not quite correctly handled. Ignore rdgOffset when RGD flag bit not set. Signed-off-by: Fam Zheng <famcool@gmail.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06VMDK: bugfix, open Haiku vmdk imageFam Zheng1-4/+11
Haiku provides a specially formed vmdk image, which let qemu abort. It a combination of sparse header and flat data (i.e. with not l1/l2 table at all). The fix is turn to descriptor when sparse header is zero in field 'capacity'. Signed-off-by: Fam Zheng <famcool@gmail.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06VMDK: creating streamOptimized subformatFam Zheng1-6/+12
Creating streamOptimized subformat. Added subformat option 'streamOptimized', to create a image with compression enabled and each cluster with a GrainMarker. Signed-off-by: Fam Zheng <famcool@gmail.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06VMDK: read/write compressed extentFam Zheng1-11/+100
Add support for reading/writing compressed extent. Signed-off-by: Fam Zheng <famcool@gmail.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06VMDK: Opening compressed extent.Fam Zheng1-0/+16
Added flags field for compressed/streamOptimized extents, open and save image configuration. Signed-off-by: Fam Zheng <famcool@gmail.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06VMDK: separate vmdk_read_extent/vmdk_write_extentFam Zheng1-9/+45
Factor out read/write extent code, since there will be more things to take care of once reading/writing compressed clusters is introduced. Signed-off-by: Fam Zheng <famcool@gmail.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06VMDK: add twoGbMaxExtentSparse supportFam Zheng1-50/+83
Add twoGbMaxExtentSparse support. Introduce vmdk_free_last_extent. Signed-off-by: Fam Zheng <famcool@gmail.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06VMDK: enable twoGbMaxExtentFlatFam Zheng1-1/+3
Enable the createType 'twoGbMaxExtentFlat'. The supporting code is already in. Signed-off-by: Fam Zheng <famcool@gmail.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06block/raw: Fix to forward method bdrv_media_changed()Markus Armbruster1-0/+7
Block driver "raw" forwards most methods to the underlying block driver. However, it doesn't implement method bdrv_media_changed(). Makes bdrv_media_changed() always return -ENOTSUP. I believe -fda /dev/fd0 gives you raw over host_floppy, and disk change detection (fdc register 7 bit 7) is broken. Testing my theory requires a computer museum, though. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06qcow2: Fix error cases to run depedent requestsKevin Wolf1-3/+4
Requests depending on a failed request would end up waiting forever. This fixes the error path to continue dependent requests even when the request has failed. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06qcow2: Properly initialise QcowL2MetaKevin Wolf1-2/+3
Dependency list pointers filled with random garbage from the stack aren't a good idea. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06linux aio: some commentsFrediano Ziglio1-0/+4
Add some notes about Linux AIO explaining why we don't use AIO in some situations. Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-03Use new macro QEMU_PACKED for packed structuresStefan Weil4-10/+10
Most changes were made using these commands: git grep -la '__attribute__((packed))'|xargs perl -pi -e 's/__attribute__\(\(packed\)\)/QEMU_PACKED/' git grep -la '__attribute__ ((packed))'|xargs perl -pi -e 's/__attribute__ \(\(packed\)\)/QEMU_PACKED/' git grep -la '__attribute__((__packed__))'|xargs perl -pi -e 's/__attribute__\(\(__packed__\)\)/QEMU_PACKED/' git grep -la '__attribute__ ((__packed__))'|xargs perl -pi -e 's/__attribute__ \(\(__packed__\)\)/QEMU_PACKED/' git grep -la '__attribute((packed))'|xargs perl -pi -e 's/__attribute\(\(packed\)\)/QEMU_PACKED/' Whitespace in linux-user/syscall_defs.h was fixed manually to avoid warnings from scripts/checkpatch.pl. Manual changes were also applied to hw/pc.c. I did not fix indentation with tabs in block/vvfat.c. The patch will show 4 errors with scripts/checkpatch.pl. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-25qcow2: remove unused qcow2_create_refcount_update functionFrediano Ziglio2-20/+0
Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-25qcow2: use always stderr for debuggingFrediano Ziglio2-3/+3
let all DEBUG_ALLOC2 printf goes to stderr Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-24sheepdog: use coroutinesMORITA Kazutaka1-57/+93
This makes the sheepdog block driver support bdrv_co_readv/writev instead of bdrv_aio_readv/writev. With this patch, Sheepdog network I/O becomes fully asynchronous. The block driver yields back when send/recv returns EAGAIN, and is resumed when the sheepdog network connection is ready for the operation. Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-23qcow2: remove memory leakFrediano Ziglio1-0/+2
Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-23qcow2: Removed QCowAIOCB entirelyFrediano Ziglio1-127/+80
Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-23qcow2: reindent and use while before the big jumpFrediano Ziglio1-137/+135
prepare to remove read/write callbacks Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-23qcow2: remove common from QCowAIOCBFrediano Ziglio1-4/+4
Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-23qcow2: remove cluster_offset from QCowAIOCBFrediano Ziglio1-11/+11
Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-23qcow2: remove l2meta from QCowAIOCBFrediano Ziglio1-7/+8
Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-23qcow2: removed cur_nr_sectors field in QCowAIOCBFrediano Ziglio1-55/+43
Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-23qcow2: Removed unused AIOCB fieldsFrediano Ziglio1-7/+3
Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-23qcow: remove old #undefined codeFrediano Ziglio1-63/+0
Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-23qcow: Remove QCowAIOCBFrediano Ziglio1-168/+123
Embed qcow_aio_read_cb into qcow_co_readv and qcow_aio_write_cb into qcow_co_writev Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-23qcow: move some blocks of code to avoid useless variable initializationFrediano Ziglio1-27/+26
Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-23qcow: QCowAIOCB field cleanupFrediano Ziglio1-72/+65
remove unused field from this structure and put some of them in qcow_aio_read_cb and qcow_aio_write_cb Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-23qcow/qcow2: Allocate QCowAIOCB structure using stackFrediano Ziglio2-63/+27
instead of calling qemi_aio_get use stack Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-23block/curl: Handle failed reads gracefully.Nicholas Thomas1-1/+19
Current behaviour if a read fails is for the acb to not get finished. This causes an infinite loop in bdrv_read_em (block.c). The read failure never gets reported to the guest and if the error condition clears, the process never recovers. With this patch, when curl reports a failure we finish the acb as a failure. This results in the guest receiving an I/O error (rather than the read hanging indefinitely) and if the error condition subsequently clears, retries work as expected. The simplest test is to put an ISO on a web server you have control over and open it with qemu-io. Then move the ISO out of the way and attempt to read some data - you should see behaviour matching the above. Signed-off-by: Nick Thomas <nick@bytemark.co.uk> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-23qcow: initialize coroutine mutexScott Wood1-0/+2
commit 52b8eb60132b27ad53476490e9d7579003390cfa added a mutex, but never initialized it. This caused a segfault. Reported-by: Alexander Graf <agraf@suse.de> Signed-off-by: Scott Wood <scottwood@freescale.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-23qcow2: fix typo in documentation for qcow2_get_cluster_offset()Devin Nakamura1-2/+2
Documentation states the num is measured in clusters, but its actually measured in sectors Signed-off-by: Devin Nakamura <devin122@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-23qcow2: Fix DEBUG_* compilationPhilipp Hahn2-4/+17
By introducing BlockDriverState compiling qcow2 with DEBUG_ALLOC and DEBUG_EXT defined got broken. Define a BdrvCheckResult structure locally which is now needed as the second argument. Also fix qcow2_read_extensions() needing BDRVQcowState. Signed-off-by: Philipp Hahn <hahn@univention.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-22w32: Fix qemu_ftruncate64Stefan Weil1-2/+6
SetFilePointer returns INVALID_SET_FILE_POINTER when it fails. In addition, GetLastError must be checked. The first call of SetFilePointer did not use INVALID_SET_FILE_POINTER, the second call used wrong error handling. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-20Use glib memory allocation and free functionsAnthony Liguori25-205/+205
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-05qcow2: Fix L1 table size after bdrv_snapshot_gotoKevin Wolf1-5/+11
When loading an internal snapshot whose L1 table is smaller than the current L1 table, the size of the current L1 would be shrunk to the snapshot's L1 size in memory, but not on disk. This lead to incorrect refcount updates and eventuelly to image corruption. Instead of writing the new L1 size to disk, this simply retains the bigger L1 size that is currently in use and makes sure that the unused part is zeroed. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Tested-by: Philipp Hahn <hahn@univention.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-02async: Remove AsyncContextKevin Wolf2-18/+0
The purpose of AsyncContexts was to protect qcow and qcow2 against reentrancy during an emulated bdrv_read/write (which includes a qemu_aio_wait() call and can run AIO callbacks of different requests if it weren't for AsyncContexts). Now both qcow and qcow2 are protected by CoMutexes and AsyncContexts can be removed. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-02qcow: Use coroutinesKevin Wolf1-118/+62
The old qcow format is another user of the AsyncContext infrastructure. Converting it to coroutines (and therefore CoMutexes) allows to remove AsyncContexts. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-02qcow2: Use coroutinesKevin Wolf3-169/+102
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-01raw-posix: Always check paio_init resultFrediano Ziglio1-6/+5
Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-01raw-posix: Typo fixFrediano Ziglio1-1/+1
Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-01block/vpc.c: Detect too-large vpc fileSerge E. Hallyn1-1/+7
VHD files technically can be up to 2Tb, but virtual pc is limited to 127G. Currently qemu-img refused to create vpc files > 127G, but it is failing to return error when converting from a non-vpc VHD file which is >127G. It returns success, but creates a truncated converted image. Also, qemu-img info claims the vpc file is 127G (and clean). This patch detects a too-large vpc file and returns -EFBIG. Without this patch, ============================================================= root@ip-10-38-123-242:~/qemu-fixed# qemu-img info /mnt/140g-dynamic.vhd image: /mnt/140g-dynamic.vhd file format: vpc virtual size: 127G (136899993600 bytes) disk size: 284K root@ip-10-38-123-242:~/qemu-fixed# qemu-img convert -f vpc -O raw /mnt/140g-dynamic.vhd /mnt/y root@ip-10-38-123-242:~/qemu-fixed# echo $? 0 root@ip-10-38-123-242:~/qemu-fixed# qemu-img info /mnt/y image: /mnt/y file format: raw virtual size: 127G (136899993600 bytes) disk size: 0 ============================================================= (The 140G image was truncated with no warning or error.) With the patch, I get: ============================================================= root@ip-10-38-123-242:~/qemu-fixed# ./qemu-img info /mnt/140g-dynamic.vhd qemu-img: Could not open '/mnt/140g-dynamic.vhd': File too large root@ip-10-38-123-242:~/qemu-fixed# ./qemu-img convert -f vpc -O raw /mnt/140g-dynamic.vhd /mnt/y qemu-img: Could not open '/mnt/140g-dynamic.vhd': File too large qemu-img: Could not open '/mnt/140g-dynamic.vhd' ============================================================= See https://bugs.launchpad.net/qemu/+bug/814222 for details. Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-01block: Make BlockDriver method bdrv_eject() return voidMarkus Armbruster2-13/+7
Callees always return 0, except for FreeBSD's cdrom_eject(), which returns -ENOTSUP when the device is in a terminally wedged state. The only caller is bdrv_eject(), and it maps -ENOTSUP to 0 since commit 4be9762a. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-01block: Make BlockDriver method bdrv_set_locked() return voidMarkus Armbruster2-9/+4
The only caller is bdrv_set_locked(), and it ignores the value. Callees always return 0, except for FreeBSD's cdrom_set_locked(), which returns -ENOTSUP when the device is in a terminally wedged state. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-01block/raw-win32: Drop disabled code for removable host devicesMarkus Armbruster1-35/+0
It's been disabled since the start (commit 19cb3738, Aug 2006), and has been untouched except for spelling fixes and such. I don't feel like dragging it along any further. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-07-25Wrap recv to avoid warningsBlue Swirl1-1/+1
Avoid warnings like these by wrapping recv(): CC slirp/ip_icmp.o /src/qemu/slirp/ip_icmp.c: In function 'icmp_receive': /src/qemu/slirp/ip_icmp.c:418:5: error: passing argument 2 of 'recv' from incompatible pointer type [-Werror] /usr/local/lib/gcc/i686-mingw32msvc/4.6.0/../../../../i686-mingw32msvc/include/winsock2.h:547:32: note: expected 'char *' but argument is of type 'struct icmp *' Remove also casts used to avoid warnings. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-07-19qcow2: Use Qcow2Cache in writeback mode during loadvm/savevmKevin Wolf3-11/+41
In snapshotting there is no guest involved, so we can safely use a writeback mode and do the flushes in the right place (i.e. at the very end). This improves the time that creating/restoring an internal snapshot takes with an image in writethrough mode. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-07-19block: add bdrv_get_allocated_file_size() operationFam Zheng3-0/+74
qemu-img.c wants to count allocated file size of image. Previously it counts a single bs->file by 'stat' or Window API. As VMDK introduces multiple file support, the operation becomes format specific with platform specific meanwhile. The functions are moved to block/raw-{posix,win32}.c and qemu-img.c calls bdrv_get_allocated_file_size to count the bs. And also added VMDK code to count his own extents. Signed-off-by: Fam Zheng <famcool@gmail.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-07-19VMDK: fix coding styleFam Zheng1-30/+46
Conform coding style in vmdk.c to pass scripts/checkpatch.pl checks. Signed-off-by: Fam Zheng <famcool@gmail.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-07-19VMDK: create different subformatsFam Zheng1-229/+274
Add create option 'format', with enums: monolithicSparse monolithicFlat twoGbMaxExtentSparse twoGbMaxExtentFlat Each creates a subformat image file. The default is monolithicSparse. Signed-off-by: Fam Zheng <famcool@gmail.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>