id = 1272 title = "qemu 7.1: assertion faillure with virtio-scsi in `blk_set_enable_write_cache`" state = "closed" created_at = "2022-10-24T15:10:22.560Z" closed_at = "2024-02-07T07:21:40.506Z" labels = ["Storage"] url = "https://gitlab.com/qemu-project/qemu/-/issues/1272" host-os = "Debian 11" host-arch = "x86_64" qemu-version = "v7.1.0" guest-os = "Windows 10" guest-arch = "x86_64" description = """During the guest boot qemu crashes with the following error: > qemu-system-x86_64: ../src/block/block-backend.c:1949: blk_set_enable_write_cache: Assertion `qemu_in_main_thread()' failed.""" reproduce = """1. Start a windows guest""" additional = """Stacktrace: ``` #0 0x00007fd6c3515ce1 in raise () from /lib/x86_64-linux-gnu/libc.so.6 #1 0x00007fd6c34ff537 in abort () from /lib/x86_64-linux-gnu/libc.so.6 #2 0x00007fd6c34ff40f in ?? () from /lib/x86_64-linux-gnu/libc.so.6 #3 0x00007fd6c350e662 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6 #4 0x000056149e2cea03 in blk_set_enable_write_cache (wce=true, blk=0x5614a01c27f0) at ../src/block/block-backend.c:1949 #5 0x000056149e2d0a67 in blk_set_enable_write_cache (blk=0x5614a01c27f0, wce=) at ../src/block/block-backend.c:1951 #6 0x000056149dfe9c59 in scsi_disk_apply_mode_select (p=0x7fd6b400c00e "\\004", page=, s=) at ../src/hw/scsi/scsi-disk.c:1520 #7 mode_select_pages (change=true, len=18, p=0x7fd6b400c00e "\\004", r=0x7fd6b4001ff0) at ../src/hw/scsi/scsi-disk.c:1570 #8 scsi_disk_emulate_mode_select (inbuf=, r=0x7fd6b4001ff0) at ../src/hw/scsi/scsi-disk.c:1640 #9 scsi_disk_emulate_write_data (req=0x7fd6b4001ff0) at ../src/hw/scsi/scsi-disk.c:1934 #10 0x000056149e18ff16 in virtio_scsi_handle_cmd_req_submit (req=, req=, s=0x5614a12f16b0) at ../src/hw/scsi/virtio-scsi.c:719 #11 virtio_scsi_handle_cmd_vq (vq=0x7fd6bab92140, s=0x5614a12f16b0) at ../src/hw/scsi/virtio-scsi.c:761 #12 virtio_scsi_handle_cmd (vq=, vdev=) at ../src/hw/scsi/virtio-scsi.c:775 #13 virtio_scsi_handle_cmd (vdev=0x5614a12f16b0, vq=0x7fd6bab92140) at ../src/hw/scsi/virtio-scsi.c:765 #14 0x000056149e1a8aa6 in virtio_queue_notify_vq (vq=0x7fd6bab92140) at ../src/hw/virtio/virtio.c:2365 #15 0x000056149e3ccea5 in aio_dispatch_handler (ctx=ctx@entry=0x5614a01babe0, node=) at ../src/util/aio-posix.c:369 #16 0x000056149e3cd868 in aio_dispatch_ready_handlers (ready_list=0x7fd6c09b2680, ctx=0x5614a01babe0) at ../src/util/aio-posix.c:399 #17 aio_poll (ctx=0x5614a01babe0, blocking=blocking@entry=true) at ../src/util/aio-posix.c:713 #18 0x000056149e2a7796 in iothread_run (opaque=opaque@entry=0x56149ffde500) at ../src/iothread.c:67 #19 0x000056149e3d0859 in qemu_thread_start (args=0x7fd6c09b26f0) at ../src/util/qemu-thread-posix.c:504 #20 0x00007fd6c36b9ea7 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0 #21 0x00007fd6c35d9aef in clone () from /lib/x86_64-linux-gnu/libc.so.6 ``` The crash was bisected to: ``` commit b1c073490553f80594b903ceedfc7c1aef6b1b19 Author: Hanna Reitz Date: Tue Mar 29 11:35:45 2022 +0200 main-loop: Disable GLOBAL_STATE_CODE() assertions ``` I have not been able to reproduce the bug with a linux guest nor with a fresh windows installation. The crashes appears with either `writethrough` and `directsync` cache modes but not with `writeback` `none` and `unsafe`. Note: if needed I can extract (privately) provide a disk image demonstrating the behavior"""