summaryrefslogtreecommitdiff
path: root/blockdev.c
AgeCommit message (Collapse)AuthorFilesLines
2014-01-24qmp: Allow to take external snapshots on bs graphs node.Benoît Canet1-7/+48
Signed-off-by: Benoit Canet <benoit@irqsave.net> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-01-24qmp: Allow block_resize to manipulate bs graph nodes.Benoît Canet1-4/+14
Signed-off-by: Benoit Canet <benoit@irqsave.net> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-01-24block: Create authorizations mechanism for external snapshot and resize.Benoît Canet1-1/+1
Signed-off-by: Benoit Canet <benoit@irqsave.net> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-01-24qmp: Allow to change password on named block driver states.Benoît Canet1-4/+9
Signed-off-by: Benoit Canet <benoit@irqsave.net> Reviewed-by: Fam Zheng <famz@redhat.com> There was two candidate ways to implement named node manipulation: 1) { 'command': 'block_passwd', 'data': {'*device': 'str', '*node-name': 'str', 'password': 'str'} } 2) { 'command': 'block_passwd', 'data': {'device': 'str', '*device-is-node': 'bool', 'password': 'str'} } Luiz proposed 1 and says 2 was an abuse of the QMP interface and proposed to rewrite the QMP block interface for 2.0. Luiz does not like in 1 the fact that 2 fields are optional but one of them must be specified leading to an abuse of the QMP semantic. Kevin argumented that 2 what a clear abuse of the device field and would not be practical when reading fast some log file because the user would read "device" and think that a device is manipulated when it's in fact a node name. Documentation of 1 make it pretty clear what to do for the user. Kevin argued that all bs are node including devices ones so 2 does not make sense. Kevin also argued that rewriting the QMP block interface would not make disapear the current one. Kevin pushed the argument that making the QAPI generator compatible with the semantic of the operation would need a rewrite that no one has done yet. A vote has been done on the list to elect the version to use and 1 won. For reference the complete thread is: "[Qemu-devel] [PATCH V4 4/7] qmp: Allow to change password on names block driver states." Signed-off-by: Benoit Canet <benoit@irqsave.net> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-01-24qmp: Add QMP query-named-block-nodes to list the named BlockDriverState nodes.Benoît Canet1-0/+5
Signed-off-by: Benoit Canet <benoit@irqsave.net> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-01-22blockdev: Move "file" to legacy_optsMax Reitz1-9/+10
Specifying the image filename through the "file" option is a legacy option and should not be supported by blockdev-add (in that case, giving a string for "file" references an existing block device). Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-01-14Merge remote branch 'luiz/queue/qmp' into qmpqEdgar E. Iglesias1-2/+4
* luiz/queue/qmp: migration: qmp_migrate(): keep working after syntax error qerror: Remove assert_no_error() qemu-option: Remove qemu_opts_create_nofail target-i386: Remove assert_no_error usage hw: Remove assert_no_error usages qdev: Delete dead code error: Add error_abort monitor: add object-add (QMP) and object_add (HMP) command monitor: add object-del (QMP) and object_del (HMP) command qom: catch errors in object_property_add_child qom: fix leak for objects created with -object rng: initialize file descriptor to -1 qemu-monitor: HMP cpu-add wrapper vl: add missing transition debug->finish_migrate Message-Id: 1389045795-18706-1-git-send-email-lcapitulino@redhat.com Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
2014-01-06qemu-option: Remove qemu_opts_create_nofailPeter Crosthwaite1-2/+4
This is a boiler-plate _nofail variant of qemu_opts_create. Remove and use error_abort in call sites. null/0 arguments needs to be added for the id and fail_if_exists fields in affected callsites due to argument inconsistency between the normal and no_fail variants. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-12-20commit: Support commit active layerFam Zheng1-2/+7
If active is top, it will be mirrored to base, (with block/mirror.c code), then the image is switched when user completes the block job. QMP documentation is updated. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-12-16qmp_change_blockdev() remove unused has_formatMarc-André Lureau1-1/+1
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-11-27block/drive-mirror: Reuse backing HD for sync=noneMax Reitz1-0/+3
For "none" sync mode in "absolute-paths" mode, the current image should be used as the backing file for the newly created image. The current behavior is: a) If the image to be mirrored has a backing file, use that (which is wrong, since the operations recorded by "none" are applied to the image itself, not to its backing file). b) If the image to be mirrored lacks a backing file, the target doesn't have one either (which is not really wrong, but not really right, either; "none" records a set of operations executed on the image file, therefore having no backing file to apply these operations on seems rather pointless). For a, this is clearly a bugfix. For b, it is still a bugfix, although it might break existing API - but since that case crashed qemu just three weeks ago (before 1452686495922b81d6cf43edf025c1aef15965c0), we can safely assume there is no such API relying on that case yet. Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 1385407736-13941-2-git-send-email-mreitz@redhat.com Signed-off-by: Anthony Liguori <aliguori@amazon.com>
2013-11-14qmp: access the local QemuOptsLists for drive optionAmos Kong1-1/+0
Currently we have three QemuOptsList (qemu_common_drive_opts, qemu_legacy_drive_opts, and qemu_drive_opts), only qemu_drive_opts is added to vm_config_groups[]. This patch changes query-command-line-options to access three local QemuOptsLists for drive option, and merge the description items together. Signed-off-by: Amos Kong <akong@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-11-14block/drive-mirror: Check for NULL backing_hdMax Reitz1-1/+3
It should be possible to execute the QMP "drive-mirror" command in "none" sync mode and "absolute-paths" mode even for block devices lacking a backing file. "absolute-paths" does in fact not require a backing file to be present, as can be seen from the "top" sync mode code path. "top" basically states that the device should indeed have a backing file - however, the current code catches the case if it doesn't and then simply treats it as "full" sync mode, creating a target image without a backing file (in "absolute-paths" mode). Thus, "absolute-paths" does not imply the target file must indeed have a backing file. Therefore, the target file may be left unbacked in case of "none" sync mode as well, if the specified device is not backed either. Currently, qemu will crash trying to dereference the backing file pointer since it assumes that it will always be non-NULL in that case ("none" with "absolute-paths"). Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-11-07blockdev: fix drive_init() opts and bs_opts leaksStefan Hajnoczi1-12/+15
These memory leaks also make drive_add if=none,id=drive0 without a file= option leak the options list. This keeps ID "drive0" around forever. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-10-17blockdev: fix cdrom read_only flagFam Zheng1-3/+4
Since 0ebd24e0, cdrom doesn't have read-only on by default, which will error out when using an read only image. Fix it by setting the default value when parsing opts. Reported-by: Edivaldo de Araujo Pereira <edivaldoapereira@yahoo.com.br> Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@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 Wolf1-4/+27
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-11blockdev: Remove IF_* check for read-only blockdev_initKevin Wolf1-6/+0
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 Wolf1-15/+17
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 Wolf1-0/+57
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 Wolf1-1/+16
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-11block: Improve driver whitelist checksKevin Wolf1-6/+2
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-11block: Add BlockDriver.bdrv_check_ext_snapshot.Benoît Canet1-0/+5
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-02block: Remove unused assignment (fixes warning from clang)Stefan Weil1-1/+0
blockdev.c:1929:13: warning: Value stored to 'ret' is never read ret = 0; ^ ~ Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2013-09-20blockdev: do not default cache.no-flush to truePaolo Bonzini1-1/+1
That's why all my VMs were so fast lately. :) This changed in 1.6.0 by mistake in patch 29c4e2b (blockdev: Split up 'cache' option, 2013-07-18). Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-09-12block: Assert validity of BdrvActionOpsMax Reitz1-0/+2
In qmp_transaction, assert that the BdrvActionOps to be used is actually valid. This assertion failing is very improbable, however, it might happen, if a new TransactionActionKind is introduced "out of order" and the actions[] array is not updated. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-12block: Error parameter for open functionsMax Reitz1-17/+13
Add an Error ** parameter to bdrv_open, bdrv_file_open and associated functions to allow more specific error messages. Signed-off-by: Max Reitz <mreitz@redhat.com>
2013-09-12qmp: add interface blockdev-snapshot-delete-internal-syncWenchao Xia1-0/+61
This interface use id and name as optional parameters, to handle the case that one image contain multiple snapshots with same name which may be '', but with different id. Adding parameter id is for historical compatiability reason, and that case is not possible in qemu's new interface for internal snapshot at block device level, but still possible in qemu-img. Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-12qmp: add interface blockdev-snapshot-internal-syncWenchao Xia1-0/+13
Snapshot ID can't be specified in this interface. Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-12qmp: add internal snapshot support in qmp_transactionWenchao Xia1-0/+116
Unlike savevm, the qmp_transaction interface will not generate snapshot name automatically, saving trouble to return information of the new created snapshot. Although qcow2 support storing multiple snapshots with same name but different ID, here it will fail when an snapshot with that name already exist before the operation. Format such as rbd do not support ID at all, and in most case, it means trouble to user when he faces multiple snapshots with same name, so ban that case. Request with empty name will be rejected. Snapshot ID can't be specified in this interface. Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-06block: use BDS ref for block jobsFam Zheng1-34/+15
Block jobs used drive_get_ref(drive_get_by_blockdev(bs)) to avoid BDS being deleted. Now we have BDS reference count, and block jobs don't care about dinfo, so replace them to get cleaner code. It is also the safe way when BDS has no drive info. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-09-06block: make bdrv_delete() staticFam Zheng1-7/+7
Manage BlockDriverState lifecycle with refcnt, so bdrv_delete() is no longer public and should be called by bdrv_unref() if refcnt is decreased to 0. This is an identical change because effectively, there's no multiple reference of BDS now: no caller of bdrv_ref() yet, only bdrv_new() sets bs->refcnt to 1, so all bdrv_unref() now actually delete the BDS. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-09-06block: Add iops_size to do the iops accounting for a given io size.Benoît Canet1-3/+14
This feature can be used in case where users are avoiding the iops limit by doing jumbo I/Os hammering the storage backend. Signed-off-by: Benoit Canet <benoit@irqsave.net> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-09-06block: Add support for throttling burst max in QMP and the command line.Benoît Canet1-16/+78
The max parameter of the leaky bucket throttling algorithm can be used to allow the guest to do bursts. The max value is a pool of I/O that the guest can use without being throttled at all. Throttling is triggered once this pool is empty. Signed-off-by: Benoit Canet <benoit@irqsave.net> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-09-06block: Enable the new throttling code in the block layer.Benoît Canet1-47/+55
Signed-off-by: Benoit Canet <benoit@irqsave.net> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-08-30Revert "block: Disable driver-specific options for 1.6"Kevin Wolf1-143/+0
This reverts commit 8afaefb8919dc8746a57c450a758717c516c7b0a. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-08-22aio / timers: Switch entire codebase to the new timer APIAlex Bligh1-1/+1
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> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-08-22block: better error message for read only format nameFam Zheng1-1/+5
When user tries to use read-only whitelist format in the command line option, failure message was "'foo' invalid format". It might be invalid only for writable, but valid for read-only, so it is confusing. Give the user easier to understand information. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-08-14block: Dont ignore previously set bdrv_flagsM. Mohan Kumar1-1/+0
bdrv_flags is set by bdrv_parse_discard_flags(), but later it is reset to zero. Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com> Message-id: 1376483201-13466-1-git-send-email-mohan@in.ibm.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-08-09block: Bugfix 'format' and 'snapshot' used in drive optionMike Qiu1-3/+9
When use -drive file='xxx',format=qcow2,snapshot=on the error message "Can't use snapshot=on with driver-specific options" can be show, and fail to start the qemu. This should not be happened, and there is no file.driver option in qemu command line. It is because the commit 74fe54f2a1b5c4f4498a8fe521e1dfc936656cd4, it puts 'driver' option if the command line use 'format' option. This patch is to solve this bug. Signed-off-by: Mike Qiu <qiudayu@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-08-02block: Disable driver-specific options for 1.6Kevin Wolf1-0/+143
We don't want to commit to the API yet before everything is worked out. Like already for 1.5, disable it again for the 1.6 release. This commit is meant to be reverted after the 1.6 release. The disabling of the driver-specific options is achieved by applying the old checks while parsing the command line. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-07-27misc: Use g_assert_not_reached for code which is expected to be unreachableStefan Weil1-1/+1
The macro g_assert_not_reached is a better self documenting replacement for assert(0) or assert(false). Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>