summaryrefslogtreecommitdiffstats
path: root/block
Commit message (Collapse)AuthorAgeFilesLines
* block: rate-limit streaming operationsStefan Hajnoczi2012-01-261-6/+59
| | | | | | | | | This patch implements rate-limiting for image streaming. If we've exceeded the bandwidth quota for a 100 ms time slice we sleep the coroutine until the next slice begins. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: add image streaming block jobStefan Hajnoczi2012-01-261-0/+133
| | | | | Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: replace unchecked strdup/malloc/calloc with glibStefan Hajnoczi2012-01-262-4/+4
| | | | | | | | | | | Most of the codebase as been converted to use glib memory allocation functions. There are still a few instances of malloc/calloc in the block layer and qemu-io. Replace them, especially since they do not check the strdup/malloc/calloc return value. Reported-by: Dr David Alan Gilbert <davidagilbert@uk.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* rbd: wire up snapshot removal and rollback functionalityGregory Farnum2012-01-261-0/+22
| | | | | | Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* prepare for future GPLv2+ relicensingPaolo Bonzini2012-01-133-0/+7
| | | | | | | | | All files under GPLv2 will get GPLv2+ changes starting tomorrow. event_notifier.c and exec-obsolete.h were only ever touched by Red Hat employees and can be relicensed now. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* vvfat: avoid leaking file descriptor in commit_one_file()Stefan Hajnoczi2012-01-131-0/+3
| | | | | Reported-by: Dr David Alan Gilbert <davidagilbert@uk.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* move corking functions to osdep.cPaolo Bonzini2011-12-221-18/+2
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* nbd: add support for NBD_CMD_TRIMPaolo Bonzini2011-12-221-0/+25
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* nbd: add support for NBD_CMD_FLUSHPaolo Bonzini2011-12-221-8/+37
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* nbd: add support for NBD_CMD_FLAG_FUAPaolo Bonzini2011-12-221-0/+4
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* nbd: allow multiple in-flight requestsPaolo Bonzini2011-12-221-13/+56
| | | | | | | | | Allow sending up to 16 requests, and drive the replies to the coroutine that did the request. The code is written to be exactly the same as before this patch when MAX_NBD_REQUESTS == 1 (modulo the extra mutex and state). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* nbd: split requestsPaolo Bonzini2011-12-221-6/+46
| | | | | | | qemu-nbd has a limit of slightly less than 1M per request. Work around this in the nbd block driver. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* nbd: switch to asynchronous operationPaolo Bonzini2011-12-221-65/+123
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* sheepdog: move coroutine send/recv function to generic codePaolo Bonzini2011-12-221-209/+21
| | | | | | | | | | | | | | Outside coroutines, avoid busy waiting on EAGAIN by temporarily making the socket blocking. The API of qemu_recvv/qemu_sendv is slightly different from do_readv/do_writev because they do not handle coroutines. It returns the number of bytes written before encountering an EAGAIN. The specificity of yielding on EAGAIN is entirely in qemu-coroutine.c. Reviewed-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* block/cow: Return real error codeLi Zhi Hui2011-12-151-15/+29
| | | | | Signed-off-by: Li Zhi Hui <zhihuili@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Allow >4 GB VM stateKevin Wolf2011-12-152-3/+33
| | | | | | | This is a compatible extension to the snapshot header format that allows saving a 64 bit VM state size. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* rbd: always set out parameter in qemu_rbd_snap_listJosh Durgin2011-12-151-1/+2
| | | | | | | | | The caller expects psn_tab to be NULL when there are no snapshots or an error occurs. This results in calling g_free on an invalid address. Reported-by: Oliver Francke <Oliver@filoo.de> Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block/qcow2.c: call qcow2_free_snapshots in the function of qcow2_closeLi Zhi Hui2011-12-151-0/+1
| | | | | | Signed-off-by: Li Zhi Hui <zhihuili@linux.vnet.ibm.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: qemu_aio_get does not return NULLPaolo Bonzini2011-12-153-36/+19
| | | | | | | | | | | | | | | | | | | | | | | | Initially done with the following semantic patch: @ rule1 @ expression E; statement S; @@ E = qemu_aio_get (...); ( - if (E == NULL) { ... } | - if (E) { <... S ...> } ) which however missed occurrences in linux-aio.c and posix-aio-compat.c. Those were done by hand. The change in vdi_aio_setup's caller was also done by hand. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: bdrv_aio_* do not return NULLPaolo Bonzini2011-12-154-95/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Initially done with the following semantic patch: @ rule1 @ expression E; statement S; @@ E = ( bdrv_aio_readv | bdrv_aio_writev | bdrv_aio_flush | bdrv_aio_discard | bdrv_aio_ioctl ) (...); ( - if (E == NULL) { ... } | - if (E) { <... S ...> } ) which however missed the occurrence in block/blkverify.c (as it should have done), and left behind some unused variables. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fix typo: delete redundant semicolonDong Xu Wang2011-12-061-2/+2
| | | | | | | Double semicolons should be single. Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* Merge remote-tracking branch 'kwolf/for-anthony' into stagingAnthony Liguori2011-12-0512-219/+362
|\
| * cow: use bdrv_co_is_allocated()Stefan Hajnoczi2011-12-051-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Now that bdrv_co_is_allocated() is available we can use it instead of the synchronous bdrv_is_allocated() interface. This is a follow-up that Kevin Wolf <kwolf@redhat.com> pointed out after applying the series that introduces bdrv_co_is_allocated(). It is safe to make cow_read() a coroutine_fn because its only caller is a coroutine_fn. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * coroutine: add qemu_co_queue_restart_all()Stefan Hajnoczi2011-12-051-1/+1
| | | | | | | | | | | | | | | | | | It's common to wake up all waiting coroutines. Introduce the qemu_co_queue_restart_all() function to do this instead of looping over qemu_co_queue_next() in every caller. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * cow: convert to .bdrv_co_is_allocated()Stefan Hajnoczi2011-12-051-4/+4
| | | | | | | | | | | | | | | | | | The cow block driver does not keep internal state for cluster lookups. This means it is safe to perform cluster lookups in coroutine context without risk of race conditions that corrupt internal state. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * vdi: convert to .bdrv_co_is_allocated()Stefan Hajnoczi2011-12-051-3/+3
| | | | | | | | | | | | | | | | | | It is trivial to switch from the synchronous .bdrv_is_allocated() interface to .bdrv_co_is_allocated() since vdi_is_allocated() does not block. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * vvfat: convert to .bdrv_co_is_allocated()Stefan Hajnoczi2011-12-051-2/+2
| | | | | | | | | | | | | | | | | | It is trivial to switch from the synchronous .bdrv_is_allocated() interface to .bdrv_co_is_allocated() since vvfat_is_allocated() does not block. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * block: convert qcow2, qcow2, and vmdk to .bdrv_co_is_allocated()Stefan Hajnoczi2011-12-053-11/+18
| | | | | | | | | | | | | | | | | | | | The qcow2, qcow, and vmdk block drivers are based on coroutines. They have a coroutine mutex which protects internal state. We can convert the .bdrv_is_allocated() function to .bdrv_co_is_allocated() by holding the mutex around the cluster lookup operation. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * qed: convert to .bdrv_co_is_allocated()Stefan Hajnoczi2011-12-051-4/+11
| | | | | | | | | | | | | | | | | | | | | | The bdrv_qed_is_allocated() function is a synchronous wrapper around qed_find_cluster(), which performs the cluster lookup. In order to convert the synchronous function to a coroutine function we yield instead of using qemu_aio_wait(). Note that QED's cache is already safe for parallel requests so no locking is needed. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * qcow2: Fix error path in qcow2_snapshot_load_tmpKevin Wolf2011-12-051-12/+22
| | | | | | | | | | | | | | | | | | If the bdrv_read() of the snapshot's L1 table fails, return the right error code and make sure that the old L1 table is still loaded and we don't break the BlockDriverState completely. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
| * qcow2: Fix order in qcow2_snapshot_deleteKevin Wolf2011-12-051-15/+33
| | | | | | | | | | | | | | | | First the snapshot must be deleted and only then the refcounts can be decreased. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
| * qcow2: Fix order of refcount updates in qcow2_snapshot_gotoKevin Wolf2011-12-052-18/+50
| | | | | | | | | | | | | | | | The refcount updates must be moved so that in the worst case we can get cluster leaks, but refcounts may never be too low. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
| * qcow2: Return real error in qcow2_snapshot_gotoKevin Wolf2011-12-051-11/+40
| | | | | | | | | | | | | | | | | | Besides fixing the return code, this adds some comments that make clear how the code works and that it potentially breaks images if we fail in the wrong place. Actually fixing this is left for the next patch. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
| * qcow2: Rework qcow2_snapshot_create error handlingKevin Wolf2011-12-051-14/+41
| | | | | | | | | | | | | | | | | | | | | | Increase refcounts only after allocating a new L1 table has succeeded in order to make leaks less likely. If writing the snapshot table fails, revert in-memory state to be consistent with that on disk. While at it, make it return the real error codes instead of -1. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
| * qcow2: Cleanups and memleak fix in qcow2_snapshot_createKevin Wolf2011-12-051-15/+11
| | | | | | | | | | | | | | | | | | sn->id_str could be leaked before this. The rest of this patch changes comments, fixes coding style or removes checks that are unnecessary with g_malloc. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
| * qcow2: Update snapshot table information at onceKevin Wolf2011-12-051-12/+10
| | | | | | | | | | | | | | | | Failing in the middle wouldn't help with the integrity of the image, so doing everything in a single request seems better. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
| * qcow2: Return real error code in qcow2_write_snapshotsKevin Wolf2011-12-051-10/+38
| | | | | | | | | | | | | | | | Doesn't immediately fix anything as the callers don't use the return value, but they will be fixed next. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
| * qcow2: Return real error code in qcow2_read_snapshotsKevin Wolf2011-12-052-7/+23
| | | | | | | | | | Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
| * block: Add coroutine_fn marker to coroutine functionsDong Xu Wang2011-12-053-8/+8
| | | | | | | | | | | | | | | | Looks better when reviewing these source files. Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * block: Use bdrv functions to replace file operation in cow.cLi Zhi Hui2011-12-051-18/+16
| | | | | | | | | | | | | | | | | | Since common file operation functions lack of error detection, so change them to bdrv series functions. Signed-off-by: Li Zhi Hui <zhihuili@linux.vnet.ibm.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * qed: adjust the way to get nb_sectorsZhi Yong Wu2011-12-051-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is only to refactor some lines of codes to get better and more robust codes. As you have seen, in qed_read_table_cb() it's nice to use qiov->size because that function doesn't obviously use a single struct iovec. In other two functions, if qiov use more than one struct iovec, the existing way will get wrong nb_sectors. To make the code more robust, it will be nicer to refactor the existing way as below. Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> Acked-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * qcow2: avoid reentrant bdrv_read() in copy_sectors()Stefan Hajnoczi2011-12-051-8/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A BlockDriverState should not issue requests on itself through the public block layer interface. Nested, or reentrant, requests are problematic because they do I/O throttling and request tracking twice. Features like block layer copy-on-read use request tracking to avoid race conditions between concurrent requests. The reentrant request will have to "wait" for its parent request to complete. But the parent is waiting for the reentrant request to make progress so we have reached deadlock. The solution is for block drivers to avoid the public block layer interfaces for reentrant requests. Instead they should call their own internal functions if they wish to perform reentrant requests. This is also a good opportunity to make copy_sectors() a true coroutine_fn. That means calling bdrv_co_writev() instead of bdrv_write(). Behavior is unchanged but we're being explicit that this executes in coroutine context. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * qcow2: Unlock during COWKevin Wolf2011-12-051-69/+35
| | | | | | | | | | | | | | | | | | | | | | Unlocking during COW allows for more parallelism. One change it requires is that buffers are dynamically allocated instead of just using a per-image buffer. While touching the code, drop the synchronous qcow2_read() function and replace it by a bdrv_read() call. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* | fix spelling in block sub directoryDong Xu Wang2011-12-023-5/+5
|/ | | | | | Cc: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* vpc: Add missing error handling in alloc_blockKevin Wolf2011-11-231-1/+4
| | | | | Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* vdi: Fix memory leakKevin Wolf2011-11-231-0/+3
| | | | | | The block map is allocated in vdi_open, but was never freed. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* vvfat: Add migration blockerKevin Wolf2011-11-231-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>
* vpc: Add migration blockerKevin Wolf2011-11-231-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>
* vmdk: Add migration blockerKevin Wolf2011-11-231-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>
* vdi: Add migration blockerKevin Wolf2011-11-231-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>
OpenPOWER on IntegriCloud