block/curl: Don't finish AIOCBs too early
The previous behaviour was to finish AIOCBs inside curl_aio_readv()if the data was cached. This caused the following failed assertionat hw/ide/pci.c:314: bmdma_cmd_writeb
"Assertion `bm->bus->dma->aiocb == ((void *)0)' failed."...
block/curl: Implement a flush function on the fd handlers
Signed-off-by: Nick Thomas <nick@bytemark.co.uk>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
rbd: allow escaping in config string
The config string is variously delimited by =, @, and /, depending on thefield. Allow these characters to be escaped by preceeding them with \.
Signed-off-by: Sage Weil <sage@newdream.net>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
rbd: ignore failures when reading from default conf location
If we are reading from the default config location, ignore any failures.It is perfectly legal for the user to specify exactly the options they needand to not rely on any config file.
Signed-off-by: Sage Weil <sage@newdream.net>...
rbd: update comment heading
Properly document the configuration string syntax and semantics. Remove(out of date) details about the librbd implementation.
rbd: call flush, if available
librbd recently added async writeback and flush support. If the newrbd_flush() call is available, call it.
VMDK: fix leak of extent_file
Release extent_file on error in vmdk_parse_extents. Added closing filesin freeing extents.
Signed-off-by: Fam Zheng <famcool@gmail.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
nbd: support feature negotiation
nbd supports writing flags in bytes 24...27 of the header,and uses that for the read-only flag. Add support for itin qemu-nbd.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
raw-posix: Fix bdrv_flush error return values
bdrv_flush is supposed to use 0/-errno return values
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Remove blanks before \n in output strings
Those blanks violate the coding conventions, seescripts/checkpatch.pl.
Blanks missing after colons in the changed lines were added.
This patch does not try to fix tabs, long lines and otherproblems in the changed lines, therefore checkpatch.pl reports...
nbd: Clean up use of block_int.h
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: initialize metadata before inserting in cluster_allocs
QCow2Meta structure was inserted into list before many fields areinitialized. Currently is not a problem cause all occur in a lockbut if qcow2_alloc_clusters would in a future unlock this lock...
qcow2: align cluster_data to block to improve performance using O_DIRECT
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: fix range check
QCowL2Meta::offset is not cluster aligned but only sector alignedhowever nb_clusters count cluster from cluster start.This fix range check. Note that old code have no corruption issuesrelated to this check cause it only cause intersection to occur...
rbd: clean up, fix style
No assignment in condition. Remove duplicate ret > 0 check.
Signed-off-by: Sage Weil <sage@newdream.net>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
rbd: fix leak in qemu_rbd_open failure paths
Fix leak of s->snap in failure path. Simplify error paths for the wholefunction.
Reported-by: Stefan Hajnoczi <stefanha@gmail.com>Signed-off-by: Sage Weil <sage@newdream.net>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
block: Rename bdrv_set_locked() to bdrv_lock_medium()
While there, make the locked parameter bool.
rbd: allow client id to be specified in config string
Allow the client id to be specified in the config string via 'id=' so thatusers can control who they authenticate as. Currently they are stuck withthe default ('admin'). This is necessary for anyone using authentication...
qcow2: removed unused depends_on field
VMDK: bugfix, opening vSphere 4 exported image
The vSphere 4 exported image is streamOptimized extent, which is notquite 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>...
VMDK: bugfix, open Haiku vmdk image
Haiku provides a specially formed vmdk image, which let qemu abort. It acombination of sparse header and flat data (i.e. with not l1/l2 table atall). The fix is turn to descriptor when sparse header is zero in field'capacity'....
VMDK: creating streamOptimized subformat
Creating streamOptimized subformat. Added subformat option'streamOptimized', to create a image with compression enabled and eachcluster with a GrainMarker.
VMDK: read/write compressed extent
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>
VMDK: Opening compressed extent.
Added flags field for compressed/streamOptimized extents, open and saveimage configuration.
VMDK: separate vmdk_read_extent/vmdk_write_extent
Factor out read/write extent code, since there will be more things totake care of once reading/writing compressed clusters is introduced.
VMDK: add twoGbMaxExtentSparse support
Add twoGbMaxExtentSparse support. Introduce vmdk_free_last_extent.
VMDK: enable twoGbMaxExtentFlat
Enable the createType 'twoGbMaxExtentFlat'. The supporting code isalready in.
block/raw: Fix to forward method bdrv_media_changed()
Block driver "raw" forwards most methods to the underlying blockdriver. 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...
linux aio: some comments
Add some notes about Linux AIO explaining why we don't use AIO insome situations.
qcow2: Properly initialise QcowL2Meta
Dependency list pointers filled with random garbage from the stack aren't agood idea.
qcow2: Fix error cases to run depedent requests
Requests depending on a failed request would end up waiting forever. This fixesthe error path to continue dependent requests even when the request has failed.
Use new macro QEMU_PACKED for packed structures
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/'...
qcow2: remove unused qcow2_create_refcount_update function
qcow2: use always stderr for debugging
let all DEBUG_ALLOC2 printf goes to stderr
sheepdog: use coroutines
This makes the sheepdog block driver support bdrv_co_readv/writevinstead of bdrv_aio_readv/writev.
With this patch, Sheepdog network I/O becomes fully asynchronous. Theblock driver yields back when send/recv returns EAGAIN, and is resumed...
qcow2: remove memory leak
block/curl: Handle failed reads gracefully.
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 failurenever gets reported to the guest and if the error condition clears, the...
qcow/qcow2: Allocate QCowAIOCB structure using stack
instead of calling qemi_aio_get use stack
qcow: QCowAIOCB field cleanup
remove unused field from this structure and put some of them in qcow_aio_read_cb and qcow_aio_write_cb
qcow: move some blocks of code to avoid useless variable initialization
qcow: Remove QCowAIOCB
Embed qcow_aio_read_cb into qcow_co_readv and qcow_aio_write_cb into qcow_co_writev
qcow: remove old #undefined code
qcow2: Removed unused AIOCB fields
qcow2: removed cur_nr_sectors field in QCowAIOCB
qcow2: remove l2meta from QCowAIOCB
qcow2: remove cluster_offset from QCowAIOCB
qcow2: remove common from QCowAIOCB
qcow2: reindent and use while before the big jump
prepare to remove read/write callbacks
qcow2: Removed QCowAIOCB entirely
qcow2: Fix DEBUG_* compilation
By introducing BlockDriverState compiling qcow2 with DEBUG_ALLOC and DEBUG_EXTdefined got broken.Define a BdrvCheckResult structure locally which is now needed as the secondargument.
Also fix qcow2_read_extensions() needing BDRVQcowState....
qcow2: fix typo in documentation for qcow2_get_cluster_offset()
Documentation states the num is measured in clusters, but itsactually measured in sectors
Signed-off-by: Devin Nakamura <devin122@gmail.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow: initialize coroutine mutex
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>
w32: Fix qemu_ftruncate64
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>...
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qcow2: Fix L1 table size after bdrv_snapshot_goto
When loading an internal snapshot whose L1 table is smaller than the current L1table, the size of the current L1 would be shrunk to the snapshot's L1 size inmemory, but not on disk. This lead to incorrect refcount updates and eventuelly...
qcow2: Use coroutines
qcow: Use coroutines
The old qcow format is another user of the AsyncContext infrastructure.Converting it to coroutines (and therefore CoMutexes) allows to removeAsyncContexts.
async: Remove AsyncContext
The purpose of AsyncContexts was to protect qcow and qcow2 against reentrancyduring an emulated bdrv_read/write (which includes a qemu_aio_wait() call andcan run AIO callbacks of different requests if it weren't for AsyncContexts)....
raw-posix: Typo fix
raw-posix: Always check paio_init result
block/raw-win32: Drop disabled code for removable host devices
It's been disabled since the start (commit 19cb3738, Aug 2006), andhas been untouched except for spelling fixes and such. I don't feellike dragging it along any further.
Signed-off-by: Markus Armbruster <armbru@redhat.com>...
block: Make BlockDriver method bdrv_set_locked() return void
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...
block: Make BlockDriver method bdrv_eject() return void
Callees always return 0, except for FreeBSD's cdrom_eject(), whichreturns -ENOTSUP when the device is in a terminally wedged state.
The only caller is bdrv_eject(), and it maps -ENOTSUP to 0 since...
block/vpc.c: Detect too-large vpc file
VHD files technically can be up to 2Tb, but virtual pc is limitedto 127G. Currently qemu-img refused to create vpc files > 127G,but it is failing to return error when converting from a non-vpcVHD file which is >127G. It returns success, but creates a truncated...
Wrap recv to avoid warnings
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]...
qcow2: Use Qcow2Cache in writeback mode during loadvm/savevm
In snapshotting there is no guest involved, so we can safely use a writebackmode and do the flushes in the right place (i.e. at the very end). Thisimproves the time that creating/restoring an internal snapshot takes with an...
block: add bdrv_get_allocated_file_size() operation
qemu-img.c wants to count allocated file size of image. Previously itcounts a single bs->file by 'stat' or Window API. As VMDK introducesmultiple file support, the operation becomes format specific with...
VMDK: move 'static' cid_update flag to bs field
Cid_update is the flag for updating CID on first write after opening theimage. This should be per image open rather than per program life cycle,so change it from static var of vmdk_write to a field in BDRVVmdkState....
VMDK: change get_cluster_offset return type
The return type of get_cluster_offset was an offset that use 0 to denote'not allocated', this will be no longer true for flat extents, as we seeflat extent file as a single huge cluster whose offset is 0 and length...
VMDK: open/read/write for monolithicFlat image
Parse vmdk decriptor file and open mono flat image.Read/write the flat extent.
VMDK: create different subformats
Add create option 'format', with enums: monolithicSparse monolithicFlat twoGbMaxExtentSparse twoGbMaxExtentFlatEach creates a subformat image file. The default is monolithicSparse.
Signed-off-by: Fam Zheng <famcool@gmail.com>...
VMDK: fix coding style
Conform coding style in vmdk.c to pass scripts/checkpatch.pl checks.
VMDK: bugfix, align offset to cluster in get_whole_cluster
In get_whole_cluster, the offset is not aligned to cluster when readingfrom backing_hd. When the first write to child is not at the clusterboundary, wrong address data from parent is copied to child....
VMDK: probe for monolithicFlat images
Probe as the same behavior as VMware does.Recognize image as monolithicFlat descriptor file when the file is textand the first effective line (not '#' leaded comment or space line) iseither 'version=1' or 'version=2'. No space or upper case charactors...
VMDK: separate vmdk_open by format version
VMDK: add field BDRVVmdkState.desc_offset
There are several occurrence of magic number 0x200 as the descriptoroffset within mono sparse image file. This is not the case for imageswith separate descriptor file. So a field is added to BDRVVmdkState tohold the correct value....
VMDK: flush multiple extents
Flush all the file that referenced by the image.
VMDK: introduce VmdkExtent
Introduced VmdkExtent array into BDRVVmdkState, enable holding multipleimage extents for multiple file image support.
sheepdog: add full data preallocation support
This introduces qemu-img create option for sheepdog which allows thedata to be fully preallocated (note that sheepdog always preallocatesmetadata).
The option is disabled by default and you need to enable it like the...
block/raw-posix: Linux compat-ioctl warning workaround
On Linux x86_64 host with 32bit userspace, runningqemu or even just "qemu-img create -f qcow2 some.img 1G" causes a kernel warning:
ioctl32(qemu-img:5296): Unknown cmd fd(3) cmd(00005326){t:'S';sz:0} arg(7fffffff) on some.img...
sheepdog: qemu_bh_new() can't return null pointer, drop check
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Strip trailing '\n' from error_report()'s first argument
error_report() prepends location, and appends a newline. The messageconstructed from the arguments should not contain a newline. Fix theobvious offenders.
qcow2: Fix in-flight list after qcow2_cache_put failure
If qcow2_cache_put returns an error during cluster allocation and theallocation fails, it must be removed from the list of in-flight allocations.Otherwise we'd get a loop in the list when the ACB is used for the next...
vdi: Avoid direct AIO callback
bdrv_aio_* must not call the callback before returning to its caller. In vdi,this could happen in some error cases. This starts the real requests processingin a BH to avoid this situation.
qcow: Avoid direct AIO callback
bdrv_aio_* must not call the callback before returning to its caller. In qcow,this could happen in some error cases. This starts the real requests processingin a BH to avoid this situation.
qcow2: Avoid direct AIO callback
bdrv_aio_* must not call the callback before returning to its caller. In qcow2,this could happen in some error cases. This starts the real requests processingin a BH to avoid this situation.
block/rbd: Remove unused local variable
Variable 'snap' is assigned a value that is never used.Remove snap and the related code.
Cc: Christian Brunner <chb@muc.de>Cc: Josh Durgin <josh.durgin@dreamhost.com>Cc: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Stefan Weil <weil@mail.berlios.de>...
Merge remote-tracking branch 'stefanha/trivial-patches' into staging
rbd: allow configuration of rados from the rbd filename
The new format is rbd:pool/image[@snapshot][:option1=value1[:option2=value2...]]Each option is used to configure rados, and may be any Ceph option, or "conf".The "conf" option specifies a Ceph configuration file to read....
rbd: check return values when scheduling aio
If scheduling fails, the number of outstanding I/Os must be correct,or there will be a hang when waiting for everything to be flushed.
Reviewed-by: Christian Brunner <chb@muc.de>Reported-by: Stefan Hajnoczi <stefanha@gmail.com>...
rbd: Add bdrv_truncate implementation
Reviewed-by: Christian Brunner <chb@muc.de>Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: Fix memory leaks in error cases
This fixes memory leaks that may be caused by I/O errors during L1 table growth(can happen during save_vm) and in qemu-img check.
qemu-img create: Fix displayed default cluster size
When not specifying a cluster size on the command line, qemu-img printeda cluster size of 0:
Formatting '/tmp/test.qcow2', fmt=qcow2 size=67108864 encryption=off cluster_size=0
This patch adds the default cluster size to the QEMUOptionParameter list, so...
block/raw-posix: get right partition size
use the correct way to get the size of a disk device or partition
From: Adam Hamsik <haad@netbsd.org>Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
rbd: use the higher level librbd instead of just librados
librbd stacks on top of librados to provide accessto rbd images.
Using librbd simplifies the qemu code, and allowsqemu to use new versions of the rbd formatwith few (if any) changes.
Reviewed-by: Christian Brunner <chb@muc.de>...
block: clarify the meaning of BDRV_O_NOCACHE
Change BDRV_O_NOCACHE to only imply bypassing the host OS file cache,but no writeback semantics. All existing callers are changed to alsospecify BDRV_O_CACHE_WB to give them writeback semantics.
Signed-off-by: Christoph Hellwig <hch@lst.de>...
vmdk: fix endianness bugs
The vmdk code is sloppy when handling the header descriptor duringcreation of an image. Fix all header accesses in the create path toeither store native endianness or convert it when appropriate.
Reported-by: Yury Tsarev <ytsarev@novell.com>...
block/raw-posix: use a character device if a block device is given
On NetBSD a userland process is better with the character deviceinterface. In addition, a block device can't be opened twice; if a Xenbackend opens it, qemu can't and vice-versa.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>...
Fix compilation warning due to missing header for sigaction (followup)
This patch removes all references to signal.h when qemu-common.h is includedas they become redundant.
Signed-off-by: Alexandre Raymond <cerbere@gmail.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
qed: support for growing images
The .bdrv_truncate() operation resizes images and growing is easy toimplement in QED. Simply check that the new size is valid and thenupdate the image_size header field to reflect the new size.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...