summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2013-10-11qemu-io: Let "open" pass options to block driverMax Reitz1-8/+31
Add an option to the open command to specify runtime options for the block driver used. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11vmdk: Fix vmdk_parse_extentsFam Zheng1-2/+5
An extra 'p++' after while loop when *p == '\n' will move p to unknown data position, risking parsing junk data or memory access violation. Cc: qemu-stable@nongnu.org Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11blockdev: blockdev_init() error conversionKevin Wolf1-25/+31
This gives us meaningful error messages for the blockdev-add QMP command. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-10-11blockdev: Don't disable COR automatically with blockdev-addKevin Wolf2-6/+34
If a read-only device is configured with copy-on-read=on, the old code only prints a warning and automatically disables copy on read. Make it a real error for blockdev-add. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-10-11blockdev: Remove 'media' parameter from blockdev_init()Kevin Wolf1-25/+15
The remaining users shouldn't be there with blockdev-add and are easy to move to drive_init(). Bonus bug fix: As a side effect, CD-ROM drives can now use block drivers on the read-only whitelist without explicitly specifying read-only=on, even if a format is explicitly specified. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-10-11qemu-iotests: Check autodel behaviour for device_delKevin Wolf4-0/+222
Block devices creates with -drive and drive_add should automatically disappear if the guest device is unplugged. blockdev-add ones shouldn't. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-10-11blockdev: Remove IF_* check for read-only blockdev_initKevin Wolf11-7/+42
IF_NONE allows read-only, which makes forbidding it in this place for other types pretty much pointless. Instead, make sure that all devices for which the check would have errored out check in their init function that they don't get a read-only BlockDriverState. This catches even cases where IF_NONE and -device is used. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-10-11blockdev: Move virtio-blk device creation to drive_initKevin Wolf1-27/+27
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-10-11blockdev: Move bus/unit/index processing to drive_initKevin Wolf1-84/+73
This requires moving the automatic ID generation at the same time, so let's do that as well. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-10-11blockdev: Move parsing of 'boot' option to drive_initKevin Wolf1-10/+11
It's already ignored and only prints a deprecation message. No use in making it available in new interfaces. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-10-11blockdev: Moving parsing of geometry options to drive_initKevin Wolf1-67/+69
This moves all of the geometry options (cyls/heads/secs/trans) to drive_init so that they can only be accessed using legacy functions, but never with anything blockdev-add related. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-10-11blockdev: Move parsing of 'if' option to drive_initKevin Wolf1-18/+22
It's always IF_NONE for blockdev-add. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Benoit Canet <benoit@irqsave.net> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-10-11blockdev: Move parsing of 'media' option to drive_initKevin Wolf1-23/+50
This moves as much as possible of the processing of the 'media' option to drive_init so that it can only be accessed using legacy functions, but never with anything blockdev-add related. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Benoit Canet <benoit@irqsave.net> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-10-11blockdev: Pass QDict to blockdev_init()Kevin Wolf1-17/+17
Working on a QDict instead of a QemuOpts that accepts anything is more in line with bdrv_open(). A QDict is what qmp_blockdev_add() already has anyway, so this saves additional conversions. And last, but not least, it allows later patches to easily extract legacy options into a separate, typed QemuOpts for drive_init() (the untyped QemuOpts that drive_init already has doesn't allow access to numbers, only strings, and is therefore useless without conversion). Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Benoit Canet <benoit@irqsave.net> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-10-11blockdev: Separate ID generation from DriveInfo creationKevin Wolf3-15/+24
blockdev-add shouldn't automatically generate IDs, but will keep most of the DriveInfo creation code. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-10-11blockdev: 'blockdev-add' QMP commandKevin Wolf3-0/+348
For examples see the changes to qmp-commands.hx. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11blockdev: Introduce DriveInfo.enable_auto_delKevin Wolf2-1/+17
BlockDriverStates shouldn't be affected by an unplugged guest device, except if created with the legacy -drive command line option or the drive_add HMP command. Make the automatic deletion as well as cancelling of jobs conditional on an enable_auto_del boolean that is only set in drive_init(). Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
2013-10-11qapi-types/visit.py: Inheritance for structsKevin Wolf3-2/+37
This introduces a new 'base' key for struct definitions that refers to another struct type. On the JSON level, the fields of the base type are included directly into the same namespace as the fields of the defined type, like with unions. On the C level, a pointer to a struct of the base type is included. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-10-11qapi-types/visit.py: Pass whole expr dict for structsKevin Wolf2-5/+14
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-10-11vmdk: refuse enabling zeroed grain with flat imagesFam Zheng3-0/+12
This is a header flag and we needs sparse for the header. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11vmdk: convert error code to use errpFam Zheng2-59/+63
Convert "fprintf(stderr,..." and standardize error messages: Remove a few local_error's and use errp. Remove "VMDK:" or "Vmdk:" prefixes in error message and fix to upper case. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11build: add command check-cleanWenchao Xia2-2/+7
This command will package the clean operations in tests. Now root Makefile simply calls the command and do not care the details of it any more. Original the built binaries for test will not be removed, now they will be deleted in clean operation. Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11tests: build the helper program by defaultWenchao Xia1-1/+7
Usually we may configure and make, then goto ./tests/qemu-iotest, check. In this case an error will happen since helper program was not built. This patch simply build it by default. A better way may be introducing Makefile in ./tests/qemu-iotest, but it is more complicate to handle out of tree case, and a bit overkill for a single file now, we can do that when more files come. Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11block/raw-posix: Employ error parameterMax Reitz2-16/+58
Make use of the error parameter in the opening and creating functions in block/raw-posix.c. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11qemu-iotests: move blank lines of output in case 059Fam Zheng2-8/+8
Move the blank line to above the test step banner, so it looks clearer in blocks. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11blkverify: Employ error parameterMax Reitz1-6/+5
Make use of the error parameter in blkverify_open. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11blkdebug: Employ error parameterMax Reitz1-4/+4
Make use of the error parameter in blkdebug_open. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11block/raw-win32: Employ error parameterMax Reitz1-5/+11
Make use of the error parameter in the opening and creating functions in block/raw-win32.c. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11block/raw_bsd: Employ error parameterMax Reitz1-2/+1
Propagate errors in raw_create rather than directly reporting and afterwards discarding them. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11qcow2: Evaluate overlap check optionsMax Reitz1-1/+28
Evaluate the runtime overlap check options and set BDRVQcowState.overlap_check appropriately. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11qcow2: Add more overlap check bitmask macrosMax Reitz1-3/+11
Introduces the macros QCOW2_OL_CONSTANT and QCOW2_OL_ALL in addition to the already existing QCOW2_OL_CACHED, signifying all metadata overlap checks that can be performed in constant time (regardless of image size etc.) and truly all available overlap checks, respectively. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11qcow2: Array assigning options to OL check bitsMax Reitz1-0/+11
Add an array which assigns the option string to its corresponding overlap check bit. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11qcow2: Add overlap-check optionsMax Reitz2-0/+55
Add runtime options to tune the overlap checks to be performed before write accesses. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11qcow2: Make overlap check mask variableMax Reitz3-4/+5
Replace the QCOW2_OL_DEFAULT macro by a variable overlap_check in BDRVQcowState. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11qcow2: Use negated overflow check maskMax Reitz6-38/+29
In qcow2_check_metadata_overlap and qcow2_pre_write_overlap_check, change the parameter signifying the checks to perform from its current positive form to a negative one, i.e., it will no longer explicitly specify every check to perform but rather a mask of checks not to perform. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11block: Improve driver whitelist checksKevin Wolf2-9/+9
The main intent of this patch is to consolidate the whitelist checks to a single point in the code instead of spreading it everywhere. This adds a nicer error message for read-only whitelisting, too, in places where it was still missing. The patch also contains a bonus bug fix: By finding the format first in bdrv_open() and then independently checking against the whitelist only later, we avoid the case that use of a non-whitelisted format results in probing rather than an error message. Previously, this could happen when using the driver=... option. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com>
2013-10-11qcow2: Use better type for numerical snapshot IDMax Reitz1-2/+3
When trying to find a new snapshot ID, the existing ones are converted to integers using strtoul. This function returns an unsigned long, therefore its result should be saved in an unsigned long as well. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11qcow2: Fix snapshot restoration in snapshot_createMax Reitz1-0/+1
If the new snapshot table could not be written in qcow2_snapshot_create, the old snapshot table has to be restored in memory and the new one released. This should include restoration of the old snapshot count as well, which is added by this patch. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11qcow2: Remove wrong metadata overlap checkMax Reitz1-8/+0
In qcow2_write_compressed, if the compression fails, a normal cluster is written to disk. This is done through bdrv_write on the qcow2 BDS itself (using the guest offset), thus it is wrong to do a metadata overlap check before. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11qcow2: Add missing space in error messageMax Reitz1-1/+1
The error message in qcow2_downgrade about an unsupported refcount order is missing a space. This patch adds it. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11block: qemu-iotests for vhdx, read sample dynamic imageJeff Cody6-1/+86
This adds the VHDX format to the qemu-iotests format, and adds a read test. The test reads from an existing sample image, that was created with Hyper-V under Windwos Server 2012. The image file is a 1GB dynamic image, with 32MB blocks. The pattern 0xa5 exists from 0MB-33MB (past a block size boundary) The pattern 0x96 exists from 33MB-66MB (past another block boundary, and leaving a partial blank block) From 66MB-1024MB, all reads should return 0. Although 1GB dynamic image with 66MB of data, the bzip2'ed image file size is only 874 bytes. This also adds in the IMGFMT_GENERIC flag, so r/o images can be tested (e.g. ./check -vhdx) without failing tests that assume r/w support. Signed-off-by: Jeff Cody <jcody@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11ahci: set ahci mode on resetMichael S. Tsirkin1-1/+9
ATM we set AHCI mode on 1st GHC write. Spec says we should set it on reset. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11qemu-iotests: Discard preallocated zero clustersMax Reitz3-0/+77
Add a new test case for discarding preallocated zero clusters; doing this should not result in any leaks. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11block: Add BlockDriver.bdrv_check_ext_snapshot.BenoƮt Canet5-0/+46
This field is used by blkverify to disable external snapshots creation. It will also be used by block filters like quorum to disable external snapshot creation. Signed-off-by: Benoit Canet <benoit@irqsave.net> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11block/get_block_status: avoid redundant callouts on raw devicesPeter Lieven3-1/+13
if a raw device like an iscsi target or host device is used the current implementation makes a second call out to get the block status of bs->file. Signed-off-by: Peter Lieven <pl@kamp.de> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11qcow2: Assert against snapshot name/ID overflowMax Reitz1-0/+1
qcow2_write_snapshots relies on the length of every snapshot ID and name fitting into an unsigned 16 bit integer. This is currently ensured by QEMU through generally only allowing 128 byte IDs and 256 byte names. However, if this should change in the future, the length written to the image file should not be silently truncated (though the name itself would be written completely). Since this is currently not an issue but might require attention due to internal QEMU changes in the future, an assert ensuring sanity is enough for now. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11qcow2: Free allocated snapshot table on errorMax Reitz1-0/+4
If an error occurs during qcow2_write_snapshots, the newly allocated snapshot table clusters are leaked and should thus be freed. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11qcow2: Always use error path on writing snapshotsMax Reitz1-3/+4
qcow2_write_snapshots does contain a fail label and there is no reason not to use it on some errors; therefore, we should always jump there on error. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11qcow2: Free preallocated zero clustersMax Reitz1-3/+5
In qcow2_free_any_clusters, preallocated zero clusters should be freed just as normal clusters are. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11qcow2: Use pread for inactive L1 in overlap checkMax Reitz1-4/+3
Currently, qcow2_check_metadata_overlap uses bdrv_read to read inactive L1 tables from disk. The number of sectors to read is calculated through a truncating integer division, therefore, if the L1 table size is not a multiple of the sector size, the final entries will not be read and their entries in memory remain undefined (from the g_malloc). Using bdrv_pread fixes this. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>