summaryrefslogtreecommitdiffstats
path: root/block/blkdebug.c
Commit message (Collapse)AuthorAgeFilesLines
* block: Move flag inheritance to bdrv_open_inherit()Kevin Wolf2015-06-121-1/+1
| | | | | | | | | | | Instead of letting every caller of bdrv_open() determine the right flags for its child node manually and pass them to the function, pass the parent node and the role of the newly opened child (like backing file, protocol layer, etc.). Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
* blkdebug: Simplify passing of Error through qemu_opts_foreach()Markus Armbruster2015-06-091-6/+4
| | | | | | | | Cc: Kevin Wolf <kwolf@redhat.com> Cc: qemu-block@nongnu.org Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Acked-by: Kevin Wolf <kwolf@redhat.com>
* QemuOpts: Convert qemu_opts_foreach() to ErrorMarkus Armbruster2015-06-091-3/+3
| | | | | | | | | Retain the function value for now, to permit selective conversion of its callers. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Acked-by: Kevin Wolf <kwolf@redhat.com>
* QemuOpts: Drop qemu_opts_foreach() parameter abort_on_failureMarkus Armbruster2015-06-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | When the argument is non-zero, qemu_opts_foreach() stops on callback returning non-zero, and returns that value. When the argument is zero, it doesn't stop, and returns the bit-wise inclusive or of all the return values. Funky :) The callers that pass zero could just as well pass one, because their callbacks can't return anything but zero: * qemu_add_globals()'s callback qdev_add_one_global() * qemu_config_write()'s callback config_write_opts() * main()'s callbacks default_driver_check(), drive_enable_snapshot(), vnc_init_func() Drop the parameter, and always stop. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Acked-by: Kevin Wolf <kwolf@redhat.com>
* blkdebug: Add bdrv_truncate()Kevin Wolf2015-04-281-0/+6
| | | | | | | | | This is, amongst others, required for qemu-iotests 033 to run as intended on VHDX, which uses explicit bdrv_truncate() calls to bs->file when allocating new blocks. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com>
* blkdebug: fix "once" ruleJohn Snow2015-03-101-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Background: The blkdebug scripts are currently engineered so that when a debug event occurs, a prefilter browses a master list of parsed rules for a certain event and adds them to an "active list" of rules to be used for the forthcoming action, provided the events and state numbers match. Then, once the request is received, the last active rule is used to inject an error if certain parameters match. This active list is cleared every time the prefilter injects a new rule for the first time during a debug event. The "once" rule currently causes the error injection, if it is triggered, to only clear the active list. This is insufficient for preventing future injections of the same rule. Remedy: This patch /deletes/ the rule from the list that the prefilter browses, so it is gone for good. In V2, we remove only the rule of interest from the active list instead of allowing the "once" rule to clear the entire list of active rules. Impact: This affects iotests 026. Several ENOSPC tests that used "once" can be seen to have output that shows multiple failure messages. After this patch, the error messages tend to be smaller and less severe, but the injection can still be seen to be working. I have patched the expected output to expect the smaller error messages. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1423257977-25630-1-git-send-email-jsnow@redhat.com Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blkdebug: Simplify and improve filename generationMax Reitz2014-12-101-71/+28
| | | | | | | | | | | | | | | | Instead of actually recreating the options from scratch, just reuse the options given for creating the BDS, which are the configuration file name and additional options. In case there are no additional options we can thus create a plain filename. This obviously results in a different output for qemu-iotest 099 which exactly tests this filename generation. Fix it up as well. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 1415697825-26678-2-git-send-email-mreitz@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Optimize bdrv_make_empty()Max Reitz2014-11-031-0/+2
| | | | | | | | | | | | | | | | | | | | | bdrv_make_empty() is currently only called if the current image represents an external snapshot that has been committed to its base image; it is therefore unlikely to have internal snapshots. In this case, bdrv_make_empty() can be greatly sped up by emptying the L1 and refcount table (while having the dirty flag set, which only works for compat=1.1) and creating a trivial refcount structure. If there are snapshots or for compat=0.10, fall back to the simple implementation (discard all clusters). [Applied s/clusters/cluster/ typo fix suggested by Eric Blake --Stefan] Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 1414159063-25977-4-git-send-email-mreitz@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* block: Rename BlockDriverCompletionFunc to BlockCompletionFuncMarkus Armbruster2014-10-201-4/+4
| | | | | | | | | | I'll use it with block backends shortly, and the name is going to fit badly there. It's a block layer thing anyway, not just a block driver thing. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: Rename BlockDriverAIOCB* to BlockAIOCB*Markus Armbruster2014-10-201-5/+5
| | | | | | | | | | I'll use BlockDriverAIOCB with block backends shortly, and the name is going to fit badly there. It's a block layer thing anyway, not just a block driver thing. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blkdebug: show an error for invalid event namesStefan Hajnoczi2014-09-251-3/+19
| | | | | | | | | | | | It is easy to typo a blkdebug configuration and waste a lot of time figuring out why no rules are matching. Push the Error** down into add_rule() so we can report an error when the event name is invalid. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: Rename qemu_aio_release -> qemu_aio_unrefFam Zheng2014-09-221-1/+1
| | | | | | Suggested-by: Benoît Canet <benoit.canet@irqsave.net> Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* blkdebug: Drop blkdebug_aiocb_info.cancelFam Zheng2014-09-221-14/+1
| | | | | Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* blkdebug: Delete BH in bdrv_aio_cancelFam Zheng2014-08-221-0/+4
| | | | | | | | Otherwise error_callback_bh will access the already released acb. Cc: qemu-stable@nongnu.org Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blkdebug: Implement bdrv_refresh_filename()Max Reitz2014-08-201-0/+97
| | | | | | | | | Because blkdebug cannot simply create a configuration file, simply refuse to reconstruct a plain filename and only generate an options QDict from the rules instead. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blkdebug: report errors on flush tooPaolo Bonzini2014-08-151-0/+20
| | | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* blkdebug: use BlockDriverState's AioContextStefan Hajnoczi2014-06-041-1/+1
| | | | | | | | | | | | | Drop the assumption that we're using the main AioContext. Convert qemu_bh_new() to aio_bh_new() so we use the BlockDriverState's AioContext. The .bdrv_detach_aio_context() and .bdrv_attach_aio_context() interfaces are not needed since no fd handlers, timers, or BHs stay registered when requests have been drained. Cc: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* block: Remove bdrv_open_image()'s force_raw optionMax Reitz2014-02-211-1/+1
| | | | | | | | | | This option is now unnecessary since specifying BDRV_O_PROTOCOL as flag will do exactly the same. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Benoit Canet <benoit@irqsave.net> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: Change BDS parameter of bdrv_open() to **Max Reitz2014-02-211-0/+1
| | | | | | | | | | | | Make bdrv_open() take a pointer to a BDS pointer, similarly to bdrv_file_open(). If a pointer to a NULL pointer is given, bdrv_open() will create a new BDS with an empty name; if the BDS pointer is not NULL, that existing BDS will be reused (in the same way as bdrv_open() already did). Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* Use error_is_set() only when necessaryMarkus Armbruster2014-02-171-2/+2
| | | | | | | | | | | | | | | | error_is_set(&var) is the same as var != NULL, but it takes whole-program analysis to figure that out. Unnecessarily hard for optimizers, static checkers, and human readers. Dumb it down to obvious. Gets rid of several dozen Coverity false positives. Note that the obvious form is already used in many places. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* blkdebug: Don't leak bs->file on failureKevin Wolf2014-02-091-5/+9
| | | | | | Reported-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
* qemu-iotests: Test pwritev RMW logicKevin Wolf2014-01-241-0/+8
| | | | | Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
* blkdebug: Make required alignment configurableKevin Wolf2014-01-241-0/+16
| | | | | | | | The new 'align' option of blkdebug can be used in order to emulate backends with a required 4k alignment on hosts which only really require 512 byte alignment. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blkdebug: Allow command-line file configurationMax Reitz2014-01-221-9/+3
| | | | | | | | Introduce the "image" option as an alternative to specifying the image through the filename. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: Allow reference for bdrv_file_open()Max Reitz2014-01-221-1/+1
| | | | | | | | | Allow specifying a reference to an existing block device (by name) for bdrv_file_open() instead of a filename and/or options. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blkdebug: Use command-line in read_config()Max Reitz2014-01-221-3/+12
| | | | | | | | | Use qemu_config_parse_qdict() to parse the command-line options in addition to the config file. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blkdebug: Always call read_config()Max Reitz2014-01-221-17/+19
| | | | | | | | | | Move the check whether there actually is a config file into the read_config() function. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blkdebug: Don't require sophisticated filenameMax Reitz2014-01-221-1/+3
| | | | | | | | | | | | | | | If the filename is not prefixed by "blkdebug:" in blkdebug_parse_filename(), the blkdebug driver was not selected through that protocol prefix, but by an explicit command line option (file.driver=blkdebug or something similar). Contrary to the current reaction, this is not a problem at all; we just need to store the filename (in the x-image option) and can go on; the user just has to manually specify the config option. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blkdebug: Use errp for read_config()Max Reitz2014-01-221-4/+6
| | | | | | | | | Use an Error variable in the read_config() function. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qemu-option: Remove qemu_opts_create_nofailPeter Crosthwaite2014-01-061-1/+1
| | | | | | | | | | | | | 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>
* blkdebug: Use QLIST_FOREACH_SAFE to resume IOFam Zheng2013-12-131-4/+4
| | | | | | | | | | Qemu-iotest 030 was broken. When the coroutine runs and finishes, it will remove itself from the req list, so let's use safe version of foreach to avoid use after free. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blkdebug: add "remove_break" commandFam Zheng2013-11-291-0/+27
| | | | | | | | | This adds "remove_break" command which is the reverse of blkdebug command "break": it removes all breakpoints with given tag and resumes all the requests. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* blkdebug: Employ error parameterMax Reitz2013-10-111-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>
* block: Error parameter for open functionsMax Reitz2013-09-121-1/+3
| | | | | | | 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>
* bdrv: Use "Error" for opening imagesMax Reitz2013-09-121-1/+2
| | | | | | | Add an Error ** parameter to BlockDriver.bdrv_open and BlockDriver.bdrv_file_open to allow more specific error messages. Signed-off-by: Max Reitz <mreitz@redhat.com>
* qcow2-refcount: Repair shared refcount blocksMax Reitz2013-09-021-0/+1
| | | | | | | | If the refcount of a refcount block is greater than one, we can at least try to repair that problem by duplicating the affected block. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blkdebug: Add BLKDBG_FLUSH_TO_OS/DISK eventsKevin Wolf2013-06-061-0/+3
| | | | | Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* block: Remove filename parameter from .bdrv_file_open()Kevin Wolf2013-04-221-2/+1
| | | | | | | It is unused now in all block drivers. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* blkdebug: Use bdrv_open options instead of filenameKevin Wolf2013-04-221-32/+82
| | | | | Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* block: Add options QDict to bdrv_file_open() prototypesKevin Wolf2013-03-221-2/+3
| | | | | | | The new parameter is unused yet. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* misc: move include files to include/qemu/Paolo Bonzini2012-12-191-2/+2
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* block: move include files to include/block/Paolo Bonzini2012-12-191-1/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* janitor: do not rely on indirect inclusions of or from qemu-char.hPaolo Bonzini2012-12-191-0/+1
| | | | | | | | | Various header files rely on qemu-char.h including qemu-config.h or main-loop.h, but they really do not need qemu-char.h at all (particularly interesting is the case of the block layer!). Clean this up, and also add missing inclusions of qemu-char.h itself. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* blkdebug: Implement suspend/resume of AIO requestsKevin Wolf2012-12-121-3/+105
| | | | | | | | | | | | | | | | | | | | | This allows more systematic AIO testing. The patch adds three new operations to blkdebug: * Setting a "breakpoint" on a blkdebug event. The next request that triggers this breakpoint is suspended and is tagged with a name. The breakpoint is removed after a request has triggered it. * A suspended request (identified by it's tag) can be resumed * It's possible to check whether a suspended request with a given tag exists. This can be used for waiting for an event. Ideally, we would instead tag requests right when they are created and set breakpoints for individual requests. However, at this point the block layer doesn't allow this easily, and breakpoints that trigger for any request already allow a lot of useful testing. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blkdebug: Factor out remove_rule()Kevin Wolf2012-12-121-2/+13
| | | | | | | | The cleanup work to remove a rule depends on the type of the rule. It's easy for the existing rules as there is no data that must be cleaned up and is specific to a type yet, but the next patch will change this. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blkdebug: Allow usage without config fileKevin Wolf2012-12-121-0/+5
| | | | | | | As soon as new rules can be set during runtime, as introduced by the next patch, blkdebug makes sense even without a config file. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* aio: rename AIOPool to AIOCBInfoStefan Hajnoczi2012-11-141-2/+2
| | | | | | | | | 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 longer needs to be modified. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blkdebug: process all set_state rules in the old statePaolo Bonzini2012-09-281-5/+7
| | | | | | | | | | | | | | | | | | | | | | | Currently it is impossible to write a blkdebug script that ping-pongs between two states, because the second set-state rule will use the state that is set in the first. If you have [set-state] event = "..." state = "1" new_state = "2" [set-state] event = "..." state = "2" new_state = "1" for example the state will remain locked at 1. This can be fixed by first processing all rules, and then setting the state. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blkdebug: optionally tie errors to a specific sectorPaolo Bonzini2012-07-091-2/+24
| | | | | | | | This makes blkdebug scripts more powerful, and independent of the exact sequence of operations performed by streaming. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* blkdebug: store list of active rulesPaolo Bonzini2012-07-091-38/+31
| | | | | | | | | | This prepares for the next patch, where some active rules may actually not trigger depending on input to readv/writev. Store the active rules in a SIMPLEQ (so that it can be emptied easily with QSIMPLEQ_INIT), and fetch the errno/once/immediately arguments from there. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
OpenPOWER on IntegriCloud