278 Commits

Author SHA1 Message Date
Chen Qun
5b10ef9531 vfio: add quirk device write method 2021-03-26 11:14:35 +08:00
Chen Qun
bbb418cfa3 pci-host: add pcie-msi read method
fix CVE-2020-15469

Add pcie-msi mmio read method to avoid NULL pointer dereference
issue.

Reported-by: Lei Sun <slei.casper@gmail.com>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>

Signed-off-by: Jiajie Li <lijiajie11@huawei.com>
2021-03-26 11:14:35 +08:00
Chen Qun
873bc22ef8 hw/pci-host: add pci-intack write method
fix CVE-2020-15469

Add pci-intack mmio write method to avoid NULL pointer dereference
issue.

Reported-by: Lei Sun <slei.casper@gmail.com>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>

Signed-off-by: Jiajie Li <lijiajie11@huawei.com>
2021-03-26 11:14:35 +08:00
openeuler-ci-bot
a70f4c6edc !240 Automatically generate code patches with openeuler !87
From: @kuhnchen18
Reviewed-by: @yorifang
Signed-off-by: @yorifang
2021-03-18 22:06:57 +08:00
Chen Qun
1b4396dd9a spec: Update release version with !87
increase release verison by one

Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
2021-03-18 22:02:37 +08:00
Chen Qun
578e31cf55 spec: Update patch and changelog with !87 block: Add sanity check when setting retry parameters !87
block: Add sanity check when setting retry parameters

Signed-off-by: Chen Qun<kuhn.chenqun@huawei.com>
2021-03-18 22:02:14 +08:00
Chen Qun
27ab61041a block: Add sanity check when setting retry parameters
Add sanity check when setting retry parameters to avoid invalid retry
configuration.

Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
2021-03-18 22:02:14 +08:00
openeuler-ci-bot
3eee17c097 !234 【编译安全选项】使能strip
From: @lijiajie128
Reviewed-by: @fangying712,@cellfaint,@yorifang
Signed-off-by: @fangying712,@yorifang
2021-03-17 17:29:50 +08:00
Jiajie Li
1d77f79cd3 enable strip for qemu-block-rbd.so and qemu-block-ssh.so
Signed-off-by: Jiajie Li <lijiajie11@huawei.com>
2021-03-17 14:32:32 +08:00
openeuler-ci-bot
b3e241753e !232 Automatically generate code patches with openeuler !79 !81
From: @kuhnchen18
Reviewed-by: @yorifang
Signed-off-by: @yorifang
2021-03-12 17:50:15 +08:00
Chen Qun
b3c33c5447 spec: Update release version with !79 !81
increase release verison by one

Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
2021-03-12 16:45:12 +08:00
Chen Qun
6912ff6399 spec: Update patch and changelog with !81 fix CVE-2021-20203 #I3A34O !81
net: vmxnet3: validate configuration values during activate (CVE-2021-20203)

Signed-off-by: Chen Qun<kuhn.chenqun@huawei.com>
2021-03-12 16:45:10 +08:00
Chen Qun
7ebae099e1 net: vmxnet3: validate configuration values during activate (CVE-2021-20203)
fix CVE-2021-20203 #I3A34O

While activating device in vmxnet3_acticate_device(), it does not
validate guest supplied configuration values against predefined
minimum - maximum limits. This may lead to integer overflow or
OOB access issues. Add checks to avoid it.

Fixes: CVE-2021-20203
Buglink: https://bugs.launchpad.net/qemu/+bug/1913873
Reported-by: Gaoning Pan <pgn@zju.edu.cn>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>

Signed-off-by: Jiajie Li <lijiajie11@huawei.com>
2021-03-12 16:45:10 +08:00
Chen Qun
5bde19b297 spec: Update patch and changelog with !79 migration: backport migration/tls patches from upstream !79
migration: fix memory leak in qmp_migrate_set_parameters
migration/tls: fix inverted semantics in multifd_channel_connect
migration/tls: add error handling in multifd_tls_handshake_thread

Signed-off-by: Chen Qun<kuhn.chenqun@huawei.com>
2021-03-12 16:45:08 +08:00
Chen Qun
4f9d9614f3 migration/tls: add error handling in multifd_tls_handshake_thread
If any error happens during multifd send thread creating (e.g. channel broke
because new domain is destroyed by the dst), multifd_tls_handshake_thread
may exit silently, leaving main migration thread hanging (ram_save_setup ->
multifd_send_sync_main -> qemu_sem_wait(&p->sem_sync)).
Fix that by adding error handling in multifd_tls_handshake_thread.

Signed-off-by: Hao Wang <wanghao232@huawei.com>
2021-03-12 16:45:08 +08:00
Chen Qun
b88f4ba8f2 migration/tls: fix inverted semantics in multifd_channel_connect
Function multifd_channel_connect() return "true" to indicate failure,
which is rather confusing. Fix that.

Signed-off-by: Hao Wang <wanghao232@huawei.com>
2021-03-12 16:45:08 +08:00
Chen Qun
7f86d5a4c2 migration: fix memory leak in qmp_migrate_set_parameters
"tmp.tls_hostname" and "tmp.tls_creds" allocated by migrate_params_test_apply()
is forgot to free at the end of qmp_migrate_set_parameters(). Fix that.

The leak stack:
Direct leak of 2 byte(s) in 2 object(s) allocated from:
   #0 0xffffb597c20b in __interceptor_malloc (/usr/lib64/libasan.so.4+0xd320b)
   #1 0xffffb52dcb1b in g_malloc (/usr/lib64/libglib-2.0.so.0+0x58b1b)
   #2 0xffffb52f8143 in g_strdup (/usr/lib64/libglib-2.0.so.0+0x74143)
   #3 0xaaaac52447fb in migrate_params_test_apply (/usr/src/debug/qemu-4.1.0/migration/migration.c:1377)
   #4 0xaaaac52fdca7 in qmp_migrate_set_parameters (/usr/src/debug/qemu-4.1.0/qapi/qapi-commands-migration.c:192)
   #5 0xaaaac551d543 in qmp_dispatch (/usr/src/debug/qemu-4.1.0/qapi/qmp-dispatch.c:165)
   #6 0xaaaac52a0a8f in qmp_dispatch (/usr/src/debug/qemu-4.1.0/monitor/qmp.c:125)
   #7 0xaaaac52a1c7f in monitor_qmp_dispatch (/usr/src/debug/qemu-4.1.0/monitor/qmp.c:214)
   #8 0xaaaac55cb0cf in aio_bh_call (/usr/src/debug/qemu-4.1.0/util/async.c:117)
   #9 0xaaaac55d4543 in aio_bh_poll (/usr/src/debug/qemu-4.1.0/util/aio-posix.c:459)
   #10 0xaaaac55cae0f in aio_dispatch (/usr/src/debug/qemu-4.1.0/util/async.c:268)
   #11 0xffffb52d6a7b in g_main_context_dispatch (/usr/lib64/libglib-2.0.so.0+0x52a7b)
   #12 0xaaaac55d1e3b(/usr/bin/qemu-kvm-4.1.0+0x1622e3b)
   #13 0xaaaac4e314bb(/usr/bin/qemu-kvm-4.1.0+0xe824bb)
   #14 0xaaaac47f45ef(/usr/bin/qemu-kvm-4.1.0+0x8455ef)
   #15 0xffffb4bfef3f in __libc_start_main (/usr/lib64/libc.so.6+0x23f3f)
   #16 0xaaaac47ffacb(/usr/bin/qemu-kvm-4.1.0+0x850acb)

Direct leak of 2 byte(s) in 2 object(s) allocated from:
   #0 0xffffb597c20b in __interceptor_malloc (/usr/lib64/libasan.so.4+0xd320b)
   #1 0xffffb52dcb1b in g_malloc (/usr/lib64/libglib-2.0.so.0+0x58b1b)
   #2 0xffffb52f8143 in g_strdup (/usr/lib64/libglib-2.0.so.0+0x74143)
   #3 0xaaaac5244893 in migrate_params_test_apply (/usr/src/debug/qemu-4.1.0/migration/migration.c:1382)
   #4 0xaaaac52fdca7 in qmp_migrate_set_parameters (/usr/src/debug/qemu-4.1.0/qapi/qapi-commands-migration.c:192)
   #5 0xaaaac551d543 in qmp_dispatch (/usr/src/debug/qemu-4.1.0/qapi/qmp-dispatch.c)
   #6 0xaaaac52a0a8f in qmp_dispatch (/usr/src/debug/qemu-4.1.0/monitor/qmp.c:125)
   #7 0xaaaac52a1c7f in monitor_qmp_dispatch (/usr/src/debug/qemu-4.1.0/monitor/qmp.c:214)
   #8 0xaaaac55cb0cf in aio_bh_call (/usr/src/debug/qemu-4.1.0/util/async.c:117)
   #9 0xaaaac55d4543 in aio_bh_poll (/usr/src/debug/qemu-4.1.0/util/aio-posix.c:459)
   #10 0xaaaac55cae0f in in aio_dispatch (/usr/src/debug/qemu-4.1.0/util/async.c:268)
   #11 0xffffb52d6a7b in g_main_context_dispatch (/usr/lib64/libglib-2.0.so.0+0x52a7b)
   #12 0xaaaac55d1e3b(/usr/bin/qemu-kvm-4.1.0+0x1622e3b)
   #13 0xaaaac4e314bb(/usr/bin/qemu-kvm-4.1.0+0xe824bb)
   #14 0xaaaac47f45ef (/usr/bin/qemu-kvm-4.1.0+0x8455ef)
   #15 0xffffb4bfef3f in __libc_start_main (/usr/lib64/libc.so.6+0x23f3f)
   #16 0xaaaac47ffacb(/usr/bin/qemu-kvm-4.1.0+0x850acb)

Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
Reviewed-by: KeQian Zhu <zhukeqian1@huawei.com>
Reviewed-by: HaiLiang <zhang.zhanghailiang@huawei.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2021-03-12 16:45:08 +08:00
openeuler-ci-bot
229c12efa6 !229 add iscsi rpm package requirement
From: @lijiajie128
Reviewed-by: @yorifang
Signed-off-by: @yorifang
2021-03-12 15:49:11 +08:00
Jiajie Li
c29fbf0083 add iscsi rpm package requirement 2021-03-11 21:10:41 +08:00
openeuler-ci-bot
30a9da64ef !220 [bugfix] iscsi: make iscsi rpm package
From: @lijiajie128
Reviewed-by: @yorifang
Signed-off-by: @yorifang
2021-03-10 16:39:06 +08:00
Jiajie Li
d82535f081 iscsi: make iscsi rpm package
Signed-off-by: Jiajie Li <lijiajie11@huawei.com>
2021-03-10 15:15:45 +08:00
openeuler-ci-bot
22d951e1e6 !214 qemu spec: configure for zstd
From: @lijiajie128
Reviewed-by: @yorifang
Signed-off-by: @yorifang
2021-03-04 09:18:37 +08:00
Jiajie Li
482b3d0cc3 qemu spec: add --enable-zstd to configure parameter
Signed-off-by: Jiajie Li <lijiajie11@huawei.com>
2021-03-03 14:47:59 +08:00
openeuler-ci-bot
5ad95274c0 !206 Automatically generate code patches with openeuler !77 !78
From: @zhendongchen
Reviewed-by: @yorifang,@yorifang
Signed-off-by: @yorifang,@yorifang
2021-02-27 14:53:20 +08:00
Euler Robot
6dd6890812 spec: Update release version with !77 !78
increase release verison by one

Signed-off-by: Euler Robot <euler.robot@huawei.com>
2021-02-26 16:28:21 +08:00
Euler Robot
f8f7dd42e8 spec: Update patch and changelog with !78
block-backend: Stop retrying when draining

Signed-off-by: Alex Chen <alex.chen@huawei.com>
2021-02-26 16:27:55 +08:00
Huawei Technologies Co., Ltd
5f96f6bac3 block-backend: Stop retrying when draining
Retrying failed requests when draining would make the draining hung. So it
is better not to trigger the retry timer when draining. And after the
virtual devices go back to work, they would retry those queued requests.

Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
Signed-off-by: Ying Fang <fangying1@huawei.com>
2021-02-26 16:27:55 +08:00
Euler Robot
f8b7dd549d spec: Update patch and changelog with !77
ide:atapi: check io_buffer_index in ide_atapi_cmd_reply_end

Signed-off-by: Alex Chen <alex.chen@huawei.com>
2021-02-26 16:27:53 +08:00
Huawei Technologies Co., Ltd
42a23f0a2f ide:atapi: check io_buffer_index in ide_atapi_cmd_reply_end
Fix CVE-2020-29443

During data transfer via packet command in 'ide_atapi_cmd_reply_end'
's->io_buffer_index' could exceed the 's->io_buffer' length, leading
to OOB access issue. Add check to avoid it.
 ...
 #9  ahci_pio_transfer ../hw/ide/ahci.c:1383
 #10 ide_transfer_start_norecurse ../hw/ide/core.c:553
 #11 ide_atapi_cmd_reply_end ../hw/ide/atapi.c:284
 #12 ide_atapi_cmd_read_pio ../hw/ide/atapi.c:329
 #13 ide_atapi_cmd_read ../hw/ide/atapi.c:442
 #14 cmd_read ../hw/ide/atapi.c:988
 #15 ide_atapi_cmd ../hw/ide/atapi.c:1352
 #16 ide_transfer_start ../hw/ide/core.c:561
 #17 cmd_packet ../hw/ide/core.c:1729
 #18 ide_exec_cmd ../hw/ide/core.c:2107
 #19 handle_reg_h2d_fis ../hw/ide/ahci.c:1267
 #20 handle_cmd ../hw/ide/ahci.c:1318
 #21 check_cmd ../hw/ide/ahci.c:592
 #22 ahci_port_write ../hw/ide/ahci.c:373
 #23 ahci_mem_write ../hw/ide/ahci.c:513

Reported-by: Wenxiang Qian <leonwxqian@gmail.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>

Signed-off-by: Jiajie Li <lijiajie11@huawei.com>
2021-02-26 16:27:53 +08:00
openeuler-ci-bot
84aba4188b !204 Automatically generate code patches with openeuler !71
From: @zhendongchen
Reviewed-by: @yorifang
Signed-off-by: @yorifang
2021-02-24 15:22:20 +08:00
Euler Robot
cfccf26734 spec: Update release version with !71
increase release verison by one

Signed-off-by: Euler Robot <euler.robot@huawei.com>
2021-02-19 21:28:48 +08:00
Euler Robot
e76de305cc spec: Update patch and changelog with !71
ati: use vga_read_byte in ati_cursor_define
sd: sdhci: assert data_count is within fifo_buffer
msix: add valid.accepts methods to check address

Signed-off-by: Alex Chen <alex.chen@huawei.com>
2021-02-19 21:27:56 +08:00
Huawei Technologies Co., Ltd
bd0d09f113 msix: add valid.accepts methods to check address
Fix CVE-2020-13754

While doing msi-x mmio operations, a guest may send an address
that leads to an OOB access issue. Add valid.accepts methods to
ensure that ensuing mmio r/w operation don't go beyond regions.

Reported-by: Ren Ding <rding@gatech.edu>
Reported-by: Hanqing Zhao <hanqing@gatech.edu>
Reported-by: Anatoly Trosinenko <anatoly.trosinenko@gmail.com>
Reported-by: Alexander Bulekov <alxndr@bu.edu>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>

patch link: https://lists.gnu.org/archive/html/qemu-devel/2020-06/msg00004.html
Signed-off-by: Jiajie Li <lijiajie11@huawei.com>
2021-02-19 21:27:56 +08:00
Huawei Technologies Co., Ltd
03ac057064 sd: sdhci: assert data_count is within fifo_buffer
Fix CVE-2020-17380

While doing multi block SDMA, transfer block size may exceed
the 's->fifo_buffer[s->buf_maxsz]' size. It may leave the
current element pointer 's->data_count' pointing out of bounds.
Leading the subsequent DMA r/w operation to OOB access issue.
Assert that 's->data_count' is within fifo_buffer.

 -> https://ruhr-uni-bochum.sciebo.de/s/NNWP2GfwzYKeKwE?path=%2Fsdhci_oob_write1
 ==1459837==ERROR: AddressSanitizer: heap-buffer-overflow
 WRITE of size 54722048 at 0x61500001e280 thread T3
 #0  __interceptor_memcpy (/lib64/libasan.so.6+0x3a71d)
 #1  flatview_read_continue ../exec.c:3245
 #2  flatview_read ../exec.c:3278
 #3  address_space_read_full ../exec.c:3291
 #4  address_space_rw ../exec.c:3319
 #5  dma_memory_rw_relaxed ../include/sysemu/dma.h:87
 #6  dma_memory_rw ../include/sysemu/dma.h:110
 #7  dma_memory_read ../include/sysemu/dma.h:116
 #8  sdhci_sdma_transfer_multi_blocks ../hw/sd/sdhci.c:629
 #9  sdhci_write ../hw/sd/sdhci.c:1097
 #10 memory_region_write_accessor ../softmmu/memory.c:483
 ...

Reported-by: Ruhr-University <bugs-syssec@rub.de>
Suggested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>

patch link: https://lists.nongnu.org/archive/html/qemu-devel/2020-09/msg01175.html
Signed-off-by: Jiajie Li <lijiajie11@hw.com>
2021-02-19 21:27:56 +08:00
Huawei Technologies Co., Ltd
ecc2505f20 ati: use vga_read_byte in ati_cursor_define
fix CVE-2019-20808

This makes sure reads are confined to vga video memory.

v3: use uint32_t, fix cut+paste bug.
v2: fix ati_cursor_draw_line too.

Reported-by: xu hang <flier_m@outlook.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20190917111441.27405-3-kraxel@redhat.com

cherry-pick from aab0e2a661b2b6bf7915c0aefe807fb60d6d9d13
Signed-off-by: Jiajie Li <lijiajie11@huawei.com>
2021-02-19 21:27:56 +08:00
openeuler-ci-bot
2e657fa808 !199 Automatically generate code patches with openeuler !69
From: @zhendongchen
Reviewed-by: @yorifang
Signed-off-by: @yorifang
2021-02-10 10:24:41 +08:00
Euler Robot
99eb051c68 spec: Update release version with !69
increase release verison by one

Signed-off-by: Euler Robot <euler.robot@huawei.com>
2021-02-04 16:28:08 +08:00
Euler Robot
ef3cb17353 spec: Update patch and changelog with !69
migration: Add multi-thread compress method
migration: Refactoring multi-thread compress migration
migration: Add multi-thread compress ops
migration: Add zstd support in multi-thread compression
migration: Add compress_level sanity check
doc: Update multi-thread compression doc
configure: Enable test and libs for zstd

Signed-off-by: Alex Chen <alex.chen@huawei.com>
2021-02-04 16:27:33 +08:00
Huawei Technologies Co., Ltd
086515ab47 configure: Enable test and libs for zstd
configure: Enable test and libs for zstd
Add it to several build systems to make testing good.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

Signed-off-by: Jiajie Li <lijiajie11@huawei.com>
2021-02-04 16:27:33 +08:00
Huawei Technologies Co., Ltd
928670c540 doc: Update multi-thread compression doc
Modify the doc to fit the previous changes.

Signed-off-by: Zeyu Jin <jinzeyu@huawei.com>
Signed-off-by: Ying Fang <fangying1@huawei.com>
2021-02-04 16:27:33 +08:00
Huawei Technologies Co., Ltd
1154612ba1 migration: Add compress_level sanity check
Zlib compression has level from 1 to 9. However Zstd compression has level
from 1 to 22 (level >= 20 not recommanded). Let's do sanity check here
to make sure a vaild compress_level is given by user.

Signed-off-by: Zeyu Jin <jinzeyu@huawei.com>
Signed-off-by: Ying Fang <fangying1@huawei.com>
2021-02-04 16:27:33 +08:00
Huawei Technologies Co., Ltd
e865b3f1cf migration: Add zstd support in multi-thread compression
This patch enables zstd option in multi-thread compression.

Signed-off-by: Zeyu Jin <jinzeyu@huawei.com>
Signed-off-by: Ying Fang <fangying1@huawei.com>
2021-02-04 16:27:33 +08:00
Huawei Technologies Co., Ltd
70bc9a5a34 migration: Add multi-thread compress ops
Add the MigrationCompressOps and MigrationDecompressOps structures to make
the compression method configurable for multi-thread compression migration.

Signed-off-by: Zeyu Jin <jinzeyu@huawei.com>
Signed-off-by: Ying Fang <fangying1@huawei.com>
2021-02-04 16:27:33 +08:00
Huawei Technologies Co., Ltd
e5ce7b7f34 migration: Refactoring multi-thread compress migration
Code refactor for the compression procedure which includes:

1. Move qemu_compress_data and qemu_put_compression_data from qemu-file.c to
ram.c, for the reason that most part of the code logical has nothing to do
with qemu-file. Besides, the decompression code is located at ram.c only.

2. Simplify the function input arguments for compression and decompression.
Wrap the input into the param structure which already exists. This change also
makes the function much more flexible for other compression methods.

Signed-off-by: Zeyu Jin <jinzeyu@huawei.com>
Signed-off-by: Ying Fang <fangying1@huawei.com>
2021-02-04 16:27:33 +08:00
Huawei Technologies Co., Ltd
9b2dc3992a migration: Add multi-thread compress method
A multi-thread compress method parameter is added to hold the method we
are going to use. By default the 'zlib' method is used to maintain the
compatibility as before.

Signed-off-by: Zeyu Jin <jinzeyu@huawei.com>
Signed-off-by: Ying Fang <fangying1@huawei.com>
2021-02-04 16:27:33 +08:00
openeuler-ci-bot
582fa99198 !197 Automatically generate code patches with openeuler !65
From: @zhendongchen
Reviewed-by: @yorifang
Signed-off-by: @yorifang
2021-02-01 10:23:15 +08:00
Euler Robot
34a1635015 spec: Update release version with !65
increase release verison by one

Signed-off-by: Euler Robot <euler.robot@huawei.com>
2021-01-30 16:26:59 +08:00
Euler Robot
4bffc50ac3 spec: Update patch and changelog with !65
scsi-bus: Refactor the code that retries requests
scsi-disk: Add support for retry on errors
qapi/block-core: Add retry option for error action
block-backend: Introduce retry timer
block-backend: Add device specific retry callback
block-backend: Enable retry action on errors
block-backend: Add timeout support for retry
block: Add error retry param setting
virtio-blk: Refactor the code that processes queued requests
virtio-blk: On restart, process queued requests in the proper context
virtio_blk: Add support for retry on errors

Signed-off-by: Alex Chen <alex.chen@huawei.com>
2021-01-30 16:26:59 +08:00
Huawei Technologies Co., Ltd
4b34648df6 virtio_blk: Add support for retry on errors
Insert failed requests into device's list for later retry and handle
queued requests to implement retry_request_cb.

Signed-off-by: Jiahui Cen <cenjiahui(a)huawei.com>
Signed-off-by: Ying Fang <fangying1(a)huawei.com>
2021-01-30 16:26:59 +08:00
Huawei Technologies Co., Ltd
42eba74d76 virtio-blk: On restart, process queued requests in the proper context
On restart, we were scheduling a BH to process queued requests, which
would run before starting up the data plane, leading to those requests
being assigned and started on coroutines on the main context.

This could cause requests to be wrongly processed in parallel from
different threads (the main thread and the iothread managing the data
plane), potentially leading to multiple issues.

For example, stopping and resuming a VM multiple times while the guest
is generating I/O on a virtio_blk device can trigger a crash with a
stack tracing looking like this one:

<------>
 Thread 2 (Thread 0x7ff736765700 (LWP 1062503)):
 #0  0x00005567a13b99d6 in iov_memset
     (iov=0x6563617073206f4e, iov_cnt=1717922848, offset=516096, fillc=0, bytes=7018105756081554803)
     at util/iov.c:69
 #1  0x00005567a13bab73 in qemu_iovec_memset
     (qiov=0x7ff73ec99748, offset=516096, fillc=0, bytes=7018105756081554803) at util/iov.c:530
 #2  0x00005567a12f411c in qemu_laio_process_completion (laiocb=0x7ff6512ee6c0) at block/linux-aio.c:86
 #3  0x00005567a12f42ff in qemu_laio_process_completions (s=0x7ff7182e8420) at block/linux-aio.c:217
 #4  0x00005567a12f480d in ioq_submit (s=0x7ff7182e8420) at block/linux-aio.c:323
 #5  0x00005567a12f43d9 in qemu_laio_process_completions_and_submit (s=0x7ff7182e8420)
     at block/linux-aio.c:236
 #6  0x00005567a12f44c2 in qemu_laio_poll_cb (opaque=0x7ff7182e8430) at block/linux-aio.c:267
 #7  0x00005567a13aed83 in run_poll_handlers_once (ctx=0x5567a2b58c70, timeout=0x7ff7367645f8)
     at util/aio-posix.c:520
 #8  0x00005567a13aee9f in run_poll_handlers (ctx=0x5567a2b58c70, max_ns=16000, timeout=0x7ff7367645f8)
     at util/aio-posix.c:562
 #9  0x00005567a13aefde in try_poll_mode (ctx=0x5567a2b58c70, timeout=0x7ff7367645f8)
     at util/aio-posix.c:597
 #10 0x00005567a13af115 in aio_poll (ctx=0x5567a2b58c70, blocking=true) at util/aio-posix.c:639
 #11 0x00005567a109acca in iothread_run (opaque=0x5567a2b29760) at iothread.c:75
 #12 0x00005567a13b2790 in qemu_thread_start (args=0x5567a2b694c0) at util/qemu-thread-posix.c:519
 #13 0x00007ff73eedf2de in start_thread () at /lib64/libpthread.so.0
 #14 0x00007ff73ec10e83 in clone () at /lib64/libc.so.6

 Thread 1 (Thread 0x7ff743986f00 (LWP 1062500)):
 #0  0x00005567a13b99d6 in iov_memset
     (iov=0x6563617073206f4e, iov_cnt=1717922848, offset=516096, fillc=0, bytes=7018105756081554803)
     at util/iov.c:69
 #1  0x00005567a13bab73 in qemu_iovec_memset
     (qiov=0x7ff73ec99748, offset=516096, fillc=0, bytes=7018105756081554803) at util/iov.c:530
 #2  0x00005567a12f411c in qemu_laio_process_completion (laiocb=0x7ff6512ee6c0) at block/linux-aio.c:86
 #3  0x00005567a12f42ff in qemu_laio_process_completions (s=0x7ff7182e8420) at block/linux-aio.c:217
 #4  0x00005567a12f480d in ioq_submit (s=0x7ff7182e8420) at block/linux-aio.c:323
 #5  0x00005567a12f4a2f in laio_do_submit (fd=19, laiocb=0x7ff5f4ff9ae0, offset=472363008, type=2)
     at block/linux-aio.c:375
 #6  0x00005567a12f4af2 in laio_co_submit
     (bs=0x5567a2b8c460, s=0x7ff7182e8420, fd=19, offset=472363008, qiov=0x7ff5f4ff9ca0, type=2)
     at block/linux-aio.c:394
 #7  0x00005567a12f1803 in raw_co_prw
     (bs=0x5567a2b8c460, offset=472363008, bytes=20480, qiov=0x7ff5f4ff9ca0, type=2)
     at block/file-posix.c:1892
 #8  0x00005567a12f1941 in raw_co_pwritev
     (bs=0x5567a2b8c460, offset=472363008, bytes=20480, qiov=0x7ff5f4ff9ca0, flags=0)
     at block/file-posix.c:1925
 #9  0x00005567a12fe3e1 in bdrv_driver_pwritev
     (bs=0x5567a2b8c460, offset=472363008, bytes=20480, qiov=0x7ff5f4ff9ca0, qiov_offset=0, flags=0)
     at block/io.c:1183
 #10 0x00005567a1300340 in bdrv_aligned_pwritev
     (child=0x5567a2b5b070, req=0x7ff5f4ff9db0, offset=472363008, bytes=20480, align=512, qiov=0x7ff72c0425b8, qiov_offset=0, flags=0) at block/io.c:1980
 #11 0x00005567a1300b29 in bdrv_co_pwritev_part
     (child=0x5567a2b5b070, offset=472363008, bytes=20480, qiov=0x7ff72c0425b8, qiov_offset=0, flags=0)
     at block/io.c:2137
 #12 0x00005567a12baba1 in qcow2_co_pwritev_task
     (bs=0x5567a2b92740, file_cluster_offset=472317952, offset=487305216, bytes=20480, qiov=0x7ff72c0425b8, qiov_offset=0, l2meta=0x0) at block/qcow2.c:2444
 #13 0x00005567a12bacdb in qcow2_co_pwritev_task_entry (task=0x5567a2b48540) at block/qcow2.c:2475
 #14 0x00005567a13167d8 in aio_task_co (opaque=0x5567a2b48540) at block/aio_task.c:45
 #15 0x00005567a13cf00c in coroutine_trampoline (i0=738245600, i1=32759) at util/coroutine-ucontext.c:115
 #16 0x00007ff73eb622e0 in __start_context () at /lib64/libc.so.6
 #17 0x00007ff6626f1350 in  ()
 #18 0x0000000000000000 in  ()
<------>

This is also known to cause crashes with this message (assertion
failed):

 aio_co_schedule: Co-routine was already scheduled in 'aio_co_schedule'

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1812765
Signed-off-by: Sergio Lopez <slp(a)redhat.com>
Message-Id: <20200603093240.40489-3-slp(a)redhat.com>
Signed-off-by: Kevin Wolf <kwolf(a)redhat.com>
2021-01-30 16:26:59 +08:00