Block layer patches
Subsystems (2)
[PULL 12/14] virtio-blk: tolerate failure to set BlockBackend AioContext
In reply to Kevin WolfFrom: Stefan Hajnoczi <[email protected]>
We no longer rely on setting the AioContext since the block layer IO_CODE APIs can be called from any thread. Now it's just a hint to help block jobs and other operations co-locate themselves in a thread with the guest I/O requests. Keep going if setting the AioContext fails.
Message-ID: <[email protected]>
--- hw/block/virtio-blk.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)
hw/block/virtio-blk.c +5 -14
@@ -1786,11 +1786,14 @@ static int virtio_blk_start_ioeventfd(VirtIODevice *vdev)memory_region_transaction_commit (); +/* +* Try to change the AioContext so that block jobs and other operations can +* co-locate their activity in the same AioContext. If it fails, nevermind. +*/ r =blk_set_aio_context (s->conf.conf.blk, s->vq_aio_context[0 ], &local_err);if (r <0 ) { -error_report_err (local_err); - goto fail_aio_context; +warn_report_err (local_err); }/*
@@ -1819,18 +1822,6 @@ static int virtio_blk_start_ioeventfd(VirtIODevice *vdev) }return 0 ; - fail_aio_context: -memory_region_transaction_begin (); - -for (i =0 ; i < nvqs; i++) { -virtio_bus_set_host_notifier (VIRTIO_BUS (qbus), i, false); - } - -memory_region_transaction_commit (); - -for (i =0 ; i < nvqs; i++) { -virtio_bus_cleanup_host_notifier (VIRTIO_BUS (qbus), i); - } fail_host_notifiers: k->set_guest_notifiers (qbus->parent, nvqs, false); fail_guest_notifiers:
Signature · 1 line
2.43.0
[PULL 03/14] commit: Allow users to request only format driver names in backing file format
In reply to Kevin WolfFrom: Peter Krempa <[email protected]>
Introduce a new flag 'backing-mask-protocol' for the block-commit QMP command which instructs the internals to use 'raw' instead of the protocol driver in case when a image is used without a dummy 'raw' wrapper.
The flag is designed such that it can be always asserted by management tools even when there isn't any update to backing files.
The flag will be used by libvirt so that the backing images still reference the proper format even when libvirt will stop using the dummy raw driver (raw driver with no other config). Libvirt needs this so that the images stay compatible with older libvirt versions which didn't expect that a protocol driver name can appear in the backing file format field.
Message-ID: <2cb46e37093ce793ea1604abc8bbb90f4c8e434b.1701796348.git.pkrempa@redhat.com>
--- qapi/block-core.json | 8 +++++- include/block/block-global-state.h | 3 ++- include/block/block_int-common.h | 4 ++- include/block/block_int-global-state.h | 3 +++ block.c | 37 +++++++++++++++++++++----- block/commit.c | 6 ++++- blockdev.c | 6 +++++ tests/unit/test-bdrv-drain.c | 3 ++- 8 files changed, 58 insertions(+), 12 deletions(-)
qapi/block-core.json +7 -1
@@ -1810,6 +1810,11 @@ # Care should be taken when specifying the string, to specify a # valid filename or protocol. (Since 2.1) # +# @backing-mask-protocol: If true, replace any protocol mentioned in the +# 'backing file format' with 'raw', rather than storing the protocol +# name as the backing format. Can be used even when no image header +# will be updated (default false; since 9.0). +# # @speed: the maximum speed, in bytes per second # # @on-error: the action to take on an error. 'ignore' means that the
@@ -1856,7 +1861,8 @@ '*base': { 'type': 'str', 'features': [ 'deprecated' ] }, '*top-node': 'str', '*top': { 'type': 'str', 'features': [ 'deprecated' ] }, - '*backing-file': 'str', '*speed': 'int', + '*backing-file': 'str', '*backing-mask-protocol': 'bool', + '*speed': 'int', '*on-error': 'BlockdevOnError', '*filter-node-name': 'str', '*auto-finalize': 'bool', '*auto-dismiss': 'bool' },
include/block/block-global-state.h +2 -1
@@ -144,7 +144,8 @@ int GRAPH_RDLOCK bdrv_make_empty(BdrvChild *c, Error **errp);void bdrv_register (BlockDriver *bdrv);int bdrv_drop_intermediate (BlockDriverState *top,BlockDriverState *base, -const char *backing_file_str); +const char *backing_file_str, +bool backing_mask_protocol); BlockDriverState * GRAPH_RDLOCKbdrv_find_overlay (BlockDriverState *active, BlockDriverState *bs);
include/block/block_int-common.h +3 -1
@@ -985,7 +985,9 @@ struct BdrvChildClass {* can update its reference. */ int (*update_filename)(BdrvChild *child,BlockDriverState *new_base, -const char *filename,Error **errp); +const char *filename, +bool backing_mask_protocol, +Error **errp); bool (*change_aio_ctx)(BdrvChild *child, AioContext *ctx, GHashTable *visited, Transaction *tran,
include/block/block_int-global-state.h +3 -0
@@ -82,6 +82,8 @@ void stream_start(const char *job_id, BlockDriverState *bs,* @speed: The maximum speed, in bytes per second, or 0 for unlimited. * @on_error: The action to take upon error. * @backing_file_str: String to use as the backing file in @top's overlay +* @backing_mask_protocol: Replace potential protocol name with 'raw' in +* 'backing file format' header * @filter_node_name: The node name that should be assigned to the filter * driver that the commit job inserts into the graph above @top. NULL means * that a node name should be autogenerated.
@@ -92,6 +94,7 @@ void commit_start(const char *job_id, BlockDriverState *bs, BlockDriverState *base, BlockDriverState *top, int creation_flags, int64_t speed, BlockdevOnError on_error, const char *backing_file_str, + bool backing_mask_protocol, const char *filter_node_name, Error **errp);/** * commit_active_start:
block.c +30 -7
@@ -1309,11 +1309,14 @@ static void bdrv_backing_detach(BdrvChild *c) }static int bdrv_backing_update_filename (BdrvChild *c,BlockDriverState *base, -const char *filename,Error **errp) +const char *filename, +bool backing_mask_protocol, +Error **errp) {BlockDriverState *parent = c->opaque;bool read_only =bdrv_is_read_only (parent);int ret; +const char *format_name;GLOBAL_STATE_CODE ();if (read_only) {
@@ -1323,9 +1326,23 @@ static int bdrv_backing_update_filename(BdrvChild *c, BlockDriverState *base, } } - ret =bdrv_change_backing_file (parent, filename, - base->drv ? base->drv->format_name :"" , - false); +if (base->drv) { +/* +* If the new base image doesn't have a format driver layer, which we +* detect by the fact that @base is a protocol driver, we record +* 'raw' as the format instead of putting the protocol name as the +* backing format +*/ +if (backing_mask_protocol && base->drv->protocol_name) { + format_name ="raw" ; + }else { + format_name = base->drv->format_name; + } + }else { + format_name ="" ; + } + + ret =bdrv_change_backing_file (parent, filename, format_name, false);if (ret <0 ) {error_setg_errno (errp, -ret,"Could not update backing file link" ); }
@@ -1479,10 +1496,14 @@ static void GRAPH_WRLOCK bdrv_child_cb_detach(BdrvChild *child) }static int bdrv_child_cb_update_filename (BdrvChild *c,BlockDriverState *base, -const char *filename,Error **errp) +const char *filename, +bool backing_mask_protocol, +Error **errp) {if (c->role &BDRV_CHILD_COW ) { -return bdrv_backing_update_filename (c, base, filename, errp); +return bdrv_backing_update_filename (c, base, filename, + backing_mask_protocol, + errp); }return 0 ; }
@@ -5803,7 +5824,8 @@ void bdrv_unfreeze_backing_chain(BlockDriverState *bs, BlockDriverState *base)* */ int bdrv_drop_intermediate (BlockDriverState *top,BlockDriverState *base, -const char *backing_file_str) +const char *backing_file_str, +bool backing_mask_protocol) {BlockDriverState *explicit_top = top;bool update_inherits_from;
@@ -5869,6 +5891,7 @@ int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base,if (c->klass->update_filename) { ret = c->klass->update_filename (c, base, backing_file_str, + backing_mask_protocol, &local_err);if (ret <0 ) {/*
block/commit.c +5 -1
@@ -42,6 +42,7 @@ typedef struct CommitBlockJob {bool base_read_only;bool chain_frozen;char *backing_file_str; +bool backing_mask_protocol; } CommitBlockJob;static int commit_prepare (Job *job)
@@ -61,7 +62,8 @@ static int commit_prepare(Job *job)/* FIXME: bdrv_drop_intermediate treats total failures and partial failures * identically. Further work is needed to disambiguate these cases. */ return bdrv_drop_intermediate (s->commit_top_bs, s->base_bs, - s->backing_file_str); + s->backing_file_str, + s->backing_mask_protocol); }static void commit_abort (Job *job)
@@ -254,6 +256,7 @@ void commit_start(const char *job_id, BlockDriverState *bs, BlockDriverState *base, BlockDriverState *top, int creation_flags, int64_t speed, BlockdevOnError on_error, const char *backing_file_str, + bool backing_mask_protocol, const char *filter_node_name, Error **errp) {CommitBlockJob *s;
@@ -408,6 +411,7 @@ void commit_start(const char *job_id, BlockDriverState *bs,blk_set_disable_request_queuing (s->top, true); s->backing_file_str =g_strdup (backing_file_str); + s->backing_mask_protocol = backing_mask_protocol; s->on_error = on_error;trace_commit_start (bs, base, top, s);
blockdev.c +6 -0
@@ -2420,6 +2420,8 @@ void qmp_block_commit(const char *job_id, const char *device,const char *top_node, const char *top, const char *backing_file, + bool has_backing_mask_protocol, + bool backing_mask_protocol, bool has_speed, int64_t speed, bool has_on_error, BlockdevOnError on_error, const char *filter_node_name,
@@ -2450,6 +2452,9 @@ void qmp_block_commit(const char *job_id, const char *device,if (has_auto_dismiss && !auto_dismiss) { job_flags |=JOB_MANUAL_DISMISS ; } +if (!has_backing_mask_protocol) { + backing_mask_protocol = false; + }/* Important Note: * libvirt relies on the DeviceNotFound error class in order to probe for
@@ -2591,6 +2596,7 @@ void qmp_block_commit(const char *job_id, const char *device, }commit_start (job_id, bs, base_bs, top_bs, job_flags, speed, on_error, backing_file, + backing_mask_protocol, filter_node_name, &local_err); }if (local_err !=NULL ) {
tests/unit/test-bdrv-drain.c +2 -1
@@ -1591,6 +1591,7 @@ static const BlockJobDriver test_simple_job_driver = {static int drop_intermediate_poll_update_filename (BdrvChild *child,BlockDriverState *new_base,const char *filename, +bool backing_mask_protocol,Error **errp) {/*
@@ -1702,7 +1703,7 @@ static void test_drop_intermediate_poll(void) job->should_complete = true;g_assert (!job_has_completed); - ret =bdrv_drop_intermediate (chain[1 ], chain[0 ],NULL ); + ret =bdrv_drop_intermediate (chain[1 ], chain[0 ],NULL , false);aio_poll (qemu_get_aio_context (), false);g_assert (ret ==0 );g_assert (job_has_completed);
Signature · 1 line
2.43.0
[PULL 06/14] iotests: port 141 to Python for reliable QMP testing
In reply to Kevin WolfFrom: Stefan Hajnoczi <[email protected]>
The common.qemu bash functions allow tests to interact with the QMP monitor of a QEMU process. I spent two days trying to update 141 when the order of the test output changed, but found it would still fail occassionally because printf() and QMP events race with synchronous QMP communication.
I gave up and ported 141 to the existing Python API for QMP tests. The Python API is less affected by the order in which QEMU prints output because it does not print all QMP traffic by default.
The next commit changes the order in which QMP messages are received. Make 141 reliable first.
Message-ID: <[email protected]>
--- tests/qemu-iotests/141 | 307 ++++++++++++++++--------------------- tests/qemu-iotests/141.out | 200 ++++++------------------ 2 files changed, 176 insertions(+), 331 deletions(-)
tests/qemu-iotests/141 +131 -176
@@ -1,9 +1,12 @@ -#!/usr/bin/env bash +#!/usr/bin/env python3 # group: rw auto quick # # Test case for ejecting BDSs with block jobs still running on them # -# Copyright (C) 2016 Red Hat, Inc. +# Originally written in bash by Hanna Czenczek, ported to Python by Stefan +# Hajnoczi. +# +# Copyright Red Hat # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by
@@ -19,177 +22,129 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -# creator [email protected] - -seq="$(basename $0)" -echo "QA output created by $seq" - -status=1 # failure is the default! - -_cleanup() -{ - _cleanup_qemu - _cleanup_test_img - for img in "$TEST_DIR"/{b,m,o}.$IMGFMT; do - _rm_test_img "$img" - done -} -trap "_cleanup; exit \$status" 0 1 2 3 15 - -# get standard environment, filters and checks -. ./common.rc -. ./common.filter -. ./common.qemu - -# Needs backing file and backing format support -_supported_fmt qcow2 qed -_supported_proto file -_supported_os Linux - - -test_blockjob() -{ - _send_qemu_cmd $QEMU_HANDLE \ - "{'execute': 'blockdev-add', - 'arguments': { - 'node-name': 'drv0', - 'driver': '$IMGFMT', - 'file': { - 'driver': 'file', - 'filename': '$TEST_IMG' - }}}" \ - 'return' - - # If "$2" is an event, we may or may not see it before the - # {"return": {}}. Therefore, filter the {"return": {}} out both - # here and in the next command. (Naturally, if we do not see it - # here, we will see it before the next command can be executed, - # so it will appear in the next _send_qemu_cmd's output.) - _send_qemu_cmd $QEMU_HANDLE \ - "$1" \ - "$2" \ - | _filter_img_create | _filter_qmp_empty_return - - # We want this to return an error because the block job is still running - _send_qemu_cmd $QEMU_HANDLE \ - "{'execute': 'blockdev-del', - 'arguments': {'node-name': 'drv0'}}" \ - 'error' | _filter_generated_node_ids | _filter_qmp_empty_return - - _send_qemu_cmd $QEMU_HANDLE \ - "{'execute': 'block-job-cancel', - 'arguments': {'device': 'job0'}}" \ - "$3" - - _send_qemu_cmd $QEMU_HANDLE \ - "{'execute': 'blockdev-del', - 'arguments': {'node-name': 'drv0'}}" \ - 'return' -} - - -TEST_IMG="$TEST_DIR/b.$IMGFMT" _make_test_img 1M -TEST_IMG="$TEST_DIR/m.$IMGFMT" _make_test_img -b "$TEST_DIR/b.$IMGFMT" -F $IMGFMT 1M -_make_test_img -b "$TEST_DIR/m.$IMGFMT" 1M -F $IMGFMT - -_launch_qemu -nodefaults - -_send_qemu_cmd $QEMU_HANDLE \ - "{'execute': 'qmp_capabilities'}" \ - 'return' - -echo -echo '=== Testing drive-backup ===' -echo - -# drive-backup will not send BLOCK_JOB_READY by itself, and cancelling the job -# will consequently result in BLOCK_JOB_CANCELLED being emitted. - -test_blockjob \ - "{'execute': 'drive-backup', - 'arguments': {'job-id': 'job0', - 'device': 'drv0', - 'target': '$TEST_DIR/o.$IMGFMT', - 'format': '$IMGFMT', - 'sync': 'none'}}" \ - 'return' \ - '"status": "null"' - -echo -echo '=== Testing drive-mirror ===' -echo - -# drive-mirror will send BLOCK_JOB_READY basically immediately, and cancelling -# the job will consequently result in BLOCK_JOB_COMPLETED being emitted. - -test_blockjob \ - "{'execute': 'drive-mirror', - 'arguments': {'job-id': 'job0', - 'device': 'drv0', - 'target': '$TEST_DIR/o.$IMGFMT', - 'format': '$IMGFMT', - 'sync': 'none'}}" \ - 'BLOCK_JOB_READY' \ - '"status": "null"' - -echo -echo '=== Testing active block-commit ===' -echo - -# An active block-commit will send BLOCK_JOB_READY basically immediately, and -# cancelling the job will consequently result in BLOCK_JOB_COMPLETED being -# emitted. - -test_blockjob \ - "{'execute': 'block-commit', - 'arguments': {'job-id': 'job0', 'device': 'drv0'}}" \ - 'BLOCK_JOB_READY' \ - '"status": "null"' - -echo -echo '=== Testing non-active block-commit ===' -echo - -# Give block-commit something to work on, otherwise it would be done -# immediately, send a BLOCK_JOB_COMPLETED and ejecting the BDS would work just -# fine without the block job still running. - -$QEMU_IO -c 'write 0 1M' "$TEST_DIR/m.$IMGFMT" | _filter_qemu_io - -test_blockjob \ - "{'execute': 'block-commit', - 'arguments': {'job-id': 'job0', - 'device': 'drv0', - 'top': '$TEST_DIR/m.$IMGFMT', - 'speed': 1}}" \ - 'return' \ - '"status": "null"' - -echo -echo '=== Testing block-stream ===' -echo - -# Give block-stream something to work on, otherwise it would be done -# immediately, send a BLOCK_JOB_COMPLETED and ejecting the BDS would work just -# fine without the block job still running. - -$QEMU_IO -c 'write 0 1M' "$TEST_DIR/b.$IMGFMT" | _filter_qemu_io - -# With some data to stream (and @speed set to 1), block-stream will not complete -# until we send the block-job-cancel command. - -test_blockjob \ - "{'execute': 'block-stream', - 'arguments': {'job-id': 'job0', - 'device': 'drv0', - 'speed': 1}}" \ - 'return' \ - '"status": "null"' - -_cleanup_qemu - -# success, all done -echo "*** done" -rm -f $seq.full -status=0 +import iotests + +# Common filters to mask values that vary in the test output +QMP_FILTERS = [iotests.filter_qmp_testfiles, \ + iotests.filter_qmp_imgfmt] + + +class TestCase: + def __init__(self, name, vm, image_path, cancel_event): + self.name = name + self.vm = vm + self.image_path = image_path + self.cancel_event = cancel_event + + def __enter__(self): + iotests.log(f'=== Testing {self.name} ===') + self.vm.qmp_log('blockdev-add', \ + node_name='drv0', \ + driver=iotests.imgfmt, \ + file={'driver': 'file', 'filename': self.image_path}, \ + filters=QMP_FILTERS) + + def __exit__(self, *exc_details): + # This is expected to fail because the job still exists + self.vm.qmp_log('blockdev-del', node_name='drv0', \ + filters=[iotests.filter_qmp_generated_node_ids]) + + self.vm.qmp_log('block-job-cancel', device='job0') + event = self.vm.event_wait(self.cancel_event) + iotests.log(event, filters=[iotests.filter_qmp_event]) + + # This time it succeeds + self.vm.qmp_log('blockdev-del', node_name='drv0') + + # Separate test cases in output + iotests.log('') + + +def main() -> None: + with iotests.FilePath('bottom', 'middle', 'top', 'target') as \ + (bottom_path, middle_path, top_path, target_path), \ + iotests.VM() as vm: + + iotests.log('Creating bottom <- middle <- top backing file chain...') + IMAGE_SIZE='1M' + iotests.qemu_img_create('-f', iotests.imgfmt, bottom_path, IMAGE_SIZE) + iotests.qemu_img_create('-f', iotests.imgfmt, \ + '-F', iotests.imgfmt, \ + '-b', bottom_path, \ + middle_path, \ + IMAGE_SIZE) + iotests.qemu_img_create('-f', iotests.imgfmt, \ + '-F', iotests.imgfmt, \ + '-b', middle_path, \ + top_path, \ + IMAGE_SIZE) + + iotests.log('Starting VM...') + vm.add_args('-nodefaults') + vm.launch() + + # drive-backup will not send BLOCK_JOB_READY by itself, and cancelling + # the job will consequently result in BLOCK_JOB_CANCELLED being + # emitted. + with TestCase('drive-backup', vm, top_path, 'BLOCK_JOB_CANCELLED'): + vm.qmp_log('drive-backup', \ + job_id='job0', \ + device='drv0', \ + target=target_path, \ + format=iotests.imgfmt, \ + sync='none', \ + filters=QMP_FILTERS) + + # drive-mirror will send BLOCK_JOB_READY basically immediately, and + # cancelling the job will consequently result in BLOCK_JOB_COMPLETED + # being emitted. + with TestCase('drive-mirror', vm, top_path, 'BLOCK_JOB_COMPLETED'): + vm.qmp_log('drive-mirror', \ + job_id='job0', \ + device='drv0', \ + target=target_path, \ + format=iotests.imgfmt, \ + sync='none', \ + filters=QMP_FILTERS) + event = vm.event_wait('BLOCK_JOB_READY') + assert event is not None # silence mypy + iotests.log(event, filters=[iotests.filter_qmp_event]) + + # An active block-commit will send BLOCK_JOB_READY basically + # immediately, and cancelling the job will consequently result in + # BLOCK_JOB_COMPLETED being emitted. + with TestCase('active block-commit', vm, top_path, \ + 'BLOCK_JOB_COMPLETED'): + vm.qmp_log('block-commit', \ + job_id='job0', \ + device='drv0') + event = vm.event_wait('BLOCK_JOB_READY') + assert event is not None # silence mypy + iotests.log(event, filters=[iotests.filter_qmp_event]) + + # Give block-commit something to work on, otherwise it would be done + # immediately, send a BLOCK_JOB_COMPLETED and ejecting the BDS would + # work just fine without the block job still running. + iotests.qemu_io(middle_path, '-c', f'write 0 {IMAGE_SIZE}') + with TestCase('non-active block-commit', vm, top_path, \ + 'BLOCK_JOB_CANCELLED'): + vm.qmp_log('block-commit', \ + job_id='job0', \ + device='drv0', \ + top=middle_path, \ + speed=1, \ + filters=[iotests.filter_qmp_testfiles]) + + # Give block-stream something to work on, otherwise it would be done + # immediately, send a BLOCK_JOB_COMPLETED and ejecting the BDS would + # work just fine without the block job still running. + iotests.qemu_io(bottom_path, '-c', f'write 0 {IMAGE_SIZE}') + with TestCase('block-stream', vm, top_path, 'BLOCK_JOB_CANCELLED'): + vm.qmp_log('block-stream', \ + job_id='job0', \ + device='drv0', \ + speed=1) + +if __name__ == '__main__': + iotests.script_main(main, supported_fmts=['qcow2', 'qed'], + supported_protocols=['file'])
tests/qemu-iotests/141.out +45 -155
224 lines not on this page · raw message
Signature · 1 line
2.43.0
[PULL 04/14] stream: Allow users to request only format driver names in backing file format
In reply to Kevin WolfFrom: Peter Krempa <[email protected]>
Introduce a new flag 'backing-mask-protocol' for the block-stream QMP command which instructs the internals to use 'raw' instead of the protocol driver in case when a image is used without a dummy 'raw' wrapper.
The flag is designed such that it can be always asserted by management tools even when there isn't any update to backing files.
The flag will be used by libvirt so that the backing images still reference the proper format even when libvirt will stop using the dummy raw driver (raw driver with no other config). Libvirt needs this so that the images stay compatible with older libvirt versions which didn't expect that a protocol driver name can appear in the backing file format field.
Message-ID: <bbee9a0a59748a8893289bf8249f568f0d587e62.1701796348.git.pkrempa@redhat.com>
--- qapi/block-core.json | 9 ++++++++- include/block/block_int-global-state.h | 3 +++ block/monitor/block-hmp-cmds.c | 2 +- block/stream.c | 10 +++++++++- blockdev.c | 7 +++++++ 5 files changed, 28 insertions(+), 3 deletions(-)
qapi/block-core.json +8 -1
@@ -2826,6 +2826,11 @@ # Care should be taken when specifying the string, to specify a # valid filename or protocol. (Since 2.1) # +# @backing-mask-protocol: If true, replace any protocol mentioned in the +# 'backing file format' with 'raw', rather than storing the protocol +# name as the backing format. Can be used even when no image header +# will be updated (default false; since 9.0). +# # @speed: the maximum speed, in bytes per second # # @on-error: the action to take on an error (default report). 'stop'
@@ -2864,7 +2869,9 @@ ## { 'command': 'block-stream', 'data': { '*job-id': 'str', 'device': 'str', '*base': 'str', - '*base-node': 'str', '*backing-file': 'str', '*bottom': 'str', + '*base-node': 'str', '*backing-file': 'str', + '*backing-mask-protocol': 'bool', + '*bottom': 'str', '*speed': 'int', '*on-error': 'BlockdevOnError', '*filter-node-name': 'str', '*auto-finalize': 'bool', '*auto-dismiss': 'bool' },
include/block/block_int-global-state.h +3 -0
@@ -46,6 +46,8 @@* flatten the whole backing file chain onto @bs. * @backing_file_str: The file name that will be written to @bs as the * the new backing file if the job completes. Ignored if @base is %NULL. +* @backing_mask_protocol: Replace potential protocol name with 'raw' in +* 'backing file format' header * @creation_flags: Flags that control the behavior of the Job lifetime. * See @BlockJobCreateFlags * @speed: The maximum speed, in bytes per second, or 0 for unlimited.
@@ -64,6 +66,7 @@*/ void stream_start(const char *job_id, BlockDriverState *bs, BlockDriverState *base, const char *backing_file_str, + bool backing_mask_protocol, BlockDriverState *bottom, int creation_flags, int64_t speed, BlockdevOnError on_error,
block/monitor/block-hmp-cmds.c +1 -1
@@ -496,7 +496,7 @@ void hmp_block_stream(Monitor *mon, const QDict *qdict)const char *base =qdict_get_try_str (qdict,"base" );int64_t speed =qdict_get_try_int (qdict,"speed" ,0 ); -qmp_block_stream (device, device, base,NULL ,NULL ,NULL , +qmp_block_stream (device, device, base,NULL ,NULL , false, false,NULL ,qdict_haskey (qdict,"speed" ), speed, true,BLOCKDEV_ON_ERROR_REPORT ,NULL , false, false, false, false, &error);
block/stream.c +9 -1
@@ -39,6 +39,7 @@ typedef struct StreamBlockJob {BlockDriverState *target_bs;BlockdevOnError on_error;char *backing_file_str; +bool backing_mask_protocol;bool bs_read_only; } StreamBlockJob;
@@ -95,7 +96,12 @@ static int stream_prepare(Job *job)if (unfiltered_base) { base_id = s->backing_file_str ?: unfiltered_base->filename;if (unfiltered_base->drv) { - base_fmt = unfiltered_base->drv->format_name; +if (s->backing_mask_protocol && + unfiltered_base->drv->protocol_name) { + base_fmt ="raw" ; + }else { + base_fmt = unfiltered_base->drv->format_name; + } } }
@@ -247,6 +253,7 @@ static const BlockJobDriver stream_job_driver = { void stream_start(const char *job_id, BlockDriverState *bs, BlockDriverState *base, const char *backing_file_str, + bool backing_mask_protocol, BlockDriverState *bottom, int creation_flags, int64_t speed, BlockdevOnError on_error,
@@ -398,6 +405,7 @@ void stream_start(const char *job_id, BlockDriverState *bs, s->base_overlay = base_overlay; s->above_base = above_base; s->backing_file_str =g_strdup (backing_file_str); + s->backing_mask_protocol = backing_mask_protocol; s->cor_filter_bs = cor_filter_bs; s->target_bs = bs; s->bs_read_only = bs_read_only;
blockdev.c +7 -0
@@ -2278,6 +2278,8 @@ void qmp_block_stream(const char *job_id, const char *device,const char *base, const char *base_node, const char *backing_file, + bool has_backing_mask_protocol, + bool backing_mask_protocol, const char *bottom, bool has_speed, int64_t speed, bool has_on_error, BlockdevOnError on_error,
@@ -2313,6 +2315,10 @@ void qmp_block_stream(const char *job_id, const char *device,return ; } +if (!has_backing_mask_protocol) { + backing_mask_protocol = false; + } +if (!has_on_error) { on_error =BLOCKDEV_ON_ERROR_REPORT ; }
@@ -2400,6 +2406,7 @@ void qmp_block_stream(const char *job_id, const char *device, }stream_start (job_id, bs, base_bs, backing_file, + backing_mask_protocol, bottom_bs, job_flags, has_speed ? speed :0 , on_error, filter_node_name, &local_err);if (local_err) {
Signature · 1 line
2.43.0
[PULL 13/14] virtio-blk: always set ioeventfd during startup
In reply to Kevin WolfFrom: Stefan Hajnoczi <[email protected]>
When starting ioeventfd it is common practice to set the event notifier so that the ioeventfd handler is triggered to run immediately. There may be no requests waiting to be processed, but the idea is that if a request snuck in then we guarantee that it will be detected.
One scenario where self-triggering the ioeventfd is necessary is when virtio_blk_handle_output() is called from a vCPU thread before the VIRTIO Device Status transitions to DRIVER_OK. In that case we need to self-trigger the ioeventfd so that the kick handled by the vCPU thread causes the vq AioContext thread to take over handling the request(s).
Message-ID: <[email protected]>
--- hw/block/virtio-blk.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
hw/block/virtio-blk.c +6 -6
@@ -1809,14 +1809,14 @@ static int virtio_blk_start_ioeventfd(VirtIODevice *vdev)smp_wmb ();/* paired with aio_notify_accept() on the read side */ /* Get this show started by hooking up our callbacks */ -if (!blk_in_drain (s->conf.conf.blk)) { -for (i =0 ; i < nvqs; i++) { -VirtQueue *vq =virtio_get_queue (vdev, i); -AioContext *ctx = s->vq_aio_context[i]; +for (i =0 ; i < nvqs; i++) { +VirtQueue *vq =virtio_get_queue (vdev, i); +AioContext *ctx = s->vq_aio_context[i]; -/* Kick right away to begin processing requests already in vring */ -event_notifier_set (virtio_queue_get_host_notifier (vq)); +/* Kick right away to begin processing requests already in vring */ +event_notifier_set (virtio_queue_get_host_notifier (vq)); +if (!blk_in_drain (s->conf.conf.blk)) {virtio_queue_aio_attach_host_notifier (vq, ctx); } }
Signature · 1 line
2.43.0
The following changes since commit 3f2a357b95845ea0bf7463eff6661e43b97d1afc:
Merge tag 'hw-cpus-20240119' of https://github.com/philmd/qemu into staging (2024-01-19 11:39:38 +0000)
are available in the Git repository at:
https://repo.or.cz/qemu/kevin.git tags/for-upstream
for you to fetch changes up to ced0d71c5270bed828ed2bd4b116ddfb12862bf9:
block/blklogwrites: Protect mutable driver state with a mutex. (2024-01-19 18:45:44 +0100)
----------------------------------------------------------------
Block layer patches
- virtio-blk: Multiqueue fixes and cleanups
- blklogwrites: Fixes for write_zeroes and superblock update races
- commit/stream: Allow users to request only format driver names in backing file format
- monitor: only run coroutine commands in qemu_aio_context
----------------------------------------------------------------
Ari Sundholm (2):
block/blklogwrites: Fix a bug when logging "write zeroes" operations. block/blklogwrites: Protect mutable driver state with a mutex.
Kevin Wolf (1):
string-output-visitor: Fix (pseudo) struct handling
Peter Krempa (2):
commit: Allow users to request only format driver names in backing file format
stream: Allow users to request only format driver names in backing file format
Stefan Hajnoczi (9):
iotests: add filter_qmp_generated_node_ids()
iotests: port 141 to Python for reliable QMP testing
monitor: only run coroutine commands in qemu_aio_context
virtio-blk: move dataplane code into virtio-blk.c
virtio-blk: rename dataplane create/destroy functions
virtio-blk: rename dataplane to ioeventfd
virtio-blk: restart s->rq reqs in vq AioContexts
virtio-blk: tolerate failure to set BlockBackend AioContext
virtio-blk: always set ioeventfd during startup
qapi/block-core.json | 17 +- hw/block/dataplane/trace.h | 1 - hw/block/dataplane/virtio-blk.h | 34 --- include/block/block-global-state.h | 3 +- include/block/block_int-common.h | 4 +- include/block/block_int-global-state.h | 6 + include/hw/virtio/virtio-blk.h | 16 +- block.c | 37 ++- block/blklogwrites.c | 120 ++++++-- block/commit.c | 6 +- block/monitor/block-hmp-cmds.c | 2 +- block/stream.c | 10 +- blockdev.c | 13 + hw/block/dataplane/virtio-blk.c | 404 ------------------------- hw/block/virtio-blk.c | 412 ++++++++++++++++++++++++-- monitor/qmp.c | 17 -- qapi/qmp-dispatch.c | 24 +- qapi/string-output-visitor.c | 46 +++ tests/unit/test-bdrv-drain.c | 3 +- tests/qemu-iotests/iotests.py | 7 + hw/block/dataplane/meson.build | 1 - hw/block/dataplane/trace-events | 5 - meson.build | 1 - tests/qemu-iotests/060.out | 4 +- tests/qemu-iotests/071.out | 4 +- tests/qemu-iotests/081.out | 16 +- tests/qemu-iotests/087.out | 12 +- tests/qemu-iotests/108.out | 2 +- tests/qemu-iotests/109 | 4 +- tests/qemu-iotests/109.out | 78 +++-- tests/qemu-iotests/117.out | 2 +- tests/qemu-iotests/120.out | 2 +- tests/qemu-iotests/127.out | 2 +- tests/qemu-iotests/140.out | 2 +- tests/qemu-iotests/141 | 307 ++++++++----------- tests/qemu-iotests/141.out | 200 +++---------- tests/qemu-iotests/143.out | 2 +- tests/qemu-iotests/156.out | 2 +- tests/qemu-iotests/176.out | 16 +- tests/qemu-iotests/182.out | 2 +- tests/qemu-iotests/183.out | 4 +- tests/qemu-iotests/184.out | 32 +- tests/qemu-iotests/185 | 6 +- tests/qemu-iotests/185.out | 45 ++- tests/qemu-iotests/191.out | 16 +- tests/qemu-iotests/195.out | 16 +- tests/qemu-iotests/223.out | 12 +- tests/qemu-iotests/227.out | 32 +- tests/qemu-iotests/247.out | 2 +- tests/qemu-iotests/273.out | 8 +- tests/qemu-iotests/308 | 4 +- tests/qemu-iotests/308.out | 4 +- tests/qemu-iotests/tests/file-io-error | 5 +- tests/qemu-iotests/tests/iothreads-resize.out | 2 +- tests/qemu-iotests/tests/qsd-jobs.out | 4 +- 55 files changed, 1014 insertions(+), 1024 deletions(-) delete mode 100644 hw/block/dataplane/trace.h delete mode 100644 hw/block/dataplane/virtio-blk.h delete mode 100644 hw/block/dataplane/virtio-blk.c delete mode 100644 hw/block/dataplane/trace-events
[PULL 07/14] monitor: only run coroutine commands in qemu_aio_context
From: Stefan Hajnoczi <[email protected]>
monitor_qmp_dispatcher_co() runs in the iohandler AioContext that is not polled during nested event loops. The coroutine currently reschedules itself in the main loop's qemu_aio_context AioContext, which is polled during nested event loops. One known problem is that QMP device-add calls drain_call_rcu(), which temporarily drops the BQL, leading to all sorts of havoc like other vCPU threads re-entering device emulation code while another vCPU thread is waiting in device emulation code with aio_poll().
Paolo Bonzini suggested running non-coroutine QMP handlers in the iohandler AioContext. This avoids trouble with nested event loops. His original idea was to move coroutine rescheduling to monitor_qmp_dispatch(), but I resorted to moving it to qmp_dispatch() because we don't know if the QMP handler needs to run in coroutine context in monitor_qmp_dispatch(). monitor_qmp_dispatch() would have been nicer since it's associated with the monitor implementation and not as general as qmp_dispatch(), which is also used by qemu-ga.
A number of qemu-iotests need updated .out files because the order of QMP events vs QMP responses has changed.
Solves Issue #1933.
Message-ID: <[email protected]>
--- monitor/qmp.c | 17 ---- qapi/qmp-dispatch.c | 24 +++++- tests/qemu-iotests/060.out | 4 +- tests/qemu-iotests/071.out | 4 +- tests/qemu-iotests/081.out | 16 ++-- tests/qemu-iotests/087.out | 12 +-- tests/qemu-iotests/108.out | 2 +- tests/qemu-iotests/109 | 4 +- tests/qemu-iotests/109.out | 78 ++++++++----------- tests/qemu-iotests/117.out | 2 +- tests/qemu-iotests/120.out | 2 +- tests/qemu-iotests/127.out | 2 +- tests/qemu-iotests/140.out | 2 +- tests/qemu-iotests/143.out | 2 +- tests/qemu-iotests/156.out | 2 +- tests/qemu-iotests/176.out | 16 ++-- tests/qemu-iotests/182.out | 2 +- tests/qemu-iotests/183.out | 4 +- tests/qemu-iotests/184.out | 32 ++++---- tests/qemu-iotests/185 | 6 +- tests/qemu-iotests/185.out | 45 +++++++++-- tests/qemu-iotests/191.out | 16 ++-- tests/qemu-iotests/195.out | 16 ++-- tests/qemu-iotests/223.out | 12 +-- tests/qemu-iotests/227.out | 32 ++++---- tests/qemu-iotests/247.out | 2 +- tests/qemu-iotests/273.out | 8 +- tests/qemu-iotests/308 | 4 +- tests/qemu-iotests/308.out | 4 +- tests/qemu-iotests/tests/file-io-error | 5 +- tests/qemu-iotests/tests/iothreads-resize.out | 2 +- tests/qemu-iotests/tests/qsd-jobs.out | 4 +- 32 files changed, 205 insertions(+), 178 deletions(-)
monitor/qmp.c +0 -17
@@ -321,14 +321,6 @@ void coroutine_fn monitor_qmp_dispatcher_co(void *data)qemu_coroutine_yield (); } -/* -* Move the coroutine from iohandler_ctx to qemu_aio_context for -* executing the command handler so that it can make progress if it -* involves an AIO_WAIT_WHILE(). -*/ -aio_co_schedule (qemu_get_aio_context (), qmp_dispatcher_co); -qemu_coroutine_yield (); -/* Process request */ if (req_obj->req) {if (trace_event_get_state (TRACE_MONITOR_QMP_CMD_IN_BAND )) {
@@ -355,15 +347,6 @@ void coroutine_fn monitor_qmp_dispatcher_co(void *data) }qmp_request_free (req_obj); - -/* -* Yield and reschedule so the main loop stays responsive. -* -* Move back to iohandler_ctx so that nested event loops for -* qemu_aio_context don't start new monitor commands. -*/ -aio_co_schedule (iohandler_get_aio_context (), qmp_dispatcher_co); -qemu_coroutine_yield (); }qatomic_set (&qmp_dispatcher_co,NULL ); }
qapi/qmp-dispatch.c +23 -1
@@ -206,9 +206,31 @@ QDict *coroutine_mixed_fn qmp_dispatch(const QmpCommandList *cmds, QObject *requassert (!(oob &&qemu_in_coroutine ()));assert (monitor_cur () ==NULL );if (!!(cmd->options &QCO_COROUTINE ) ==qemu_in_coroutine ()) { +if (qemu_in_coroutine ()) { +/* +* Move the coroutine from iohandler_ctx to qemu_aio_context for +* executing the command handler so that it can make progress if it +* involves an AIO_WAIT_WHILE(). +*/ +aio_co_schedule (qemu_get_aio_context (),qemu_coroutine_self ()); +qemu_coroutine_yield (); + } +monitor_set_cur (qemu_coroutine_self (), cur_mon); cmd->fn (args, &ret, &err);monitor_set_cur (qemu_coroutine_self (),NULL ); + +if (qemu_in_coroutine ()) { +/* +* Yield and reschedule so the main loop stays responsive. +* +* Move back to iohandler_ctx so that nested event loops for +* qemu_aio_context don't start new monitor commands. +*/ +aio_co_schedule (iohandler_get_aio_context (), +qemu_coroutine_self ()); +qemu_coroutine_yield (); + } }else {/* * Actual context doesn't match the one the command needs.
@@ -232,7 +254,7 @@ QDict *coroutine_mixed_fn qmp_dispatch(const QmpCommandList *cmds, QObject *requ .errp = &err, .co = qemu_coroutine_self(), }; -aio_bh_schedule_oneshot (qemu_get_aio_context (), do_qmp_dispatch_bh, +aio_bh_schedule_oneshot (iohandler_get_aio_context (), do_qmp_dispatch_bh, &data);qemu_coroutine_yield (); }
tests/qemu-iotests/060.out +2 -2
@@ -421,8 +421,8 @@ QMP_VERSION {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_IMAGE_CORRUPTED", "data": {"device": "none0", "msg": "Preventing invalid write on metadata (overlaps with refcount table)", "offset": 65536, "node-name": "drive", "fatal": true, "size": 65536}} write failed: Input/output error {"return": ""} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} === Testing incoming inactive corrupted image ===
@@ -432,8 +432,8 @@ QMP_VERSION qcow2: Image is corrupt: L2 table offset 0x2a2a2a00 unaligned (L1 index: 0); further non-fatal corruption events will be suppressed {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_IMAGE_CORRUPTED", "data": {"device": "", "msg": "L2 table offset 0x2a2a2a00 unaligned (L1 index: 0)", "node-name": "drive", "fatal": false}} {"return": ""} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} corrupt: false *** done
tests/qemu-iotests/071.out +2 -2
@@ -45,8 +45,8 @@ QMP_VERSION {"return": {}} read failed: Input/output error {"return": ""} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} === Testing blkverify on existing block device ===
@@ -84,9 +84,9 @@ wrote 512/512 bytes at offset 0 {"return": ""} read failed: Input/output error {"return": ""} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} QEMU_PROG: Failed to flush the L2 table cache: Input/output error QEMU_PROG: Failed to flush the refcount block cache: Input/output error +{"return": {}} *** done
tests/qemu-iotests/081.out +8 -8
@@ -35,8 +35,8 @@ QMP_VERSION read 10485760/10485760 bytes at offset 0 10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} == using quorum rewrite corrupted mode ==
@@ -67,8 +67,8 @@ QMP_VERSION read 10485760/10485760 bytes at offset 0 10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} -- checking that the image has been corrected -- read 10485760/10485760 bytes at offset 0
@@ -106,8 +106,8 @@ QMP_VERSION {"return": {}} {"return": {}} {"return": {}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} Testing: QMP_VERSION
@@ -115,8 +115,8 @@ QMP_VERSION {"return": {}} {"return": {}} {"error": {"class": "GenericError", "desc": "Cannot add a child to a quorum in blkverify mode"}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} == dynamically removing a child from a quorum ==
@@ -125,31 +125,31 @@ QMP_VERSION {"return": {}} {"return": {}} {"return": {}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} Testing: QMP_VERSION {"return": {}} {"return": {}} {"error": {"class": "GenericError", "desc": "The number of children cannot be lower than the vote threshold 2"}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} Testing: QMP_VERSION {"return": {}} {"error": {"class": "GenericError", "desc": "blkverify=on can only be set if there are exactly two files and vote-threshold is 2"}} {"error": {"class": "GenericError", "desc": "Cannot find device='drive0-quorum' nor node-name='drive0-quorum'"}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} Testing: QMP_VERSION {"return": {}} {"return": {}} {"error": {"class": "GenericError", "desc": "The number of children cannot be lower than the vote threshold 2"}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} *** done
tests/qemu-iotests/087.out +6 -6
@@ -7,8 +7,8 @@ Testing: QMP_VERSION {"return": {}} {"error": {"class": "GenericError", "desc": "'node-name' must be specified for the root node"}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} === Duplicate ID ===
@@ -18,8 +18,8 @@ QMP_VERSION {"return": {}} {"error": {"class": "GenericError", "desc": "node-name=disk is conflicting with a device id"}} {"error": {"class": "GenericError", "desc": "Duplicate nodes with node-name='test-node'"}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} === aio=native without O_DIRECT ===
@@ -28,8 +28,8 @@ Testing: QMP_VERSION {"return": {}} {"error": {"class": "GenericError", "desc": "aio=native was specified, but it requires cache.direct=on, which was not specified."}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} === Encrypted image QCow ===
@@ -40,8 +40,8 @@ QMP_VERSION {"return": {}} {"return": {}} {"error": {"class": "GenericError", "desc": "Use of AES-CBC encrypted IMGFMT images is no longer supported in system emulators"}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} === Encrypted image LUKS ===
@@ -52,8 +52,8 @@ QMP_VERSION {"return": {}} {"return": {}} {"return": {}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} === Missing driver ===
@@ -63,7 +63,7 @@ Testing: -S QMP_VERSION {"return": {}} {"error": {"class": "GenericError", "desc": "Parameter 'driver' is missing"}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} *** done
tests/qemu-iotests/108.out +1 -1
@@ -173,8 +173,8 @@ OK: Reftable is where we expect it {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "create"}} {"return": {}} { "execute": "quit" } -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
tests/qemu-iotests/109 +2 -2
@@ -57,13 +57,13 @@ run_qemu() _launch_qemu -drive file="${source_img}",format=raw,cache=${CACHEMODE},aio=${AIOMODE},id=src _send_qemu_cmd $QEMU_HANDLE "{ 'execute': 'qmp_capabilities' }" "return" - _send_qemu_cmd $QEMU_HANDLE \ + capture_events="$qmp_event" _send_qemu_cmd $QEMU_HANDLE \ "{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': '$raw_img', $qmp_format 'mode': 'existing', 'sync': 'full'}}" \ "return" - _send_qemu_cmd $QEMU_HANDLE '' "$qmp_event" + capture_events="$qmp_event JOB_STATUS_CHANGE" _wait_event $QEMU_HANDLE "$qmp_event" if test "$qmp_event" = BLOCK_JOB_ERROR; then _send_qemu_cmd $QEMU_HANDLE '' '"status": "null"' fi
tests/qemu-iotests/109.out +33 -45
405 lines not on this page · raw message
tests/qemu-iotests/117.out +1 -1
@@ -18,8 +18,8 @@ wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} { 'execute': 'quit' } -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} No errors were found on the image. read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
tests/qemu-iotests/120.out +1 -1
@@ -5,8 +5,8 @@ QMP_VERSION wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 0
tests/qemu-iotests/127.out +1 -1
@@ -28,6 +28,6 @@ wrote 42/42 bytes at offset 0 { 'execute': 'quit' } {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "mirror"}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} *** done
tests/qemu-iotests/140.out +1 -1
@@ -19,6 +19,6 @@ read 65536/65536 bytes at offset 0 qemu-io: can't open device nbd+unix:///drv?socket=SOCK_DIR/nbd: Requested export not available server reported: export 'drv' not present { 'execute': 'quit' } -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} *** done
tests/qemu-iotests/143.out +1 -1
@@ -10,6 +10,6 @@ server reported: export 'no_such_export' not present qemu-io: can't open device nbd+unix:///aa--aa1?socket=SOCK_DIR/nbd: Requested export not available server reported: export 'aa--aa...' not present { 'execute': 'quit' } -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} *** done
tests/qemu-iotests/156.out +1 -1
@@ -72,8 +72,8 @@ read 65536/65536 bytes at offset 196608 {"return": ""} { 'execute': 'quit' } -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
tests/qemu-iotests/176.out +8 -8
@@ -169,8 +169,8 @@ QMP_VERSION {"return": {}} {"return": {}} {"return": {}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} wrote 196608/196608 bytes at offset 2147287040 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 131072/131072 bytes at offset 2147352576
@@ -206,8 +206,8 @@ QMP_VERSION {"return": {}} {"return": {}} {"return": {"sha256": HASH}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} === Test pass bitmap.1 ===
@@ -218,8 +218,8 @@ QMP_VERSION {"return": {}} {"return": {}} {"return": {}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} wrote 196608/196608 bytes at offset 2147287040 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 131072/131072 bytes at offset 2147352576
@@ -256,8 +256,8 @@ QMP_VERSION {"return": {}} {"return": {}} {"return": {"sha256": HASH}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} === Test pass bitmap.2 ===
@@ -268,8 +268,8 @@ QMP_VERSION {"return": {}} {"return": {}} {"return": {}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} wrote 196608/196608 bytes at offset 2147287040 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 131072/131072 bytes at offset 2147352576
@@ -306,8 +306,8 @@ QMP_VERSION {"return": {}} {"return": {}} {"return": {"sha256": HASH}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} === Test pass bitmap.3 ===
@@ -318,8 +318,8 @@ QMP_VERSION {"return": {}} {"return": {}} {"return": {}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} wrote 196608/196608 bytes at offset 2147287040 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 131072/131072 bytes at offset 2147352576
@@ -353,6 +353,6 @@ QMP_VERSION {"return": {}} {"return": {}} {"return": {"sha256": HASH}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} *** done
tests/qemu-iotests/182.out +1 -1
@@ -53,6 +53,6 @@ Formatting 'TEST_DIR/t.qcow2.overlay', fmt=qcow2 cluster_size=65536 extended_l2= {'execute': 'qmp_capabilities'} {"return": {}} {'execute': 'quit'} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} *** done
tests/qemu-iotests/183.out +2 -2
@@ -53,11 +53,11 @@ wrote 65536/65536 bytes at offset 1048576 === Shut down and check image === {"execute":"quit"} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} {"return": {}} {"execute":"quit"} -{"return": {}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} No errors were found on the image. No errors were found on the image. wrote 65536/65536 bytes at offset 1048576
tests/qemu-iotests/184.out +16 -16
@@ -89,10 +89,6 @@ Testing: "return": [ ] } -{ - "return": { - } -} { "timestamp": { "seconds": TIMESTAMP,
@@ -104,6 +100,10 @@ Testing: "reason": "host-qmp-quit" } } +{ + "return": { + } +} == property changes in ThrottleGroup ==
@@ -169,10 +169,6 @@ Testing: "iops-total-max": 0 } } -{ - "return": { - } -} { "timestamp": { "seconds": TIMESTAMP,
@@ -184,6 +180,10 @@ Testing: "reason": "host-qmp-quit" } } +{ + "return": { + } +} == object creation/set errors ==
@@ -211,10 +211,6 @@ Testing: "desc": "bps/iops/max total values and read/write values cannot be used at the same time" } } -{ - "return": { - } -} { "timestamp": { "seconds": TIMESTAMP,
@@ -226,6 +222,10 @@ Testing: "reason": "host-qmp-quit" } } +{ + "return": { + } +} == don't specify group ==
@@ -247,10 +247,6 @@ Testing: "desc": "Parameter 'throttle-group' is missing" } } -{ - "return": { - } -} { "timestamp": { "seconds": TIMESTAMP,
@@ -262,6 +258,10 @@ Testing: "reason": "host-qmp-quit" } } +{ + "return": { + } +} *** done
tests/qemu-iotests/185 +3 -3
@@ -344,14 +344,14 @@ wait_for_job_and_quit() { sleep 1 + # List of expected events + capture_events='BLOCK_JOB_CANCELLED JOB_STATUS_CHANGE SHUTDOWN' + _send_qemu_cmd $h \ '{"execute": "quit"}' \ 'return' - # List of expected events - capture_events='BLOCK_JOB_CANCELLED JOB_STATUS_CHANGE SHUTDOWN' _wait_event $h 'SHUTDOWN' - QEMU_EVENTS= # Ignore all JOB_STATUS_CHANGE events that came before SHUTDOWN _wait_event $h 'JOB_STATUS_CHANGE' # standby _wait_event $h 'JOB_STATUS_CHANGE' # ready _wait_event $h 'JOB_STATUS_CHANGE' # standby
tests/qemu-iotests/185.out +40 -5
85 lines not on this page · raw message
tests/qemu-iotests/191.out +8 -8
@@ -378,10 +378,6 @@ wrote 65536/65536 bytes at offset 1048576 ] } { 'execute': 'quit' } -{ - "return": { - } -} { "timestamp": { "seconds": TIMESTAMP,
@@ -393,6 +389,10 @@ wrote 65536/65536 bytes at offset 1048576 "reason": "host-qmp-quit" } } +{ + "return": { + } +} image: TEST_DIR/t.IMGFMT file format: IMGFMT virtual size: 64 MiB (67108864 bytes)
@@ -796,10 +796,6 @@ wrote 65536/65536 bytes at offset 1048576 ] } { 'execute': 'quit' } -{ - "return": { - } -} { "timestamp": { "seconds": TIMESTAMP,
@@ -811,6 +807,10 @@ wrote 65536/65536 bytes at offset 1048576 "reason": "host-qmp-quit" } } +{ + "return": { + } +} image: TEST_DIR/t.IMGFMT file format: IMGFMT virtual size: 64 MiB (67108864 bytes)
tests/qemu-iotests/195.out +8 -8
@@ -17,10 +17,6 @@ Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,backing.node-name=mid "return": { } } -{ - "return": { - } -} { "timestamp": { "seconds": TIMESTAMP,
@@ -32,6 +28,10 @@ Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,backing.node-name=mid "reason": "host-qmp-quit" } } +{ + "return": { + } +} image: TEST_DIR/t.IMGFMT.mid file format: IMGFMT
@@ -55,10 +55,6 @@ Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,node-name=top "return": { } } -{ - "return": { - } -} { "timestamp": { "seconds": TIMESTAMP,
@@ -70,6 +66,10 @@ Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,node-name=top "reason": "host-qmp-quit" } } +{ + "return": { + } +} image: TEST_DIR/t.IMGFMT file format: IMGFMT
tests/qemu-iotests/223.out +6 -6
@@ -11,8 +11,8 @@ QMP_VERSION {"return": {}} {"return": {}} {"return": {}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} === Write part of the file under active bitmap ===
@@ -145,14 +145,14 @@ read 2097152/2097152 bytes at offset 2097152 {"execute":"nbd-server-remove", "arguments":{"name":"n"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "n"}} {"return": {}} {"execute":"nbd-server-remove", "arguments":{"name":"n2"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "n"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "n2"}} {"return": {}} {"execute":"nbd-server-remove", "arguments":{"name":"n2"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "n2"}} {"error": {"class": "GenericError", "desc": "Export 'n2' is not found"}} {"execute":"nbd-server-stop"} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "n3"}}
@@ -267,14 +267,14 @@ read 2097152/2097152 bytes at offset 2097152 {"execute":"nbd-server-remove", "arguments":{"name":"n"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "n"}} {"return": {}} {"execute":"nbd-server-remove", "arguments":{"name":"n2"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "n"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "n2"}} {"return": {}} {"execute":"nbd-server-remove", "arguments":{"name":"n2"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "n2"}} {"error": {"class": "GenericError", "desc": "Export 'n2' is not found"}} {"execute":"nbd-server-stop"} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "n3"}}
@@ -282,8 +282,8 @@ read 2097152/2097152 bytes at offset 2097152 {"execute":"nbd-server-stop"} {"error": {"class": "GenericError", "desc": "NBD server not running"}} {"execute":"quit"} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} === Use qemu-nbd as server ===
tests/qemu-iotests/227.out +16 -16
@@ -54,10 +54,6 @@ Testing: -drive driver=null-co,read-zeroes=on,if=virtio } ] } -{ - "return": { - } -} { "timestamp": { "seconds": TIMESTAMP,
@@ -69,6 +65,10 @@ Testing: -drive driver=null-co,read-zeroes=on,if=virtio "reason": "host-qmp-quit" } } +{ + "return": { + } +} === blockstats with -drive if=none ===
@@ -124,10 +124,6 @@ Testing: -drive driver=null-co,if=none } ] } -{ - "return": { - } -} { "timestamp": { "seconds": TIMESTAMP,
@@ -139,6 +135,10 @@ Testing: -drive driver=null-co,if=none "reason": "host-qmp-quit" } } +{ + "return": { + } +} === blockstats with -blockdev ===
@@ -155,10 +155,6 @@ Testing: -blockdev driver=null-co,node-name=null "return": [ ] } -{ - "return": { - } -} { "timestamp": { "seconds": TIMESTAMP,
@@ -170,6 +166,10 @@ Testing: -blockdev driver=null-co,node-name=null "reason": "host-qmp-quit" } } +{ + "return": { + } +} === blockstats with -blockdev and -device ===
@@ -226,10 +226,6 @@ Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device virtio-b } ] } -{ - "return": { - } -} { "timestamp": { "seconds": TIMESTAMP,
@@ -241,5 +237,9 @@ Testing: -blockdev driver=null-co,read-zeroes=on,node-name=null -device virtio-b "reason": "host-qmp-quit" } } +{ + "return": { + } +} *** done
tests/qemu-iotests/247.out +1 -1
@@ -17,6 +17,6 @@ QMP_VERSION {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "job0", "len": 134217728, "offset": 134217728, "speed": 0, "type": "commit"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} *** done
tests/qemu-iotests/273.out +4 -4
@@ -282,10 +282,6 @@ Testing: -blockdev file,node-name=base,filename=TEST_DIR/t.IMGFMT.base -blockdev ] } } -{ - "return": { - } -} { "timestamp": { "seconds": TIMESTAMP,
@@ -297,5 +293,9 @@ Testing: -blockdev file,node-name=base,filename=TEST_DIR/t.IMGFMT.base -blockdev "reason": "host-qmp-quit" } } +{ + "return": { + } +} *** done
tests/qemu-iotests/308 +2 -2
@@ -77,6 +77,7 @@ fuse_export_add() # $1: Export ID fuse_export_del() { + capture_events="BLOCK_EXPORT_DELETED" \ _send_qemu_cmd $QEMU_HANDLE \ "{'execute': 'block-export-del', 'arguments': {
@@ -84,8 +85,7 @@ fuse_export_del() } }" \ 'return' - _send_qemu_cmd $QEMU_HANDLE \ - '' \ + _wait_event $QEMU_HANDLE \ 'BLOCK_EXPORT_DELETED' }
tests/qemu-iotests/308.out +2 -2
@@ -165,9 +165,9 @@ OK: Post-truncate image size is as expected === Tear down === {'execute': 'quit'} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "export-mp"}} +{"return": {}} === Compare copy with original === Images are identical.
@@ -201,9 +201,9 @@ wrote 67108864/67108864 bytes at offset 0 read 67108864/67108864 bytes at offset 0 64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {'execute': 'quit'} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "export"}} +{"return": {}} read 67108864/67108864 bytes at offset 0 64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) *** done
tests/qemu-iotests/tests/file-io-error +2 -3
@@ -99,13 +99,12 @@ echo $QEMU_IO -f file -c 'write 0 64M' "$TEST_DIR/fuse-export" | _filter_qemu_io echo -_send_qemu_cmd $QEMU_HANDLE \ +capture_events=BLOCK_EXPORT_DELETED _send_qemu_cmd $QEMU_HANDLE \ "{'execute': 'block-export-del', 'arguments': {'id': 'exp0'}}" \ 'return' -_send_qemu_cmd $QEMU_HANDLE \ - '' \ +_wait_event $QEMU_HANDLE \ 'BLOCK_EXPORT_DELETED' _send_qemu_cmd $QEMU_HANDLE \
tests/qemu-iotests/tests/iothreads-resize.out +1 -1
@@ -3,8 +3,8 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 QMP_VERSION {"return": {}} {"return": {}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} image: TEST_DIR/t.IMGFMT file format: IMGFMT virtual size: 128 MiB (134217728 bytes)
tests/qemu-iotests/tests/qsd-jobs.out +2 -2
@@ -7,8 +7,8 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/ QMP_VERSION {"return": {}} {"return": {}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}} +{"return": {}} === Streaming can't get permission on base node ===
@@ -17,6 +17,6 @@ QMP_VERSION {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}} {"error": {"class": "GenericError", "desc": "Permission conflict on node 'fmt_base': permissions 'write' are both required by an unnamed block device (uses node 'fmt_base' as 'root' child) and unshared by stream job 'job0' (uses node 'fmt_base' as 'intermediate node' child)."}} -{"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "export1"}} +{"return": {}} *** done
Signature · 1 line
2.43.0
[PULL 08/14] virtio-blk: move dataplane code into virtio-blk.c
In reply to Kevin WolfFrom: Stefan Hajnoczi <[email protected]>
The dataplane code used to be significantly different from the non-dataplane code and therefore had a separate source file.
Over time the difference has gotten smaller because the I/O code paths were unified. Nowadays the distinction between the VirtIOBlock and VirtIOBlockDataPlane structs is more of an inconvenience that hinders code simplification.
Move hw/block/dataplane/virtio-blk.c into hw/block/virtio-blk.c, merging VirtIOBlockDataPlane's fields into VirtIOBlock.
hw/block/virtio-blk.c used VirtIOBlock->dataplane to check if virtio_blk_data_plane_create() was successful. This is not necessary because ->dataplane_started and ->dataplane_disabled can be used instead. This patch makes those changes in order to drop VirtIOBlock->dataplane.
Message-ID: <[email protected]>
--- hw/block/dataplane/trace.h | 1 - hw/block/dataplane/virtio-blk.h | 34 --- include/hw/virtio/virtio-blk.h | 12 +- hw/block/dataplane/virtio-blk.c | 404 -------------------------------- hw/block/virtio-blk.c | 362 ++++++++++++++++++++++++++-- hw/block/dataplane/meson.build | 1 - hw/block/dataplane/trace-events | 5 - meson.build | 1 - 8 files changed, 357 insertions(+), 463 deletions(-) delete mode 100644 hw/block/dataplane/trace.h delete mode 100644 hw/block/dataplane/virtio-blk.h delete mode 100644 hw/block/dataplane/virtio-blk.c delete mode 100644 hw/block/dataplane/trace-events
hw/block/dataplane/trace.h deleted +0 -1
@@ -1 +0,0 @@ -#include "trace/trace-hw_block_dataplane.h"
hw/block/dataplane/virtio-blk.h deleted +0 -34
@@ -1,34 +0,0 @@ -/* -* Dedicated thread for virtio-blk I/O processing -* -* Copyright 2012 IBM, Corp. -* Copyright 2012 Red Hat, Inc. and/or its affiliates -* -* Authors: -* Stefan Hajnoczi <[email protected]> -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -* -*/ - -#ifndef HW_DATAPLANE_VIRTIO_BLK_H -#define HW_DATAPLANE_VIRTIO_BLK_H - -#include "hw/virtio/virtio.h" - -typedef struct VirtIOBlockDataPlane VirtIOBlockDataPlane ; - -bool virtio_blk_data_plane_create (VirtIODevice *vdev,VirtIOBlkConf *conf, -VirtIOBlockDataPlane **dataplane, -Error **errp); -void virtio_blk_data_plane_destroy (VirtIOBlockDataPlane *s); -void virtio_blk_data_plane_notify (VirtIOBlockDataPlane *s,VirtQueue *vq); - -int virtio_blk_data_plane_start (VirtIODevice *vdev); -void virtio_blk_data_plane_stop (VirtIODevice *vdev); - -void virtio_blk_data_plane_detach (VirtIOBlockDataPlane *s); -void virtio_blk_data_plane_attach (VirtIOBlockDataPlane *s); - -#endif /* HW_DATAPLANE_VIRTIO_BLK_H */
include/hw/virtio/virtio-blk.h +9 -3
@@ -50,8 +50,6 @@ struct VirtIOBlkConfbool x_enable_wce_if_config_wce; }; -struct VirtIOBlockDataPlane ; -struct VirtIOBlockReq ;struct VirtIOBlock {VirtIODevice parent_obj;
@@ -64,7 +62,15 @@ struct VirtIOBlock {VMChangeStateEntry *change;bool dataplane_disabled;bool dataplane_started; -struct VirtIOBlockDataPlane *dataplane; +bool dataplane_starting; +bool dataplane_stopping; + +/* +* The AioContext for each virtqueue. The BlockDriverState will use the +* first element as its AioContext. +*/ +AioContext **vq_aio_context; +uint64_t host_features;size_t config_size;BlockRAMRegistrar blk_ram_registrar;
hw/block/dataplane/virtio-blk.c deleted +0 -404
404 lines not on this page · raw message
hw/block/virtio-blk.c +348 -14
417 lines not on this page · raw message
hw/block/dataplane/meson.build +0 -1
@@ -1,2 +1 @@ -system_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c')) specific_ss.add(when: 'CONFIG_XEN_BUS', if_true: files('xen-block.c'))
hw/block/dataplane/trace-events deleted +0 -5
@@ -1,5 +0,0 @@ -# See docs/devel/tracing.rst for syntax documentation. - -# virtio-blk.c -virtio_blk_data_plane_start(void *s) "dataplane %p" -virtio_blk_data_plane_stop(void *s) "dataplane %p"
meson.build +0 -1
@@ -3286,7 +3286,6 @@ if have_system 'hw/arm', 'hw/audio', 'hw/block', - 'hw/block/dataplane', 'hw/char', 'hw/display', 'hw/dma',
Signature · 1 line
2.43.0
[PULL 11/14] virtio-blk: restart s->rq reqs in vq AioContexts
In reply to Kevin WolfFrom: Stefan Hajnoczi <[email protected]>
A virtio-blk device with the iothread-vq-mapping parameter has per-virtqueue AioContexts. It is not thread-safe to process s->rq requests in the BlockBackend AioContext since that may be different from the virtqueue's AioContext to which this request belongs. The code currently races and could crash.
Adapt virtio_blk_dma_restart_cb() to first split s->rq into per-vq lists and then schedule a BH each vq's AioContext as necessary. This way requests are safely processed in their vq's AioContext.
Message-ID: <[email protected]>
--- hw/block/virtio-blk.c | 44 ++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-)
hw/block/virtio-blk.c +33 -11
@@ -1156,16 +1156,11 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)static void virtio_blk_dma_restart_bh (void *opaque) { -VirtIOBlock *s = opaque; +VirtIOBlockReq *req = opaque; +VirtIOBlock *s = req->dev;/* we're called with at least one request */ -VirtIOBlockReq *req;MultiReqBuffer mrb = {}; - WITH_QEMU_LOCK_GUARD(&s->rq_lock) { - req = s->rq; - s->rq =NULL ; - } -while (req) {VirtIOBlockReq *next = req->next;if (virtio_blk_handle_request (req, &mrb)) {
@@ -1195,16 +1190,43 @@ static void virtio_blk_dma_restart_cb(void *opaque, bool running, RunState state) {VirtIOBlock *s = opaque; +uint16_t num_queues = s->conf.num_queues;if (!running) {return ; } -/* Paired with dec in virtio_blk_dma_restart_bh() */ -blk_inc_in_flight (s->conf.conf.blk); +/* Split the device-wide s->rq request list into per-vq request lists */ + g_autofree VirtIOBlockReq **vq_rq = g_new0(VirtIOBlockReq *, num_queues); +VirtIOBlockReq *rq; + + WITH_QEMU_LOCK_GUARD(&s->rq_lock) { + rq = s->rq; + s->rq =NULL ; + } + +while (rq) { +VirtIOBlockReq *next = rq->next; +uint16_t idx =virtio_get_queue_index (rq->vq); + + rq->next = vq_rq[idx]; + vq_rq[idx] = rq; + rq = next; + } -aio_bh_schedule_oneshot (blk_get_aio_context (s->conf.conf.blk), - virtio_blk_dma_restart_bh, s); +/* Schedule a BH to submit the requests in each vq's AioContext */ +for (uint16_t i =0 ; i < num_queues; i++) { +if (!vq_rq[i]) { +continue ; + } + +/* Paired with dec in virtio_blk_dma_restart_bh() */ +blk_inc_in_flight (s->conf.conf.blk); + +aio_bh_schedule_oneshot (s->vq_aio_context[i], + virtio_blk_dma_restart_bh, + vq_rq[i]); + } }static void virtio_blk_reset (VirtIODevice *vdev)
Signature · 1 line
2.43.0
[PULL 09/14] virtio-blk: rename dataplane create/destroy functions
In reply to Kevin WolfFrom: Stefan Hajnoczi <[email protected]>
virtio_blk_data_plane_create() and virtio_blk_data_plane_destroy() are actually about s->vq_aio_context[] rather than managing dataplane-specific state.
As a prerequisite to using s->vq_aio_context[] in all code paths (even when dataplane is not used), rename these functions to reflect that they just manage s->vq_aio_context and call them regardless of whether or not dataplane is in use.
Note that virtio-blk supports running with -device virtio-blk-pci,ioevent=off where the vCPU thread enters the device emulation code. In this mode ioeventfd is not used for virtqueue processing. However, we still want to initialize s->vq_aio_context[] to qemu_aio_context in that case since I/O completion callbacks will be invoked in the main loop thread.
Message-ID: <[email protected]>
--- hw/block/virtio-blk.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
hw/block/virtio-blk.c +12 -11
@@ -1608,7 +1608,7 @@ apply_vq_mapping(IOThreadVirtQueueMappingList *iothread_vq_mapping_list,IOThread *iothread =iothread_by_id (node->value->iothread);AioContext *ctx =iothread_get_aio_context (iothread); -/* Released in virtio_blk_data_plane_destroy() */ +/* Released in virtio_blk_vq_aio_context_cleanup() */ object_ref (OBJECT (iothread));if (node->value->vqs) {
@@ -1631,7 +1631,7 @@ apply_vq_mapping(IOThreadVirtQueueMappingList *iothread_vq_mapping_list, }/* Context: BQL held */ -static bool virtio_blk_data_plane_create (VirtIOBlock *s,Error **errp) +static bool virtio_blk_vq_aio_context_init (VirtIOBlock *s,Error **errp) {VirtIODevice *vdev =VIRTIO_DEVICE (s);VirtIOBlkConf *conf = &s->conf;
@@ -1659,11 +1659,6 @@ static bool virtio_blk_data_plane_create(VirtIOBlock *s, Error **errp)return false; } } -/* Don't try if transport does not support notifiers. */ -if (!virtio_device_ioeventfd_enabled (vdev)) { - s->dataplane_disabled = true; -return false; - } s->vq_aio_context = g_new(AioContext *, conf->num_queues);
@@ -1676,7 +1671,7 @@ static bool virtio_blk_data_plane_create(VirtIOBlock *s, Error **errp) s->vq_aio_context[i] = ctx; } -/* Released in virtio_blk_data_plane_destroy() */ +/* Released in virtio_blk_vq_aio_context_cleanup() */ object_ref (OBJECT (conf->iothread)); }else {AioContext *ctx =qemu_get_aio_context ();
@@ -1689,7 +1684,7 @@ static bool virtio_blk_data_plane_create(VirtIOBlock *s, Error **errp) }/* Context: BQL held */ -static void virtio_blk_data_plane_destroy (VirtIOBlock *s) +static void virtio_blk_vq_aio_context_cleanup (VirtIOBlock *s) {VirtIOBlkConf *conf = &s->conf;
@@ -2015,7 +2010,13 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)virtio_add_queue (vdev, conf->queue_size, virtio_blk_handle_output); }qemu_coroutine_inc_pool_size (conf->num_queues * conf->queue_size /2 ); -virtio_blk_data_plane_create (s, &err); + +/* Don't start dataplane if transport does not support notifiers. */ +if (!virtio_device_ioeventfd_enabled (vdev)) { + s->dataplane_disabled = true; + } + +virtio_blk_vq_aio_context_init (s, &err);if (err !=NULL ) {error_propagate (errp, err);for (i =0 ; i < conf->num_queues; i++) {
@@ -2052,7 +2053,7 @@ static void virtio_blk_device_unrealize(DeviceState *dev)blk_drain (s->blk);del_boot_device_lchs (dev,"/disk@0,0" ); -virtio_blk_data_plane_destroy (s); +virtio_blk_vq_aio_context_cleanup (s);for (i =0 ; i < conf->num_queues; i++) {virtio_del_queue (vdev, i); }
Signature · 1 line
2.43.0
[PULL 05/14] iotests: add filter_qmp_generated_node_ids()
In reply to Kevin WolfFrom: Stefan Hajnoczi <[email protected]>
Add a filter function for QMP responses that contain QEMU's automatically generated node ids. The ids change between runs and must be masked in the reference output.
The next commit will use this new function.
Message-ID: <[email protected]>
--- tests/qemu-iotests/iotests.py | 7 +++++++ 1 file changed, 7 insertions(+)
tests/qemu-iotests/iotests.py +7 -0
@@ -651,6 +651,13 @@ def _filter(_key, value): def filter_generated_node_ids(msg): return re.sub("#block[0-9]+", "NODE_NAME", msg) +def filter_qmp_generated_node_ids(qmsg): + def _filter(_key, value): + if is_str(value): + return filter_generated_node_ids(value) + return value + return filter_qmp(qmsg, _filter) + def filter_img_info(output: str, filename: str, drop_child_info: bool = True) -> str: lines = []
Signature · 1 line
2.43.0
[PULL 14/14] block/blklogwrites: Protect mutable driver state with a mutex.
In reply to Kevin WolfFrom: Ari Sundholm <[email protected]>
During the review of a fix for a concurrency issue in blklogwrites, it was found that the driver needs an additional fix when enabling multiqueue, which is a new feature introduced in QEMU 9.0, as the driver state may be read and written by multiple threads at the same time, which was not the case when the driver was originally written.
Fix the multi-threaded scenario by introducing a mutex to protect the mutable fields in the driver state, and always having the mutex locked by the current thread when accessing them. Also use the mutex and a CoQueue to ensure that the super block is not being written to by multiple threads concurrently and updates are properly serialized.
Additionally, add the const qualifier to a few BDRVBlkLogWritesState pointer targets in contexts where the driver state is not written to.
Message-ID: <[email protected]>
--- block/blklogwrites.c | 85 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 77 insertions(+), 8 deletions(-)
block/blklogwrites.c +77 -8
@@ -3,7 +3,7 @@* * Copyright (c) 2017 Tuomas Tynkkynen <[email protected]> * Copyright (c) 2018 Aapo Vienamo <[email protected]> -* Copyright (c) 2018 Ari Sundholm <[email protected]> +* Copyright (c) 2018-2024 Ari Sundholm <[email protected]> * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory.
@@ -55,9 +55,34 @@ typedef struct {BdrvChild *log_file;uint32_t sectorsize;uint32_t sectorbits; +uint64_t update_interval; + +/* +* The mutable state of the driver, consisting of the current log sector +* and the number of log entries. +* +* May be read and/or written from multiple threads, and the mutex must be +* held when accessing these fields. +*/ uint64_t cur_log_sector;uint64_t nr_entries; -uint64_t update_interval; +QemuMutex mutex; + +/* +* The super block sequence number. Non-zero if a super block update is in +* progress. +* +* The mutex must be held when accessing this field. +*/ +uint64_t super_update_seq; + +/* +* A coroutine-aware queue to serialize super block updates. +* +* Used with the mutex to ensure that only one thread be updating the super +* block at a time. +*/ +CoQueue super_update_queue; } BDRVBlkLogWritesState;static QemuOptsList runtime_opts = {
@@ -169,6 +194,9 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags, goto fail; } +qemu_mutex_init (&s->mutex); +qemu_co_queue_init (&s->super_update_queue); + log_append =qemu_opt_get_bool (opts,"log-append" , false);if (log_append) {
@@ -231,6 +259,8 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags, s->nr_entries =0 ; } + s->super_update_seq =0 ; +if (!blk_log_writes_sector_size_valid (log_sector_size)) { ret = -EINVAL ;error_setg (errp,"Invalid log sector size %" PRIu64, log_sector_size);
@@ -255,6 +285,7 @@ fail_log:bdrv_unref_child (bs, s->log_file);bdrv_graph_wrunlock (); s->log_file =NULL ; +qemu_mutex_destroy (&s->mutex); } fail:qemu_opts_del (opts);
@@ -269,6 +300,7 @@ static void blk_log_writes_close(BlockDriverState *bs)bdrv_unref_child (bs, s->log_file); s->log_file =NULL ;bdrv_graph_wrunlock (); +qemu_mutex_destroy (&s->mutex); } static int64_t coroutine_fn GRAPH_RDLOCK
@@ -295,7 +327,7 @@ static void blk_log_writes_child_perm(BlockDriverState *bs, BdrvChild *c,static void blk_log_writes_refresh_limits (BlockDriverState *bs,Error **errp) { -BDRVBlkLogWritesState *s = bs->opaque; +const BDRVBlkLogWritesState *s = bs->opaque; bs->bl.request_alignment = s->sectorsize; }
@@ -338,15 +370,18 @@ blk_log_writes_co_do_log(BlkLogWritesLogReq *lr)* driver may be modified by other driver operations while waiting for the * I/O to complete. */ +qemu_mutex_lock (&s->mutex);const uint64_t entry_start_sector = s->cur_log_sector;const uint64_t entry_offset = entry_start_sector << s->sectorbits;const uint64_t qiov_aligned_size =ROUND_UP (lr->qiov->size, s->sectorsize);const uint64_t entry_aligned_size = qiov_aligned_size +ROUND_UP (lr->zero_size, s->sectorsize);const uint64_t entry_nr_sectors = entry_aligned_size >> s->sectorbits; +const uint64_t entry_seq = s->nr_entries +1 ; - s->nr_entries++; + s->nr_entries = entry_seq; s->cur_log_sector += entry_nr_sectors; +qemu_mutex_unlock (&s->mutex);/* * Write the log entry. Note that if this is a "write zeroes" operation,
@@ -366,17 +401,44 @@ blk_log_writes_co_do_log(BlkLogWritesLogReq *lr)/* Update super block on flush or every update interval */ if (lr->log_ret ==0 && ((lr->entry.flags &LOG_FLUSH_FLAG ) - || (s->nr_entries % s->update_interval ==0 ))) + || (entry_seq % s->update_interval ==0 ))) {struct log_write_super super = { .magic =cpu_to_le64 (WRITE_LOG_MAGIC ), .version =cpu_to_le64 (WRITE_LOG_VERSION ), - .nr_entries =cpu_to_le64 (s->nr_entries), + .nr_entries =const_le64 (0 ), .sectorsize =cpu_to_le32 (s->sectorsize), }; -void *zeroes =g_malloc0 (s->sectorsize -sizeof (super)); +void *zeroes;QEMUIOVector qiov; +/* +* Wait if a super block update is already in progress. +* Bail out if a newer update got its turn before us. +*/ + WITH_QEMU_LOCK_GUARD(&s->mutex) { +CoQueueWaitFlags wait_flags =0 ; +while (s->super_update_seq) { +if (entry_seq < s->super_update_seq) { +return ; + } +qemu_co_queue_wait_flags (&s->super_update_queue, + &s->mutex, wait_flags); + +/* +* In case the wait condition remains true after wakeup, +* to avoid starvation, make sure that this request is +* scheduled to rerun next by pushing it to the front of the +* queue. +*/ + wait_flags =CO_QUEUE_WAIT_FRONT ; + } + s->super_update_seq = entry_seq; + super.nr_entries =cpu_to_le64 (s->nr_entries); + } + + zeroes =g_malloc0 (s->sectorsize -sizeof (super)); +qemu_iovec_init (&qiov,2 );qemu_iovec_add (&qiov, &super,sizeof (super));qemu_iovec_add (&qiov, zeroes, s->sectorsize -sizeof (super));
@@ -386,6 +448,13 @@ blk_log_writes_co_do_log(BlkLogWritesLogReq *lr)if (lr->log_ret ==0 ) { lr->log_ret =bdrv_co_flush (s->log_file->bs); } + +/* The super block has been updated. Let another request have a go. */ +qemu_mutex_lock (&s->mutex); + s->super_update_seq =0 ; + (void )qemu_co_queue_next (&s->super_update_queue); +qemu_mutex_unlock (&s->mutex); +qemu_iovec_destroy (&qiov);g_free (zeroes); }
@@ -405,7 +474,7 @@ blk_log_writes_co_log(BlockDriverState *bs, uint64_t offset, uint64_t bytes, {QEMUIOVector log_qiov;size_t niov = qiov ? qiov->niov :0 ; -BDRVBlkLogWritesState *s = bs->opaque; +const BDRVBlkLogWritesState *s = bs->opaque;BlkLogWritesFileReq fr = { .bs = bs, .offset = offset,
Signature · 1 line
2.43.0
[PULL 10/14] virtio-blk: rename dataplane to ioeventfd
In reply to Kevin WolfFrom: Stefan Hajnoczi <[email protected]>
The dataplane code is really about using ioeventfd. It's used both for IOThreads (what we think of as dataplane) and for the core virtio-pci code's ioeventfd feature (which is enabled by default and used when no IOThread has been specified). Rename the code to reflect this.
Message-ID: <[email protected]>
--- include/hw/virtio/virtio-blk.h | 8 ++-- hw/block/virtio-blk.c | 78 +++++++++++++++++----------------- 2 files changed, 43 insertions(+), 43 deletions(-)
include/hw/virtio/virtio-blk.h +4 -4
@@ -60,10 +60,10 @@ struct VirtIOBlock {unsigned short sector_mask;bool original_wce;VMChangeStateEntry *change; -bool dataplane_disabled; -bool dataplane_started; -bool dataplane_starting; -bool dataplane_stopping; +bool ioeventfd_disabled; +bool ioeventfd_started; +bool ioeventfd_starting; +bool ioeventfd_stopping;/* * The AioContext for each virtqueue. The BlockDriverState will use the
hw/block/virtio-blk.c +39 -39
232 lines not on this page · raw message
Signature · 1 line
2.43.0
[PULL 02/14] string-output-visitor: Fix (pseudo) struct handling
In reply to Kevin WolfCommit ff32bb53 tried to get minimal struct support into the string output visitor by just making it return "<omitted>". Unfortunately, it forgot that the caller will still make more visitor calls for the content of the struct.
If the struct is contained in a list, such as IOThreadVirtQueueMapping, in the better case its fields show up as separate list entries. In the worse case, it contains another list, and the string output visitor doesn't support nested lists and asserts that this doesn't happen. So as soon as the optional "vqs" field in IOThreadVirtQueueMapping is specified, we get a crash.
This can be reproduced with the following command line:
echo "info qtree" | ./qemu-system-x86_64 \
-object iothread,id=t0 \
-blockdev null-co,node-name=disk \
-device '{"driver": "virtio-blk-pci", "drive": "disk",
"iothread-vq-mapping": [{"iothread": "t0", "vqs": [0]}]}' \
-monitor stdioFix the problem by counting the nesting level of structs and ignoring any visitor calls for values (apart from start/end_struct) while we're not on the top level.
Lists nested directly within lists remain unimplemented, as we don't currently have a use case for them.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2069
Message-ID: <[email protected]>
--- qapi/string-output-visitor.c | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
qapi/string-output-visitor.c +46 -0
@@ -65,6 +65,7 @@ struct StringOutputVisitor } range_start, range_end;GList *ranges;void *list;/* Only needed for sanity checking the caller */ +unsigned int struct_nesting; };static StringOutputVisitor *to_sov (Visitor *v)
@@ -144,6 +145,10 @@ static bool print_type_int64(Visitor *v, const char *name, int64_t *obj,StringOutputVisitor *sov =to_sov (v);GList *l; +if (sov->struct_nesting) { +return true; + } +switch (sov->list_mode) {case LM_NONE :string_output_append (sov, *obj);
@@ -231,6 +236,10 @@ static bool print_type_size(Visitor *v, const char *name, uint64_t *obj,uint64_t val;char *out, *psize; +if (sov->struct_nesting) { +return true; + } +if (!sov->human) { out =g_strdup_printf ("%" PRIu64, *obj);string_output_set (sov, out);
@@ -250,6 +259,11 @@ static bool print_type_bool(Visitor *v, const char *name, bool *obj, Error **errp) {StringOutputVisitor *sov =to_sov (v); + +if (sov->struct_nesting) { +return true; + } +string_output_set (sov,g_strdup (*obj ?"true" :"false" ));return true; }
@@ -260,6 +274,10 @@ static bool print_type_str(Visitor *v, const char *name, char **obj,StringOutputVisitor *sov =to_sov (v);char *out; +if (sov->struct_nesting) { +return true; + } +if (sov->human) { out = *obj ?g_strdup_printf ("\"%s\"" , *obj) :g_strdup ("<null>" ); }else {
@@ -273,6 +291,11 @@ static bool print_type_number(Visitor *v, const char *name, double *obj, Error **errp) {StringOutputVisitor *sov =to_sov (v); + +if (sov->struct_nesting) { +return true; + } +string_output_set (sov,g_strdup_printf ("%.17g" , *obj));return true; }
@@ -283,6 +306,10 @@ static bool print_type_null(Visitor *v, const char *name, QNull **obj,StringOutputVisitor *sov =to_sov (v);char *out; +if (sov->struct_nesting) { +return true; + } +if (sov->human) { out =g_strdup ("<null>" ); }else {
@@ -295,6 +322,9 @@ static bool print_type_null(Visitor *v, const char *name, QNull **obj,static bool start_struct (Visitor *v,const char *name,void **obj,size_t size,Error **errp) { +StringOutputVisitor *sov =to_sov (v); + + sov->struct_nesting++;return true; }
@@ -302,6 +332,10 @@ static void end_struct(Visitor *v, void **obj) {StringOutputVisitor *sov =to_sov (v); +if (--sov->struct_nesting) { +return ; + } +/* TODO actually print struct fields */ string_output_set (sov,g_strdup ("<omitted>" )); }
@@ -312,6 +346,10 @@ start_list(Visitor *v, const char *name, GenericList **list, size_t size, {StringOutputVisitor *sov =to_sov (v); +if (sov->struct_nesting) { +return true; + } +/* we can't traverse a list in a list */ assert (sov->list_mode ==LM_NONE );/* We don't support visits without a list */
@@ -329,6 +367,10 @@ static GenericList *next_list(Visitor *v, GenericList *tail, size_t size)StringOutputVisitor *sov =to_sov (v);GenericList *ret = tail->next; +if (sov->struct_nesting) { +return ret; + } +if (ret && !ret->next) { sov->list_mode =LM_END ; }
@@ -339,6 +381,10 @@ static void end_list(Visitor *v, void **obj) {StringOutputVisitor *sov =to_sov (v); +if (sov->struct_nesting) { +return ; + } +assert (sov->list == obj); assert(sov->list_mode == LM_STARTED || sov->list_mode == LM_END ||
Signature · 1 line
2.43.0
[PULL 01/14] block/blklogwrites: Fix a bug when logging "write zeroes" operations.
In reply to Kevin WolfFrom: Ari Sundholm <[email protected]>
There is a bug in the blklogwrites driver pertaining to logging "write zeroes" operations, causing log corruption. This can be easily observed by setting detect-zeroes to something other than "off" for the driver.
The issue is caused by a concurrency bug pertaining to the fact that "write zeroes" operations have to be logged in two parts: first the log entry metadata, then the zeroed-out region. While the log entry metadata is being written by bdrv_co_pwritev(), another operation may begin in the meanwhile and modify the state of the blklogwrites driver. This is as intended by the coroutine-driven I/O model in QEMU, of course.
Unfortunately, this specific scenario is mishandled. A short example:
1. Initially, in the current operation (#1), the current log sector
number in the driver state is only incremented by the number of sectors taken by the log entry metadata, after which the log entry metadata is written. The current operation yields.
2. Another operation (#2) may start while the log entry metadata is
being written. It uses the current log position as the start offset for its log entry. This is in the sector right after the operation #1 log entry metadata, which is bad!
3. After bdrv_co_pwritev() returns (#1), the current log sector
number is reread from the driver state in order to find out the start offset for bdrv_co_pwrite_zeroes(). This is an obvious blunder, as the offset will be the sector right after the (misplaced) operation #2 log entry, which means that the zeroed-out region begins at the wrong offset.
4. As a result of the above, the log is corrupt.
Fix this by only reading the driver metadata once, computing the offsets and sizes in one go (including the optional zeroed-out region) and setting the log sector number to the appropriate value for the next operation in line.
Message-ID: <[email protected]>
--- block/blklogwrites.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-)
block/blklogwrites.c +26 -9
@@ -328,22 +328,39 @@ static void coroutine_fn GRAPH_RDLOCK blk_log_writes_co_do_log(BlkLogWritesLogReq *lr) {BDRVBlkLogWritesState *s = lr->bs->opaque; -uint64_t cur_log_offset = s->cur_log_sector << s->sectorbits; - s->nr_entries++; - s->cur_log_sector += -ROUND_UP (lr->qiov->size, s->sectorsize) >> s->sectorbits; +/* +* Determine the offsets and sizes of different parts of the entry, and +* update the state of the driver. +* +* This needs to be done in one go, before any actual I/O is done, as the +* log entry may have to be written in two parts, and the state of the +* driver may be modified by other driver operations while waiting for the +* I/O to complete. +*/ +const uint64_t entry_start_sector = s->cur_log_sector; +const uint64_t entry_offset = entry_start_sector << s->sectorbits; +const uint64_t qiov_aligned_size =ROUND_UP (lr->qiov->size, s->sectorsize); +const uint64_t entry_aligned_size = qiov_aligned_size + +ROUND_UP (lr->zero_size, s->sectorsize); +const uint64_t entry_nr_sectors = entry_aligned_size >> s->sectorbits; - lr->log_ret =bdrv_co_pwritev (s->log_file, cur_log_offset, lr->qiov->size, + s->nr_entries++; + s->cur_log_sector += entry_nr_sectors; + +/* +* Write the log entry. Note that if this is a "write zeroes" operation, +* only the entry header is written here, with the zeroing being done +* separately below. +*/ + lr->log_ret =bdrv_co_pwritev (s->log_file, entry_offset, lr->qiov->size, lr->qiov,0 );/* Logging for the "write zeroes" operation */ if (lr->log_ret ==0 && lr->zero_size) { - cur_log_offset = s->cur_log_sector << s->sectorbits; - s->cur_log_sector += -ROUND_UP (lr->zero_size, s->sectorsize) >> s->sectorbits; +const uint64_t zeroes_offset = entry_offset + qiov_aligned_size; - lr->log_ret =bdrv_co_pwrite_zeroes (s->log_file, cur_log_offset, + lr->log_ret =bdrv_co_pwrite_zeroes (s->log_file, zeroes_offset, lr->zero_size,0 ); }
Signature · 1 line
2.43.0
Quoted 16 lines · Kevin Wolf
The following changes since commit
3f2a357b95845ea0bf7463eff6661e43b97d1afc:Merge tag 'hw-cpus-20240119' of https://github.com/philmd/qemu into staging (2024-01-19 11:39:38 +0000)
are available in the Git repository at:
https://repo.or.cz/qemu/kevin.git tags/for-upstream
for you to fetch changes up to
ced0d71c5270bed828ed2bd4b116ddfb12862bf9:block/blklogwrites: Protect mutable driver state with a mutex. (2024-01-19 18:45:44 +0100)
----------------------------------------------------------------
Block layer patches
Quoted 7 lines
- virtio-blk: Multiqueue fixes and cleanups
- blklogwrites: Fixes forwrite_zeroesand superblock update races
- commit/stream: Allow users to request only format driver names in backing file format
- monitor: only run coroutine commands inqemu_aio_context----------------------------------------------------------------
Got some compile failures on this one; looks like the compiler on our s390 box didn't like this:
https://gitlab.com/qemu-project/qemu/-/jobs/5973441293
https://gitlab.com/qemu-project/qemu/-/jobs/5973441291
https://gitlab.com/qemu-project/qemu/-/jobs/5973441330
In file included from ../include/qemu/host-utils.h:33,
from ../include/qemu/bitops.h:16,
from ../include/qemu/timer.h:4,
from ../include/block/aio.h:24,
from ../include/block/aio-wait.h:28,
from ../include/block/block-io.h:27,
from ../block/blklogwrites.c:15:../block/blklogwrites.c: In function ‘blk_log_writes_co_do_log’:../include/qemu/bswap.h:148:36: error: left shift count >= width of type [-Werror=shift-count-overflow]
148 | ((((_x) & 0x00000000000000ffU) << 56) | \
| ^~../block/blklogwrites.c:409:27: note: in expansion of macro ‘const_le64’ 409 | .nr_entries = const_le64(0),
| ^~~~~~~~~~../include/qemu/bswap.h:149:36: error: left shift count >= width of type [-Werror=shift-count-overflow]
149 | (((_x) & 0x000000000000ff00U) << 40) | \
| ^~../block/blklogwrites.c:409:27: note: in expansion of macro ‘const_le64’ 409 | .nr_entries = const_le64(0),
| ^~~~~~~~~~
cc1: all warnings being treated as errors
thanks
-- PMM
Am 20.01.2024 um 18:21 hat Peter Maydell geschrieben:
Quoted 47 lines · Kevin Wolf
Quoted 16 lines
The following changes since commit
3f2a357b95845ea0bf7463eff6661e43b97d1afc:Merge tag 'hw-cpus-20240119' of https://github.com/philmd/qemu into staging (2024-01-19 11:39:38 +0000)
are available in the Git repository at:
https://repo.or.cz/qemu/kevin.git tags/for-upstream
for you to fetch changes up to
ced0d71c5270bed828ed2bd4b116ddfb12862bf9:block/blklogwrites: Protect mutable driver state with a mutex. (2024-01-19 18:45:44 +0100)
----------------------------------------------------------------
Block layer patchesQuoted 7 lines
- virtio-blk: Multiqueue fixes and cleanups
- blklogwrites: Fixes forwrite_zeroesand superblock update races
- commit/stream: Allow users to request only format driver names in backing file format
- monitor: only run coroutine commands inqemu_aio_context----------------------------------------------------------------
Got some compile failures on this one; looks like the compiler on our s390 box didn't like this:
https://gitlab.com/qemu-project/qemu/-/jobs/5973441293
https://gitlab.com/qemu-project/qemu/-/jobs/5973441291
https://gitlab.com/qemu-project/qemu/-/jobs/5973441330In file included from
../include/qemu/host-utils.h:33,
from../include/qemu/bitops.h:16,
from../include/qemu/timer.h:4,
from../include/block/aio.h:24,
from../include/block/aio-wait.h:28,
from../include/block/block-io.h:27,
from../block/blklogwrites.c:15:../block/blklogwrites.c: In function ‘blk_log_writes_co_do_log’:../include/qemu/bswap.h:148:36: error: left shift count >= width of type [-Werror=shift-count-overflow]
148 | ((((_x) &0x00000000000000ffU) << 56) | \
| ^~../block/blklogwrites.c:409:27: note: in expansion of macro ‘const_le64’ 409 | .nr_entries =const_le64(0),
| ^~~~~~~~~~
Quoted 8 lines
../include/qemu/bswap.h:149:36: error: left shift count >= width of type [-Werror=shift-count-overflow]
149 | (((_x) &0x000000000000ff00U) << 40) | \
| ^~../block/blklogwrites.c:409:27: note: in expansion of macro ‘const_le64’ 409 | .nr_entries =const_le64(0),
| ^~~~~~~~~~
cc1: all warnings being treated as errors
Looks like const_le64() introduced in commit 845d80a8 is buggy. I wonder why we even added it when there is no user of it (this blklogwrites one is the first one, so it exposes the error).
Of course, 0 is just as good as const_le64(0), so I'll just change it to that for now. But I suppose const_le64() should either be fixed (and used by something) or removed.
Kevin
Quoted 33 lines · Kevin Wolf
Am 20.01.2024 um 18:21 hat Peter Maydell geschrieben:
Quoted 22 lines
Got some compile failures on this one; looks like the compiler on our s390 box didn't like this:
https://gitlab.com/qemu-project/qemu/-/jobs/5973441293
https://gitlab.com/qemu-project/qemu/-/jobs/5973441291
https://gitlab.com/qemu-project/qemu/-/jobs/5973441330In file included from
../include/qemu/host-utils.h:33,
from../include/qemu/bitops.h:16,
from../include/qemu/timer.h:4,
from../include/block/aio.h:24,
from../include/block/aio-wait.h:28,
from../include/block/block-io.h:27,
from../block/blklogwrites.c:15:../block/blklogwrites.c: In function ‘blk_log_writes_co_do_log’:../include/qemu/bswap.h:148:36: error: left shift count >= width of type [-Werror=shift-count-overflow]
148 | ((((_x) &0x00000000000000ffU) << 56) | \
| ^~../block/blklogwrites.c:409:27: note: in expansion of macro ‘const_le64’ 409 | .nr_entries =const_le64(0),
| ^~~~~~~~~~Quoted 8 lines
../include/qemu/bswap.h:149:36: error: left shift count >= width of type [-Werror=shift-count-overflow]
149 | (((_x) &0x000000000000ff00U) << 40) | \
| ^~../block/blklogwrites.c:409:27: note: in expansion of macro ‘const_le64’ 409 | .nr_entries =const_le64(0),
| ^~~~~~~~~~
cc1: all warnings being treated as errors
Quoted 7 lines
Looks like
const_le64()introduced in commit845d80a8is buggy. I wonder why we even added it when there is no user of it (this blklogwrites one is the first one, so it exposes the error).Of course, 0 is just as good as
const_le64(0), so I'll just change it to that for now. But I supposeconst_le64()should either be fixed (and used by something) or removed.
Using ULL as the suffix on the constants in the macro should be sufficient to fix the problem, I suspect.
-- PMM