qcow2: Round QCowL2Meta.offset down to cluster boundary
The offset within the cluster is already present as n_start and this iswhat the code uses. QCowL2Meta.offset is only needed at a clustergranularity.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: Introduce Qcow2COWRegion
This makes it easier to address the areas for which a COW must beperformed. As a nice side effect, the COW code inqcow2_alloc_cluster_link_l2 becomes really trivial.
blkdebug: Allow usage without config file
As soon as new rules can be set during runtime, as introduced by thenext patch, blkdebug makes sense even without a config file.
blkdebug: Factor out remove_rule()
The cleanup work to remove a rule depends on the type of the rule. It'seasy for the existing rules as there is no data that must be cleaned upand is specific to a type yet, but the next patch will change this.
blkdebug: Implement suspend/resume of AIO requests
This allows more systematic AIO testing. The patch adds three newoperations to blkdebug:
qcow2: Move BLKDBG_EVENT out of the lock
We want to use these events to suspend requests for testing concurrentAIO requests. Suspending requests while they are holding the CoMutex israther boring for this purpose.
Fix error code checking for SetFilePointer() call
An error has occurred if the return value is invalid_set_file_pointerand getlasterror doesn't return no_error.
Signed-off-by: Fabien Chouteau <chouteau@adacore.com>Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
rbd: Fix race between aio completition and aio cancel
This one fixes a race which qemu had also in iscsi block driverbetween cancellation and io completition.
qemu_rbd_aio_cancel was not synchronously waiting for the end ofthe command.
To archieve this it introduces a new status flag which uses...
block: vpc support for ~2 TB disks
The VHD specification allows for up to a 2 TB disk size. The currentimplementation in qemu emulates EIDE and ATA-2 hardware which only allowsfor up to 127 GB. This disk size limitation can be overridden by allowingup to 255 heads instead of the normal 4 bit limitation of 16. Doing so...
raw-posix: inline paio_ioctl into hdev_aio_ioctl
clang now warns about an unused function: CC block/raw-posix.oblock/raw-posix.c:707:26: warning: unused function paio_ioctl[-Wunused-function]static BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd,...
aio: Get rid of qemu_aio_flush()
There are no remaining users, and new users should probably beusing bdrv_drain_all() in the first place.
block: vpc initialize the uuid footer field
Initialize the uuid field in the footer with a generated uuid.
Signed-off-by: Charles Arnold <carnold@suse.com>Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
iscsi: do not assume device is zero initialized
Without any complex checks we can't assume that aniscsi target is initialized to zero.
Signed-off-by: Peter Lieven <pl@kamp.de>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
iscsi: fix deadlock during login
If the connection is interrupted before the first login is successfullycompleted qemu-kvm is waiting forever in qemu_aio_wait().
This is fixed by performing an sync login to the target. If theconnection breaks after the first successful login errors are...
iscsi: fix segfault in url parsing
If an invalid URL is specified iscsi_get_error(iscsi) is calledwith iscsi == NULL.
use int64_t for return values from rbd instead of int
rbd / rados tends to return pretty often length of writesor discarded blocks. These values might be bigger than int.
The steps to reproduce are:
mkfs.xfs -f a whole device bigger than int in bytes. mkfs.xfs sends...
block: add bdrv_reopen() support for raw hdev, floppy, and cdrom
For hdev, floppy, and cdrom, the reopen() handlers are the same asfor the file reopen handler. For floppy and cdrom types, however,we keep O_NONBLOCK, as in the _open function.
Signed-off-by: Jeff Cody <jcody@redhat.com>...
vdi: don't override libuuid symbols
It's poor symbol hygiene to provide a global symbols that collide with acommon library like libuuid. If QEMU links against a shared librarythat depends on uuid_generate() it can end up calling our stub versionof the function....
vmdk: Fix data corruption bug in WRITE and READ handling
Fixed a MAJOR BUG in VMDK files on file boundaries on readsand ALSO ON WRITES WHICH MIGHT CORRUPT THE IMAGE AND DATA!!!!!!
Triggered for example with the following VMDK file (partly listed):RW 4193792 FLAT "XP-W1-f001.vmdk" 0...
qcow2: Fix refcount table size calculation
A missing factor for the refcount table entry size in the calculationcould mean that too little memory was allocated for the in-memoryrepresentation of the table, resulting in a buffer overflow.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
block: Workaround for older versions of MinGW gcc
Versions before gcc-4.6 don't support unnamed fields in initializers(see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10676).
Offset and OffsetHigh belong to an unnamed struct which is part of anunnamed union. Therefore the original code does not work with older...
aio: rename AIOPool to AIOCBInfo
Now that AIOPool no longer keeps a freelist, it isn't really a "pool" anymore. Rename it to AIOCBInfo and make it const since it no longerneeds to be modified.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
nbd: accept URIs
The URI syntax is consistent with the Gluster syntax. Export namesare specified in the path, preceded by one or more (otherwise unused)slashes.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
nbd: accept relative path to Unix socket
Adding the "is_unix" member now will simplify the parsing of NBD URIs.
Merge remote-tracking branch 'origin/master' into threadpool
raw-win32: add emulated AIO support
raw-posix: move linux-aio.c to block/
raw-win32: implement native asynchronous I/O
With the new support for EventNotifiers in the AIO event loop, wecan hook a completion port to every opened file and use asynchronousI/O on them.
Wine's support is extremely inefficient, also because it really does...
block: switch posix-aio-compat to threadpool
This is not meant for portability, but to remove code duplication.
raw: merge posix-aio-compat.c into block/raw-posix.c
Making the qemu_paiocb specific to raw devices will let us access membersof the BDRVRawState arbitrarily.
raw-posix: rename raw-posix-aio.h, hide unavailable prototypes
aio: add Win32 implementation
The Win32 implementation will only accept EventNotifiers, thus a fewdrivers are disabled under Windows. EventNotifiers are a good matchfor the GSource implementation, too, because the Win32 port of gliballows to place their HANDLEs in a GPollFD....
mirror: implement completion
Switching to the target of the migration is done mostly asynchronously,and reported to management via the BLOCK_JOB_COMPLETED event; the onlysynchronous phase is opening the backing files. bdrv_open_backing_filecan always be done, even for migration of the full image (aka sync:...
mirror: add support for on-source-error/on-target-error
Error management is important for mirroring; otherwise, an error on thetarget (even something as "innocent" as ENOSPC) requires to start againwith a full copy. Similar to on_read_error/on_write_error, two separate...
block: in commit, determine base image from the top image
This simplifies some code and error checking, and also fixes a bug.
bdrv_find_backing_image() should only be passed absolute filenames,or filenames relative to the chain. In the QMP message handler for...
block: rename block_job_complete to block_job_completed
The imperative will be used for the QMP command.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
mirror: introduce mirror job
This patch adds the implementation of a new job that mirrors a disk toa new image while letting the guest continue using the old image.The target is treated as a "black box" and data is copied from thesource to the target in the background. This can be used for several...
sheepdog: use bool for boolean variables
This improves readability.
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Merge branch 'trivial-patches' of git://github.com/stefanha/qemu
cleanup useless return sentence
This patch cleans up return sentences in the end of void functions.
Reported-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Amos Kong <akong@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
qcow2: mark this file's sole strncpy use as justified
Acked-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Jim Meyering <meyering@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
sheepdog: avoid a few buffer overruns
vmdk: relative_path: use pstrcpy in place of strncpy
Avoid strncpy+manual-NUL-terminate. Use pstrcpy instead.
stream: add on-error argument
This patch adds support for error management to streaming.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
blkdebug: process all set_state rules in the old state
Currently it is impossible to write a blkdebug script that ping-pongsbetween two states, because the second set-state rule will use thestate that is set in the first. If you have
[set-state] event = "..."...
iostatus: move BlockdevOnError declaration to QAPI
This will let block-stream reuse the enum. Places that used the enumsare renamed accordingly.
block: move job APIs to separate files
block: add live block commit functionality
This adds the live commit coroutine. This iteration focuses on thecommit only below the active layer, and not the active layer itself.
The behaviour is similar to block streaming; the sectors are walkedthrough, and anything that exists above 'base' is committed back down...
block: Support GlusterFS as a QEMU block backend.
This patch adds gluster as the new block backend in QEMU. This givesQEMU the ability to boot VM images from gluster volumes. Its alreadypossible to boot from VM images on gluster volumes using FUSE mount, but...
Merge remote-tracking branch 'kwolf/for-anthony' into staging
block: purge s->aligned_buf and s->aligned_buf_size from raw-posix.c
The aligned_buf pointer and aligned_buf size are no longer used inraw_posix.c, so remove all references to them.
Signed-off-by: Jeff Cody <jcody@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: raw-posix image file reopen
This is derived from the Supriya Kannery's reopen patches.
This contains the raw-posix driver changes for the bdrv_reopen_*functions. All changes are staged into a temporary scratch bufferduring the prepare() stage, and copied over to the live structure...
block: raw image file reopen
These are the stubs for the file reopen drivers for the raw format.
There is currently nothing that needs to be done by the raw driverin reopen.
block: qed image file reopen
These are the stubs for the file reopen drivers for the qed format.
There is currently nothing that needs to be done by the qed driverin reopen.
block: qcow2 image file reopen
These are the stubs for the file reopen drivers for the qcow2 format.
There is currently nothing that needs to be done by the qcow2 driverin reopen.
block: qcow image file reopen
These are the stubs for the file reopen drivers for the qcow format.
There is currently nothing that needs to be done by the qcow driverin reopen.
block: vmdk image file reopen
This patch supports reopen for VMDK image files. VMDK extents are addedto the existing reopen queue, so that the transactional model of reopenis maintained with multiple image files.
block: vdi image file reopen
There is currently nothing that needs to be done for VDI reopen.
block: vpc image file reopen
There is currently nothing that needs to be done for VPC imagefile reopen.
block: move aio initialization into a helper function
Move AIO initialization for raw-posix block driver into a helper function.
In addition to just code motion, the aio_ctx pointer is checked for NULL,prior to calling laio_init(), to make sure laio_init() is only run once....
block: move open flag parsing in raw block drivers to helper functions
Code motion, to move parsing of open flags into a helper function.
block: do not parse BDRV_O_CACHE_WB in block drivers
Block drivers should ignore BDRV_O_CACHE_WB in .bdrv_open flags,and in the bs->open_flags.
This patch removes the code, leaving the behaviour behind as ifBDRV_O_CACHE_WB was set.
block: use BDRV_O_NOCACHE instead of s->aligned_buf in raw-posix.c
Rather than check for a non-NULL aligned_buf to determine ifraw_aio_submit needs to check for alignment, check for the presenceof BDRV_O_NOCACHE in the bs->open_flags.
iSCSI: We dont need to explicitely call qemu_notify_event() any more
We no longer need to explicitely call qemu_notify_event() any moresince this is now done automatically any time the filehandles we listento change.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>...
iSCSI: We need to support SG_IO also from iscsi_ioctl()
We need to support SG_IO from the synchronous iscsi_ioctl() sincescsi-block uses this to do an INQ to the device to discover its propertiesThis patch makes scsi-block work with iscsi.
sheepdog: fix savevm and loadvm
This patch sets data to be sent to Sheepdog correctly and fixes savevmand loadvm operations on a Sheepdog image.
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/curl: Fix wrong free statement
Report from smatch:block/curl.c:546 curl_close(21) info: redundant null check on s->url calling free()
The check was redundant, and free was also wrong because the memorywas allocated using g_strdup.
Signed-off-by: Stefan Weil <sw@weilnetz.de>...
vdi: Fix warning from clang
ccc-analyzer reports these warnings:
block/vdi.c:704:13: warning: Dereference of null pointer bmap[i] = VDI_UNALLOCATED; ^block/vdi.c:702:13: warning: Dereference of null pointer bmap[i] = i;...
qed: refuse unaligned zero writes with a backing file
Zero writes have cluster granularity in QED. Therefore they can only beused to zero entire clusters.
If the zero write request leaves sectors untouched, zeroing the entirecluster would obscure the backing file. Instead return -ENOTSUP, which...
stream: complete early if end of backing file is reached
It is possible to create an image that is larger than its backing file.Reading beyond the end of the backing file produces zeroes if no writeshave been made to those sectors in the image file.
This patch finishes streaming early when the end of the backing file is...
iscsi: Set number of blocks to 0 for blank CDROM devices
The number of blocks of the device is used to compute the device sizein bdrv_getlength()/iscsi_getlength().For MMC devices, the ReturnedLogicalBlockAddress in the READCAPACITY10has a special meaning when it is 0....
Merge remote-tracking branch 'bonzini/scsi-next' into staging
sheepdog: don't leak socket file descriptor upon connection failure
Signed-off-by: Jim Meyering <meyering@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
iscsi: move iscsi_schedule_bh and iscsi_readv_writev_bh_cb
Put these functions at the beginning, to avoid forward referencesin the next patches.
iscsi: simplify iscsi_schedule_bh
It is always used with the same callback, remove the argument. Andits return value is never used, assume allocation succeeds.
iscsi: fix races between task completion and abort
This patch fixes two main issues with block/iscsi.c:
1) iscsi_task_mgmt_abort_task_async calls iscsi_scsi_task_cancel whichwas also directly called in iscsi_aio_cancel
2) a race between task completion and task abortion could happen cause...
Revert "iscsi: Fix NULL dereferences / races between task completion and abort"
This reverts commit 64e69e80920d82df3fa679bc41b13770d2f99360. The commitreturned immediately from iscsi_aio_cancel, risking corruption in case thefollowing happens:
guest qemu target...
vmdk: Read footer for streamOptimized images
The footer takes precedence over the header when it exists. It containsthe real grain directory offset that is missing in the header. Withoutthis patch, streamOptimized images with a footer cannot be read.
vmdk: Fix header structure
Commit bb45ded9 swapped gd_offset and rgd_offset. This is wrong.
iscsi: Fix NULL dereferences / races between task completion and abort
Signed-off-by: Stefan Priebe <s.priebe@profihost.ag>Acked-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Prevent detection of /dev/fdset/ as floppy
Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Convert open calls to qemu_open
This patch converts all block layer open calls to qemu_open.
Note that this adds the O_CLOEXEC flag to the changed open pathswhen the O_CLOEXEC macro is defined.
Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>...
block: Convert close calls to qemu_close
This patch converts all block layer close calls, that correspondto qemu_open calls, to qemu_close.
qed: mark image clean after repair succeeds
The dirty bit is cleared after image repair succeeds in qed_open().Move this into qed_check() so that all callers benefit from thisbehavior when fix=true.
This is necessary so qemu-img check can call .bdrv_check() and mark the...
qcow2: mark image clean after repair succeeds
The dirty bit is cleared after image repair succeeds in qcow2_open().Move this into qcow2_check() so that all callers benefit from thisbehavior when fix mode is enabled.
block: add BLOCK_O_CHECK for qemu-img check
Image formats with a dirty bit, like qed and qcow2, repair dirty imagefiles upon open with BDRV_O_RDWR. Performing automatic repair whenqemu-img check runs is not ideal because the bdrv_open() call repairsthe image before the actual bdrv_check() call from qemu-img.c....
iscsi: Pick default initiator-name based on the name of the VM
This patch updates the iscsi layer to automatically pick a 'unique'initiator-name based on the name of the vm in case the user has not setan explicit iqn-name to use.
Create a new function qemu_get_vm_name() that returns the name of the VM,...
iscsi: do not leak initiator_name
The argument of iscsi_create_context is never freed by libiscsi,which in fact calls strdup on it. Avoid a leak.
iscsi: reorganize code for parse_initiator_name
Merge the occurrences of the "iqn.2008-11.org.linux-kvm" stringto avoid duplication.
qcow2: introduce dirty bit
This patch adds an incompatible feature bit to mark images that have notbeen closed cleanly. When a dirty image file is opened a consistencycheck and repair is performed.
Update qemu-iotests 031 and 036 since the extension header size changes...
qcow2: implement lazy refcounts
Lazy refcounts is a performance optimization for qcow2 that postponesrefcount metadata updates and instead marks the image dirty. In thecase of crash or power failure the image will be left in a dirty stateand repaired next time it is opened....
vvfat: Fix partition table
Unless parameter ":floppy:" is given, vvfat creates a virtual imagewith DOS MBR defining a single partition which holds the FAT filesystem. The size of the virtual image depends on the width of theFAT: 32 MiB (CHS 64, 16, 63) for 12 bit FAT, 504 MiB (CHS 1024, 16,...
vvfat: Do not clobber the user's geometry
vvfat creates a virtual VFAT filesystem with a certain logicalgeometry that depends on its options. It sets the "geometry hint" tothis geometry. It is the only block driver to do this.
The geometry hint is about about physical geometry, and used only by...
sheepdog: always use coroutine-based network functions
This reduces some code duplication.
sheepdog: do not blindly memset all read buffers
Only buffers that map to unallocated blocks need to be zeroed.
Signed-off-by: Christoph Hellwig <hch@lst.de>Acked-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Merge remote-tracking branch 'mjt/mjt-iov2' into staging