win32-aio: drop win32_aio_flush_cb()
The io_flush argument to qemu_aio_set_event_notifier() has been removedsince the block layer learnt to drain requests by itself. Fix theWindows build for win32-aio.o by updating theqemu_aio_set_event_notifier() call and dropping win32_aio_flush_cb()....
aio / timers: convert block_job_sleep_ns and co_sleep_ns to new API
Convert block_job_sleep_ns and co_sleep_ns to use the new timerAPI.
Signed-off-by: Alex Bligh <alex@alex.org.uk>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
aio / timers: Switch entire codebase to the new timer API
This is an autogenerated patch using scripts/switch-timer-api.
Switch the entire code base to using the new timer API.
Note this patch may introduce some line length issues.
Signed-off-by: Alex Bligh <alex@alex.org.uk>...
vmdk: Move l1_size check into vmdk_add_extent()
This header check is common to VMDK3 and VMDK4, so move it intovmdk_add_extent().
Signed-off-by: Fam Zheng <famz@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
vmdk: fix L1 and L2 table size in vmdk3 open
VMDK3 header has the field l1dir_size, but vmdk_open_vmdk3 hardcoded thevalue. This patch honors the header field.
And the L2 table size is 4096 according to VMDK spec1, instead of1 << 9 (512).
[1]:http://www.vmware.com/support/developer/vddk/vmdk_50_technote.pdf?src=vmdk...
vmdk: support vmfsSparse files
VMware ESX hosts use a variant of the VMDK3 format, identified by thevmfsSparse create type ad the VMFSSPARSE extent type.
It has 16 KB grain tables (L2) and a variable-size grain directory (L1).In addition, the grain size is always 512, but that is not a problem...
vmdk: support vmfs files
VMware ESX hosts also use different create and extent types for flatfiles, respectively "vmfs" and "VMFS". This is not documented, but itcan be found at http://kb.vmware.com/kb/10002511 (Recreating a missingvirtual machine disk (VMDK) descriptor file)....
block: Introduce bs->zero_beyond_eof
In 4146b46c42e0989cb5842e04d88ab6ccb1713a48 (block: Produce zeros whenprotocols reading beyond end of file), we break qemu-iotests ./check-qcow2 022. This happens because qcow2 temporarily sets ->growable = 1for vmstate accesses (which are stored beyond the end of regular image...
qcow2: Change default for new images to compat=1.1
By the time that qemu 1.7 will be released, enough time will have passedsince qemu 1.1, which is the first version to understand version 3images, that changing the default shouldn't hurt many people any more...
block/iscsi: drop iscsi_process_flush()
.io_flush() is no longer called so drop iscsi_process_flush().
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block/linux-aio: drop qemu_laio_completion_cb()
.io_flush() is no longer called so drop qemu_laio_completion_cb(). Itturns out that count is now unused so drop that too.
block/nbd: drop nbd_have_request()
.io_flush() is no longer called so drop nbd_have_request(). We cannotdrop in_flight since it is still used by other block/nbd.c code.
block/rbd: drop qemu_rbd_aio_flush_cb()
.io_flush() is no longer called so drop qemu_rbd_aio_flush_cb().qemu_aio_count is unused now so drop it too.
block/sheepdog: drop have_co_req() and aio_flush_request()
.io_flush() is no longer called so drop have_co_req() andaio_flush_request().
block/ssh: drop return_true()
.io_flush() is no longer called so drop return_true().
aio: drop io_flush argument
The .io_flush() handler no longer exists and has no users. Drop theio_flush argument to aio_set_fd_handler() and related functions.
The AioFlushEventNotifierHandler and AioFlushHandler typedefs are nolonger used and are dropped too....
block/gluster: drop qemu_gluster_aio_flush_cb()
Since .io_flush() is no longer called we do not needqemu_gluster_aio_flush_cb() anymore. It turns out that qemu_aio_countis unused now and can be dropped.
Thanks to Bharata B Rao <bharata@linux.vnet.ibm.com> for catching a...
block/curl: drop curl_aio_flush()
.io_flush() is no longer called so drop curl_aio_flush(). The acb[]array that the function checks is still used in other parts ofblock/curl.c. Therefore we cannot remove acb[], it is needed.
block: stop relying on io_flush() in bdrv_drain_all()
If a block driver has no file descriptors to monitor but there are stillactive requests, it can return 1 from .io_flush(). This is used to spinduring synchronous I/O.
Stop relying on .io_flush() and instead check...
raw: add license header
Most of the block layer is under the BSD license, thus it is reasonableto license block/raw.c the same way. CCed people should ACK by replyingwith a Signed-off-by line.
Cc: Christoph Hellwig <hch@lst.de>Cc: Kevin Wolf <kwolf@redhat.com>...
vmdk: Make VMDK3Header and VmdkGrainMarker QEMU_PACKED
It's best to make it consistent that all on disk structures areQEMU_PACKED.
Signed-off-by: Fam Zheng <famz@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
vmdk: use unsigned values for on disk header fields
The size and offset fields are all non-negative values, use uint64_t forthem to avoid getting negative in memory value by int overflow.
vmdk: check granularity field in opening
Granularity is used to calculate the cluster size and allocate r/wbuffer. Check the value from image before using it, so we don't abort()for unbounded memory allocation.
Signed-off-by: Fam Zheng <famz@redhat.com>...
vmdk: check l2 table size when opening
header.num_gtes_per_gte determines size for L2 table. Check for too bigvalue before using it. Limit to 512M entries (2GB per one L2 table).
vmdk: check l1 size before opening image
L1 table size is calculated from capacity, granularity and l2 tablesize. If capacity is too big or later two are too small, the L1 tablewill be too big to allocate in memory. Limit it to a reasonable range.
vmdk: use heap allocation for whole_grain
We should never grow the stack beyond 1 MB, otherwise we'll fall off theend. Thread stacks and coroutine stacks (1 MB) do not grow.get_cluster_offset() allocates a big stack offset, it will fail for bigcluster images, change to heap allocated buffer....
vmdk: rename num_gtes_per_gte to num_gtes_per_gt
num_gtes_per_gte is a historical typo, rename it to a more sensiblename. It means "number of GrainTableEntries per GrainTable".
sheepdog: add missing .bdrv_has_zero_init
Commit 3ac21627 changed the behaviour of bdrv_has_zero_init() to defaultto 0. In the review for Sheepdog it turned out that enabling it is safe,so that commit updated one BlockDriver definition of sheepdog to use...
vmdk: fix comment for vmdk_co_write_zeroes
The comment was truncated. Add the missing parts, especially explain whywe need zero_dry_run.
Signed-off-by: Fam Zheng <famz@redhat.com>Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
block/iscsi.c: Fix printf format error.
The error on armv7hl was:
block/iscsi.c: In function ‘is_request_lun_aligned’:block/iscsi.c:251:26: error: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int64_t’ [-Werror=format=] iscsilun->block_size, sector_num, nb_sectors);...
block/sheepdog: Rename 'dprintf' to 'DPRINTF'
'dprintf' is the name of a POSIX standard function so we should not bestealing it for our debug macro. Rename to 'DPRINTF' (in line witha number of other source files.)
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>...
Merge remote-tracking branch 'stefanha/block' into staging
gluster: Add image resize support
Implement .bdrv_truncate in GlusterFS block driver so that GlusterFS backendcan support image resizing.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>Tested-by: Bharata B Rao <bharata@linux.vnet.ibm.com>...
misc: Fix new typos in comments and strings
All these typos were found by codespell.
sould -> shouldemperical -> empiricalintialization -> initializationsuccessfuly -> successfullygaurantee -> guarantee
Fix also another error (before before) in the same context....
Implement sync modes for drive-backup.
This patch adds sync-modes to the drive-backup interface andimplements the FULL, NONE and TOP modes of synchronization.
FULL performs as before copying the entire contents of the drivewhile preserving the point-in-time using CoW....
qcow2: Use dashes instead of underscores in options
This is what QMP wants to use. The options haven't been enabled in anyrelease yet, so we're still free to change them.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>
block/raw: add .bdrv_get_info
Signed-off-by: Peter Lieven <pl@kamp.de>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
gluster: Add discard support for GlusterFS block driver.
Implement bdrv_aio_discard for gluster.
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>Reviewed-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: fix vvfat error path for enable_write_target
s->qcow and s->qcow_filename are allocated but not freed on error. Fix thepossible leaks, remove unnecessary check for bdrv_new(), propagate ret code ofbdrv_create() and also the one of enable_write_target()....
block/raw: add bdrv_co_write_zeroes
Signed-off-by: Peter Lieven <pl@kamp.de>Reviewed-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
iscsi: remove support for misaligned nb_sectors in aio_readv
this hask is not working (anymore). support for misaligned offsets shouldbe handled at the block layer.
Signed-off-by: Peter Lieven <pl@kamp.de>Cc: qemu-stable@nongnu.orgSigned-off-by: Paolo Bonzini <pbonzini@redhat.com>
iscsi: assert that sectors are aligned to LUN blocksize
if the blocksize of an iSCSI LUN is bigger than the BDRV_SECTOR_SIZEit is possible that sector_num or nb_sectors are not correctlyaligned.
to avoid corruption we fail requests which are misaligned....
iscsi: factor out sector conversions
Reviewed-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Peter Lieven <pl@kamp.de>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
iscsi: fix -ENOSPC in iscsi_create()
the -ENOPSC case did not work due to the missing goto.
Reported-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Peter Lieven <pl@kamp.de>Cc: qemu-stable@nongnu.orgSigned-off-by: Paolo Bonzini <pbonzini@redhat.com>
Fix iSCSI crash on SG_IO with an iovector
Don't assume that SG_IO is always invoked with a simple buffer,check the iovec_count and if it is >= 1 then we need to pass an arrayof iovectors to libiscsi instead of just a plain buffer.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>...
block: Don't parse protocol from file.filename
One of the major reasons for doing something new for -blockdev andblockdev-add was that the old block layer code parses filenames insteadof just taking them literally. So we should really leave it untouched...
vmdk: Implement .bdrv_has_zero_init
Depending on the subformat, has_zero_init queries underlying storage forflat extent. If it has a flat extent and its underlying storage doesn'thave zero init, return 0. Otherwise return 1.
Aligns the operator assignments....
curl: refuse to open URL from HTTP server without range support
CURL driver requests partial data from server on guest IO req. For HTTPand HTTPS, it uses "Range: ***" in requests, and this will not work ifserver not accepting range. This patch does this check when open....
block: change default of .has_zero_init to 0
.has_zero_init defaults to 1 for all formats and protocols.
this is a dangerous default since this means that allnew added drivers need to manually overwrite it to 0 ifthey do not ensure that a device is zero initialized...
vpc: Implement .bdrv_has_zero_init
Depending on the subformat, has_zero_init on VHD must behave like rawand query the underlying storage (fixed) or like other sparse formatsthat can always return 1 (dynamic, differencing).
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Make BlockJobTypes const
block/ssh: Set bdrv_has_zero_init according to the file type.
If the remote is a regular file, set it to true (ie. reads ofuninitialized areas in a newly created file will return zeroes).If we can't prove that, return false (a safe default).
Tested by adding a debugging print statement [not part of this commit]...
gluster: Return bdrv_has_zero_init = 0
GlusterFS volumes can be backed by block devices, in which casebdrv_create() doesn't make sure that the image is zeroed out. It iscurrently not possibly to detect whether a given image is backed by afile or a block device, and incorrectly assuming that it is zeroed...
vmdk: remove wrong calculation of relative path
When creating image with backing file, the driver tries to calculate therelative path from created image file to backing file, but the pathcomputation is incorrect. e.g.:
$ qemu-img create -f vmdk -b vmdk-data-disk.vmdk vmdk-data-snapshot1...
raw-posix: Fix /dev/cdrom magic on OS X
The raw-posix driver has code to provide a /dev/cdrom on OS X eventhough it doesn't really exist. However, since commit c66a6157 the realfilename is dismissed after finding it, so opening /dev/cdrom fails.Put the filename back into the options QDict to make this work again....
block: add basic backup support to block driver
backup_start() creates a block job that copies a point-in-time snapshotof a block device to a target block device.
We call backup_do_cow() for each write during backup. That functionreads the original data from the block device before it gets...
vmdk: refuse to open higher version than supported
Refuse to open higher version for safety.
Although we try to be compatible with published VMDK spec, VMware hasnewer version from ESXi 5.1 exported OVF/OVA, which we have no knowledgewhat's changed in it. And it is very likely to have more new versions in...
qcow2: Add refcount update reason to all callers
This adds a refcount update reason to all callers of update_refcounts(),so that a follow-up patch can use this information to decide whetherclusters that reach a refcount of 0 should be discarded in the image...
qcow2: Options to enable discard for freed clusters
Deleted snapshots are discarded in the image file by default, discardrequests take their default from the -drive discard=... option and otherplaces that free clusters must always be enabled explicitly....
qcow2: Batch discards
This optimises the discard operation for freed clusters by batchingdiscard requests (both snapshot deletion and bdrv_discard end upupdating the refcounts cluster by cluster).
Note that we don't discard asynchronously, but keep s->lock held. This...
Merge remote-tracking branch 'bonzini/scsi-next' into staging
iscsi: simplify freeing of tasks
Always free them in the iscsi_aio_*_acb functions and remove thechecks in their callers. Remove ifs when the task struct waspreviously dereferenced (spotted by Coverity).
Cc: qemu-stable@nongnu.orgSigned-off-by: Paolo Bonzini <pbonzini@redhat.com>
iscsi: reorganize iscsi_readcapacity_sync
Avoid the goto, and use the same retry logic for the 10- and 16-byte versions.
nbd: strip braces from literal IPv6 address in URI
Otherwise they would get passed to getaddrinfo and fail with:address resolution failed for [::1]:1234: Name or service not known
(Broken by commit v1.4.0-736-gf17c90b)
Signed-off-by: Ján Tomko <jtomko@redhat.com>...
Merge remote-tracking branch 'luiz/queue/qmp' into staging
block/curl.c: Refuse to open the handle for writes.
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>Signed-off-by: Fam Zheng <famz@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
vmdk: byteswap VMDK4Header.desc_offset field
Remember to byteswap VMDK4Header.desc_offset on big-endian machines.
Cc: qemu-stable@nongnu.orgSigned-off-by: Stefan Hajnoczi <stefanha@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
curl: Don't set curl options on the handle just before it's going to be deleted.
(Found by Kamil Dudka)
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>Cc: Michael Tokarev <mjt@tls.msk.ru>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
vmdk: Allow reading variable size descriptor files
the hard-coded 2k buffer on the stack won't allow reading big descriptorfiles which can be generated when storing big images. For example 500Gvmdk splitted to 2G chunks.
Signed-off-by: Evgeny Budilovsky <evgeny.budilovsky@ravellosystems.com>...
sheepdog: fix snapshot tag initialization
This is an old and obvious bug. We should pass snapshot_id to thetag. Or simple command like 'qemu-img snapshot -a tag sheepdog:image' will fail
Cc: qemu-devel@nongnu.orgCc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>...
sheepdog: support 'qemu-img snapshot -a'
Just call sd_create_branch() in the snapshot_goto to rollback the image is goodenough. With this patch, 'loadvm' process for sheepdog is modified:
Suppose we have a snapshot chain A --> B --> C, we do 'loadvm A' so as to get...
block: mirror_complete(): use error_setg_file_open()
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>Acked-by: Kevin Wolf <kwolf@redhat.com>
curl: Whitespace only changes.
Trivial patch to remove odd whitespace.
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
block: add snapshot info query function bdrv_query_snapshot_info_list()
This patch adds function bdrv_query_snapshot_info_list(), which willretrieve snapshot info of an image in qmp object format. The implementationis based on the code moved from qemu-img.c with modification to fit more...
block: add image info query function bdrv_query_image_info()
This patch adds function bdrv_query_image_info(), which willretrieve image info in qmp object format. The implementation isbased on the code moved from qemu-img.c, but uses block layerfunction to get snapshot info....
qmp: add ImageInfo in BlockDeviceInfo used by query-block
Now image info will be retrieved as an embbed json object insideBlockDeviceInfo, backing chain info and all related internal snapshotinfo can be got in the enhanced recursive structure of ImageInfo. New...
blkdebug: Add BLKDBG_FLUSH_TO_OS/DISK events
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: move snapshot code in block.c to block/snapshot.c
All snapshot related code, except bdrv_snapshot_dump() andbdrv_is_snapshot(), is moved to block/snapshot.c. bdrv_snapshot_dump()will be moved to another file later. bdrv_is_snapshot() is not related...
block: move qmp and info dump related code to block/qapi.c
This patch is a pure code move patch, except following modification:1 get_human_readable_size() is changed to static function.2 dump_human_image_info() is renamed to bdrv_image_info_dump().3 in qmp_query_block() and qmp_query_blockstats, use bdrv_next(bs)...
block: dump snapshot and image info to specified output
bdrv_snapshot_dump() and bdrv_image_info_dump() do not dump to a buffer now,some internal buffers are still used for format control, which have nochance to be truncated. As a result, these two functions have no more issue...
Remove twice include of qemu-common.h
This patch is used to remove twice include of "qemu-common.h" inblock/win32-aio.c
Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>Reviewed-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
qcow2: Catch some L1 table index overflows
This catches the situation that is described in the bug report athttps://bugs.launchpad.net/qemu/+bug/865518 and goes like this:
$ qemu-img create -f qcow2 huge.qcow2 $((1024*1024))T Formatting 'huge.qcow2', fmt=qcow2 size=1152921504606846976 encryption=off cluster_size=65536 lazy_refcounts=off...
remove double semicolons
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
vmdk: add bdrv_co_write_zeroes
Use special offset to write zeroes efficiently, when zeroed-grain GTE isavailable. If zero-write an allocated cluster, cluster is leaked becauseits offset pointer is overwritten by "0x1".
vmdk: store fields of VmdkMetaData in cpu endian
Previously VmdkMetaData.offset is stored little endian while otherfields are cpu endian. This changes offset to cpu endian and convertbefore writing to image.Signed-off-by: Fam Zheng <famz@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
vmdk: change magic number to macro
Two hard coded flag bits are changed to macros.Signed-off-by: Fam Zheng <famz@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
vmdk: Add option to create zeroed-grain image
Add image create option "zeroed-grain" to enable zeroed-grain GTEfeature of vmdk sparse extents. When this option is on, header versionof newly created extent will be 2 and VMDK4_FLAG_ZERO_GRAIN flag bitwill be set....
vmdk: add support for “zeroed‐grain” GTE
Introduced support for zeroed-grain GTE, as specified in Virtual DiskFormat 5.01.
Recent VMware hosted platform products support a new “zeroed‐grain” grain table entry (GTE). The zeroed‐grain GTE returns all zeros on...
vmdk: named return code.
Internal routines in vmdk.c previously return -1 on error and 0 onsuccess. More return values are useful for future changes such aszeroed-grain GTE. Change all the magic `return 0` and `return -1` tomacro names:
block: vhdx header for the QEMU support of VHDX images
This is based on Microsoft's VHDX specification: "VHDX Format Specification v0.95", published 4/12/2012 https://www.microsoft.com/en-us/download/details.aspx?id=29681
These structures define the various header, metadata, and other...
block: initial VHDX driver support framework - supports open and probe
This is the initial block driver framework for VHDX image support(i.e. Hyper-V image file formats), that supports opening VHDX files, andparsing the headers.
This commit does not yet enable:...
block: add read-only support to VHDX image format.
This adds in read-only support to the VHDX image format. This supportsreads for fixed-size, and dynamic sized VHDX images.
Differencing files are still unsupported.
The image must be opened without BDRV_O_RDWR set, because we do not...
sheepdog: fix loadvm operation
Currently the 'loadvm' opertaion works as following:1. switch to the snapshot2. mark current working VDI as a snapshot3. rely on sd_create_branch to create a new working VDI based on the snapshot
This works not the same as other format as QCOW2. For e.g,...
sheepdog: use BDRV_SECTOR_SIZE
Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Cc: Kevin Wolf <kwolf@redhat.com>Cc: Stefan Hajnoczi <stefanha@redhat.com>Signed-off-by: Liu Yuan <tailai.ly@taobao.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
sheepdog: implement .bdrv_co_is_allocated()
rbd: Fix use after free in rbd_open()
Commit a9ccedc3 frees the QemuOpts for the driver-specific optionsimmediately, even though it still needs the filename string that iscontained there. This doesn't work. Move the deletion of the QemuOpts tothe end of the function where its content isn't needed any more....
sheepdog: cleanup find_vdi_name
This makes 'filename' and 'tag' constant variables, and renames'for_snapshot' to 'lock' to clear how it works.
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
sheepdog: add SD_RES_READONLY result code
Sheepdog returns SD_RES_READONLY when qemu sends write requests to thesnapshot vdi. This adds the result code and makes sd_strerror() printits error reason.
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>...
sheepdog: add helper function to reload inode
This adds a helper function to update the current inode state with thespecified vdi object.
sheepdog: resend write requests when SD_RES_READONLY is received
When a snapshot is taken from out side of qemu (e.g. qemu-imgsnapshot), write requests to the current vdi return SD_RES_READONLY.In this case, the sheepdog block driver needs to update the current...