aboutsummaryrefslogtreecommitdiffstats
path: root/block
AgeCommit message (Collapse)AuthorFilesLines
2011-11-23vvfat: Add migration blockerKevin Wolf1-0/+17
vvfat caches more or less everything when in writable mode. For migration to work, it would have to be invalidated. Block migration for now when in writable mode (default is readonly). Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-23vpc: Add migration blockerKevin Wolf1-0/+13
vpc caches the BAT. For migration to work, it would have to be invalidated. Block migration for now. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-23vmdk: Add migration blockerKevin Wolf1-1/+15
VMDK caches L2 tables. For migration to work, they would have to be invalidated. Block migration for now. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-23vdi: Add migration blockerKevin Wolf1-0/+12
vdi caches the block map. For migration to work, it would have to be invalidated. Block migration for now. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-23qcow: Add migration blockerKevin Wolf1-0/+12
qcow caches L2 tables. For migration to work, they would have to be invalidated. Block migration for now. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-22sheepdog: Avoid deadlock in error pathDong Xu Wang1-0/+2
s->lock should be unlocked before leaving add_aio_request. Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-21Include zlib.h using #include <>Stefan Weil1-1/+1
zlib.h is not a local include file, therefore it should be included using <> instead of "". Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-11-21qed: add migration blocker (v2)Anthony Liguori2-0/+12
Now when you try to migrate with qed, you get: (qemu) migrate tcp:localhost:1025 Block format 'qed' used by device 'ide0-hd0' does not support feature 'live migration' (qemu) Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-11-21qcow2: implement bdrv_invalidate_cache (v2)Anthony Liguori2-0/+36
We don't reopen the actual file, but instead invoke the close and open routines. We specifically ignore the backing file since it's contents are read-only and therefore immutable. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-11-11block: Introduce bdrv_co_flush_to_osKevin Wolf1-2/+8
qcow2 has a writeback metadata cache, so flushing a qcow2 image actually consists of writing back that cache to the protocol and only then flushes the protocol in order to get everything stable on disk. This introduces a separate bdrv_co_flush_to_os to reflect the split. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-11block: Rename bdrv_co_flush to bdrv_co_flush_to_diskKevin Wolf9-42/+51
There are two different types of flush that you can do: Flushing one level up to the OS (i.e. writing data to the host page cache) or flushing it all the way down to the disk. The existing functions flush to the disk, reflect this in the function name. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-11block: Fix vpc initialization of the Dynamic Disk HeaderCharles Arnold1-1/+5
The Data Offset field in the Dynamic Disk Header is an 8 byte field. Although the specification (2006-10-11) gives an example of initializing only the first 4 bytes, images generated by Microsoft on Windows initialize all 8 bytes. Failure to initialize all 8 bytes results in errors from utilities like Citrix's vhd-util which checks specifically for the proper Data Offset field initialization. Signed-off-by: Charles Arnold <carnold@suse.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-11vvfat: Fix read-write modeKevin Wolf1-21/+23
vvfat used to directly call into the qcow2 block driver instead of using the block.c wrappers. With the coroutine conversion, this stopped working. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2011-11-04vvfat: reorganize computation of disk geometryPaolo Bonzini1-16/+24
First determine FAT12/16/32, then compute geometry from that for both FDD and HDD. For 1.44MB floppies, and 2.88MB floppies using FAT16, change to 1 sector/cluster. The default remains 2.88MB with FAT12 and 2 sectors/cluster. Both DOS and mkdosfs by default format a 2.88MB floppy as FAT12. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-04vvfat: do not hardcode sector counts in error messagePaolo Bonzini1-5/+2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-04vvfat: unify and correct computation of sector countPaolo Bonzini1-3/+3
The sector count is stored in the partition and hence must not include the sectors before its start. At the same time, remove the useless special casing for 1.44 MB floppies. This fixes fsck on VVFAT hard disks, which otherwise tries to seek past the end of the disk. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-04vvfat: need to use first_sectors_number to distinguish fdd/hddPaolo Bonzini1-2/+2
This is consistent with what "real" floppies have, so file(1) now actually recognizes the VVFAT image as a 1.44 MB floppy. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-04vvfat: do not fail if the disk has spare sectorsPaolo Bonzini1-2/+2
If the number of "faked sectors" + the number of sectors that are part of a cluster does not sum up to the total number of sectors, qemu-img convert fails. Read these spare sectors as all zeros. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-04vvfat: fix out of bounds array_get usagePaolo Bonzini1-0/+1
When reading the address of the first free entry, you cannot use array_get without first marking all entries as occupied. This is visible if you change the sectors per cluster on a floppy from 2 to 1. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-04block/cloop: Use g_free instead of freeDong Xu Wang1-3/+3
Fix mismatching allocation and deallocation: g_free should be used to pair with g_malloc. Reviewed-by: Andreas Färber <afaerber@suse.de> Reviewed_by: Ray Wang <raywang@linux.vnet.ibm.com> Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-04block/cloop: Fix coding styleDong Xu Wang1-52/+63
Fix coding style in block/cloop.c. Reviewed-by: Andreas Färber <afaerber@suse.de> Reviewed_by: Ray Wang <raywang@linux.vnet.ibm.com> Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-31Merge remote-tracking branch 'kwolf/for-anthony' into stagingAnthony Liguori5-27/+647
Conflicts: block/vmdk.c
2011-10-31Merge remote-tracking branch 'stefanha/trivial-patches' into stagingAnthony Liguori2-5/+5
2011-10-28block: fix qcow2_co_flush deadlockDong Xu Wang1-0/+2
If qcow2_cache_flush failed, s->lock will not be unlock. Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28vmdk: Fix possible segfaultsKevin Wolf1-1/+6
Data we read from the disk isn't necessarily null terminated and may not contain the string we're looking for. The code needs to be a bit more careful here. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28vmdk: Improve error handlingKevin Wolf1-6/+15
Return the right error values in some more places. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28vmdk: Fix use of uninitialised valueKevin Wolf1-1/+1
In error cases, cid is never set. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28qcow: Fix bdrv_write_compressed error handlingKevin Wolf1-11/+19
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2011-10-28Teach block/vdi about "discarded" (no longer allocated) blocksEric Sunshine1-9/+14
An entry in the VDI block map will hold an offset to the actual block if the block is allocated, or one of two specially-interpreted values if not allocated. Using VirtualBox terminology, value VDI_IMAGE_BLOCK_FREE (0xffffffff) represents a never-allocated block (semantically arbitrary content). VDI_IMAGE_BLOCK_ZERO (0xfffffffe) represents a "discarded" block (semantically zero-filled). block/vdi knows only about VDI_IMAGE_BLOCK_FREE. Teach it about VDI_IMAGE_BLOCK_ZERO. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28iSCSI block driverRonnie Sahlberg1-0/+591
This provides built-in support for iSCSI to QEMU. This has the advantage that the iSCSI devices need not be made visible to the host, which is useful if you have very many virtual machines and very many iscsi devices. It also has the benefit that non-root users of QEMU can access iSCSI devices across the network without requiring root privilege on the host. This driver interfaces with the multiplatform posix library for iscsi initiator/client access to iscsi devices hosted at git://github.com/sahlberg/libiscsi.git The patch adds the driver to interface with the iscsi library. It also updated the configure script to * by default, probe is libiscsi is available and if so, build qemu against libiscsi. * --enable-libiscsi Force a build against libiscsi. If libiscsi is not available the build will fail. * --disable-libiscsi Do not link against libiscsi, even if it is available. When linked with libiscsi, qemu gains support to access iscsi resources such as disks and cdrom directly, without having to make the devices visible to the host. You can specify devices using a iscsi url of the form : iscsi://[<username>[:<password>@]]<host>[:<port]/<target-iqn-name>/<lun> When using authentication, the password can optionally be set with LIBISCSI_CHAP_PASSWORD="password" to avoid it showing up in the process list Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-26qed: remove unneeded variable assignmentPavel Borzenkov1-1/+0
'ret' is unconditionally overwitten by qed_read_l1_table_sync() Spotted by Clang Analyzer Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-10-26qed: don't pass NULL to memcpyPavel Borzenkov1-2/+4
Spotted by Clang Analyzer [Note this memcpy call has always been safe because the length will be 0 when the pointer is NULL] Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-10-26vmdk: vmdk_read_cid returns garbage if p_name is NULLPavel Borzenkov1-1/+1
Spotted by Clang Analyzer Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-10-26vmdk: remove unneeded variable assignmentPavel Borzenkov1-1/+0
Spotted by Clang Analyzer Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-10-21block: change discard to co_discardPaolo Bonzini2-6/+13
Since coroutine operation is now mandatory, convert both bdrv_discard implementations to coroutines. For qcow2, this means taking the lock around the operation. raw-posix remains synchronous. The bdrv_discard callback is then unused and can be eliminated. Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-21block: change flush to co_flushPaolo Bonzini8-30/+29
Since coroutine operation is now mandatory, convert all bdrv_flush implementations to coroutines. For qcow2, this means taking the lock. Other implementations are simpler and just forward bdrv_flush to the underlying protocol, so they can avoid the lock. The bdrv_flush callback is then unused and can be eliminated. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-21block: take lock around bdrv_write implementationsPaolo Bonzini5-5/+60
This does the first part of the conversion to coroutines, by wrapping bdrv_write implementations to take the mutex. Drivers that implement bdrv_write rather than bdrv_co_writev can then benefit from asynchronous operation (at least if the underlying protocol supports it, which is not the case for raw-win32), even though they still operate with a bounce buffer. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-21block: take lock around bdrv_read implementationsPaolo Bonzini9-9/+108
This does the first part of the conversion to coroutines, by wrapping bdrv_read implementations to take the mutex. Drivers that implement bdrv_read rather than bdrv_co_readv can then benefit from asynchronous operation (at least if the underlying protocol supports it, which is not the case for raw-win32), even though they still operate with a bounce buffer. raw-win32 does not need the lock, because it cannot yield. nbd also doesn't probably, but better be safe. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-21block: add a CoMutex to synchronous read driversPaolo Bonzini9-0/+18
The big conversion of bdrv_read/write to coroutines caused the two homonymous callbacks in BlockDriver to become reentrant. It goes like this: 1) bdrv_read is now called in a coroutine, and calls bdrv_read or bdrv_pread. 2) the nested bdrv_read goes through the fast path in bdrv_rw_co_entry; 3) in the common case when the protocol is file, bdrv_co_do_readv calls bdrv_co_readv_em (and from here goes to bdrv_co_io_em), which yields until the AIO operation is complete; 4) if bdrv_read had been called from a bottom half, the main loop is free to iterate again: a device model or another bottom half can then come and call bdrv_read again. This applies to all four of read/write/flush/discard. It would also apply to is_allocated, but it is not used from within coroutines: besides qemu-img.c and qemu-io.c, which operate synchronously, the only user is the monitor. Copy-on-read will introduce a use in the block layer, and will require converting it. The solution is "simply" to convert all drivers to coroutines! We just need to add a CoMutex that is taken around affected operations. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-21vmdk: clean up openPaolo Bonzini1-22/+15
Move vmdk_parent_open to vmdk_open. There's another path how vmdk_parent_open can be reached: vmdk_parse_extents() -> vmdk_open_sparse() -> vmdk_open_vmdk4() -> vmdk_open_desc_file(). If that can happen, however, the code is bogus. vmdk_parent_open reads from bs->file: if (bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE) != DESC_SIZE) { but it is always called with s->desc_offset == 0 and with the same bs->file. So the data that vmdk_parent_open reads comes always from the same place, and anyway there is only one place where it can write it, namely bs->backing_file. So, if it cannot happen, the patched code is okay. It is also possible that the recursive call can happen, but only once. In that case there would still be a bug in vmdk_open_desc_file setting s->desc_offset = 0, but the patched code is okay. Finally, in the case where multiple recursive calls can happen the code would need to be rewritten anyway. It is likely that this would anyway involve adding several parameters to vmdk_parent_open, and calling it from vmdk_open_vmdk4. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-21vmdk: fix return values of vmdk_parent_openPaolo Bonzini1-6/+9
While vmdk_open_desc_file (touched by the patch) correctly changed -1 to -EINVAL, vmdk_open did not. Fix it directly in vmdk_parent_open. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-21qcow2: Fix bdrv_write_compressed error handlingKevin Wolf2-13/+22
If during allocation of compressed clusters the cluster was already allocated uncompressed, fail and properly release the l2_table (the latter avoids a failed assertion). While at it, make it return some real error numbers instead of -1. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
2011-10-21block: add bdrv_co_discard and bdrv_aio_discard supportPaolo Bonzini1-4/+6
This similarly adds support for coroutine and asynchronous discard. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-21block: drop redundant bdrv_flush implementationStefan Hajnoczi7-74/+3
Block drivers now only need to provide either of .bdrv_co_flush, .bdrv_aio_flush() or for legacy drivers .bdrv_flush(). Remove the redundant .bdrv_flush() implementations. [Paolo Bonzini: change raw driver to bdrv_co_flush] Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-21sheepdog: add coroutine_fn markersPaolo Bonzini1-7/+7
This makes the following patch easier to review. Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-14Merge remote-tracking branch 'kwolf/for-anthony' into stagingAnthony Liguori3-382/+60
2011-10-14block: use coroutine interface for raw formatStefan Hajnoczi1-24/+8
The raw format delegates all operations to bs->file (the protocol). Previously this block driver exposed both sync and aio interfaces. Since the block layer now works in terms of coroutines, expose the coroutine interfaces and drop the others. This avoids unnecessary emulation of sync and aio interfaces. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-14raw-posix: remove bdrv_read()/bdrv_write()Stefan Hajnoczi1-277/+0
Block drivers only need to provide one of sync, aio, or coroutine interfaces. Since raw-posix.c provides aio interfaces, simply drop the synchronous interfaces since they can be emulated using aio and coroutines. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-14block/qcow: Fix use of free() instead of g_free()Stefan Weil1-1/+1
cppcheck reported this error: qemu/block/qcow.c:599: error: Mismatching allocation and deallocation: cluster_data Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-10-14sheepdog: correct spellingDong Xu Wang1-1/+1
Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>