summaryrefslogtreecommitdiffstats
path: root/block
Commit message (Collapse)AuthorAgeFilesLines
* qcow2: Reduce number of I/O requestsKevin Wolf2012-03-122-77/+167
| | | | | | | | | | | | | | If the first part of a write request is allocated, but the second isn't and it can be allocated so that the resulting area is contiguous, handle it at once. This is a common case for sequential writes. After this patch, alloc_cluster_offset() only checks if the clusters are already allocated or how many new clusters can be allocated contigouosly. The actual cluster allocation is split off into a new function do_alloc_cluster_offset(). Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qcow2: Add qcow2_alloc_clusters_at()Kevin Wolf2012-03-122-0/+30
| | | | | | | | | This function allows to allocate clusters at a given offset in the image file. This is useful if you want to allocate the second part of an area that must be contiguous. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qcow2: Factor out count_cow_clustersKevin Wolf2012-03-121-19/+36
| | | | | Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qcow2: Add error messages in qcow2_truncateKevin Wolf2012-03-121-0/+3
| | | | | | | | | | qemu-img resize has some limitations with qcow2, but the user is only told that "this image format does not support resize". Quite confusing, so add some more detailed error_report() calls and change "this image format" into "this image". Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qcow2: Add some tracingKevin Wolf2012-03-123-1/+41
| | | | | Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qed: do not evict in-use L2 table cache entriesStefan Hajnoczi2012-03-121-4/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The L2 table cache reduces QED metadata reads that would be required when translating LBAs to offsets into the image file. Since requests execute in parallel it is possible to share an L2 table between multiple requests. There is a potential data corruption issue when an in-use L2 table is evicted from the cache because the following situation occurs: 1. An allocating write performs an update to L2 table "A". 2. Another request needs L2 table "B" and causes table "A" to be evicted. 3. A new read request needs L2 table "A" but it is not cached. As a result the L2 update from #1 can overlap with the L2 fetch from #3. We must avoid doing overlapping I/O requests here since the worst case outcome is that the L2 fetch completes before the L2 update and yields stale data. In that case we would effectively discard the L2 update and lose data clusters! Thanks to Benoît Canet <benoit.canet@gmail.com> for extensive testing and debugging which lead to discovery of this bug. Reported-by: Benoît Canet <benoit.canet@gmail.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Tested-by: Benoît Canet <benoit.canet@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block/vmdk: Fix warning from splint (comparision of unsigned value)Stefan Weil2012-03-071-1/+1
| | | | | | | l1_entry_sectors will never be less than 0. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qcow2: Reject too large header extensionsKevin Wolf2012-02-291-0/+5
| | | | | | | | | Image files that make qemu-img info read several gigabytes into the unknown header extensions list are bad. Just fail opening the image if an extension claims to be larger than the header extension area. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qcow2: Fix offset in qcow2_read_extensionsKevin Wolf2012-02-291-3/+2
| | | | | | | | | | | | | The spec says that the length of extensions is padded to 8 bytes, not the offset. Currently this is the same because the header size is a multiple of 8, so this is only about compatibility with future changes to the header size. While touching it, move the calculation to a common place instead of duplicating it for each header extension type. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qcow2: Fix build with DEBUG_EXT enabledKevin Wolf2012-02-291-1/+0
| | | | Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: bdrv_eject(): Make eject_flag a real boolLuiz Capitulino2012-02-222-4/+4
| | | | | | Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Acked-by: Kevin Wolf <kwolf@redhat.com>
* sheepdog: fix co_recv coroutine contextMORITA Kazutaka2012-02-091-0/+3
| | | | | | | | | | | | | | | | The co_recv coroutine has two things that will try to enter it: 1. The select(2) read callback on the sheepdog socket. 2. The aio_add_request() blocking operations, including a coroutine mutex. This patch fixes it by setting NULL to co_recv before sending data. In future, we should make the sheepdog driver fully coroutine-based and simplify request handling. Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Keep unknown header extension when rewriting headerKevin Wolf2012-02-092-2/+50
| | | | | | | | | If we want header extensions to work as compatible extensions, we can't destroy yet unknown header extensions when rewriting the header (e.g. for changing the backing file). Save all unknown header extensions in a list of blobs and include them in a new header. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Update whole header at onceKevin Wolf2012-02-092-60/+95
| | | | | | | | | | | | | In order to switch the backing file, qcow2 issues multiple write requests that only changed a part of the image header. Any failure after the first one would leave the header in an corrupted state. With this patch, the whole header is written at once, so we can't fail in the middle. At the same time, this gives us a reusable functions that updates all fields of the qcow2 header and not only the backing file. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* vpc: Round up image size during fixed image creationKevin Wolf2012-02-091-13/+10
| | | | | | | | | | The geometry calculation algorithm from the VHD spec rounds the image size down if it doesn't exactly match a geometry. During image conversion, this causes the image to be truncated. For dynamic images, we already have code in place to round up instead, let's do the same for fixed images. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* vpc: Add support for Fixed Disk typeCharles Arnold2012-02-091-91/+194
| | | | | | | | | | | | | | | | | The Virtual Hard Disk Image Format Specification allows for three types of hard disk formats, Fixed, Dynamic, and Differencing. Qemu currently only supports Dynamic disks. This patch adds support for the Fixed Disk format. Usage: Example 1: qemu-img create -f vpc -o type=fixed <filename> [size] Example 2: qemu-img convert -O vpc -o type=fixed <input filename> <output filename> While it is also allowed to specify '-o type=dynamic', the default disk type remains Dynamic and is what is used when the type is left unspecified. Signed-off-by: Charles Arnold <carnold@suse.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* iSCSI: add configuration variables for iSCSIRonnie Sahlberg2012-02-091-10/+129
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds configuration variables for iSCSI to set initiator-name to use when logging in to the target, which type of header-digest to negotiate with the target and username and password for CHAP authentication. This allows specifying a initiator-name either from the command line -iscsi initiator-name=iqn.2004-01.com.example:test or from a configuration file included with -readconfig [iscsi] initiator-name = iqn.2004-01.com.example:test header-digest = CRC32C|CRC32C-NONE|NONE-CRC32C|NONE user = CHAP username password = CHAP password If you use several different targets, you can also configure this on a per target basis by using a group name: [iscsi "iqn.target.name"] ... The configuration file can be read using -readconfig. Example : qemu-system-i386 -drive file=iscsi://127.0.0.1/iqn.ronnie.test/1 -readconfig iscsi.conf Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qed: add .bdrv_co_write_zeroes() supportStefan Hajnoczi2012-02-092-8/+103
| | | | | | | | | | | | | | Zero writes are a dedicated interface for writing regions of zeroes into the image file. If clusters are not yet allocated it is possible to use an efficient metadata representation which keeps the image file compact and does not store individual zero bytes. Implementing this for the QED image format is fairly straightforward. The only issue is that when a zero write touches an existing cluster we have to allocate a bounce buffer and perform a regular write. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qed: replace is_write with flags fieldStefan Hajnoczi2012-02-092-8/+13
| | | | | | | | | | | | | | Per-request attributes like read/write are currently implemented as bool fields in the QEDAIOCB struct. This becomes unwiedly as the number of attributes grows. For example, the qed_aio_setup() function would have to take multiple bool arguments and at call sites it would be hard to distinguish the meaning of each bool. Instead use a flags field with bitmask constants. This will be used when zero write support is added. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow: Use bdrv functions to replace file operationLi Zhi Hui2012-01-261-17/+31
| | | | | | | | | Since common file operation functions lack of error detection and use much more I/O syscalls, so change them to bdrv series functions and reduce I/O request. Signed-off-by: Li Zhi Hui <zhihuili@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow: Return real error code in qcow_openLi Zhi Hui2012-01-261-19/+37
| | | | | Signed-off-by: Li Zhi Hui <zhihuili@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block/vdi: Zero unused parts when allocating a new block (fix #919242)Stefan Weil2012-01-261-2/+6
| | | | | | | | | | | | | | | | | | | The new block was filled with zero when it was allocated by g_malloc0, but when it was reused later and only partially used, data from the previously allocated block were still present and written to the new block. This caused the problems reported by bug #919242 (https://bugs.launchpad.net/qemu/+bug/919242). Now the unused parts of the new block which are before and after the data are always filled with zero, so it is no longer necessary to zero the whole block with g_malloc0. I also updated the copyright comment. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: add support for partial streamingMarcelo Tosatti2012-01-261-4/+87
| | | | | | | | | Add support for streaming data from an intermediate section of the image chain (see patch and documentation for details). Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* 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>
OpenPOWER on IntegriCloud