7f1c5b import qemu-kvm-7.2.0-10.el9

Authored and Committed by centosrcm 2 years ago
245 files changed. 16490 lines added. 16423 lines removed.
.gitignore
file modified
+1 -1
.qemu-kvm.metadata
file modified
+1 -1
SOURCES/0004-Initial-redhat-build.patch
file modified
+31 -42
SOURCES/0005-Enable-disable-devices-for-RHEL.patch
file modified
+90 -75
SOURCES/0006-Machine-type-related-general-changes.patch
file modified
+93 -47
SOURCES/0007-Add-aarch64-machine-types.patch
file modified
+345 -22
SOURCES/0008-Add-ppc64-machine-types.patch
file modified
+38 -22
SOURCES/0009-Add-s390x-machine-types.patch
file modified
+105 -45
SOURCES/0010-Add-x86_64-machine-types.patch
file modified
+224 -64
SOURCES/0011-Enable-make-check.patch
file modified
+95 -20
SOURCES/0012-vfio-cap-number-of-devices-that-can-be-assigned.patch
file modified
+11 -11
SOURCES/0013-Add-support-statement-to-help-output.patch
file modified
+4 -4
SOURCES/0014-Use-qemu-kvm-in-documentation-instead-of-qemu-system.patchSOURCES/0015-Use-qemu-kvm-in-documentation-instead-of-qemu-system.patch
file renamed
+4 -4
SOURCES/0014-globally-limit-the-maximum-number-of-CPUs.patch
file removed
-45
SOURCES/0015-BZ1653590-Require-at-least-64kiB-pages-for-downstrea.patchSOURCES/0017-BZ1653590-Require-at-least-64kiB-pages-for-downstrea.patch
file renamed
+2 -2
SOURCES/0016-qcow2-Deprecation-warning-when-opening-v2-images-rw.patchSOURCES/0018-qcow2-Deprecation-warning-when-opening-v2-images-rw.patch
file renamed
+3 -3
SOURCES/0016-virtio-scsi-Reject-scsi-cd-if-data-plane-enabled-RHE.patch
file removed
-66
SOURCES/0018-Addd-7.2-compat-bits-for-RHEL-9.1-machine-type.patch
file added
+26
SOURCES/0019-WRB-Introduce-RHEL-9.0.0-hw-compat-structure.patch
file removed
-135
SOURCES/0019-redhat-Update-s390x-machine-type-compatibility-for-Q.patch
file added
+47
SOURCES/0020-redhat-Update-s390x-machine-type-compatibility-for-r.patch
file removed
-38
SOURCES/0020-redhat-aarch64-add-rhel9.2.0-virt-machine-type.patch
file added
+43
SOURCES/0021-pc-Move-s3-s4-suspend-disabling-to-compat.patch
file removed
-70
SOURCES/0021-redhat-Add-new-rhel-9.2.0-s390x-machine-type.patch
file added
+62
SOURCES/0022-x86-rhel-9.2.0-machine-type.patch
file added
+75
SOURCES/kvm-Add-dirty-sync-missed-zero-copy-migration-stat.patch
file removed
-87
SOURCES/kvm-Enable-virtio-iommu-pci-on-aarch64.patch
file removed
-41
SOURCES/kvm-Enable-virtio-iommu-pci-on-x86_64.patch
file removed
-41
SOURCES/kvm-Introduce-event-loop-base-abstract-class.patch
file removed
-503
SOURCES/kvm-KVM-keep-track-of-running-ioctls.patch
file added
+82
SOURCES/kvm-QIOChannel-Add-flags-on-io_writev-and-introduce-io_f.patch
file removed
-420
SOURCES/kvm-QIOChannelSocket-Add-support-for-MSG_ZEROCOPY-IPV6.patch
file removed
-56
SOURCES/kvm-QIOChannelSocket-Fix-zero-copy-flush-returning-code-.patch
file removed
-65
SOURCES/kvm-QIOChannelSocket-Fix-zero-copy-send-so-socket-flush-.patch
file removed
-58
SOURCES/kvm-QIOChannelSocket-Implement-io_writev-zero-copy-flag-.patch
file removed
-249
SOURCES/kvm-QIOChannelSocket-Introduce-assert-and-reduce-ifdefs-.patch
file removed
-82
SOURCES/kvm-RHEL-only-AArch64-Drop-unsupported-CPU-types.patch
file removed
-237
SOURCES/kvm-RHEL-only-tests-avocado-Switch-aarch64-tests-from-a5.patch
file removed
-95
SOURCES/kvm-Revert-globally-limit-the-maximum-number-of-CPUs.patch
file removed
-58
SOURCES/kvm-Revert-migration-Simplify-unqueue_page.patch
file removed
-134
SOURCES/kvm-Revert-vhost-user-Introduce-nested-event-loop-in-vho.patch
file added
+140
SOURCES/kvm-Revert-vhost-user-Monitor-slave-channel-in-vhost_use.patch
file added
+143
SOURCES/kvm-Revert-virtio-scsi-Reject-scsi-cd-if-data-plane-enab.patch
file removed
-51
SOURCES/kvm-accel-introduce-accelerator-blocker-API.patch
file added
+348
SOURCES/kvm-accel-tcg-Test-CPUJumpCache-in-tb_jmp_cache_clear_pa.patch
file added
+58
SOURCES/kvm-block-Call-drain-callbacks-only-once.patch
file added
+250
SOURCES/kvm-block-Don-t-poll-in-bdrv_replace_child_noperm.patch
file added
+298
SOURCES/kvm-block-Don-t-use-subtree-drains-in-bdrv_drop_intermed.patch
file added
+54
SOURCES/kvm-block-Drain-individual-nodes-during-reopen.patch
file added
+157
SOURCES/kvm-block-Drop-out-of-coroutine-in-bdrv_do_drained_begin.patch
file added
+96
SOURCES/kvm-block-Fix-locking-for-bdrv_reopen_queue_child.patch
file added
+67
SOURCES/kvm-block-Improve-empty-format-specific-info-dump.patch
file added
+132
SOURCES/kvm-block-Inline-bdrv_drain_invoke.patch
file added
+81
SOURCES/kvm-block-Remove-drained_end_counter.patch
file added
+433
SOURCES/kvm-block-Remove-ignore_bds_parents-parameter-from-drain.patch
file added
+274
SOURCES/kvm-block-Remove-poll-parameter-from-bdrv_parent_drained.patch
file added
+106
SOURCES/kvm-block-Remove-subtree-drains.patch
file added
+896
SOURCES/kvm-block-Revert-.bdrv_drained_begin-end-to-non-coroutin.patch
file added
+302
SOURCES/kvm-block-Split-BlockNodeInfo-off-of-ImageInfo.patch
file added
+246
SOURCES/kvm-block-drop-bdrv_remove_filter_or_cow_child.patch
file added
+70
SOURCES/kvm-block-file-Add-file-specific-image-info.patch
file added
+145
SOURCES/kvm-block-qapi-Add-indentation-to-bdrv_node_info_dump.patch
file added
+206
SOURCES/kvm-block-qapi-Introduce-BlockGraphInfo.patch
file added
+155
SOURCES/kvm-block-qapi-Let-bdrv_query_image_info-recurse.patch
file added
+197
SOURCES/kvm-block-temporarily-hold-the-new-AioContext-of-bs_top-.patch
file added
+99
SOURCES/kvm-block-vmdk-Change-extent-info-type.patch
file added
+140
SOURCES/kvm-configs-devices-aarch64-softmmu-Enable-CONFIG_VIRTIO.patch
file removed
-41
SOURCES/kvm-coroutine-Rename-qemu_coroutine_inc-dec_pool_size.patch
file removed
-101
SOURCES/kvm-coroutine-Revert-to-constant-batch-size.patch
file removed
-138
SOURCES/kvm-coroutine-ucontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch
file removed
-132
SOURCES/kvm-coroutine-use-QEMU_DEFINE_STATIC_CO_TLS.patch
file removed
-139
SOURCES/kvm-coroutine-win32-use-QEMU_DEFINE_STATIC_CO_TLS.patch
file removed
-99
SOURCES/kvm-hw-acpi-aml-build-Use-existing-CPU-topology-to-build.patch
file removed
-179
SOURCES/kvm-hw-arm-virt-Add-compact-highmem-property.patch
file added
+169
SOURCES/kvm-hw-arm-virt-Add-properties-to-disable-high-memory-re.patch
file added
+179
SOURCES/kvm-hw-arm-virt-Consider-SMP-configuration-in-CPU-topolo.patch
file removed
-74
SOURCES/kvm-hw-arm-virt-Enable-compat-high-memory-region-address.patch
file added
+51
SOURCES/kvm-hw-arm-virt-Fix-CPU-s-default-NUMA-node-ID.patch
file removed
-88
SOURCES/kvm-hw-arm-virt-Fix-missing-initialization-in-instance-c.patch
file removed
-56
SOURCES/kvm-hw-arm-virt-Improve-high-memory-region-address-assig.patch
file added
+112
SOURCES/kvm-hw-arm-virt-Introduce-variable-region_base-in-virt_s.patch
file added
+82
SOURCES/kvm-hw-arm-virt-Introduce-virt_get_high_memmap_enabled-h.patch
file added
+95
SOURCES/kvm-hw-arm-virt-Introduce-virt_set_high_memmap-helper.patch
file added
+130
SOURCES/kvm-hw-arm-virt-Remove-the-dtb-kaslr-seed-machine-option.patch
file removed
-76
SOURCES/kvm-hw-arm-virt-Rename-variable-size-to-region_size-in-v.patch
file added
+83
SOURCES/kvm-hw-block-fdc-Prevent-end-of-track-overrun-CVE-2021-3.patch
file removed
-96
SOURCES/kvm-hw-virtio-Replace-g_memdup-by-g_memdup2.patch
file removed
-95
SOURCES/kvm-io-Add-support-for-MSG_PEEK-for-socket-channel.patch
file added
+386
SOURCES/kvm-iotests-106-214-308-Read-only-one-size-line.patch
file added
+99
SOURCES/kvm-iotests-108-Fix-when-missing-user_allow_other.patch
file removed
-52
SOURCES/kvm-iotests-108-Test-new-refcount-rebuild-algorithm.patch
file removed
-445
SOURCES/kvm-iotests-Filter-child-node-information.patch
file added
+171
SOURCES/kvm-kvm-Atomic-memslot-updates.patch
file added
+286
SOURCES/kvm-kvm-don-t-use-perror-without-useful-errno.patch
file removed
-62
SOURCES/kvm-linux-aio-explain-why-max-batch-is-checked-in-laio_i.patch
file removed
-49
SOURCES/kvm-linux-aio-fix-unbalanced-plugged-counter-in-laio_io_.patch
file removed
-56
SOURCES/kvm-linux-headers-Update-to-v6.1.patch
file added
+577
SOURCES/kvm-meson-create-have_vhost_-variables.patch
file removed
-154
SOURCES/kvm-meson-use-have_vhost_-variables-to-pick-sources.patch
file removed
-213
SOURCES/kvm-meson.build-Fix-docker-test-build-alpine-when-includ.patch
file removed
-87
SOURCES/kvm-migration-Add-migrate_use_tls-helper.patch
file removed
-106
SOURCES/kvm-migration-Add-zero-copy-send-parameter-for-QMP-HMP-f.patch
file removed
-250
SOURCES/kvm-migration-Allow-migrate-recover-to-run-multiple-time.patch
file removed
-98
SOURCES/kvm-migration-Avoid-false-positive-on-non-supported-scen.patch
file removed
-93
SOURCES/kvm-migration-Change-zero_copy_send-from-migration-param.patch
file removed
-289
SOURCES/kvm-migration-Fix-operator-type.patch
file removed
-47
SOURCES/kvm-migration-add-remaining-params-has_-true-in-migratio.patch
file removed
-62
SOURCES/kvm-migration-check-magic-value-for-deciding-the-mapping.patch
file added
+330
SOURCES/kvm-migration-multifd-Report-to-user-when-zerocopy-not-w.patch
file removed
-83
SOURCES/kvm-multifd-Copy-pages-before-compressing-them-with-zlib.patch
file removed
-142
SOURCES/kvm-multifd-Implement-zero-copy-write-in-multifd-migrati.patch
file removed
-182
SOURCES/kvm-multifd-Send-header-packet-without-flags-if-zero-cop.patch
file removed
-102
SOURCES/kvm-multifd-multifd_send_sync_main-now-returns-negative-.patch
file removed
-163
SOURCES/kvm-nbd-server-Allow-MULTI_CONN-for-shared-writable-expo.patch
file removed
-381
SOURCES/kvm-net-stream-add-a-new-option-to-automatically-reconne.patch
file added
+325
SOURCES/kvm-pc-bios-s390-ccw-Fix-booting-with-logical-block-size.patch
file removed
-63
SOURCES/kvm-pc-bios-s390-ccw-Split-virtio-scsi-code-from-virtio_.patch
file removed
-180
SOURCES/kvm-pc-bios-s390-ccw-bootmap-Improve-the-guessing-logic-.patch
file removed
-102
SOURCES/kvm-pc-bios-s390-ccw-netboot.mak-Ignore-Clang-s-warnings.patch
file removed
-78
SOURCES/kvm-pc-bios-s390-ccw-virtio-Beautify-the-code-for-readin.patch
file removed
-56
SOURCES/kvm-pc-bios-s390-ccw-virtio-Introduce-a-macro-for-the-DA.patch
file removed
-63
SOURCES/kvm-pc-bios-s390-ccw-virtio-Read-device-config-after-fea.patch
file removed
-67
SOURCES/kvm-pc-bios-s390-ccw-virtio-Set-missing-status-bits-whil.patch
file removed
-93
SOURCES/kvm-pc-bios-s390-ccw-virtio-blkdev-Remove-virtio_assume_.patch
file removed
-101
SOURCES/kvm-pc-bios-s390-ccw-virtio-blkdev-Request-the-right-fea.patch
file removed
-63
SOURCES/kvm-pc-bios-s390-ccw-virtio-blkdev-Simplify-fix-virtio_i.patch
file removed
-124
SOURCES/kvm-qapi-machine.json-Add-cluster-id.patch
file removed
-126
SOURCES/kvm-qcow2-Add-errp-to-rebuild_refcount_structure.patch
file removed
-162
SOURCES/kvm-qcow2-Fix-theoretical-corruption-in-store_bitmap-err.patch
file added
+67
SOURCES/kvm-qcow2-Improve-refcount-structure-rebuilding.patch
file removed
-465
SOURCES/kvm-qed-Don-t-yield-in-bdrv_qed_co_drain_begin.patch
file added
+84
SOURCES/kvm-qemu-img-Change-info-key-names-for-protocol-nodes.patch
file added
+197
SOURCES/kvm-qemu-img-Let-info-print-block-graph.patch
file added
+261
SOURCES/kvm-qemu-img-Use-BlockNodeInfo.patch
file added
+241
SOURCES/kvm-qemu-img-bitmap-Report-errors-while-closing-the-imag.patch
file added
+70
SOURCES/kvm-qemu-img-commit-Report-errors-while-closing-the-imag.patch
file added
+67
SOURCES/kvm-qemu-iotests-Test-qemu-img-bitmap-commit-exit-code-o.patch
file added
+166
SOURCES/kvm-qemu-nbd-Pass-max-connections-to-blockdev-layer.patch
file removed
-92
SOURCES/kvm-qga-linux-add-usb-support-to-guest-get-fsinfo.patch
file added
+49
SOURCES/kvm-qtest-numa-test-Correct-CPU-and-NUMA-association-in-.patch
file removed
-100
SOURCES/kvm-qtest-numa-test-Specify-CPU-topology-in-aarch64_numa.patch
file removed
-68
SOURCES/kvm-redhat-Update-linux-headers-linux-kvm.h-to-v5.18-rc6.patch
file removed
-106
SOURCES/kvm-redhat-fix-virt-rhel9.2.0-compat-props.patch
file added
+43
SOURCES/kvm-s390x-pci-coalesce-unmap-operations.patch
file added
+125
SOURCES/kvm-s390x-pci-reset-ISM-passthrough-devices-on-shutdown-.patch
file added
+147
SOURCES/kvm-s390x-pci-shrink-DMA-aperture-to-be-bound-by-vfio-DM.patch
file added
+91
SOURCES/kvm-s390x-pv-Implement-a-CGS-check-helper.patch
file added
+109
SOURCES/kvm-s390x-s390-virtio-ccw-Activate-zPCI-features-on-s390.patch
file added
+70
SOURCES/kvm-stream-Replace-subtree-drain-with-a-single-node-drai.patch
file added
+159
SOURCES/kvm-sysemu-tpm-Add-a-stub-function-for-TPM_IS_CRB.patch
file removed
-54
SOURCES/kvm-target-arm-deprecate-named-CPU-models.patch
file removed
-129
SOURCES/kvm-target-i386-deprecate-CPUs-older-than-x86_64-v2-ABI.patch
file removed
-273
SOURCES/kvm-target-ppc-cpu-models-Fix-ppc_cpu_aliases-list-for-R.patch
file removed
-48
SOURCES/kvm-target-s390x-arch_dump-Fix-memory-corruption-in-s390.patch
file added
+50
SOURCES/kvm-target-s390x-deprecate-CPUs-older-than-z14.patch
file removed
-194
SOURCES/kvm-target-s390x-kvm-Honor-storage-keys-during-emulation.patch
file removed
-103
SOURCES/kvm-test-bdrv-drain-Don-t-yield-in-.bdrv_co_drained_begi.patch
file added
+153
SOURCES/kvm-tests-avocado-update-aarch64_virt-test-to-exercise-c.patch
file removed
-157
SOURCES/kvm-tests-qtest-fdc-test-Add-a-regression-test-for-CVE-2.patch
file removed
-119
SOURCES/kvm-tests-qtest-netdev-test-stream-and-dgram-backends.patch
file added
+505
SOURCES/kvm-util-event-loop-base-Introduce-options-to-set-the-th.patch
file removed
-385
SOURCES/kvm-util-main-loop-Introduce-the-main-loop-into-QOM.patch
file removed
-233
SOURCES/kvm-util-userfaultfd-Add-uffd_open.patch
file added
+169
SOURCES/kvm-util-userfaultfd-Support-dev-userfaultfd.patch
file added
+94
SOURCES/kvm-vdpa-Add-device-migration-blocker.patch
file removed
-106
SOURCES/kvm-vdpa-Add-x-svq-to-NetdevVhostVDPAOptions.patch
file removed
-223
SOURCES/kvm-vdpa-Avoid-compiler-to-squash-reads-to-used-idx.patch
file removed
-65
SOURCES/kvm-vdpa-Buffer-CVQ-support-on-shadow-virtqueue.patch
file removed
-323
SOURCES/kvm-vdpa-Export-vhost_vdpa_dma_map-and-unmap-calls.patch
file removed
-84
SOURCES/kvm-vdpa-Extract-get-features-part-from-vhost_vdpa_get_m.patch
file removed
-108
SOURCES/kvm-vdpa-Fix-bad-index-calculus-at-vhost_vdpa_get_vring_.patch
file removed
-50
SOURCES/kvm-vdpa-Fix-file-descriptor-leak-on-get-features-error.patch
file removed
-58
SOURCES/kvm-vdpa-Fix-index-calculus-at-vhost_vdpa_svqs_start.patch
file removed
-45
SOURCES/kvm-vdpa-Fix-memory-listener-deletions-of-iova-tree.patch
file removed
-61
SOURCES/kvm-vdpa-add-asid-parameter-to-vhost_vdpa_dma_map-unmap.patch
file added
+221
SOURCES/kvm-vdpa-add-shadow_data-to-vhost_vdpa.patch
file added
+94
SOURCES/kvm-vdpa-add-vhost_vdpa_net_valid_svq_features.patch
file added
+76
SOURCES/kvm-vdpa-allocate-SVQ-array-unconditionally.patch
file added
+50
SOURCES/kvm-vdpa-always-start-CVQ-in-SVQ-mode-if-possible.patch
file added
+193
SOURCES/kvm-vdpa-do-not-handle-VIRTIO_NET_F_GUEST_ANNOUNCE-in-vh.patch
file added
+44
SOURCES/kvm-vdpa-fix-VHOST_BACKEND_F_IOTLB_ASID-flag-check.patch
file added
+48
SOURCES/kvm-vdpa-handle-VIRTIO_NET_CTRL_ANNOUNCE-in-vhost_vdpa_n.patch
file added
+59
SOURCES/kvm-vdpa-manual-forward-CVQ-buffers.patch
file removed
-166
SOURCES/kvm-vdpa-move-SVQ-vring-features-check-to-net.patch
file added
+118
SOURCES/kvm-vdpa-request-iova_range-only-once.patch
file added
+145
SOURCES/kvm-vdpa-store-x-svq-parameter-in-VhostVDPAState.patch
file added
+62
SOURCES/kvm-vdpa-use-v-shadow_vqs_enabled-in-vhost_vdpa_svqs_sta.patch
file added
+58
SOURCES/kvm-vfio-common-remove-spurious-tpm-crb-cmd-misalignment.patch
file removed
-114
SOURCES/kvm-vfio-common-remove-spurious-warning-on-vfio_listener.patch
file removed
-78
SOURCES/kvm-vhost-Add-SVQDescState.patch
file removed
-135
SOURCES/kvm-vhost-Add-svq-avail_handler-callback.patch
file removed
-164
SOURCES/kvm-vhost-Check-for-queue-full-at-vhost_svq_add.patch
file removed
-134
SOURCES/kvm-vhost-Decouple-vhost_svq_add-from-VirtQueueElement.patch
file removed
-138
SOURCES/kvm-vhost-Expose-vhost_svq_add.patch
file removed
-73
SOURCES/kvm-vhost-Fix-device-s-used-descriptor-dequeue.patch
file removed
-83
SOURCES/kvm-vhost-Fix-element-in-vhost_svq_add-failure.patch
file removed
-68
SOURCES/kvm-vhost-Move-vhost_svq_kick-call-to-vhost_svq_add.patch
file removed
-61
SOURCES/kvm-vhost-Reorder-vhost_svq_kick.patch
file removed
-88
SOURCES/kvm-vhost-Track-descriptor-chain-in-private-at-SVQ.patch
file removed
-123
SOURCES/kvm-vhost-Track-number-of-descs-in-SVQDescState.patch
file removed
-81
SOURCES/kvm-vhost-add-support-for-configure-interrupt.patch
file added
+185
SOURCES/kvm-vhost-add-vhost_svq_poll.patch
file removed
-92
SOURCES/kvm-vhost-add-vhost_svq_push_elem.patch
file removed
-83
SOURCES/kvm-vhost-allocate-SVQ-device-file-descriptors-at-device.patch
file added
+171
SOURCES/kvm-vhost-fix-vq-dirty-bitmap-syncing-when-vIOMMU-is-ena.patch
file added
+157
SOURCES/kvm-vhost-introduce-new-VhostOps-vhost_set_config_call.patch
file added
+56
SOURCES/kvm-vhost-move-descriptor-translation-to-vhost_svq_vring.patch
file removed
-120
SOURCES/kvm-vhost-move-iova_tree-set-to-vhost_svq_start.patch
file added
+122
SOURCES/kvm-vhost-net-fix-improper-cleanup-in-vhost_net_start.patch
file removed
-56
SOURCES/kvm-vhost-net-vdpa-add-stubs-for-when-no-virtio-net-devi.patch
file removed
-87
SOURCES/kvm-vhost-set-SVQ-device-call-handler-at-SVQ-start.patch
file added
+73
SOURCES/kvm-vhost-vdpa-add-support-for-config-interrupt.patch
file added
+73
SOURCES/kvm-vhost-vdpa-backend-feature-should-set-only-once.patch
file removed
-58
SOURCES/kvm-vhost-vdpa-change-name-and-polarity-for-vhost_vdpa_o.patch
file removed
-123
SOURCES/kvm-vhost-vdpa-fix-improper-cleanup-in-net_init_vhost_vd.patch
file removed
-48
SOURCES/kvm-virtio-add-support-for-configure-interrupt.patch
file added
+115
SOURCES/kvm-virtio-introduce-macro-VIRTIO_CONFIG_IRQ_IDX.patch
file added
+262
SOURCES/kvm-virtio-iommu-Add-an-assert-check-in-translate-routin.patch
file removed
-46
SOURCES/kvm-virtio-iommu-Add-bypass-mode-support-to-assigned-dev.patch
file removed
-250
SOURCES/kvm-virtio-iommu-Fix-migration-regression.patch
file removed
-54
SOURCES/kvm-virtio-iommu-Fix-the-partial-copy-of-probe-request.patch
file removed
-67
SOURCES/kvm-virtio-iommu-Use-recursive-lock-to-avoid-deadlock.patch
file removed
-141
SOURCES/kvm-virtio-mmio-add-support-for-configure-interrupt.patch
file added
+80
SOURCES/kvm-virtio-net-Expose-MAC_TABLE_ENTRIES.patch
file removed
-69
SOURCES/kvm-virtio-net-Expose-ctrl-virtqueue-logic.patch
file removed
-169
SOURCES/kvm-virtio-net-add-support-for-configure-interrupt.patch
file added
+115
SOURCES/kvm-virtio-net-align-ctrl_vq-index-for-non-mq-guest-for-.patch
file removed
-143
SOURCES/kvm-virtio-net-don-t-handle-mq-request-in-userspace-hand.patch
file removed
-109
SOURCES/kvm-virtio-net-setup-vhost_dev-and-notifiers-for-cvq-onl.patch
file removed
-52
SOURCES/kvm-virtio-pci-add-support-for-configure-interrupt.patch
file added
+274
SOURCES/kvm-virtio-pci-decouple-notifier-from-interrupt-process.patch
file added
+272
SOURCES/kvm-virtio-pci-decouple-the-single-vector-from-the-inter.patch
file added
+212
SOURCES/kvm-virtio-rng-pci-fix-migration-compat-for-vectors.patch
file added
+53
SOURCES/kvm-virtio-rng-pci-fix-transitional-migration-compat-for.patch
file added
+47
SOURCES/kvm-virtio-scsi-clean-up-virtio_scsi_handle_cmd_vq.patch
file removed
-77
SOURCES/kvm-virtio-scsi-clean-up-virtio_scsi_handle_ctrl_vq.patch
file removed
-65
SOURCES/kvm-virtio-scsi-clean-up-virtio_scsi_handle_event_vq.patch
file removed
-62
SOURCES/kvm-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch
file removed
-103
SOURCES/kvm-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch
file removed
-119
SOURCES/kvm-virtio-scsi-move-request-related-items-from-.h-to-.c.patch
file removed
-168
SOURCES/kvm-virtio_net-Modify-virtio_net_get_config-to-early-ret.patch
file added
+74
SOURCES/kvm-virtio_net-copy-VIRTIO_NET_S_ANNOUNCE-if-device-mode.patch
file added
+46
SOURCES/qemu-ga.sysconfig
file modified
+4 -4
SOURCES/qemu-guest-agent.service
file modified
+1 -1
SPECS/qemu-kvm.spec
file modified
+463 -300
    import qemu-kvm-7.2.0-10.el9
    
        
file modified
+1 -1
.gitignore CHANGED
@@ -1 +1 @@
1
- SOURCES/qemu-7.0.0.tar.xz
1
+ SOURCES/qemu-7.2.0.tar.xz
file modified
+1 -1
.qemu-kvm.metadata CHANGED
@@ -1 +1 @@
1
- c3fd2403106c33d0470bc9ba4fb4b946c0402248 SOURCES/qemu-7.0.0.tar.xz
1
+ 634a3e4b381cbf13085eb1568accb85cbd9d89c4 SOURCES/qemu-7.2.0.tar.xz
SOURCES/0004-Initial-redhat-build.patch CHANGED
@@ -1,4 +1,4 @@
1
- From fc113ecd7c99646a7ced0b99570b5927ae6d595f Mon Sep 17 00:00:00 2001
1
+ From ccc4a5bdc8c2f27678312364a7c12aeafd009bb6 Mon Sep 17 00:00:00 2001
2
2
From: Miroslav Rezanina <mrezanin@redhat.com>
3
3
Date: Wed, 26 May 2021 10:56:02 +0200
4
4
Subject: Initial redhat build
@@ -13,7 +13,7 @@ several issues are fixed in QEMU tree:
13
13
14
14
We disable make check due to issues with some of the tests.
15
15
16
- This rebase is based on qemu-kvm-6.2.0-13.el9
16
+ This rebase is based on qemu-kvm-7.1.0-7.el9
17
17
18
18
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
19
19
--
@@ -50,6 +50,22 @@ Rebase changes (7.0.0):
50
50
- Change permissions on installing tests/Makefile.include
51
51
- Remove ssh block driver
52
52
53
+ Rebase changes (7.1.0 rc0):
54
+ - --disable-vnc-png renamed to --disable-png (upstream)
55
+ - removed --disable-vhost-vsock and --disable-vhost-scsi
56
+ - capstone submodule removed
57
+ - Temporary include capstone build
58
+
59
+ Rebase changes (7.2.0 rc0):
60
+ - Switch --enable-slirp=system to --enable-slirp
61
+
62
+ Rebaes changes (7.2.0 rc2):
63
+ - Added new configure options (blkio and sndio, both disabled)
64
+
65
+ Rebase changes (7.2.0):
66
+ - Fix SRPM name generation to work on Fedora 37
67
+ - Switch back to system meson
68
+
53
69
Merged patches (6.0.0):
54
70
- 605758c902 Limit build on Power to qemu-img and qemu-ga only
55
71
@@ -142,46 +158,34 @@ Merged patches (7.0.0):
142
158
- d46d2710b2 spec: Obsolete old usb redir subpackage
143
159
- 6f52a50b68 spec: Obsolete ssh driver
144
160
161
+ Merged patches (7.2.0 rc4):
162
+ - 8c6834feb6 Remove opengl display device subpackages (C9S MR 124)
163
+ - 0ecc97f29e spec: Add requires for packages with additional virtio-gpu variants (C9S MR 124)
164
+
145
165
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
166
+
167
+ fix
146
168
---
147
- .distro/85-kvm.preset | 5 -
148
169
.distro/Makefile | 100 +
149
- .distro/Makefile.common | 40 +
170
+ .distro/Makefile.common | 41 +
150
171
.distro/README.tests | 39 +
151
- .distro/ksm.service | 13 -
152
- .distro/ksm.sysconfig | 4 -
153
- .distro/ksmctl.c | 77 -
154
- .distro/ksmtuned | 139 -
155
- .distro/ksmtuned.conf | 21 -
156
- .distro/ksmtuned.service | 12 -
157
- .distro/kvm-setup | 49 -
158
- .distro/kvm-setup.service | 14 -
159
172
.distro/modules-load.conf | 4 +
160
173
.distro/qemu-guest-agent.service | 1 -
161
- .distro/qemu-kvm.spec.template | 4034 +++++++++++++++++++++++
174
+ .distro/qemu-kvm.spec.template | 4315 +++++++++++++++++++++++
162
175
.distro/rpminspect.yaml | 6 +-
163
176
.distro/scripts/extract_build_cmd.py | 12 +
177
+ .distro/scripts/process-patches.sh | 4 +
164
178
.gitignore | 1 +
165
179
README.systemtap | 43 +
166
- meson.build | 4 +-
167
180
scripts/qemu-guest-agent/fsfreeze-hook | 2 +-
168
181
scripts/systemtap/conf.d/qemu_kvm.conf | 4 +
169
182
scripts/systemtap/script.d/qemu_kvm.stp | 1 +
170
183
tests/check-block.sh | 2 +
171
184
ui/vnc-auth-sasl.c | 2 +-
172
- 25 files changed, 4290 insertions(+), 339 deletions(-)
185
+ 16 files changed, 4573 insertions(+), 4 deletions(-)
173
- delete mode 100644 .distro/85-kvm.preset
174
186
create mode 100644 .distro/Makefile
175
187
create mode 100644 .distro/Makefile.common
176
188
create mode 100644 .distro/README.tests
177
- delete mode 100644 .distro/ksm.service
178
- delete mode 100644 .distro/ksm.sysconfig
179
- delete mode 100644 .distro/ksmctl.c
180
- delete mode 100644 .distro/ksmtuned
181
- delete mode 100644 .distro/ksmtuned.conf
182
- delete mode 100644 .distro/ksmtuned.service
183
- delete mode 100644 .distro/kvm-setup
184
- delete mode 100644 .distro/kvm-setup.service
185
189
create mode 100644 .distro/modules-load.conf
186
190
create mode 100644 .distro/qemu-kvm.spec.template
187
191
create mode 100644 README.systemtap
@@ -237,21 +241,6 @@ index 0000000000..ad913fc990
237
241
+
238
242
+3. Translate the trace record to readable format.
239
243
+ # /usr/share/qemu-kvm/simpletrace.py --no-header /usr/share/qemu-kvm/trace-events /tmp/trace.log
240
- diff --git a/meson.build b/meson.build
241
- index 861de93c4f..6f7e430f0f 100644
242
- --- a/meson.build
243
- +++ b/meson.build
244
- @@ -2394,7 +2394,9 @@ if capstone_opt == 'internal'
245
- # Include all configuration defines via a header file, which will wind up
246
- # as a dependency on the object file, and thus changes here will result
247
- # in a rebuild.
248
- - '-include', 'capstone-defs.h'
249
- + '-include', 'capstone-defs.h',
250
- +
251
- + '-Wp,-D_GLIBCXX_ASSERTIONS',
252
- ]
253
-
254
- libcapstone = static_library('capstone',
255
244
diff --git a/scripts/qemu-guest-agent/fsfreeze-hook b/scripts/qemu-guest-agent/fsfreeze-hook
256
245
index 13aafd4845..e9b84ec028 100755
257
246
--- a/scripts/qemu-guest-agent/fsfreeze-hook
@@ -283,11 +272,11 @@ index 0000000000..c04abf9449
283
272
@@ -0,0 +1 @@
284
273
+probe qemu.kvm.simpletrace.handle_qmp_command,qemu.kvm.simpletrace.monitor_protocol_*,qemu.kvm.simpletrace.migrate_set_state {}
285
274
diff --git a/tests/check-block.sh b/tests/check-block.sh
286
- index f59496396c..d900d8b35e 100755
275
+ index 5de2c1ba0b..6af743f441 100755
287
276
--- a/tests/check-block.sh
288
277
+++ b/tests/check-block.sh
289
- @@ -48,6 +48,8 @@ if LANG=C bash --version | grep -q 'GNU bash, version [123]' ; then
290
- skip "bash version too old ==> Not running the qemu-iotests."
278
+ @@ -22,6 +22,8 @@ if [ -z "$(find . -name 'qemu-system-*' -print)" ]; then
279
+ skip "No qemu-system binary available ==> Not running the qemu-iotests."
291
280
fi
292
281
293
282
+exit 0
SOURCES/0005-Enable-disable-devices-for-RHEL.patch CHANGED
@@ -1,6 +1,6 @@
1
- From 51ec7495d69fe4b4d0b61642ca6c0e7fd7a1032d Mon Sep 17 00:00:00 2001
1
+ From 90366cd2ead5a5301aaceed56477d2e6d9f1b3cd Mon Sep 17 00:00:00 2001
2
2
From: Miroslav Rezanina <mrezanin@redhat.com>
3
- Date: Thu, 15 Jul 2021 03:22:36 -0400
3
+ Date: Wed, 7 Dec 2022 03:05:48 -0500
4
4
Subject: Enable/disable devices for RHEL
5
5
6
6
This commit adds all changes related to changes in supported devices.
@@ -22,6 +22,16 @@ Rebase notes (7.0.0):
22
22
- Renamed CONFIG_ARM_GIC_TCG to CONFIG_ARM_GICV3_TCG
23
23
- Removed upstream devices
24
24
25
+ Rebase notes (7.1.0 rc0):
26
+ - Added CONFIG_VHOST_VSOCK and CONFIG_VHOST_USER_VSOCK configs
27
+ - Added CONFIG_CXL and CONFIG_CXL_MEM_DEVICE for aarch64 and x86_64
28
+
29
+ Rebase notes (7.1.0 rc3):
30
+ - Added CONFIG_VHOST_USER_FS option (all archs)
31
+
32
+ Rebase notes (7.2.0 rc20):
33
+ - Removed disabling a15mpcore.c as no longer needed
34
+
25
35
Merged patches (6.1.0):
26
36
- c51bf45304 Remove SPICE and QXL from x86_64-rh-devices.mak
27
37
- 02fc745601 aarch64-rh-devices: add CONFIG_PVPANIC_PCI
@@ -37,17 +47,22 @@ Merged patches (6.2.0):
37
47
Merged patches (7.0.0):
38
48
- fd7c45a5a8 redhat: Enable virtio-mem as tech-preview on x86-64
39
49
- c9e68ea451 Enable SGX -- RH Only
50
+
51
+ Merged patches (7.1.0 rc0):
52
+ - 38b89dc245 pc: Move s3/s4 suspend disabling to compat (only hw/acpi/ich9.c chunk)
53
+ - 8f663466c6 configs/devices/aarch64-softmmu: Enable CONFIG_VIRTIO_MEM
54
+ - 1bf372717a Enable virtio-iommu-pci on aarch64
55
+ - ae3f269458 Enable virtio-iommu-pci on x86_64
40
56
---
41
57
.distro/qemu-kvm.spec.template | 18 +--
42
- .../aarch64-softmmu/aarch64-rh-devices.mak | 34 ++++++
43
- .../ppc64-softmmu/ppc64-rh-devices.mak | 35 ++++++
58
+ .../aarch64-softmmu/aarch64-rh-devices.mak | 41 +++++++
59
+ .../ppc64-softmmu/ppc64-rh-devices.mak | 37 ++++++
44
60
configs/devices/rh-virtio.mak | 10 ++
45
- .../s390x-softmmu/s390x-rh-devices.mak | 15 +++
46
- .../x86_64-softmmu/x86_64-rh-devices.mak | 103 ++++++++++++++++++
61
+ .../s390x-softmmu/s390x-rh-devices.mak | 18 +++
62
+ .../x86_64-softmmu/x86_64-rh-devices.mak | 109 ++++++++++++++++++
47
- hw/acpi/ich9.c | 4 +-
48
63
hw/arm/meson.build | 2 +-
49
64
hw/block/fdc.c | 10 ++
50
- hw/cpu/meson.build | 5 +-
65
+ hw/cpu/meson.build | 3 +-
51
66
hw/display/cirrus_vga.c | 5 +-
52
67
hw/ide/piix.c | 5 +-
53
68
hw/input/pckbd.c | 2 +
@@ -58,7 +73,7 @@ Merged patches (7.0.0):
58
73
target/ppc/cpu-models.c | 9 ++
59
74
target/s390x/cpu_models_sysemu.c | 3 +
60
75
target/s390x/kvm/kvm.c | 8 ++
61
- 20 files changed, 269 insertions(+), 15 deletions(-)
76
+ 19 files changed, 283 insertions(+), 13 deletions(-)
62
77
create mode 100644 configs/devices/aarch64-softmmu/aarch64-rh-devices.mak
63
78
create mode 100644 configs/devices/ppc64-softmmu/ppc64-rh-devices.mak
64
79
create mode 100644 configs/devices/rh-virtio.mak
@@ -67,10 +82,10 @@ Merged patches (7.0.0):
67
82
68
83
diff --git a/configs/devices/aarch64-softmmu/aarch64-rh-devices.mak b/configs/devices/aarch64-softmmu/aarch64-rh-devices.mak
69
84
new file mode 100644
70
- index 0000000000..5f6ee1de5b
85
+ index 0000000000..720ec0cb57
71
86
--- /dev/null
72
87
+++ b/configs/devices/aarch64-softmmu/aarch64-rh-devices.mak
73
- @@ -0,0 +1,34 @@
88
+ @@ -0,0 +1,41 @@
74
89
+include ../rh-virtio.mak
75
90
+
76
91
+CONFIG_ARM_GIC_KVM=y
@@ -79,6 +94,8 @@ index 0000000000..5f6ee1de5b
79
94
+CONFIG_ARM_SMMUV3=y
80
95
+CONFIG_ARM_V7M=y
81
96
+CONFIG_ARM_VIRT=y
97
+ +CONFIG_CXL=y
98
+ +CONFIG_CXL_MEM_DEVICE=y
82
99
+CONFIG_EDID=y
83
100
+CONFIG_PCIE_PORT=y
84
101
+CONFIG_PCI_DEVICES=y
@@ -95,6 +112,8 @@ index 0000000000..5f6ee1de5b
95
112
+CONFIG_VFIO_PCI=y
96
113
+CONFIG_VIRTIO_MMIO=y
97
114
+CONFIG_VIRTIO_PCI=y
115
+ +CONFIG_VIRTIO_MEM=y
116
+ +CONFIG_VIRTIO_IOMMU=y
98
117
+CONFIG_XIO3130=y
99
118
+CONFIG_NVDIMM=y
100
119
+CONFIG_ACPI_APEI=y
@@ -105,12 +124,15 @@ index 0000000000..5f6ee1de5b
105
124
+CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
106
125
+CONFIG_PVPANIC_PCI=y
107
126
+CONFIG_PXB=y
127
+ +CONFIG_VHOST_VSOCK=y
128
+ +CONFIG_VHOST_USER_VSOCK=y
129
+ +CONFIG_VHOST_USER_FS=y
108
130
diff --git a/configs/devices/ppc64-softmmu/ppc64-rh-devices.mak b/configs/devices/ppc64-softmmu/ppc64-rh-devices.mak
109
131
new file mode 100644
110
- index 0000000000..6a3e3f0227
132
+ index 0000000000..dbb7d30829
111
133
--- /dev/null
112
134
+++ b/configs/devices/ppc64-softmmu/ppc64-rh-devices.mak
113
- @@ -0,0 +1,35 @@
135
+ @@ -0,0 +1,37 @@
114
136
+include ../rh-virtio.mak
115
137
+
116
138
+CONFIG_DIMM=y
@@ -146,6 +168,8 @@ index 0000000000..6a3e3f0227
146
168
+CONFIG_TPM=y
147
169
+CONFIG_TPM_SPAPR=y
148
170
+CONFIG_TPM_EMULATOR=y
171
+ +CONFIG_VHOST_VSOCK=y
172
+ +CONFIG_VHOST_USER_VSOCK=y
149
173
diff --git a/configs/devices/rh-virtio.mak b/configs/devices/rh-virtio.mak
150
174
new file mode 100644
151
175
index 0000000000..94ede1b5f6
@@ -164,10 +188,10 @@ index 0000000000..94ede1b5f6
164
188
+CONFIG_VIRTIO_SERIAL=y
165
189
diff --git a/configs/devices/s390x-softmmu/s390x-rh-devices.mak b/configs/devices/s390x-softmmu/s390x-rh-devices.mak
166
190
new file mode 100644
167
- index 0000000000..d3b38312e1
191
+ index 0000000000..69a799adbd
168
192
--- /dev/null
169
193
+++ b/configs/devices/s390x-softmmu/s390x-rh-devices.mak
170
- @@ -0,0 +1,15 @@
194
+ @@ -0,0 +1,18 @@
171
195
+include ../rh-virtio.mak
172
196
+
173
197
+CONFIG_PCI=y
@@ -183,12 +207,15 @@ index 0000000000..d3b38312e1
183
207
+CONFIG_VHOST_USER=y
184
208
+CONFIG_VIRTIO_CCW=y
185
209
+CONFIG_WDT_DIAG288=y
210
+ +CONFIG_VHOST_VSOCK=y
211
+ +CONFIG_VHOST_USER_VSOCK=y
212
+ +CONFIG_VHOST_USER_FS=y
186
213
diff --git a/configs/devices/x86_64-softmmu/x86_64-rh-devices.mak b/configs/devices/x86_64-softmmu/x86_64-rh-devices.mak
187
214
new file mode 100644
188
- index 0000000000..d0c9e66641
215
+ index 0000000000..10cb0a14e0
189
216
--- /dev/null
190
217
+++ b/configs/devices/x86_64-softmmu/x86_64-rh-devices.mak
191
- @@ -0,0 +1,103 @@
218
+ @@ -0,0 +1,109 @@
192
219
+include ../rh-virtio.mak
193
220
+
194
221
+CONFIG_ACPI=y
@@ -204,6 +231,8 @@ index 0000000000..d0c9e66641
204
231
+CONFIG_APIC=y
205
232
+CONFIG_APM=y
206
233
+CONFIG_BOCHS_DISPLAY=y
234
+ +CONFIG_CXL=y
235
+ +CONFIG_CXL_MEM_DEVICE=y
207
236
+CONFIG_DIMM=y
208
237
+CONFIG_E1000E_PCI_EXPRESS=y
209
238
+CONFIG_E1000_PCI=y
@@ -281,6 +310,7 @@ index 0000000000..d0c9e66641
281
310
+CONFIG_VIRTIO_MEM=y
282
311
+CONFIG_VIRTIO_PCI=y
283
312
+CONFIG_VIRTIO_VGA=y
313
+ +CONFIG_VIRTIO_IOMMU=y
284
314
+CONFIG_VMMOUSE=y
285
315
+CONFIG_VMPORT=y
286
316
+CONFIG_VTD=y
@@ -292,26 +322,14 @@ index 0000000000..d0c9e66641
292
322
+CONFIG_TPM_TIS_ISA=y
293
323
+CONFIG_TPM_EMULATOR=y
294
324
+CONFIG_SGX=y
295
- diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
296
- index bd9bbade70..de1e401cdf 100644
297
- --- a/hw/acpi/ich9.c
325
+ +CONFIG_VHOST_VSOCK=y
326
+ +CONFIG_VHOST_USER_VSOCK=y
327
+ +CONFIG_VHOST_USER_FS=y
298
- +++ b/hw/acpi/ich9.c
299
- @@ -435,8 +435,8 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm)
300
- static const uint32_t gpe0_len = ICH9_PMIO_GPE0_LEN;
301
- pm->acpi_memory_hotplug.is_enabled = true;
302
- pm->cpu_hotplug_legacy = true;
303
- - pm->disable_s3 = 0;
304
- - pm->disable_s4 = 0;
305
- + pm->disable_s3 = 1;
306
- + pm->disable_s4 = 1;
307
- pm->s4_val = 2;
308
- pm->use_acpi_hotplug_bridge = true;
309
- pm->keep_pci_slot_hpc = true;
310
328
diff --git a/hw/arm/meson.build b/hw/arm/meson.build
311
- index 721a8eb8be..87ed4dd914 100644
329
+ index 92f9f6e000..c5e94c997c 100644
312
330
--- a/hw/arm/meson.build
313
331
+++ b/hw/arm/meson.build
314
- @@ -31,7 +31,7 @@ arm_ss.add(when: 'CONFIG_VEXPRESS', if_true: files('vexpress.c'))
332
+ @@ -30,7 +30,7 @@ arm_ss.add(when: 'CONFIG_VEXPRESS', if_true: files('vexpress.c'))
315
333
arm_ss.add(when: 'CONFIG_ZYNQ', if_true: files('xilinx_zynq.c'))
316
334
arm_ss.add(when: 'CONFIG_SABRELITE', if_true: files('sabrelite.c'))
317
335
@@ -321,7 +339,7 @@ index 721a8eb8be..87ed4dd914 100644
321
339
arm_ss.add(when: 'CONFIG_PXA2XX', if_true: files('pxa2xx.c', 'pxa2xx_gpio.c', 'pxa2xx_pic.c'))
322
340
arm_ss.add(when: 'CONFIG_DIGIC', if_true: files('digic.c'))
323
341
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
324
- index 347875a0cd..ca1776121f 100644
342
+ index 64ae4a6899..9b8e782c19 100644
325
343
--- a/hw/block/fdc.c
326
344
+++ b/hw/block/fdc.c
327
345
@@ -49,6 +49,8 @@
@@ -333,7 +351,7 @@ index 347875a0cd..ca1776121f 100644
333
351
/********************************************************/
334
352
/* debug Floppy devices */
335
353
336
- @@ -2338,6 +2340,14 @@ void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl, Error **errp)
354
+ @@ -2346,6 +2348,14 @@ void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl, Error **errp)
337
355
FDrive *drive;
338
356
static int command_tables_inited = 0;
339
357
@@ -349,24 +367,21 @@ index 347875a0cd..ca1776121f 100644
349
367
error_setg(errp, "Cannot choose a fallback FDrive type of 'auto'");
350
368
return;
351
369
diff --git a/hw/cpu/meson.build b/hw/cpu/meson.build
352
- index 9e52fee9e7..bb71c9f3e7 100644
370
+ index 9e52fee9e7..87c209a754 100644
353
371
--- a/hw/cpu/meson.build
354
372
+++ b/hw/cpu/meson.build
355
- @@ -1,6 +1,7 @@
373
+ @@ -1,4 +1,5 @@
356
374
-softmmu_ss.add(files('core.c', 'cluster.c'))
357
375
+#softmmu_ss.add(files('core.c', 'cluster.c'))
358
376
+softmmu_ss.add(files('core.c'))
359
377
360
378
specific_ss.add(when: 'CONFIG_ARM11MPCORE', if_true: files('arm11mpcore.c'))
361
379
specific_ss.add(when: 'CONFIG_REALVIEW', if_true: files('realview_mpcore.c'))
362
- specific_ss.add(when: 'CONFIG_A9MPCORE', if_true: files('a9mpcore.c'))
363
- -specific_ss.add(when: 'CONFIG_A15MPCORE', if_true: files('a15mpcore.c'))
364
- +#specific_ss.add(when: 'CONFIG_A15MPCORE', if_true: files('a15mpcore.c'))
365
380
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
366
- index 3bb6a58698..6447fdb02e 100644
381
+ index 6e8c747c46..1948ebee8e 100644
367
382
--- a/hw/display/cirrus_vga.c
368
383
+++ b/hw/display/cirrus_vga.c
369
- @@ -2945,7 +2945,10 @@ static void pci_cirrus_vga_realize(PCIDevice *dev, Error **errp)
384
+ @@ -2946,7 +2946,10 @@ static void pci_cirrus_vga_realize(PCIDevice *dev, Error **errp)
370
385
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
371
386
int16_t device_id = pc->device_id;
372
387
@@ -379,10 +394,10 @@ index 3bb6a58698..6447fdb02e 100644
379
394
* Also accept 8 MB/16 MB for backward compatibility.
380
395
*/
381
396
diff --git a/hw/ide/piix.c b/hw/ide/piix.c
382
- index ce89fd0aa3..fbcf802b13 100644
397
+ index 267dbf37db..87fcda4062 100644
383
398
--- a/hw/ide/piix.c
384
399
+++ b/hw/ide/piix.c
385
- @@ -232,7 +232,8 @@ static void piix3_ide_class_init(ObjectClass *klass, void *data)
400
+ @@ -199,7 +199,8 @@ static void piix3_ide_class_init(ObjectClass *klass, void *data)
386
401
k->device_id = PCI_DEVICE_ID_INTEL_82371SB_1;
387
402
k->class_id = PCI_CLASS_STORAGE_IDE;
388
403
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
@@ -392,7 +407,7 @@ index ce89fd0aa3..fbcf802b13 100644
392
407
}
393
408
394
409
static const TypeInfo piix3_ide_info = {
395
- @@ -261,6 +262,8 @@ static void piix4_ide_class_init(ObjectClass *klass, void *data)
410
+ @@ -222,6 +223,8 @@ static void piix4_ide_class_init(ObjectClass *klass, void *data)
396
411
k->class_id = PCI_CLASS_STORAGE_IDE;
397
412
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
398
413
dc->hotpluggable = false;
@@ -402,12 +417,12 @@ index ce89fd0aa3..fbcf802b13 100644
402
417
403
418
static const TypeInfo piix4_ide_info = {
404
419
diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
405
- index 4efdf75620..5143ebaa27 100644
420
+ index b92b63bedc..3b6235dde6 100644
406
421
--- a/hw/input/pckbd.c
407
422
+++ b/hw/input/pckbd.c
408
- @@ -814,6 +814,8 @@ static void i8042_class_initfn(ObjectClass *klass, void *data)
423
+ @@ -957,6 +957,8 @@ static void i8042_class_initfn(ObjectClass *klass, void *data)
409
424
dc->vmsd = &vmstate_kbd_isa;
410
- isa->build_aml = i8042_build_aml;
425
+ adevc->build_dev_aml = i8042_build_aml;
411
426
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
412
427
+ /* Disabled for Red Hat Enterprise Linux: */
413
428
+ dc->user_creatable = false;
@@ -415,10 +430,10 @@ index 4efdf75620..5143ebaa27 100644
415
430
416
431
static const TypeInfo i8042_info = {
417
432
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
418
- index f5bc81296d..282d01e374 100644
433
+ index e26e0a64c1..41492fae79 100644
419
434
--- a/hw/net/e1000.c
420
435
+++ b/hw/net/e1000.c
421
- @@ -1821,6 +1821,7 @@ static const E1000Info e1000_devices[] = {
436
+ @@ -1824,6 +1824,7 @@ static const E1000Info e1000_devices[] = {
422
437
.revision = 0x03,
423
438
.phy_id2 = E1000_PHY_ID2_8254xx_DEFAULT,
424
439
},
@@ -426,7 +441,7 @@ index f5bc81296d..282d01e374 100644
426
441
{
427
442
.name = "e1000-82544gc",
428
443
.device_id = E1000_DEV_ID_82544GC_COPPER,
429
- @@ -1833,6 +1834,7 @@ static const E1000Info e1000_devices[] = {
444
+ @@ -1836,6 +1837,7 @@ static const E1000Info e1000_devices[] = {
430
445
.revision = 0x03,
431
446
.phy_id2 = E1000_PHY_ID2_8254xx_DEFAULT,
432
447
},
@@ -452,7 +467,7 @@ index 8a4861f45a..fcb5dfe792 100644
452
467
DEFINE_SPAPR_CPU_CORE_TYPE("power7+_v2.1"),
453
468
DEFINE_SPAPR_CPU_CORE_TYPE("power8_v2.0"),
454
469
diff --git a/hw/usb/meson.build b/hw/usb/meson.build
455
- index de853d780d..0776ae6a20 100644
470
+ index 793df42e21..cd3c305471 100644
456
471
--- a/hw/usb/meson.build
457
472
+++ b/hw/usb/meson.build
458
473
@@ -52,7 +52,7 @@ softmmu_ss.add(when: 'CONFIG_USB_SMARTCARD', if_true: files('dev-smartcard-reade
@@ -465,10 +480,10 @@ index de853d780d..0776ae6a20 100644
465
480
endif
466
481
467
482
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
468
- index 13d0e9b195..3826fa5122 100644
483
+ index 9a2cef7d05..a528ff9a3d 100644
469
484
--- a/target/arm/cpu_tcg.c
470
485
+++ b/target/arm/cpu_tcg.c
471
- @@ -22,6 +22,7 @@
486
+ @@ -151,6 +151,7 @@ void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu)
472
487
/* CPU models. These are not needed for the AArch64 linux-user build. */
473
488
#if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
474
489
@@ -476,31 +491,31 @@ index 13d0e9b195..3826fa5122 100644
476
491
#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG)
477
492
static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
478
493
{
479
- @@ -375,6 +376,7 @@ static void cortex_a9_initfn(Object *obj)
480
- cpu->ccsidr[1] = 0x200fe019; /* 16k L1 icache. */
494
+ @@ -504,6 +505,7 @@ static void cortex_a9_initfn(Object *obj)
495
+ cpu->isar.reset_pmcr_el0 = 0x41093000;
481
496
define_arm_cp_regs(cpu, cortexa9_cp_reginfo);
482
497
}
483
498
+#endif /* disabled for RHEL */
484
499
485
500
#ifndef CONFIG_USER_ONLY
486
501
static uint64_t a15_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
487
- @@ -400,6 +402,7 @@ static const ARMCPRegInfo cortexa15_cp_reginfo[] = {
488
- REGINFO_SENTINEL
502
+ @@ -528,6 +530,7 @@ static const ARMCPRegInfo cortexa15_cp_reginfo[] = {
503
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
489
504
};
490
505
491
506
+#if 0 /* Disabled for Red Hat Enterprise Linux */
492
507
static void cortex_a7_initfn(Object *obj)
493
508
{
494
509
ARMCPU *cpu = ARM_CPU(obj);
495
- @@ -445,6 +448,7 @@ static void cortex_a7_initfn(Object *obj)
496
- cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */
510
+ @@ -576,6 +579,7 @@ static void cortex_a7_initfn(Object *obj)
511
+ cpu->isar.reset_pmcr_el0 = 0x41072000;
497
512
define_arm_cp_regs(cpu, cortexa15_cp_reginfo); /* Same as A15 */
498
513
}
499
514
+#endif /* disabled for RHEL */
500
515
501
516
static void cortex_a15_initfn(Object *obj)
502
517
{
503
- @@ -488,6 +492,7 @@ static void cortex_a15_initfn(Object *obj)
518
+ @@ -624,6 +628,7 @@ static void cortex_a15_initfn(Object *obj)
504
519
define_arm_cp_regs(cpu, cortexa15_cp_reginfo);
505
520
}
506
521
@@ -508,7 +523,7 @@ index 13d0e9b195..3826fa5122 100644
508
523
static void cortex_m0_initfn(Object *obj)
509
524
{
510
525
ARMCPU *cpu = ARM_CPU(obj);
511
- @@ -928,6 +933,7 @@ static void arm_v7m_class_init(ObjectClass *oc, void *data)
526
+ @@ -1065,6 +1070,7 @@ static void arm_v7m_class_init(ObjectClass *oc, void *data)
512
527
513
528
cc->gdb_core_xml_file = "arm-m-profile.xml";
514
529
}
@@ -516,7 +531,7 @@ index 13d0e9b195..3826fa5122 100644
516
531
517
532
#ifndef TARGET_AARCH64
518
533
/*
519
- @@ -1007,6 +1013,7 @@ static void arm_max_initfn(Object *obj)
534
+ @@ -1132,6 +1138,7 @@ static void arm_max_initfn(Object *obj)
520
535
#endif /* !TARGET_AARCH64 */
521
536
522
537
static const ARMCPUInfo arm_tcg_cpus[] = {
@@ -524,7 +539,7 @@ index 13d0e9b195..3826fa5122 100644
524
539
{ .name = "arm926", .initfn = arm926_initfn },
525
540
{ .name = "arm946", .initfn = arm946_initfn },
526
541
{ .name = "arm1026", .initfn = arm1026_initfn },
527
- @@ -1022,7 +1029,9 @@ static const ARMCPUInfo arm_tcg_cpus[] = {
542
+ @@ -1147,7 +1154,9 @@ static const ARMCPUInfo arm_tcg_cpus[] = {
528
543
{ .name = "cortex-a7", .initfn = cortex_a7_initfn },
529
544
{ .name = "cortex-a8", .initfn = cortex_a8_initfn },
530
545
{ .name = "cortex-a9", .initfn = cortex_a9_initfn },
@@ -534,7 +549,7 @@ index 13d0e9b195..3826fa5122 100644
534
549
{ .name = "cortex-m0", .initfn = cortex_m0_initfn,
535
550
.class_init = arm_v7m_class_init },
536
551
{ .name = "cortex-m3", .initfn = cortex_m3_initfn,
537
- @@ -1053,6 +1062,7 @@ static const ARMCPUInfo arm_tcg_cpus[] = {
552
+ @@ -1178,6 +1187,7 @@ static const ARMCPUInfo arm_tcg_cpus[] = {
538
553
{ .name = "pxa270-b1", .initfn = pxa270b1_initfn },
539
554
{ .name = "pxa270-c0", .initfn = pxa270c0_initfn },
540
555
{ .name = "pxa270-c5", .initfn = pxa270c5_initfn },
@@ -543,7 +558,7 @@ index 13d0e9b195..3826fa5122 100644
543
558
{ .name = "max", .initfn = arm_max_initfn },
544
559
#endif
545
560
diff --git a/target/ppc/cpu-models.c b/target/ppc/cpu-models.c
546
- index 976be5e0d1..dd78883410 100644
561
+ index 912b037c63..cd3ff700ac 100644
547
562
--- a/target/ppc/cpu-models.c
548
563
+++ b/target/ppc/cpu-models.c
549
564
@@ -66,6 +66,7 @@
@@ -573,7 +588,7 @@ index 976be5e0d1..dd78883410 100644
573
588
POWERPC_DEF("power7_v2.3", CPU_POWERPC_POWER7_v23, POWER7,
574
589
"POWER7 v2.3")
575
590
POWERPC_DEF("power7+_v2.1", CPU_POWERPC_POWER7P_v21, POWER7,
576
- @@ -897,12 +901,15 @@ PowerPCCPUAlias ppc_cpu_aliases[] = {
591
+ @@ -896,12 +900,15 @@ PowerPCCPUAlias ppc_cpu_aliases[] = {
577
592
{ "7447a", "7447a_v1.2" },
578
593
{ "7457a", "7457a_v1.2" },
579
594
{ "apollo7pm", "7457a_v1.0" },
@@ -589,7 +604,7 @@ index 976be5e0d1..dd78883410 100644
589
604
{ "power7", "power7_v2.3" },
590
605
{ "power7+", "power7+_v2.1" },
591
606
{ "power8e", "power8e_v2.1" },
592
- @@ -912,6 +919,7 @@ PowerPCCPUAlias ppc_cpu_aliases[] = {
607
+ @@ -911,12 +918,14 @@ PowerPCCPUAlias ppc_cpu_aliases[] = {
593
608
{ "power10", "power10_v2.0" },
594
609
#endif
595
610
@@ -597,18 +612,18 @@ index 976be5e0d1..dd78883410 100644
597
612
/* Generic PowerPCs */
598
613
#if defined(TARGET_PPC64)
599
614
{ "ppc64", "970fx_v3.1" },
600
- @@ -919,5 +927,6 @@ PowerPCCPUAlias ppc_cpu_aliases[] = {
615
+ #endif
601
616
{ "ppc32", "604" },
602
617
{ "ppc", "604" },
603
- { "default", "604" },
604
618
+#endif
619
+
605
620
{ NULL, NULL }
606
621
};
607
622
diff --git a/target/s390x/cpu_models_sysemu.c b/target/s390x/cpu_models_sysemu.c
608
- index 05c3ccaaff..6a04ccab1b 100644
623
+ index d8a141a023..d086b1c39c 100644
609
624
--- a/target/s390x/cpu_models_sysemu.c
610
625
+++ b/target/s390x/cpu_models_sysemu.c
611
- @@ -36,6 +36,9 @@ static void check_unavailable_features(const S390CPUModel *max_model,
626
+ @@ -35,6 +35,9 @@ static void check_unavailable_features(const S390CPUModel *max_model,
612
627
(max_model->def->gen == model->def->gen &&
613
628
max_model->def->ec_ga < model->def->ec_ga)) {
614
629
list_add_feat("type", unavailable);
@@ -619,10 +634,10 @@ index 05c3ccaaff..6a04ccab1b 100644
619
634
620
635
/* detect missing features if any to properly report them */
621
636
diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c
622
- index 6acf14d5ec..74f089d87f 100644
637
+ index 3ac7ec9acf..97da1a6424 100644
623
638
--- a/target/s390x/kvm/kvm.c
624
639
+++ b/target/s390x/kvm/kvm.c
625
- @@ -2512,6 +2512,14 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp)
640
+ @@ -2529,6 +2529,14 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp)
626
641
error_setg(errp, "KVM doesn't support CPU models");
627
642
return;
628
643
}
SOURCES/0006-Machine-type-related-general-changes.patch CHANGED
@@ -1,4 +1,4 @@
1
- From a525db3951dc68c469d1f51bdc69ab6e75e72c37 Mon Sep 17 00:00:00 2001
1
+ From 0208f38671b9de4036c0d56142a7f22e5091bae0 Mon Sep 17 00:00:00 2001
2
2
From: Miroslav Rezanina <mrezanin@redhat.com>
3
3
Date: Fri, 11 Jan 2019 09:54:45 +0100
4
4
Subject: Machine type related general changes
@@ -19,6 +19,10 @@ Rebase notes (7.0.0):
19
19
- Remove downstream changes leftovers in hw/rtc/mc146818rtc.c
20
20
- Remove unnecessary change in hw/usb/hcd-uhci.c
21
21
22
+ Rebase notes (7.1.0 rc0):
23
+ - Moved adding rhel_old_machine_deprecation variable from s390x to general machine types commit
24
+ - Moved adding hw_compat_rhel_8_6 struct from x86_64 to general machine types commit
25
+
22
26
Merged patches (6.1.0):
23
27
- f2fb42a3c6 redhat: add missing entries in hw_compat_rhel_8_4
24
28
- 1949ec258e hw/arm/virt: Disable PL011 clock migration through hw_compat_rhel_8_3
@@ -35,28 +39,35 @@ Merged patches (6.2.0):
35
39
Merged patches (7.0.0):
36
40
- ef5afcc86d Fix virtio-net-pci* "vectors" compat
37
41
- 168f0d56e3 compat: Update hw_compat_rhel_8_5 with 6.2.0 RC2 changes
42
+
43
+ Merged patches (7.1.0 rc0):
44
+ - 38b89dc245 pc: Move s3/s4 suspend disabling to compat (only hw/acpi/piix4.c chunk)
45
+ - 1d6439527a WRB: Introduce RHEL 9.0.0 hw compat structure (only hw/core/machine.c and include/hw/boards.h chunk)
46
+
47
+ Merged patches (7.2.0 rc0):
48
+ - 0be2889fa2 Introduce upstream 7.0 compat changes (only applicable parts)
38
49
---
39
- hw/acpi/piix4.c | 6 +-
50
+ hw/acpi/piix4.c | 2 +-
40
51
hw/arm/virt.c | 2 +-
41
- hw/core/machine.c | 186 +++++++++++++++++++++++++++++++++++
52
+ hw/core/machine.c | 222 +++++++++++++++++++++++++++++++++++
42
53
hw/display/vga-isa.c | 2 +-
43
54
hw/i386/pc_piix.c | 2 +
44
55
hw/i386/pc_q35.c | 2 +
45
56
hw/net/rtl8139.c | 4 +-
46
- hw/smbios/smbios.c | 46 ++++++++-
57
+ hw/smbios/smbios.c | 46 +++++++-
47
58
hw/timer/i8254_common.c | 2 +-
48
- hw/usb/hcd-xhci-pci.c | 59 ++++++++---
59
+ hw/usb/hcd-xhci-pci.c | 59 +++++++---
49
60
hw/usb/hcd-xhci-pci.h | 1 +
50
- include/hw/boards.h | 21 ++++
61
+ include/hw/boards.h | 31 +++++
51
62
include/hw/firmware/smbios.h | 5 +-
52
63
include/hw/i386/pc.h | 3 +
53
- 14 files changed, 316 insertions(+), 25 deletions(-)
64
+ 14 files changed, 360 insertions(+), 23 deletions(-)
54
65
55
66
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
56
- index fe5625d07a..28544e78c3 100644
67
+ index 0a81f1ad93..dbfb362a8f 100644
57
68
--- a/hw/acpi/piix4.c
58
69
+++ b/hw/acpi/piix4.c
59
- @@ -287,7 +287,7 @@ static bool vmstate_test_migrate_acpi_index(void *opaque, int version_id)
70
+ @@ -248,7 +248,7 @@ static bool vmstate_test_migrate_acpi_index(void *opaque, int version_id)
60
71
static const VMStateDescription vmstate_acpi = {
61
72
.name = "piix4_pm",
62
73
.version_id = 3,
@@ -65,22 +76,11 @@ index fe5625d07a..28544e78c3 100644
65
76
.post_load = vmstate_acpi_post_load,
66
77
.fields = (VMStateField[]) {
67
78
VMSTATE_PCI_DEVICE(parent_obj, PIIX4PMState),
68
- @@ -653,8 +653,8 @@ static void piix4_send_gpe(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
69
-
70
- static Property piix4_pm_properties[] = {
71
- DEFINE_PROP_UINT32("smb_io_base", PIIX4PMState, smb_io_base, 0),
72
- - DEFINE_PROP_UINT8(ACPI_PM_PROP_S3_DISABLED, PIIX4PMState, disable_s3, 0),
73
- - DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_DISABLED, PIIX4PMState, disable_s4, 0),
74
- + DEFINE_PROP_UINT8(ACPI_PM_PROP_S3_DISABLED, PIIX4PMState, disable_s3, 1),
75
- + DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_DISABLED, PIIX4PMState, disable_s4, 1),
76
- DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
77
- DEFINE_PROP_BOOL(ACPI_PM_PROP_ACPI_PCIHP_BRIDGE, PIIX4PMState,
78
- use_acpi_hotplug_bridge, true),
79
79
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
80
- index d2e5ecd234..6a84031fd7 100644
80
+ index b871350856..d633300fdc 100644
81
81
--- a/hw/arm/virt.c
82
82
+++ b/hw/arm/virt.c
83
- @@ -1596,7 +1596,7 @@ static void virt_build_smbios(VirtMachineState *vms)
83
+ @@ -1619,7 +1619,7 @@ static void virt_build_smbios(VirtMachineState *vms)
84
84
85
85
smbios_set_defaults("QEMU", product,
86
86
vmc->smbios_old_sys_ver ? "1.0" : mc->name, false,
@@ -90,14 +90,50 @@ index d2e5ecd234..6a84031fd7 100644
90
90
smbios_get_tables(MACHINE(vms), NULL, 0,
91
91
&smbios_tables, &smbios_tables_len,
92
92
diff --git a/hw/core/machine.c b/hw/core/machine.c
93
- index 1e23fdc14b..ea430d844e 100644
93
+ index 8d34caa31d..9edec1ca05 100644
94
94
--- a/hw/core/machine.c
95
95
+++ b/hw/core/machine.c
96
- @@ -37,6 +37,192 @@
96
+ @@ -40,6 +40,228 @@
97
- #include "hw/virtio/virtio.h"
98
97
#include "hw/virtio/virtio-pci.h"
98
+ #include "qom/object_interfaces.h"
99
99
100
100
+/*
101
+ + * RHEL only: machine types for previous major releases are deprecated
102
+ + */
103
+ +const char *rhel_old_machine_deprecation =
104
+ + "machine types for previous major releases are deprecated";
105
+ +
106
+ +/*
107
+ + * Mostly the same as hw_compat_7_0
108
+ + */
109
+ +GlobalProperty hw_compat_rhel_9_1[] = {
110
+ + /* hw_compat_rhel_9_1 from hw_compat_7_0 */
111
+ + { "arm-gicv3-common", "force-8-bit-prio", "on" },
112
+ + /* hw_compat_rhel_9_1 from hw_compat_7_0 */
113
+ + { "nvme-ns", "eui64-default", "on"},
114
+ +};
115
+ +const size_t hw_compat_rhel_9_1_len = G_N_ELEMENTS(hw_compat_rhel_9_1);
116
+ +
117
+ +/*
118
+ + * Mostly the same as hw_compat_6_2
119
+ + */
120
+ +GlobalProperty hw_compat_rhel_9_0[] = {
121
+ + /* hw_compat_rhel_9_0 from hw_compat_6_2 */
122
+ + { "PIIX4_PM", "x-not-migrate-acpi-index", "on"},
123
+ +};
124
+ +const size_t hw_compat_rhel_9_0_len = G_N_ELEMENTS(hw_compat_rhel_9_0);
125
+ +
126
+ +GlobalProperty hw_compat_rhel_8_6[] = {
127
+ + /* hw_compat_rhel_8_6 bz 2065589 */
128
+ + /*
129
+ + * vhost-vsock device in RHEL 8 kernels doesn't support seqpacket, so
130
+ + * we need do disable it downstream on the latest hw_compat_rhel_8.
131
+ + */
132
+ + { "vhost-vsock-device", "seqpacket", "off" },
133
+ +};
134
+ +const size_t hw_compat_rhel_8_6_len = G_N_ELEMENTS(hw_compat_rhel_8_6);
135
+ +
136
+ +/*
101
137
+ * Mostly the same as hw_compat_6_0 and hw_compat_6_1
102
138
+ */
103
139
+GlobalProperty hw_compat_rhel_8_5[] = {
@@ -283,14 +319,14 @@ index 1e23fdc14b..ea430d844e 100644
283
319
+};
284
320
+const size_t hw_compat_rhel_7_6_len = G_N_ELEMENTS(hw_compat_rhel_7_6);
285
321
+
286
- GlobalProperty hw_compat_6_2[] = {
287
- { "PIIX4_PM", "x-not-migrate-acpi-index", "on"},
322
+ GlobalProperty hw_compat_7_1[] = {
323
+ { "virtio-device", "queue_reset", "false" },
288
324
};
289
325
diff --git a/hw/display/vga-isa.c b/hw/display/vga-isa.c
290
- index 46abbc5653..505467059b 100644
326
+ index 2a5437d803..0db2c2b2a1 100644
291
327
--- a/hw/display/vga-isa.c
292
328
+++ b/hw/display/vga-isa.c
293
- @@ -88,7 +88,7 @@ static void vga_isa_realizefn(DeviceState *dev, Error **errp)
329
+ @@ -89,7 +89,7 @@ static void vga_isa_realizefn(DeviceState *dev, Error **errp)
294
330
}
295
331
296
332
static Property vga_isa_properties[] = {
@@ -300,10 +336,10 @@ index 46abbc5653..505467059b 100644
300
336
};
301
337
302
338
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
303
- index b72c03d0a6..c797e98312 100644
339
+ index 0ad0ed1603..0985ff67d2 100644
304
340
--- a/hw/i386/pc_piix.c
305
341
+++ b/hw/i386/pc_piix.c
306
- @@ -177,6 +177,8 @@ static void pc_init1(MachineState *machine,
342
+ @@ -187,6 +187,8 @@ static void pc_init1(MachineState *machine,
307
343
smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
308
344
mc->name, pcmc->smbios_legacy_mode,
309
345
pcmc->smbios_uuid_encoded,
@@ -313,10 +349,10 @@ index b72c03d0a6..c797e98312 100644
313
349
}
314
350
315
351
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
316
- index 1780f79bc1..b695f88c45 100644
352
+ index a496bd6e74..ea582254e3 100644
317
353
--- a/hw/i386/pc_q35.c
318
354
+++ b/hw/i386/pc_q35.c
319
- @@ -200,6 +200,8 @@ static void pc_q35_init(MachineState *machine)
355
+ @@ -201,6 +201,8 @@ static void pc_q35_init(MachineState *machine)
320
356
smbios_set_defaults("QEMU", "Standard PC (Q35 + ICH9, 2009)",
321
357
mc->name, pcmc->smbios_legacy_mode,
322
358
pcmc->smbios_uuid_encoded,
@@ -326,10 +362,10 @@ index 1780f79bc1..b695f88c45 100644
326
362
}
327
363
328
364
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
329
- index 6b65823b4b..75dacabc43 100644
365
+ index 700b1b66b6..13693aeb4f 100644
330
366
--- a/hw/net/rtl8139.c
331
367
+++ b/hw/net/rtl8139.c
332
- @@ -3179,7 +3179,7 @@ static int rtl8139_pre_save(void *opaque)
368
+ @@ -3178,7 +3178,7 @@ static int rtl8139_pre_save(void *opaque)
333
369
334
370
static const VMStateDescription vmstate_rtl8139 = {
335
371
.name = "rtl8139",
@@ -338,7 +374,7 @@ index 6b65823b4b..75dacabc43 100644
338
374
.minimum_version_id = 3,
339
375
.post_load = rtl8139_post_load,
340
376
.pre_save = rtl8139_pre_save,
341
- @@ -3260,7 +3260,9 @@ static const VMStateDescription vmstate_rtl8139 = {
377
+ @@ -3259,7 +3259,9 @@ static const VMStateDescription vmstate_rtl8139 = {
342
378
VMSTATE_UINT32(tally_counters.TxMCol, RTL8139State),
343
379
VMSTATE_UINT64(tally_counters.RxOkPhy, RTL8139State),
344
380
VMSTATE_UINT64(tally_counters.RxOkBrd, RTL8139State),
@@ -349,7 +385,7 @@ index 6b65823b4b..75dacabc43 100644
349
385
VMSTATE_UINT16(tally_counters.TxUndrn, RTL8139State),
350
386
351
387
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
352
- index 60349ee402..0edcc98434 100644
388
+ index b4243de735..c5ad69237e 100644
353
389
--- a/hw/smbios/smbios.c
354
390
+++ b/hw/smbios/smbios.c
355
391
@@ -57,6 +57,9 @@ static bool smbios_legacy = true;
@@ -362,7 +398,7 @@ index 60349ee402..0edcc98434 100644
362
398
363
399
uint8_t *smbios_tables;
364
400
size_t smbios_tables_len;
365
- @@ -639,7 +642,7 @@ static void smbios_build_type_1_table(void)
401
+ @@ -669,7 +672,7 @@ static void smbios_build_type_1_table(void)
366
402
367
403
static void smbios_build_type_2_table(void)
368
404
{
@@ -371,7 +407,7 @@ index 60349ee402..0edcc98434 100644
371
407
372
408
SMBIOS_TABLE_SET_STR(2, manufacturer_str, type2.manufacturer);
373
409
SMBIOS_TABLE_SET_STR(2, product_str, type2.product);
374
- @@ -914,7 +917,10 @@ void smbios_set_cpuid(uint32_t version, uint32_t features)
410
+ @@ -977,7 +980,10 @@ void smbios_set_cpuid(uint32_t version, uint32_t features)
375
411
376
412
void smbios_set_defaults(const char *manufacturer, const char *product,
377
413
const char *version, bool legacy_mode,
@@ -383,7 +419,7 @@ index 60349ee402..0edcc98434 100644
383
419
{
384
420
smbios_have_defaults = true;
385
421
smbios_legacy = legacy_mode;
386
- @@ -935,11 +941,45 @@ void smbios_set_defaults(const char *manufacturer, const char *product,
422
+ @@ -998,11 +1004,45 @@ void smbios_set_defaults(const char *manufacturer, const char *product,
387
423
g_free(smbios_entries);
388
424
}
389
425
@@ -444,7 +480,7 @@ index 050875b497..32935da46c 100644
444
480
vmstate_pit_channel, PITChannelState),
445
481
VMSTATE_INT64(channels[0].next_transition_time,
446
482
diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
447
- index e934b1a5b1..e18b05e528 100644
483
+ index 643d4643e4..529bad9366 100644
448
484
--- a/hw/usb/hcd-xhci-pci.c
449
485
+++ b/hw/usb/hcd-xhci-pci.c
450
486
@@ -104,6 +104,33 @@ static int xhci_pci_vmstate_post_load(void *opaque, int version_id)
@@ -555,13 +591,22 @@ index c193f79443..086a1feb1e 100644
555
591
556
592
#endif
557
593
diff --git a/include/hw/boards.h b/include/hw/boards.h
558
- index c92ac8815c..c90a19b4d1 100644
594
+ index 90f1dd3aeb..2209d4e416 100644
559
595
--- a/include/hw/boards.h
560
596
+++ b/include/hw/boards.h
561
- @@ -449,4 +449,25 @@ extern const size_t hw_compat_2_2_len;
597
+ @@ -454,4 +454,35 @@ extern const size_t hw_compat_2_2_len;
562
598
extern GlobalProperty hw_compat_2_1[];
563
599
extern const size_t hw_compat_2_1_len;
564
600
601
+ +extern GlobalProperty hw_compat_rhel_9_1[];
602
+ +extern const size_t hw_compat_rhel_9_1_len;
603
+ +
604
+ +extern GlobalProperty hw_compat_rhel_9_0[];
605
+ +extern const size_t hw_compat_rhel_9_0_len;
606
+ +
607
+ +extern GlobalProperty hw_compat_rhel_8_6[];
608
+ +extern const size_t hw_compat_rhel_8_6_len;
609
+ +
565
610
+extern GlobalProperty hw_compat_rhel_8_5[];
566
611
+extern const size_t hw_compat_rhel_8_5_len;
567
612
+
@@ -583,12 +628,13 @@ index c92ac8815c..c90a19b4d1 100644
583
628
+extern GlobalProperty hw_compat_rhel_7_6[];
584
629
+extern const size_t hw_compat_rhel_7_6_len;
585
630
+
631
+ +extern const char *rhel_old_machine_deprecation;
586
632
#endif
587
633
diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h
588
- index 4b7ad77a44..9acff96a86 100644
634
+ index 7f3259a630..d24b3ccd32 100644
589
635
--- a/include/hw/firmware/smbios.h
590
636
+++ b/include/hw/firmware/smbios.h
591
- @@ -272,7 +272,10 @@ void smbios_entry_add(QemuOpts *opts, Error **errp);
637
+ @@ -294,7 +294,10 @@ void smbios_entry_add(QemuOpts *opts, Error **errp);
592
638
void smbios_set_cpuid(uint32_t version, uint32_t features);
593
639
void smbios_set_defaults(const char *manufacturer, const char *product,
594
640
const char *version, bool legacy_mode,
@@ -601,10 +647,10 @@ index 4b7ad77a44..9acff96a86 100644
601
647
void smbios_get_tables(MachineState *ms,
602
648
const struct smbios_phys_mem_area *mem_array,
603
649
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
604
- index 1a27de9c8b..91331059d9 100644
650
+ index c95333514e..3754eaa97d 100644
605
651
--- a/include/hw/i386/pc.h
606
652
+++ b/include/hw/i386/pc.h
607
- @@ -113,6 +113,9 @@ struct PCMachineClass {
653
+ @@ -112,6 +112,9 @@ struct PCMachineClass {
608
654
bool smbios_defaults;
609
655
bool smbios_legacy_mode;
610
656
bool smbios_uuid_encoded;
SOURCES/0007-Add-aarch64-machine-types.patch CHANGED
@@ -1,4 +1,4 @@
1
- From 697aaa43e3c0f20fc312f06be6c1093f1ba907e1 Mon Sep 17 00:00:00 2001
1
+ From 8501581c99760ed8a800d0c98eeb17a4bf450366 Mon Sep 17 00:00:00 2001
2
2
From: Miroslav Rezanina <mrezanin@redhat.com>
3
3
Date: Fri, 19 Oct 2018 12:53:31 +0200
4
4
Subject: Add aarch64 machine types
@@ -17,6 +17,15 @@ Rebase notes (7.0.0):
17
17
- Added dtb-kaslr-seed option
18
18
- Set no_tcg_lpa2 to true
19
19
20
+ Rebase notes (7.1.0 rc0):
21
+ - replace dtb_kaslr_seed by dtb_randomness
22
+
23
+ Rebase notes (7.1.0 rc3):
24
+ - Updated dtb_randomness comment
25
+
26
+ Rebase notes (7.2.0 rc0):
27
+ - Disabled cortex-a35
28
+
20
29
Merged patches (6.2.0):
21
30
- 9a3d4fde0e hw/arm/virt: Remove 9.0 machine type
22
31
- f7d04d6695 hw: arm: virt: Add hw_compat_rhel_8_5 to 8.5 machine type
@@ -29,13 +38,31 @@ Merged patches (7.0.0):
29
38
- a1d1b6eeb6 hw/arm/virt: Expose the 'RAS' option
30
39
- 47f8fe1b82 hw/arm/virt: Add 9.0 machine type and remove 8.5 one
31
40
- ed2346788f hw/arm/virt: Check no_tcg_its and minor style changes
41
+
42
+ Merged patches (7.0.0):
43
+ - f79b31bdef hw/arm/virt: Remove the dtb-kaslr-seed machine option
44
+ - b6fca85f4a hw/arm/virt: Fix missing initialization in instance/class_init()
45
+
46
+ Merged patches (7.1.0 rc0):
47
+ - ac97dd4f9f RHEL-only: AArch64: Drop unsupported CPU types
48
+ - e9c0a70664 target/arm: deprecate named CPU models
49
+
50
+ Merged patches (7.2.0 rc0):
51
+ - 0be2889fa2 Introduce upstream 7.0 compat changes (only applicable parts)
32
52
---
33
- hw/arm/virt.c | 234 +++++++++++++++++++++++++++++++++++++++++-
34
- include/hw/arm/virt.h | 8 ++
35
- 2 files changed, 241 insertions(+), 1 deletion(-)
53
+ hw/arm/virt.c | 237 ++++++++++++++++++++++++++++++++-
54
+ include/hw/arm/virt.h | 8 ++
55
+ target/arm/cpu-qom.h | 1 +
56
+ target/arm/cpu.c | 5 +
57
+ target/arm/cpu.h | 2 +
58
+ target/arm/cpu64.c | 16 ++-
59
+ target/arm/cpu_tcg.c | 12 +-
60
+ target/arm/helper.c | 2 +
61
+ tests/qtest/arm-cpu-features.c | 6 +
62
+ 9 files changed, 277 insertions(+), 12 deletions(-)
36
63
37
64
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
38
- index 6a84031fd7..e06862d22a 100644
65
+ index d633300fdc..dfcab40a73 100644
39
66
--- a/hw/arm/virt.c
40
67
+++ b/hw/arm/virt.c
41
68
@@ -80,6 +80,7 @@
@@ -96,7 +123,27 @@ index 6a84031fd7..e06862d22a 100644
96
123
97
124
/* Number of external interrupt lines to configure the GIC with */
98
125
#define NUM_IRQS 256
99
- @@ -2250,6 +2292,7 @@ static void machvirt_init(MachineState *machine)
126
+ @@ -197,15 +239,19 @@ static const int a15irqmap[] = {
127
+ };
128
+
129
+ static const char *valid_cpus[] = {
130
+ +#if 0 /* Disabled for Red Hat Enterprise Linux */
131
+ ARM_CPU_TYPE_NAME("cortex-a7"),
132
+ ARM_CPU_TYPE_NAME("cortex-a15"),
133
+ ARM_CPU_TYPE_NAME("cortex-a35"),
134
+ ARM_CPU_TYPE_NAME("cortex-a53"),
135
+ +#endif /* disabled for RHEL */
136
+ ARM_CPU_TYPE_NAME("cortex-a57"),
137
+ +#if 0 /* Disabled for Red Hat Enterprise Linux */
138
+ ARM_CPU_TYPE_NAME("cortex-a72"),
139
+ ARM_CPU_TYPE_NAME("cortex-a76"),
140
+ ARM_CPU_TYPE_NAME("a64fx"),
141
+ ARM_CPU_TYPE_NAME("neoverse-n1"),
142
+ +#endif /* disabled for RHEL */
143
+ ARM_CPU_TYPE_NAME("host"),
144
+ ARM_CPU_TYPE_NAME("max"),
145
+ };
146
+ @@ -2290,6 +2336,7 @@ static void machvirt_init(MachineState *machine)
100
147
qemu_add_machine_init_done_notifier(&vms->machine_done);
101
148
}
102
149
@@ -104,7 +151,7 @@ index 6a84031fd7..e06862d22a 100644
104
151
static bool virt_get_secure(Object *obj, Error **errp)
105
152
{
106
153
VirtMachineState *vms = VIRT_MACHINE(obj);
107
- @@ -2277,6 +2320,7 @@ static void virt_set_virt(Object *obj, bool value, Error **errp)
154
+ @@ -2317,6 +2364,7 @@ static void virt_set_virt(Object *obj, bool value, Error **errp)
108
155
109
156
vms->virt = value;
110
157
}
@@ -112,7 +159,23 @@ index 6a84031fd7..e06862d22a 100644
112
159
113
160
static bool virt_get_highmem(Object *obj, Error **errp)
114
161
{
115
- @@ -2402,6 +2446,7 @@ static void virt_set_ras(Object *obj, bool value, Error **errp)
162
+ @@ -2346,6 +2394,7 @@ static void virt_set_its(Object *obj, bool value, Error **errp)
163
+ vms->its = value;
164
+ }
165
+
166
+ +#if 0 /* Disabled for Red Hat Enterprise Linux */
167
+ static bool virt_get_dtb_randomness(Object *obj, Error **errp)
168
+ {
169
+ VirtMachineState *vms = VIRT_MACHINE(obj);
170
+ @@ -2359,6 +2408,7 @@ static void virt_set_dtb_randomness(Object *obj, bool value, Error **errp)
171
+
172
+ vms->dtb_randomness = value;
173
+ }
174
+ +#endif /* disabled for RHEL */
175
+
176
+ static char *virt_get_oem_id(Object *obj, Error **errp)
177
+ {
178
+ @@ -2442,6 +2492,7 @@ static void virt_set_ras(Object *obj, bool value, Error **errp)
116
179
vms->ras = value;
117
180
}
118
181
@@ -120,7 +183,7 @@ index 6a84031fd7..e06862d22a 100644
120
183
static bool virt_get_mte(Object *obj, Error **errp)
121
184
{
122
185
VirtMachineState *vms = VIRT_MACHINE(obj);
123
- @@ -2415,6 +2460,7 @@ static void virt_set_mte(Object *obj, bool value, Error **errp)
186
+ @@ -2455,6 +2506,7 @@ static void virt_set_mte(Object *obj, bool value, Error **errp)
124
187
125
188
vms->mte = value;
126
189
}
@@ -128,7 +191,7 @@ index 6a84031fd7..e06862d22a 100644
128
191
129
192
static char *virt_get_gic_version(Object *obj, Error **errp)
130
193
{
131
- @@ -2818,6 +2864,7 @@ static int virt_kvm_type(MachineState *ms, const char *type_str)
194
+ @@ -2886,6 +2938,7 @@ static int virt_kvm_type(MachineState *ms, const char *type_str)
132
195
return fixed_ipa ? 0 : requested_pa_size;
133
196
}
134
197
@@ -136,7 +199,7 @@ index 6a84031fd7..e06862d22a 100644
136
199
static void virt_machine_class_init(ObjectClass *oc, void *data)
137
200
{
138
201
MachineClass *mc = MACHINE_CLASS(oc);
139
- @@ -3206,3 +3253,188 @@ static void virt_machine_2_6_options(MachineClass *mc)
202
+ @@ -3294,3 +3347,185 @@ static void virt_machine_2_6_options(MachineClass *mc)
140
203
vmc->no_pmu = true;
141
204
}
142
205
DEFINE_VIRT_MACHINE(2, 6)
@@ -171,6 +234,7 @@ index 6a84031fd7..e06862d22a 100644
171
234
+ hc->unplug_request = virt_machine_device_unplug_request_cb;
172
235
+ hc->unplug = virt_machine_device_unplug_cb;
173
236
+ mc->nvdimm_supported = true;
237
+ + mc->smp_props.clusters_supported = true;
174
238
+ mc->auto_enable_numa_with_memhp = true;
175
239
+ mc->auto_enable_numa_with_memdev = true;
176
240
+ mc->default_ram_id = "mach-virt.ram";
@@ -233,13 +297,6 @@ index 6a84031fd7..e06862d22a 100644
233
297
+ "Override the default value of field OEM Table ID "
234
298
+ "in ACPI table header."
235
299
+ "The string may be up to 8 bytes in size");
236
- +
237
- + object_class_property_add_bool(oc, "dtb-kaslr-seed",
238
- + virt_get_dtb_kaslr_seed,
239
- + virt_set_dtb_kaslr_seed);
240
- + object_class_property_set_description(oc, "dtb-kaslr-seed",
241
- + "Set off to disable passing of kaslr-seed "
242
- + "dtb node to guest");
243
300
+}
244
301
+
245
302
+static void rhel_virt_instance_init(Object *obj)
@@ -258,6 +315,8 @@ index 6a84031fd7..e06862d22a 100644
258
315
+ vms->gic_version = VIRT_GIC_VERSION_NOSEL;
259
316
+
260
317
+ vms->highmem_ecam = !vmc->no_highmem_ecam;
318
+ + vms->highmem_mmio = true;
319
+ + vms->highmem_redists = true;
261
320
+
262
321
+ if (vmc->no_its) {
263
322
+ vms->its = false;
@@ -284,8 +343,8 @@ index 6a84031fd7..e06862d22a 100644
284
343
+ /* MTE is disabled by default and non-configurable for RHEL */
285
344
+ vms->mte = false;
286
345
+
287
- + /* Supply a kaslr-seed by default */
288
- + vms->dtb_kaslr_seed = true;
346
+ + /* Supply kaslr-seed and rng-seed by default, non-configurable for RHEL */
347
+ + vms->dtb_randomness = true;
289
348
+
290
349
+ vms->irqmap = a15irqmap;
291
350
+
@@ -320,16 +379,17 @@ index 6a84031fd7..e06862d22a 100644
320
379
+ VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
321
380
+
322
381
+ compat_props_add(mc->compat_props, arm_rhel_compat, arm_rhel_compat_len);
382
+ + compat_props_add(mc->compat_props, hw_compat_rhel_9_1, hw_compat_rhel_9_1_len);
323
383
+
324
384
+ /* Disable FEAT_LPA2 since old kernels (<= v5.12) don't boot with that feature */
325
385
+ vmc->no_tcg_lpa2 = true;
326
386
+}
327
387
+DEFINE_RHEL_MACHINE_AS_LATEST(9, 0, 0)
328
388
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
329
- index 7e76ee2619..9b1efe8f0e 100644
389
+ index 6ec479ca2b..22b54ec510 100644
330
390
--- a/include/hw/arm/virt.h
331
391
+++ b/include/hw/arm/virt.h
332
- @@ -179,9 +179,17 @@ struct VirtMachineState {
392
+ @@ -180,9 +180,17 @@ struct VirtMachineState {
333
393
334
394
#define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)
335
395
@@ -347,6 +407,269 @@ index 7e76ee2619..9b1efe8f0e 100644
347
407
void virt_acpi_setup(VirtMachineState *vms);
348
408
bool virt_is_acpi_enabled(VirtMachineState *vms);
349
409
410
+ diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h
411
+ index 64c44cef2d..82e97249bc 100644
412
+ --- a/target/arm/cpu-qom.h
413
+ +++ b/target/arm/cpu-qom.h
414
+ @@ -35,6 +35,7 @@ typedef struct ARMCPUInfo {
415
+ const char *name;
416
+ void (*initfn)(Object *obj);
417
+ void (*class_init)(ObjectClass *oc, void *data);
418
+ + const char *deprecation_note;
419
+ } ARMCPUInfo;
420
+
421
+ void arm_cpu_register(const ARMCPUInfo *info);
422
+ diff --git a/target/arm/cpu.c b/target/arm/cpu.c
423
+ index 38d066c294..a845814bfb 100644
424
+ --- a/target/arm/cpu.c
425
+ +++ b/target/arm/cpu.c
426
+ @@ -2250,8 +2250,13 @@ static void arm_cpu_instance_init(Object *obj)
427
+ static void cpu_register_class_init(ObjectClass *oc, void *data)
428
+ {
429
+ ARMCPUClass *acc = ARM_CPU_CLASS(oc);
430
+ + CPUClass *cc = CPU_CLASS(oc);
431
+
432
+ acc->info = data;
433
+ +
434
+ + if (acc->info->deprecation_note) {
435
+ + cc->deprecation_note = acc->info->deprecation_note;
436
+ + }
437
+ }
438
+
439
+ void arm_cpu_register(const ARMCPUInfo *info)
440
+ diff --git a/target/arm/cpu.h b/target/arm/cpu.h
441
+ index 9aeed3c848..f9f504d89e 100644
442
+ --- a/target/arm/cpu.h
443
+ +++ b/target/arm/cpu.h
444
+ @@ -34,6 +34,8 @@
445
+ #define KVM_HAVE_MCE_INJECTION 1
446
+ #endif
447
+
448
+ +#define RHEL_CPU_DEPRECATION "use 'host' / 'max'"
449
+ +
450
+ #define EXCP_UDEF 1 /* undefined instruction */
451
+ #define EXCP_SWI 2 /* software interrupt */
452
+ #define EXCP_PREFETCH_ABORT 3
453
+ diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
454
+ index 3d74f134f5..4b330a52b5 100644
455
+ --- a/target/arm/cpu64.c
456
+ +++ b/target/arm/cpu64.c
457
+ @@ -36,6 +36,7 @@
458
+ #include "hw/qdev-properties.h"
459
+ #include "internals.h"
460
+
461
+ +#if 0 /* Disabled for Red Hat Enterprise Linux */
462
+ static void aarch64_a35_initfn(Object *obj)
463
+ {
464
+ ARMCPU *cpu = ARM_CPU(obj);
465
+ @@ -115,6 +116,7 @@ static void aarch64_a35_initfn(Object *obj)
466
+ /* These values are the same with A53/A57/A72. */
467
+ define_cortex_a72_a57_a53_cp_reginfo(cpu);
468
+ }
469
+ +#endif /* disabled for RHEL */
470
+
471
+ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp)
472
+ {
473
+ @@ -735,6 +737,7 @@ static void aarch64_a57_initfn(Object *obj)
474
+ define_cortex_a72_a57_a53_cp_reginfo(cpu);
475
+ }
476
+
477
+ +#if 0 /* Disabled for Red Hat Enterprise Linux */
478
+ static void aarch64_a53_initfn(Object *obj)
479
+ {
480
+ ARMCPU *cpu = ARM_CPU(obj);
481
+ @@ -1033,6 +1036,7 @@ static void aarch64_neoverse_n1_initfn(Object *obj)
482
+ /* From D5.1 AArch64 PMU register summary */
483
+ cpu->isar.reset_pmcr_el0 = 0x410c3000;
484
+ }
485
+ +#endif /* disabled for RHEL */
486
+
487
+ static void aarch64_host_initfn(Object *obj)
488
+ {
489
+ @@ -1240,13 +1244,18 @@ static void aarch64_max_initfn(Object *obj)
490
+ }
491
+
492
+ static const ARMCPUInfo aarch64_cpus[] = {
493
+ +#if 0 /* Disabled for Red Hat Enterprise Linux */
494
+ { .name = "cortex-a35", .initfn = aarch64_a35_initfn },
495
+ - { .name = "cortex-a57", .initfn = aarch64_a57_initfn },
496
+ +#endif /* disabled for RHEL */
497
+ + { .name = "cortex-a57", .initfn = aarch64_a57_initfn,
498
+ + .deprecation_note = RHEL_CPU_DEPRECATION },
499
+ +#if 0 /* Disabled for Red Hat Enterprise Linux */
500
+ { .name = "cortex-a53", .initfn = aarch64_a53_initfn },
501
+ { .name = "cortex-a72", .initfn = aarch64_a72_initfn },
502
+ { .name = "cortex-a76", .initfn = aarch64_a76_initfn },
503
+ { .name = "a64fx", .initfn = aarch64_a64fx_initfn },
504
+ { .name = "neoverse-n1", .initfn = aarch64_neoverse_n1_initfn },
505
+ +#endif /* disabled for RHEL */
506
+ { .name = "max", .initfn = aarch64_max_initfn },
507
+ #if defined(CONFIG_KVM) || defined(CONFIG_HVF)
508
+ { .name = "host", .initfn = aarch64_host_initfn },
509
+ @@ -1318,8 +1327,13 @@ static void aarch64_cpu_instance_init(Object *obj)
510
+ static void cpu_register_class_init(ObjectClass *oc, void *data)
511
+ {
512
+ ARMCPUClass *acc = ARM_CPU_CLASS(oc);
513
+ + CPUClass *cc = CPU_CLASS(oc);
514
+
515
+ acc->info = data;
516
+ +
517
+ + if (acc->info->deprecation_note) {
518
+ + cc->deprecation_note = acc->info->deprecation_note;
519
+ + }
520
+ }
521
+
522
+ void aarch64_cpu_register(const ARMCPUInfo *info)
523
+ diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
524
+ index a528ff9a3d..053f70e399 100644
525
+ --- a/target/arm/cpu_tcg.c
526
+ +++ b/target/arm/cpu_tcg.c
527
+ @@ -148,10 +148,10 @@ void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu)
528
+ }
529
+ #endif /* !CONFIG_USER_ONLY */
530
+
531
+ +#if 0 /* Disabled for Red Hat Enterprise Linux */
532
+ /* CPU models. These are not needed for the AArch64 linux-user build. */
533
+ #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
534
+
535
+ -#if 0 /* Disabled for Red Hat Enterprise Linux */
536
+ #if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG)
537
+ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
538
+ {
539
+ @@ -505,7 +505,6 @@ static void cortex_a9_initfn(Object *obj)
540
+ cpu->isar.reset_pmcr_el0 = 0x41093000;
541
+ define_arm_cp_regs(cpu, cortexa9_cp_reginfo);
542
+ }
543
+ -#endif /* disabled for RHEL */
544
+
545
+ #ifndef CONFIG_USER_ONLY
546
+ static uint64_t a15_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
547
+ @@ -530,7 +529,6 @@ static const ARMCPRegInfo cortexa15_cp_reginfo[] = {
548
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
549
+ };
550
+
551
+ -#if 0 /* Disabled for Red Hat Enterprise Linux */
552
+ static void cortex_a7_initfn(Object *obj)
553
+ {
554
+ ARMCPU *cpu = ARM_CPU(obj);
555
+ @@ -579,7 +577,6 @@ static void cortex_a7_initfn(Object *obj)
556
+ cpu->isar.reset_pmcr_el0 = 0x41072000;
557
+ define_arm_cp_regs(cpu, cortexa15_cp_reginfo); /* Same as A15 */
558
+ }
559
+ -#endif /* disabled for RHEL */
560
+
561
+ static void cortex_a15_initfn(Object *obj)
562
+ {
563
+ @@ -628,7 +625,6 @@ static void cortex_a15_initfn(Object *obj)
564
+ define_arm_cp_regs(cpu, cortexa15_cp_reginfo);
565
+ }
566
+
567
+ -#if 0 /* Disabled for Red Hat Enterprise Linux */
568
+ static void cortex_m0_initfn(Object *obj)
569
+ {
570
+ ARMCPU *cpu = ARM_CPU(obj);
571
+ @@ -1070,7 +1066,6 @@ static void arm_v7m_class_init(ObjectClass *oc, void *data)
572
+
573
+ cc->gdb_core_xml_file = "arm-m-profile.xml";
574
+ }
575
+ -#endif /* disabled for RHEL */
576
+
577
+ #ifndef TARGET_AARCH64
578
+ /*
579
+ @@ -1138,7 +1133,6 @@ static void arm_max_initfn(Object *obj)
580
+ #endif /* !TARGET_AARCH64 */
581
+
582
+ static const ARMCPUInfo arm_tcg_cpus[] = {
583
+ -#if 0 /* Disabled for Red Hat Enterprise Linux */
584
+ { .name = "arm926", .initfn = arm926_initfn },
585
+ { .name = "arm946", .initfn = arm946_initfn },
586
+ { .name = "arm1026", .initfn = arm1026_initfn },
587
+ @@ -1154,9 +1148,7 @@ static const ARMCPUInfo arm_tcg_cpus[] = {
588
+ { .name = "cortex-a7", .initfn = cortex_a7_initfn },
589
+ { .name = "cortex-a8", .initfn = cortex_a8_initfn },
590
+ { .name = "cortex-a9", .initfn = cortex_a9_initfn },
591
+ -#endif /* disabled for RHEL */
592
+ { .name = "cortex-a15", .initfn = cortex_a15_initfn },
593
+ -#if 0 /* Disabled for Red Hat Enterprise Linux */
594
+ { .name = "cortex-m0", .initfn = cortex_m0_initfn,
595
+ .class_init = arm_v7m_class_init },
596
+ { .name = "cortex-m3", .initfn = cortex_m3_initfn,
597
+ @@ -1187,7 +1179,6 @@ static const ARMCPUInfo arm_tcg_cpus[] = {
598
+ { .name = "pxa270-b1", .initfn = pxa270b1_initfn },
599
+ { .name = "pxa270-c0", .initfn = pxa270c0_initfn },
600
+ { .name = "pxa270-c5", .initfn = pxa270c5_initfn },
601
+ -#endif /* disabled for RHEL */
602
+ #ifndef TARGET_AARCH64
603
+ { .name = "max", .initfn = arm_max_initfn },
604
+ #endif
605
+ @@ -1215,3 +1206,4 @@ static void arm_tcg_cpu_register_types(void)
606
+ type_init(arm_tcg_cpu_register_types)
607
+
608
+ #endif /* !CONFIG_USER_ONLY || !TARGET_AARCH64 */
609
+ +#endif /* disabled for RHEL */
610
+ diff --git a/target/arm/helper.c b/target/arm/helper.c
611
+ index d8c8223ec3..ad9d235773 100644
612
+ --- a/target/arm/helper.c
613
+ +++ b/target/arm/helper.c
614
+ @@ -8476,6 +8476,7 @@ void arm_cpu_list(void)
615
+ static void arm_cpu_add_definition(gpointer data, gpointer user_data)
616
+ {
617
+ ObjectClass *oc = data;
618
+ + CPUClass *cc = CPU_CLASS(oc);
619
+ CpuDefinitionInfoList **cpu_list = user_data;
620
+ CpuDefinitionInfo *info;
621
+ const char *typename;
622
+ @@ -8485,6 +8486,7 @@ static void arm_cpu_add_definition(gpointer data, gpointer user_data)
623
+ info->name = g_strndup(typename,
624
+ strlen(typename) - strlen("-" TYPE_ARM_CPU));
625
+ info->q_typename = g_strdup(typename);
626
+ + info->deprecated = !!cc->deprecation_note;
627
+
628
+ QAPI_LIST_PREPEND(*cpu_list, info);
629
+ }
630
+ diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
631
+ index 5a14527386..a3579fc303 100644
632
+ --- a/tests/qtest/arm-cpu-features.c
633
+ +++ b/tests/qtest/arm-cpu-features.c
634
+ @@ -440,8 +440,10 @@ static void test_query_cpu_model_expansion(const void *data)
635
+ assert_error(qts, "host", "The CPU type 'host' requires KVM", NULL);
636
+
637
+ /* Test expected feature presence/absence for some cpu types */
638
+ +#if 0 /* Disabled for Red Hat Enterprise Linux */
639
+ assert_has_feature_enabled(qts, "cortex-a15", "pmu");
640
+ assert_has_not_feature(qts, "cortex-a15", "aarch64");
641
+ +#endif /* disabled for RHEL */
642
+
643
+ /* Enabling and disabling pmu should always work. */
644
+ assert_has_feature_enabled(qts, "max", "pmu");
645
+ @@ -458,6 +460,7 @@ static void test_query_cpu_model_expansion(const void *data)
646
+ assert_has_feature_enabled(qts, "cortex-a57", "pmu");
647
+ assert_has_feature_enabled(qts, "cortex-a57", "aarch64");
648
+
649
+ +#if 0 /* Disabled for Red Hat Enterprise Linux */
650
+ assert_has_feature_enabled(qts, "a64fx", "pmu");
651
+ assert_has_feature_enabled(qts, "a64fx", "aarch64");
652
+ /*
653
+ @@ -470,6 +473,7 @@ static void test_query_cpu_model_expansion(const void *data)
654
+ "{ 'sve384': true }");
655
+ assert_error(qts, "a64fx", "cannot enable sve640",
656
+ "{ 'sve640': true }");
657
+ +#endif /* disabled for RHEL */
658
+
659
+ sve_tests_default(qts, "max");
660
+ pauth_tests_default(qts, "max");
661
+ @@ -505,9 +509,11 @@ static void test_query_cpu_model_expansion_kvm(const void *data)
662
+ QDict *resp;
663
+ char *error;
664
+
665
+ +#if 0 /* Disabled for Red Hat Enterprise Linux */
666
+ assert_error(qts, "cortex-a15",
667
+ "We cannot guarantee the CPU type 'cortex-a15' works "
668
+ "with KVM on this host", NULL);
669
+ +#endif /* disabled for RHEL */
670
+
671
+ assert_has_feature_enabled(qts, "host", "aarch64");
672
+
350
673
--
351
674
2.31.1
352
675
SOURCES/0008-Add-ppc64-machine-types.patch CHANGED
@@ -1,4 +1,4 @@
1
- From f61b3d7dc000886e23943457ee9baf1d4cae43b4 Mon Sep 17 00:00:00 2001
1
+ From 2c523f1b6c9470e1cd517ba99e414cde02727e16 Mon Sep 17 00:00:00 2001
2
2
From: Miroslav Rezanina <mrezanin@redhat.com>
3
3
Date: Fri, 19 Oct 2018 13:27:13 +0200
4
4
Subject: Add ppc64 machine types
@@ -19,21 +19,25 @@ Merged patches (6.1.0):
19
19
- 0215eb3356 Remove RHEL 7.3.0 machine types (only ppc64 changes)
20
20
- af69d1ca6e Remove RHEL 7.4.0 machine types (only ppc64 changes)
21
21
- 8f7a74ab78 Remove RHEL 7.5.0 machine types (only ppc64 changes)
22
+
23
+ Merged patches (7.1.0 rc0):
24
+ - baa6790171 target/ppc/cpu-models: Fix ppc_cpu_aliases list for RHEL
22
25
---
23
26
hw/ppc/spapr.c | 243 ++++++++++++++++++++++++++++++++++++++++
24
27
hw/ppc/spapr_cpu_core.c | 13 +++
25
28
include/hw/ppc/spapr.h | 4 +
26
29
target/ppc/compat.c | 13 ++-
30
+ target/ppc/cpu-models.c | 1 +
27
31
target/ppc/cpu.h | 1 +
28
32
target/ppc/kvm.c | 27 +++++
29
33
target/ppc/kvm_ppc.h | 13 +++
30
- 7 files changed, 313 insertions(+), 1 deletion(-)
34
+ 8 files changed, 314 insertions(+), 1 deletion(-)
31
35
32
36
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
33
- index a4372ba189..5fdf8b506d 100644
37
+ index 66b414d2e9..499eb49253 100644
34
38
--- a/hw/ppc/spapr.c
35
39
+++ b/hw/ppc/spapr.c
36
- @@ -1622,6 +1622,9 @@ static void spapr_machine_reset(MachineState *machine)
40
+ @@ -1633,6 +1633,9 @@ static void spapr_machine_reset(MachineState *machine, ShutdownCause reason)
37
41
38
42
pef_kvm_reset(machine->cgs, &error_fatal);
39
43
spapr_caps_apply(spapr);
@@ -43,7 +47,7 @@ index a4372ba189..5fdf8b506d 100644
43
47
44
48
first_ppc_cpu = POWERPC_CPU(first_cpu);
45
49
if (kvm_enabled() && kvmppc_has_cap_mmu_radix() &&
46
- @@ -3317,6 +3320,20 @@ static void spapr_set_host_serial(Object *obj, const char *value, Error **errp)
50
+ @@ -3347,6 +3350,20 @@ static void spapr_set_host_serial(Object *obj, const char *value, Error **errp)
47
51
spapr->host_serial = g_strdup(value);
48
52
}
49
53
@@ -64,7 +68,7 @@ index a4372ba189..5fdf8b506d 100644
64
68
static void spapr_instance_init(Object *obj)
65
69
{
66
70
SpaprMachineState *spapr = SPAPR_MACHINE(obj);
67
- @@ -3395,6 +3412,12 @@ static void spapr_instance_init(Object *obj)
71
+ @@ -3425,6 +3442,12 @@ static void spapr_instance_init(Object *obj)
68
72
spapr_get_host_serial, spapr_set_host_serial);
69
73
object_property_set_description(obj, "host-serial",
70
74
"Host serial number to advertise in guest device tree");
@@ -77,7 +81,7 @@ index a4372ba189..5fdf8b506d 100644
77
81
}
78
82
79
83
static void spapr_machine_finalizefn(Object *obj)
80
- @@ -4652,6 +4675,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
84
+ @@ -4682,6 +4705,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
81
85
vmc->client_architecture_support = spapr_vof_client_architecture_support;
82
86
vmc->quiesce = spapr_vof_quiesce;
83
87
vmc->setprop = spapr_vof_setprop;
@@ -85,15 +89,15 @@ index a4372ba189..5fdf8b506d 100644
85
89
}
86
90
87
91
static const TypeInfo spapr_machine_info = {
88
- @@ -4703,6 +4727,7 @@ static void spapr_machine_latest_class_options(MachineClass *mc)
92
+ @@ -4733,6 +4757,7 @@ static void spapr_machine_latest_class_options(MachineClass *mc)
89
93
} \
90
94
type_init(spapr_machine_register_##suffix)
91
95
92
96
+#if 0 /* Disabled for Red Hat Enterprise Linux */
93
97
/*
94
- * pseries-7.0
98
+ * pseries-7.2
95
99
*/
96
- @@ -4830,6 +4855,7 @@ static void spapr_machine_4_1_class_options(MachineClass *mc)
100
+ @@ -4882,6 +4907,7 @@ static void spapr_machine_4_1_class_options(MachineClass *mc)
97
101
}
98
102
99
103
DEFINE_SPAPR_MACHINE(4_1, "4.1", false);
@@ -101,7 +105,7 @@ index a4372ba189..5fdf8b506d 100644
101
105
102
106
/*
103
107
* pseries-4.0
104
- @@ -4849,6 +4875,8 @@ static bool phb_placement_4_0(SpaprMachineState *spapr, uint32_t index,
108
+ @@ -4901,6 +4927,8 @@ static bool phb_placement_4_0(SpaprMachineState *spapr, uint32_t index,
105
109
*nv2atsd = 0;
106
110
return true;
107
111
}
@@ -110,7 +114,7 @@ index a4372ba189..5fdf8b506d 100644
110
114
static void spapr_machine_4_0_class_options(MachineClass *mc)
111
115
{
112
116
SpaprMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
113
- @@ -5176,6 +5204,221 @@ static void spapr_machine_2_1_class_options(MachineClass *mc)
117
+ @@ -5228,6 +5256,221 @@ static void spapr_machine_2_1_class_options(MachineClass *mc)
114
118
compat_props_add(mc->compat_props, hw_compat_2_1, hw_compat_2_1_len);
115
119
}
116
120
DEFINE_SPAPR_MACHINE(2_1, "2.1", false);
@@ -371,7 +375,7 @@ index fcb5dfe792..ab8fb5bf62 100644
371
375
qdev_unrealize(DEVICE(cpu));
372
376
return false;
373
377
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
374
- index f5c33dcc86..4a68e0a901 100644
378
+ index 04a95669ab..d5f4cf5e03 100644
375
379
--- a/include/hw/ppc/spapr.h
376
380
+++ b/include/hw/ppc/spapr.h
377
381
@@ -154,6 +154,7 @@ struct SpaprMachineClass {
@@ -382,7 +386,7 @@ index f5c33dcc86..4a68e0a901 100644
382
386
bool (*phb_placement)(SpaprMachineState *spapr, uint32_t index,
383
387
uint64_t *buid, hwaddr *pio,
384
388
hwaddr *mmio32, hwaddr *mmio64,
385
- @@ -241,6 +242,9 @@ struct SpaprMachineState {
389
+ @@ -256,6 +257,9 @@ struct SpaprMachineState {
386
390
/* Set by -boot */
387
391
char *boot_device;
388
392
@@ -417,11 +421,23 @@ index 7949a24f5a..f207a9ba01 100644
417
421
{
418
422
const CompatInfo *compat = compat_by_pvr(compat_pvr);
419
423
const CompatInfo *min = compat_by_pvr(min_compat_pvr);
424
+ diff --git a/target/ppc/cpu-models.c b/target/ppc/cpu-models.c
425
+ index cd3ff700ac..1cb49c8087 100644
426
+ --- a/target/ppc/cpu-models.c
427
+ +++ b/target/ppc/cpu-models.c
428
+ @@ -746,6 +746,7 @@
429
+ /* PowerPC CPU aliases */
430
+
431
+ PowerPCCPUAlias ppc_cpu_aliases[] = {
432
+ +#if 0 /* Disabled for Red Hat Enterprise Linux */
433
+ { "405", "405d4" },
434
+ { "405cr", "405crc" },
435
+ { "405gp", "405gpd" },
420
436
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
421
- index 047b24ba50..79c5ac50b9 100644
437
+ index 81d4263a07..508fbed90b 100644
422
438
--- a/target/ppc/cpu.h
423
439
+++ b/target/ppc/cpu.h
424
- @@ -1462,6 +1462,7 @@ static inline int cpu_mmu_index(CPUPPCState *env, bool ifetch)
440
+ @@ -1467,6 +1467,7 @@ static inline int cpu_mmu_index(CPUPPCState *env, bool ifetch)
425
441
426
442
/* Compatibility modes */
427
443
#if defined(TARGET_PPC64)
@@ -430,10 +446,10 @@ index 047b24ba50..79c5ac50b9 100644
430
446
uint32_t min_compat_pvr, uint32_t max_compat_pvr);
431
447
bool ppc_type_check_compat(const char *cputype, uint32_t compat_pvr,
432
448
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
433
- index dc93b99189..154888cce5 100644
449
+ index 7c25348b7b..83671c955f 100644
434
450
--- a/target/ppc/kvm.c
435
451
+++ b/target/ppc/kvm.c
436
- @@ -90,6 +90,7 @@ static int cap_ppc_nested_kvm_hv;
452
+ @@ -89,6 +89,7 @@ static int cap_ppc_nested_kvm_hv;
437
453
static int cap_large_decr;
438
454
static int cap_fwnmi;
439
455
static int cap_rpt_invalidate;
@@ -441,7 +457,7 @@ index dc93b99189..154888cce5 100644
441
457
442
458
static uint32_t debug_inst_opcode;
443
459
444
- @@ -137,6 +138,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
460
+ @@ -136,6 +137,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
445
461
cap_resize_hpt = kvm_vm_check_extension(s, KVM_CAP_SPAPR_RESIZE_HPT);
446
462
kvmppc_get_cpu_characteristics(s);
447
463
cap_ppc_nested_kvm_hv = kvm_vm_check_extension(s, KVM_CAP_PPC_NESTED_HV);
@@ -449,7 +465,7 @@ index dc93b99189..154888cce5 100644
449
465
cap_large_decr = kvmppc_get_dec_bits();
450
466
cap_fwnmi = kvm_vm_check_extension(s, KVM_CAP_PPC_FWNMI);
451
467
/*
452
- @@ -2563,6 +2565,16 @@ int kvmppc_has_cap_rpt_invalidate(void)
468
+ @@ -2570,6 +2572,16 @@ int kvmppc_has_cap_rpt_invalidate(void)
453
469
return cap_rpt_invalidate;
454
470
}
455
471
@@ -466,9 +482,9 @@ index dc93b99189..154888cce5 100644
466
482
PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void)
467
483
{
468
484
uint32_t host_pvr = mfpvr();
469
- @@ -2959,3 +2971,18 @@ bool kvm_arch_cpu_check_are_resettable(void)
485
+ @@ -2970,3 +2982,18 @@ bool kvm_arch_cpu_check_are_resettable(void)
486
+ void kvm_arch_accel_class_init(ObjectClass *oc)
470
487
{
471
- return true;
472
488
}
473
489
+
474
490
+void kvmppc_svm_allow(Error **errp)
SOURCES/0009-Add-s390x-machine-types.patch CHANGED
@@ -1,4 +1,4 @@
1
- From 680f343e58a50a99d17bc7dedd3ee90980912023 Mon Sep 17 00:00:00 2001
1
+ From 1973257ed781a93943f27f1518933e8c09c50f88 Mon Sep 17 00:00:00 2001
2
2
From: Miroslav Rezanina <mrezanin@redhat.com>
3
3
Date: Fri, 19 Oct 2018 13:47:32 +0200
4
4
Subject: Add s390x machine types
@@ -7,6 +7,10 @@ Adding changes to add RHEL machine types for s390x architecture.
7
7
8
8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9
9
--
10
+
11
+ Rebase changes (7.1.0 rc0):
12
+ - Moved adding rhel_old_machine_deprecation variable to general machine types commit
13
+
10
14
Merged patches (6.1.0):
11
15
- 64a9a5c971 hw/s390x: Remove the RHEL7-only machine type
12
16
- 395516d62b redhat: s390x: add rhel-8.5.0 compat machine
@@ -18,62 +22,51 @@ Merged patches (7.0.0):
18
22
- e6ff4de4f7 redhat: Add s390x machine type compatibility handling for the rebase to v6.2
19
23
- 4b0efa7e21 redhat: Add rhel8.6.0 and rhel9.0.0 machine types for s390x
20
24
- dcc64971bf RHEL: mark old machine types as deprecated (partialy)
25
+
26
+ Merged patches (7.1.0 rc0):
27
+ - 1d6439527a WRB: Introduce RHEL 9.0.0 hw compat structure (only hw/s390x/s390-virtio-ccw.c chunk)
28
+ - c8ad21ca31 redhat: Update s390x machine type compatibility for rebase to QEMU 7.0.0
29
+ - 5bcf8d874c target/s390x: deprecate CPUs older than z14
30
+
31
+ Merged patches (7.2.0 rc0):
32
+ - 0be2889fa2 Introduce upstream 7.0 compat changes (only applicable parts)
21
33
---
22
- hw/core/machine.c | 6 +++
23
- hw/s390x/s390-virtio-ccw.c | 104 ++++++++++++++++++++++++++++++++++++-
24
- include/hw/boards.h | 2 +
25
- 3 files changed, 111 insertions(+), 1 deletion(-)
34
+ hw/s390x/s390-virtio-ccw.c | 108 +++++++++++++++++++++++++++++++
35
+ target/s390x/cpu_models.c | 11 ++++
36
+ target/s390x/cpu_models.h | 2 +
37
+ target/s390x/cpu_models_sysemu.c | 2 +
38
+ 4 files changed, 123 insertions(+)
26
39
27
- diff --git a/hw/core/machine.c b/hw/core/machine.c
28
- index ea430d844e..77202a3570 100644
29
- --- a/hw/core/machine.c
30
- +++ b/hw/core/machine.c
31
- @@ -37,6 +37,12 @@
32
- #include "hw/virtio/virtio.h"
33
- #include "hw/virtio/virtio-pci.h"
34
-
35
- +/*
36
- + * RHEL only: machine types for previous major releases are deprecated
37
- + */
38
- +const char *rhel_old_machine_deprecation =
39
- + "machine types for previous major releases are deprecated";
40
- +
41
- /*
42
- * Mostly the same as hw_compat_6_0 and hw_compat_6_1
43
- */
44
40
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
45
- index 90480e7cf9..ec4176a1e0 100644
41
+ index 2e64ffab45..8d5221fbb1 100644
46
42
--- a/hw/s390x/s390-virtio-ccw.c
47
43
+++ b/hw/s390x/s390-virtio-ccw.c
48
- @@ -767,7 +767,7 @@ bool css_migration_enabled(void)
44
+ @@ -823,6 +823,7 @@ bool css_migration_enabled(void)
49
- { \
50
- MachineClass *mc = MACHINE_CLASS(oc); \
51
- ccw_machine_##suffix##_class_options(mc); \
52
- - mc->desc = "VirtIO-ccw based S390 machine v" verstr; \
53
- + mc->desc = "VirtIO-ccw based S390 machine " verstr; \
54
- if (latest) { \
55
- mc->alias = "s390-ccw-virtio"; \
56
- mc->is_default = true; \
57
- @@ -791,6 +791,7 @@ bool css_migration_enabled(void)
58
45
} \
59
46
type_init(ccw_machine_register_##suffix)
60
47
61
48
+#if 0 /* Disabled for Red Hat Enterprise Linux */
62
- static void ccw_machine_7_0_instance_options(MachineState *machine)
49
+ static void ccw_machine_7_2_instance_options(MachineState *machine)
63
50
{
64
51
}
65
- @@ -1115,6 +1116,107 @@ static void ccw_machine_2_4_class_options(MachineClass *mc)
52
+ @@ -1186,6 +1187,113 @@ static void ccw_machine_2_4_class_options(MachineClass *mc)
66
53
compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
67
54
}
68
55
DEFINE_CCW_MACHINE(2_4, "2.4", false);
69
56
+#endif
70
57
+
58
+ +
71
59
+static void ccw_machine_rhel900_instance_options(MachineState *machine)
72
60
+{
61
+ + static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V6_2 };
62
+ +
63
+ + s390_set_qemu_cpu_model(0x3906, 14, 2, qemu_cpu_feat);
73
64
+}
74
65
+
75
66
+static void ccw_machine_rhel900_class_options(MachineClass *mc)
76
67
+{
68
+ + compat_props_add(mc->compat_props, hw_compat_rhel_9_1, hw_compat_rhel_9_1_len);
69
+ + compat_props_add(mc->compat_props, hw_compat_rhel_9_0, hw_compat_rhel_9_0_len);
77
70
+}
78
71
+DEFINE_CCW_MACHINE(rhel900, "rhel9.0.0", true);
79
72
+
@@ -170,17 +163,84 @@ index 90480e7cf9..ec4176a1e0 100644
170
163
171
164
static void ccw_machine_register_types(void)
172
165
{
173
- diff --git a/include/hw/boards.h b/include/hw/boards.h
174
- index c90a19b4d1..bf59275f18 100644
175
- --- a/include/hw/boards.h
176
- +++ b/include/hw/boards.h
177
- @@ -470,4 +470,6 @@ extern const size_t hw_compat_rhel_8_0_len;
178
- extern GlobalProperty hw_compat_rhel_7_6[];
179
- extern const size_t hw_compat_rhel_7_6_len;
180
-
181
- +extern const char *rhel_old_machine_deprecation;
166
+ diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
167
+ index c3a4f80633..739770dc15 100644
168
+ --- a/target/s390x/cpu_models.c
169
+ +++ b/target/s390x/cpu_models.c
170
+ @@ -45,6 +45,9 @@
171
+ * of a following release have been a superset of the previous release. With
172
+ * generation 15 one base feature and one optional feature have been deprecated.
173
+ */
174
+ +
175
+ +#define RHEL_CPU_DEPRECATION "use at least 'z14', or 'host' / 'qemu' / 'max'"
182
176
+
183
- #endif
177
+ static S390CPUDef s390_cpu_defs[] = {
178
+ CPUDEF_INIT(0x2064, 7, 1, 38, 0x00000000U, "z900", "IBM zSeries 900 GA1"),
179
+ CPUDEF_INIT(0x2064, 7, 2, 38, 0x00000000U, "z900.2", "IBM zSeries 900 GA2"),
180
+ @@ -854,22 +857,30 @@ static void s390_host_cpu_model_class_init(ObjectClass *oc, void *data)
181
+ static void s390_base_cpu_model_class_init(ObjectClass *oc, void *data)
182
+ {
183
+ S390CPUClass *xcc = S390_CPU_CLASS(oc);
184
+ + CPUClass *cc = CPU_CLASS(oc);
185
+
186
+ /* all base models are migration safe */
187
+ xcc->cpu_def = (const S390CPUDef *) data;
188
+ xcc->is_migration_safe = true;
189
+ xcc->is_static = true;
190
+ xcc->desc = xcc->cpu_def->desc;
191
+ + if (xcc->cpu_def->gen < 14) {
192
+ + cc->deprecation_note = RHEL_CPU_DEPRECATION;
193
+ + }
194
+ }
195
+
196
+ static void s390_cpu_model_class_init(ObjectClass *oc, void *data)
197
+ {
198
+ S390CPUClass *xcc = S390_CPU_CLASS(oc);
199
+ + CPUClass *cc = CPU_CLASS(oc);
200
+
201
+ /* model that can change between QEMU versions */
202
+ xcc->cpu_def = (const S390CPUDef *) data;
203
+ xcc->is_migration_safe = true;
204
+ xcc->desc = xcc->cpu_def->desc;
205
+ + if (xcc->cpu_def->gen < 14) {
206
+ + cc->deprecation_note = RHEL_CPU_DEPRECATION;
207
+ + }
208
+ }
209
+
210
+ static void s390_qemu_cpu_model_class_init(ObjectClass *oc, void *data)
211
+ diff --git a/target/s390x/cpu_models.h b/target/s390x/cpu_models.h
212
+ index fb1adc8b21..d76745afa9 100644
213
+ --- a/target/s390x/cpu_models.h
214
+ +++ b/target/s390x/cpu_models.h
215
+ @@ -38,6 +38,8 @@ struct S390CPUDef {
216
+ S390FeatBitmap full_feat;
217
+ /* used to init full_feat from generated data */
218
+ S390FeatInit full_init;
219
+ + /* if deprecated, provides a suggestion */
220
+ + const char *deprecation_note;
221
+ };
222
+
223
+ /* CPU model based on a CPU definition */
224
+ diff --git a/target/s390x/cpu_models_sysemu.c b/target/s390x/cpu_models_sysemu.c
225
+ index d086b1c39c..1b9cc66405 100644
226
+ --- a/target/s390x/cpu_models_sysemu.c
227
+ +++ b/target/s390x/cpu_models_sysemu.c
228
+ @@ -60,6 +60,7 @@ static void create_cpu_model_list(ObjectClass *klass, void *opaque)
229
+ CpuDefinitionInfo *info;
230
+ char *name = g_strdup(object_class_get_name(klass));
231
+ S390CPUClass *scc = S390_CPU_CLASS(klass);
232
+ + CPUClass *cc = CPU_CLASS(klass);
233
+
234
+ /* strip off the -s390x-cpu */
235
+ g_strrstr(name, "-" TYPE_S390_CPU)[0] = 0;
236
+ @@ -69,6 +70,7 @@ static void create_cpu_model_list(ObjectClass *klass, void *opaque)
237
+ info->migration_safe = scc->is_migration_safe;
238
+ info->q_static = scc->is_static;
239
+ info->q_typename = g_strdup(object_class_get_name(klass));
240
+ + info->deprecated = !!cc->deprecation_note;
241
+ /* check for unavailable features */
242
+ if (cpu_list_data->model) {
243
+ Object *obj;
184
244
--
185
245
2.31.1
186
246
SOURCES/0010-Add-x86_64-machine-types.patch CHANGED
@@ -1,4 +1,4 @@
1
- From 427a575ca57966bc72e1ebf218081da530d435d7 Mon Sep 17 00:00:00 2001
1
+ From 0935624ccdddc286d6eeeb0c1b70d78983c21aa2 Mon Sep 17 00:00:00 2001
2
2
From: Miroslav Rezanina <mrezanin@redhat.com>
3
3
Date: Fri, 19 Oct 2018 13:10:31 +0200
4
4
Subject: Add x86_64 machine types
@@ -31,45 +31,32 @@ Merged patches (7.0.0):
31
31
- 6110d865e5 x86: Add q35 RHEL 9.0.0 machine type
32
32
- dcc64971bf RHEL: mark old machine types as deprecated (partialy)
33
33
- 6b396f182b RHEL: disable "seqpacket" for "vhost-vsock-device" in rhel8.6.0
34
+
35
+ Merged patches (7.1.0 rc0):
36
+ - 38b89dc245 pc: Move s3/s4 suspend disabling to compat (only hw/i386/pc.c chunk)
37
+ - 1d6439527a WRB: Introduce RHEL 9.0.0 hw compat structure (x86_64 specific changes)
38
+ - 35b5c8554f target/i386: deprecate CPUs older than x86_64-v2 ABI
39
+
40
+ Merged patches (7.2.0 rc0):
41
+ - 0be2889fa2 Introduce upstream 7.0 compat changes (only applicable parts)
34
42
---
35
- hw/core/machine.c | 10 ++
36
- hw/i386/pc.c | 135 +++++++++++++++++++++-
37
- hw/i386/pc_piix.c | 79 ++++++++++++-
43
+ hw/i386/pc.c | 147 ++++++++++++++++++++++-
44
+ hw/i386/pc_piix.c | 86 +++++++++++++-
45
+ hw/i386/pc_q35.c | 234 ++++++++++++++++++++++++++++++++++++-
38
- hw/i386/pc_q35.c | 227 ++++++++++++++++++++++++++++++++++++-
39
46
hw/s390x/s390-virtio-ccw.c | 1 +
40
- include/hw/boards.h | 5 +
41
- include/hw/i386/pc.h | 24 ++++
47
+ include/hw/boards.h | 2 +
48
+ include/hw/i386/pc.h | 27 +++++
49
+ target/i386/cpu.c | 21 ++++
42
50
target/i386/kvm/kvm-cpu.c | 1 +
43
51
target/i386/kvm/kvm.c | 4 +
44
52
tests/qtest/pvpanic-test.c | 5 +-
45
- 10 files changed, 484 insertions(+), 7 deletions(-)
53
+ 10 files changed, 521 insertions(+), 7 deletions(-)
46
54
47
- diff --git a/hw/core/machine.c b/hw/core/machine.c
48
- index 77202a3570..28989b6e7b 100644
49
- --- a/hw/core/machine.c
50
- +++ b/hw/core/machine.c
51
- @@ -43,6 +43,16 @@
52
- const char *rhel_old_machine_deprecation =
53
- "machine types for previous major releases are deprecated";
54
-
55
- +GlobalProperty hw_compat_rhel_8_6[] = {
56
- + /* hw_compat_rhel_8_6 bz 2065589 */
57
- + /*
58
- + * vhost-vsock device in RHEL 8 kernels doesn't support seqpacket, so
59
- + * we need do disable it downstream on the latest hw_compat_rhel_8.
60
- + */
61
- + { "vhost-vsock-device", "seqpacket", "off" },
62
- +};
63
- +const size_t hw_compat_rhel_8_6_len = G_N_ELEMENTS(hw_compat_rhel_8_6);
64
- +
65
- /*
66
- * Mostly the same as hw_compat_6_0 and hw_compat_6_1
67
- */
68
55
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
69
- index fd55fc725c..263d882af6 100644
56
+ index 546b703cb4..c7b1350e64 100644
70
57
--- a/hw/i386/pc.c
71
58
+++ b/hw/i386/pc.c
72
- @@ -375,6 +375,137 @@ GlobalProperty pc_compat_1_4[] = {
59
+ @@ -393,6 +393,149 @@ GlobalProperty pc_compat_1_4[] = {
73
60
};
74
61
const size_t pc_compat_1_4_len = G_N_ELEMENTS(pc_compat_1_4);
75
62
@@ -78,6 +65,12 @@ index fd55fc725c..263d882af6 100644
78
65
+ * machine type.
79
66
+ */
80
67
+GlobalProperty pc_rhel_compat[] = {
68
+ + /* we don't support s3/s4 suspend */
69
+ + { "PIIX4_PM", "disable_s3", "1" },
70
+ + { "PIIX4_PM", "disable_s4", "1" },
71
+ + { "ICH9-LPC", "disable_s3", "1" },
72
+ + { "ICH9-LPC", "disable_s4", "1" },
73
+ +
81
74
+ { TYPE_X86_CPU, "host-phys-bits", "on" },
82
75
+ { TYPE_X86_CPU, "host-phys-bits-limit", "48" },
83
76
+ { TYPE_X86_CPU, "vmx-entry-load-perf-global-ctrl", "off" },
@@ -89,6 +82,12 @@ index fd55fc725c..263d882af6 100644
89
82
+};
90
83
+const size_t pc_rhel_compat_len = G_N_ELEMENTS(pc_rhel_compat);
91
84
+
85
+ +GlobalProperty pc_rhel_9_0_compat[] = {
86
+ + /* pc_rhel_9_0_compat from pc_compat_6_2 */
87
+ + { "virtio-mem", "unplugged-inaccessible", "off" },
88
+ +};
89
+ +const size_t pc_rhel_9_0_compat_len = G_N_ELEMENTS(pc_rhel_9_0_compat);
90
+ +
92
91
+GlobalProperty pc_rhel_8_5_compat[] = {
93
92
+ /* pc_rhel_8_5_compat from pc_compat_6_0 */
94
93
+ { "qemu64" "-" TYPE_X86_CPU, "family", "6" },
@@ -207,7 +206,7 @@ index fd55fc725c..263d882af6 100644
207
206
GSIState *pc_gsi_create(qemu_irq **irqs, bool pci_enabled)
208
207
{
209
208
GSIState *s;
210
- @@ -1738,6 +1869,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
209
+ @@ -1907,6 +2050,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
211
210
pcmc->pvh_enabled = true;
212
211
pcmc->kvmclock_create_always = true;
213
212
assert(!mc->get_hotplug_handler);
@@ -215,7 +214,7 @@ index fd55fc725c..263d882af6 100644
215
214
mc->get_hotplug_handler = pc_get_hotplug_handler;
216
215
mc->hotplug_allowed = pc_hotplug_allowed;
217
216
mc->cpu_index_to_instance_props = x86_cpu_index_to_props;
218
- @@ -1748,7 +1880,8 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
217
+ @@ -1917,7 +2061,8 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
219
218
mc->has_hotpluggable_cpus = true;
220
219
mc->default_boot_order = "cad";
221
220
mc->block_default_type = IF_IDE;
@@ -226,10 +225,10 @@ index fd55fc725c..263d882af6 100644
226
225
mc->wakeup = pc_machine_wakeup;
227
226
hc->pre_plug = pc_machine_device_pre_plug_cb;
228
227
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
229
- index c797e98312..0cacc0d623 100644
228
+ index 0985ff67d2..173a1fd10b 100644
230
229
--- a/hw/i386/pc_piix.c
231
230
+++ b/hw/i386/pc_piix.c
232
- @@ -50,6 +50,7 @@
231
+ @@ -53,6 +53,7 @@
233
232
#include "qapi/error.h"
234
233
#include "qemu/error-report.h"
235
234
#include "sysemu/xen.h"
@@ -237,7 +236,7 @@ index c797e98312..0cacc0d623 100644
237
236
#ifdef CONFIG_XEN
238
237
#include <xen/hvm/hvm_info_table.h>
239
238
#include "hw/xen/xen_pt.h"
240
- @@ -174,8 +175,8 @@ static void pc_init1(MachineState *machine,
239
+ @@ -184,8 +185,8 @@ static void pc_init1(MachineState *machine,
241
240
if (pcmc->smbios_defaults) {
242
241
MachineClass *mc = MACHINE_GET_CLASS(machine);
243
242
/* These values are guest ABI, do not change */
@@ -248,7 +247,7 @@ index c797e98312..0cacc0d623 100644
248
247
pcmc->smbios_uuid_encoded,
249
248
pcmc->smbios_stream_product,
250
249
pcmc->smbios_stream_version,
251
- @@ -314,6 +315,7 @@ static void pc_init1(MachineState *machine,
250
+ @@ -334,6 +335,7 @@ static void pc_init1(MachineState *machine,
252
251
* hw_compat_*, pc_compat_*, or * pc_*_machine_options().
253
252
*/
254
253
@@ -256,7 +255,7 @@ index c797e98312..0cacc0d623 100644
256
255
static void pc_compat_2_3_fn(MachineState *machine)
257
256
{
258
257
X86MachineState *x86ms = X86_MACHINE(machine);
259
- @@ -967,3 +969,76 @@ static void xenfv_3_1_machine_options(MachineClass *m)
258
+ @@ -896,3 +898,83 @@ static void xenfv_3_1_machine_options(MachineClass *m)
260
259
DEFINE_PC_MACHINE(xenfv, "xenfv-3.1", pc_xen_hvm_init,
261
260
xenfv_3_1_machine_options);
262
261
#endif
@@ -305,6 +304,13 @@ index c797e98312..0cacc0d623 100644
305
304
+ pcmc->kvmclock_create_always = false;
306
305
+ /* From pc_i440fx_5_1_machine_options() */
307
306
+ pcmc->pci_root_uid = 1;
307
+ + pcmc->legacy_no_rng_seed = true;
308
+ + compat_props_add(m->compat_props, hw_compat_rhel_9_1,
309
+ + hw_compat_rhel_9_1_len);
310
+ + compat_props_add(m->compat_props, hw_compat_rhel_9_0,
311
+ + hw_compat_rhel_9_0_len);
312
+ + compat_props_add(m->compat_props, pc_rhel_9_0_compat,
313
+ + pc_rhel_9_0_compat_len);
308
314
+ compat_props_add(m->compat_props, hw_compat_rhel_8_6,
309
315
+ hw_compat_rhel_8_6_len);
310
316
+ compat_props_add(m->compat_props, hw_compat_rhel_8_5,
@@ -334,10 +340,10 @@ index c797e98312..0cacc0d623 100644
334
340
+DEFINE_PC_MACHINE(rhel760, "pc-i440fx-rhel7.6.0", pc_init_rhel760,
335
341
+ pc_machine_rhel760_options);
336
342
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
337
- index b695f88c45..157160e069 100644
343
+ index ea582254e3..97c3630021 100644
338
344
--- a/hw/i386/pc_q35.c
339
345
+++ b/hw/i386/pc_q35.c
340
- @@ -197,8 +197,8 @@ static void pc_q35_init(MachineState *machine)
346
+ @@ -198,8 +198,8 @@ static void pc_q35_init(MachineState *machine)
341
347
342
348
if (pcmc->smbios_defaults) {
343
349
/* These values are guest ABI, do not change */
@@ -348,7 +354,7 @@ index b695f88c45..157160e069 100644
348
354
pcmc->smbios_uuid_encoded,
349
355
pcmc->smbios_stream_product,
350
356
pcmc->smbios_stream_version,
351
- @@ -342,6 +342,7 @@ static void pc_q35_init(MachineState *machine)
357
+ @@ -352,6 +352,7 @@ static void pc_q35_init(MachineState *machine)
352
358
DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn)
353
359
354
360
@@ -356,7 +362,7 @@ index b695f88c45..157160e069 100644
356
362
static void pc_q35_machine_options(MachineClass *m)
357
363
{
358
364
PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
359
- @@ -631,3 +632,225 @@ static void pc_q35_2_4_machine_options(MachineClass *m)
365
+ @@ -666,3 +667,232 @@ static void pc_q35_2_4_machine_options(MachineClass *m)
360
366
361
367
DEFINE_Q35_MACHINE(v2_4, "pc-q35-2.4", NULL,
362
368
pc_q35_2_4_machine_options);
@@ -397,6 +403,13 @@ index b695f88c45..157160e069 100644
397
403
+ m->desc = "RHEL-9.0.0 PC (Q35 + ICH9, 2009)";
398
404
+ pcmc->smbios_stream_product = "RHEL";
399
405
+ pcmc->smbios_stream_version = "9.0.0";
406
+ + pcmc->legacy_no_rng_seed = true;
407
+ + compat_props_add(m->compat_props, hw_compat_rhel_9_1,
408
+ + hw_compat_rhel_9_1_len);
409
+ + compat_props_add(m->compat_props, hw_compat_rhel_9_0,
410
+ + hw_compat_rhel_9_0_len);
411
+ + compat_props_add(m->compat_props, pc_rhel_9_0_compat,
412
+ + pc_rhel_9_0_compat_len);
400
413
+}
401
414
+
402
415
+DEFINE_PC_MACHINE(q35_rhel900, "pc-q35-rhel9.0.0", pc_q35_init_rhel900,
@@ -583,10 +596,10 @@ index b695f88c45..157160e069 100644
583
596
+DEFINE_PC_MACHINE(q35_rhel760, "pc-q35-rhel7.6.0", pc_q35_init_rhel760,
584
597
+ pc_q35_machine_rhel760_options);
585
598
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
586
- index ec4176a1e0..465a2a09d2 100644
599
+ index 8d5221fbb1..ba640e3d9e 100644
587
600
--- a/hw/s390x/s390-virtio-ccw.c
588
601
+++ b/hw/s390x/s390-virtio-ccw.c
589
- @@ -1136,6 +1136,7 @@ static void ccw_machine_rhel860_instance_options(MachineState *machine)
602
+ @@ -1213,6 +1213,7 @@ static void ccw_machine_rhel860_instance_options(MachineState *machine)
590
603
static void ccw_machine_rhel860_class_options(MachineClass *mc)
591
604
{
592
605
ccw_machine_rhel900_class_options(mc);
@@ -595,7 +608,7 @@ index ec4176a1e0..465a2a09d2 100644
595
608
/* All RHEL machines for prior major releases are deprecated */
596
609
mc->deprecation_reason = rhel_old_machine_deprecation;
597
610
diff --git a/include/hw/boards.h b/include/hw/boards.h
598
- index bf59275f18..d1555665df 100644
611
+ index 2209d4e416..fd75f551b1 100644
599
612
--- a/include/hw/boards.h
600
613
+++ b/include/hw/boards.h
601
614
@@ -266,6 +266,8 @@ struct MachineClass {
@@ -607,27 +620,20 @@ index bf59275f18..d1555665df 100644
607
620
bool ignore_boot_device_suffixes;
608
621
bool smbus_no_migration_support;
609
622
bool nvdimm_supported;
610
- @@ -449,6 +451,9 @@ extern const size_t hw_compat_2_2_len;
611
- extern GlobalProperty hw_compat_2_1[];
612
- extern const size_t hw_compat_2_1_len;
613
-
614
- +extern GlobalProperty hw_compat_rhel_8_6[];
615
- +extern const size_t hw_compat_rhel_8_6_len;
616
- +
617
- extern GlobalProperty hw_compat_rhel_8_5[];
618
- extern const size_t hw_compat_rhel_8_5_len;
619
-
620
623
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
621
- index 91331059d9..419a6ec24b 100644
624
+ index 3754eaa97d..4266fe2fdb 100644
622
625
--- a/include/hw/i386/pc.h
623
626
+++ b/include/hw/i386/pc.h
624
- @@ -289,6 +289,30 @@ extern const size_t pc_compat_1_5_len;
627
+ @@ -293,6 +293,33 @@ extern const size_t pc_compat_1_5_len;
625
628
extern GlobalProperty pc_compat_1_4[];
626
629
extern const size_t pc_compat_1_4_len;
627
630
628
631
+extern GlobalProperty pc_rhel_compat[];
629
632
+extern const size_t pc_rhel_compat_len;
630
633
+
634
+ +extern GlobalProperty pc_rhel_9_0_compat[];
635
+ +extern const size_t pc_rhel_9_0_compat_len;
636
+ +
631
637
+extern GlobalProperty pc_rhel_8_5_compat[];
632
638
+extern const size_t pc_rhel_8_5_compat_len;
633
639
+
@@ -649,11 +655,165 @@ index 91331059d9..419a6ec24b 100644
649
655
+extern GlobalProperty pc_rhel_7_6_compat[];
650
656
+extern const size_t pc_rhel_7_6_compat_len;
651
657
+
652
- /* Helper for setting model-id for CPU models that changed model-id
653
- * depending on QEMU versions up to QEMU 2.4.
658
+ #define DEFINE_PC_MACHINE(suffix, namestr, initfn, optsfn) \
659
+ static void pc_machine_##suffix##_class_init(ObjectClass *oc, void *data) \
660
+ { \
661
+ diff --git a/target/i386/cpu.c b/target/i386/cpu.c
662
+ index 22b681ca37..f7c526cbe6 100644
663
+ --- a/target/i386/cpu.c
664
+ +++ b/target/i386/cpu.c
665
+ @@ -1832,9 +1832,13 @@ static const CPUCaches epyc_milan_cache_info = {
666
+ * PT in VMX operation
654
667
*/
668
+
669
+ +#define RHEL_CPU_DEPRECATION \
670
+ + "use at least 'Nehalem' / 'Opteron_G4', or 'host' / 'max'"
671
+ +
672
+ static const X86CPUDefinition builtin_x86_defs[] = {
673
+ {
674
+ .name = "qemu64",
675
+ + .deprecation_note = RHEL_CPU_DEPRECATION,
676
+ .level = 0xd,
677
+ .vendor = CPUID_VENDOR_AMD,
678
+ .family = 15,
679
+ @@ -1855,6 +1859,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
680
+ },
681
+ {
682
+ .name = "phenom",
683
+ + .deprecation_note = RHEL_CPU_DEPRECATION,
684
+ .level = 5,
685
+ .vendor = CPUID_VENDOR_AMD,
686
+ .family = 16,
687
+ @@ -1887,6 +1892,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
688
+ },
689
+ {
690
+ .name = "core2duo",
691
+ + .deprecation_note = RHEL_CPU_DEPRECATION,
692
+ .level = 10,
693
+ .vendor = CPUID_VENDOR_INTEL,
694
+ .family = 6,
695
+ @@ -1929,6 +1935,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
696
+ },
697
+ {
698
+ .name = "kvm64",
699
+ + .deprecation_note = RHEL_CPU_DEPRECATION,
700
+ .level = 0xd,
701
+ .vendor = CPUID_VENDOR_INTEL,
702
+ .family = 15,
703
+ @@ -1970,6 +1977,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
704
+ },
705
+ {
706
+ .name = "qemu32",
707
+ + .deprecation_note = RHEL_CPU_DEPRECATION,
708
+ .level = 4,
709
+ .vendor = CPUID_VENDOR_INTEL,
710
+ .family = 6,
711
+ @@ -1984,6 +1992,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
712
+ },
713
+ {
714
+ .name = "kvm32",
715
+ + .deprecation_note = RHEL_CPU_DEPRECATION,
716
+ .level = 5,
717
+ .vendor = CPUID_VENDOR_INTEL,
718
+ .family = 15,
719
+ @@ -2014,6 +2023,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
720
+ },
721
+ {
722
+ .name = "coreduo",
723
+ + .deprecation_note = RHEL_CPU_DEPRECATION,
724
+ .level = 10,
725
+ .vendor = CPUID_VENDOR_INTEL,
726
+ .family = 6,
727
+ @@ -2047,6 +2057,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
728
+ },
729
+ {
730
+ .name = "486",
731
+ + .deprecation_note = RHEL_CPU_DEPRECATION,
732
+ .level = 1,
733
+ .vendor = CPUID_VENDOR_INTEL,
734
+ .family = 4,
735
+ @@ -2059,6 +2070,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
736
+ },
737
+ {
738
+ .name = "pentium",
739
+ + .deprecation_note = RHEL_CPU_DEPRECATION,
740
+ .level = 1,
741
+ .vendor = CPUID_VENDOR_INTEL,
742
+ .family = 5,
743
+ @@ -2071,6 +2083,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
744
+ },
745
+ {
746
+ .name = "pentium2",
747
+ + .deprecation_note = RHEL_CPU_DEPRECATION,
748
+ .level = 2,
749
+ .vendor = CPUID_VENDOR_INTEL,
750
+ .family = 6,
751
+ @@ -2083,6 +2096,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
752
+ },
753
+ {
754
+ .name = "pentium3",
755
+ + .deprecation_note = RHEL_CPU_DEPRECATION,
756
+ .level = 3,
757
+ .vendor = CPUID_VENDOR_INTEL,
758
+ .family = 6,
759
+ @@ -2095,6 +2109,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
760
+ },
761
+ {
762
+ .name = "athlon",
763
+ + .deprecation_note = RHEL_CPU_DEPRECATION,
764
+ .level = 2,
765
+ .vendor = CPUID_VENDOR_AMD,
766
+ .family = 6,
767
+ @@ -2110,6 +2125,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
768
+ },
769
+ {
770
+ .name = "n270",
771
+ + .deprecation_note = RHEL_CPU_DEPRECATION,
772
+ .level = 10,
773
+ .vendor = CPUID_VENDOR_INTEL,
774
+ .family = 6,
775
+ @@ -2135,6 +2151,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
776
+ },
777
+ {
778
+ .name = "Conroe",
779
+ + .deprecation_note = RHEL_CPU_DEPRECATION,
780
+ .level = 10,
781
+ .vendor = CPUID_VENDOR_INTEL,
782
+ .family = 6,
783
+ @@ -2175,6 +2192,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
784
+ },
785
+ {
786
+ .name = "Penryn",
787
+ + .deprecation_note = RHEL_CPU_DEPRECATION,
788
+ .level = 10,
789
+ .vendor = CPUID_VENDOR_INTEL,
790
+ .family = 6,
791
+ @@ -3762,6 +3780,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
792
+ },
793
+ {
794
+ .name = "Opteron_G1",
795
+ + .deprecation_note = RHEL_CPU_DEPRECATION,
796
+ .level = 5,
797
+ .vendor = CPUID_VENDOR_AMD,
798
+ .family = 15,
799
+ @@ -3782,6 +3801,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
800
+ },
801
+ {
802
+ .name = "Opteron_G2",
803
+ + .deprecation_note = RHEL_CPU_DEPRECATION,
804
+ .level = 5,
805
+ .vendor = CPUID_VENDOR_AMD,
806
+ .family = 15,
807
+ @@ -3804,6 +3824,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
808
+ },
809
+ {
810
+ .name = "Opteron_G3",
811
+ + .deprecation_note = RHEL_CPU_DEPRECATION,
812
+ .level = 5,
813
+ .vendor = CPUID_VENDOR_AMD,
814
+ .family = 16,
655
815
diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c
656
- index 5eb955ce9a..74c1396a93 100644
816
+ index 7237378a7d..7b8a3d5af0 100644
657
817
--- a/target/i386/kvm/kvm-cpu.c
658
818
+++ b/target/i386/kvm/kvm-cpu.c
659
819
@@ -137,6 +137,7 @@ static PropValue kvm_default_props[] = {
@@ -665,10 +825,10 @@ index 5eb955ce9a..74c1396a93 100644
665
825
};
666
826
667
827
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
668
- index 9cf8e03669..6d1e009443 100644
828
+ index a213209379..81526a1575 100644
669
829
--- a/target/i386/kvm/kvm.c
670
830
+++ b/target/i386/kvm/kvm.c
671
- @@ -3488,6 +3488,7 @@ static int kvm_get_msrs(X86CPU *cpu)
831
+ @@ -3707,6 +3707,7 @@ static int kvm_get_msrs(X86CPU *cpu)
672
832
struct kvm_msr_entry *msrs = cpu->kvm_msr_buf->entries;
673
833
int ret, i;
674
834
uint64_t mtrr_top_bits;
@@ -676,7 +836,7 @@ index 9cf8e03669..6d1e009443 100644
676
836
677
837
kvm_msr_buf_reset(cpu);
678
838
679
- @@ -3822,6 +3823,9 @@ static int kvm_get_msrs(X86CPU *cpu)
839
+ @@ -4062,6 +4063,9 @@ static int kvm_get_msrs(X86CPU *cpu)
680
840
break;
681
841
case MSR_KVM_ASYNC_PF_EN:
682
842
env->async_pf_en_msr = msrs[i].data;
@@ -687,7 +847,7 @@ index 9cf8e03669..6d1e009443 100644
687
847
case MSR_KVM_ASYNC_PF_INT:
688
848
env->async_pf_int_msr = msrs[i].data;
689
849
diff --git a/tests/qtest/pvpanic-test.c b/tests/qtest/pvpanic-test.c
690
- index 6dcad2db49..580c2c43d2 100644
850
+ index bc7b7dfc39..96e6dee3a1 100644
691
851
--- a/tests/qtest/pvpanic-test.c
692
852
+++ b/tests/qtest/pvpanic-test.c
693
853
@@ -17,7 +17,7 @@ static void test_panic_nopause(void)
SOURCES/0011-Enable-make-check.patch CHANGED
@@ -1,4 +1,4 @@
1
- From 5e419e5e0a721bdbbfa6d9b82c8be5c5b3d26a01 Mon Sep 17 00:00:00 2001
1
+ From badfb1290c8eea8a2e1769b2392c7899d5077698 Mon Sep 17 00:00:00 2001
2
2
From: Miroslav Rezanina <mrezanin@redhat.com>
3
3
Date: Wed, 2 Sep 2020 09:39:41 +0200
4
4
Subject: Enable make check
@@ -24,22 +24,88 @@ Rebase changes (7.0.0):
24
24
- Remove unnecessary changes in iotest 051
25
25
- Remove changes in bios-tables-test.c and prom-env-test.c qtests
26
26
27
+ Rebase changes (7.1.0 rc0):
28
+ - Disable bcm2835-dma-test (added upstream)
29
+
27
30
Merged patches (6.1.0):
28
31
- 2f129df7d3 redhat: Enable the 'test-block-iothread' test again
32
+
33
+ Merged patches (7.1.0 rc0):
34
+ - 64d736640e RHEL-only: tests/avocado: Switch aarch64 tests from a53 to a57
29
35
---
30
36
.distro/qemu-kvm.spec.template | 5 ++---
37
+ tests/avocado/replay_kernel.py | 2 +-
38
+ tests/avocado/reverse_debugging.py | 2 +-
39
+ tests/avocado/tcg_plugins.py | 6 +++---
31
40
tests/qtest/fuzz-e1000e-test.c | 2 +-
32
41
tests/qtest/fuzz-virtio-scsi-test.c | 2 +-
33
42
tests/qtest/intel-hda-test.c | 2 +-
34
43
tests/qtest/libqos/meson.build | 2 +-
35
44
tests/qtest/lpc-ich9-test.c | 2 +-
36
- tests/qtest/meson.build | 4 ----
45
+ tests/qtest/meson.build | 7 +------
37
46
tests/qtest/usb-hcd-xhci-test.c | 4 ++++
38
47
tests/qtest/virtio-net-failover.c | 1 +
39
- 9 files changed, 12 insertions(+), 12 deletions(-)
48
+ 12 files changed, 18 insertions(+), 19 deletions(-)
40
49
50
+ diff --git a/tests/avocado/replay_kernel.py b/tests/avocado/replay_kernel.py
51
+ index 00a26e4a0c..fe5ecf238a 100644
52
+ --- a/tests/avocado/replay_kernel.py
53
+ +++ b/tests/avocado/replay_kernel.py
54
+ @@ -147,7 +147,7 @@ def test_aarch64_virt(self):
55
+ """
56
+ :avocado: tags=arch:aarch64
57
+ :avocado: tags=machine:virt
58
+ - :avocado: tags=cpu:cortex-a53
59
+ + :avocado: tags=cpu:cortex-a57
60
+ """
61
+ kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
62
+ '/linux/releases/29/Everything/aarch64/os/images/pxeboot'
63
+ diff --git a/tests/avocado/reverse_debugging.py b/tests/avocado/reverse_debugging.py
64
+ index d2921e70c3..66d185ed42 100644
65
+ --- a/tests/avocado/reverse_debugging.py
66
+ +++ b/tests/avocado/reverse_debugging.py
67
+ @@ -198,7 +198,7 @@ def test_aarch64_virt(self):
68
+ """
69
+ :avocado: tags=arch:aarch64
70
+ :avocado: tags=machine:virt
71
+ - :avocado: tags=cpu:cortex-a53
72
+ + :avocado: tags=cpu:cortex-a57
73
+ """
74
+ kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
75
+ '/linux/releases/29/Everything/aarch64/os/images/pxeboot'
76
+ diff --git a/tests/avocado/tcg_plugins.py b/tests/avocado/tcg_plugins.py
77
+ index 642d2e49e3..93b3afd823 100644
78
+ --- a/tests/avocado/tcg_plugins.py
79
+ +++ b/tests/avocado/tcg_plugins.py
80
+ @@ -68,7 +68,7 @@ def test_aarch64_virt_insn(self):
81
+ :avocado: tags=accel:tcg
82
+ :avocado: tags=arch:aarch64
83
+ :avocado: tags=machine:virt
84
+ - :avocado: tags=cpu:cortex-a53
85
+ + :avocado: tags=cpu:cortex-a57
86
+ """
87
+ kernel_path = self._grab_aarch64_kernel()
88
+ kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
89
+ @@ -94,7 +94,7 @@ def test_aarch64_virt_insn_icount(self):
90
+ :avocado: tags=accel:tcg
91
+ :avocado: tags=arch:aarch64
92
+ :avocado: tags=machine:virt
93
+ - :avocado: tags=cpu:cortex-a53
94
+ + :avocado: tags=cpu:cortex-a57
95
+ """
96
+ kernel_path = self._grab_aarch64_kernel()
97
+ kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
98
+ @@ -120,7 +120,7 @@ def test_aarch64_virt_mem_icount(self):
99
+ :avocado: tags=accel:tcg
100
+ :avocado: tags=arch:aarch64
101
+ :avocado: tags=machine:virt
102
+ - :avocado: tags=cpu:cortex-a53
103
+ + :avocado: tags=cpu:cortex-a57
104
+ """
105
+ kernel_path = self._grab_aarch64_kernel()
106
+ kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
41
107
diff --git a/tests/qtest/fuzz-e1000e-test.c b/tests/qtest/fuzz-e1000e-test.c
42
- index 66229e6096..947fba73b7 100644
108
+ index 5052883fb6..b5286f4b12 100644
43
109
--- a/tests/qtest/fuzz-e1000e-test.c
44
110
+++ b/tests/qtest/fuzz-e1000e-test.c
45
111
@@ -17,7 +17,7 @@ static void test_lp1879531_eth_get_rss_ex_dst_addr(void)
@@ -52,20 +118,20 @@ index 66229e6096..947fba73b7 100644
52
118
qtest_outl(s, 0xcf8, 0x80001010);
53
119
qtest_outl(s, 0xcfc, 0xe1020000);
54
120
diff --git a/tests/qtest/fuzz-virtio-scsi-test.c b/tests/qtest/fuzz-virtio-scsi-test.c
55
- index aaf6d10e18..43727d62ac 100644
121
+ index e37b48b2cc..88647da054 100644
56
122
--- a/tests/qtest/fuzz-virtio-scsi-test.c
57
123
+++ b/tests/qtest/fuzz-virtio-scsi-test.c
58
124
@@ -19,7 +19,7 @@ static void test_mmio_oob_from_memory_region_cache(void)
59
125
{
60
126
QTestState *s;
61
127
62
- - s = qtest_init("-M pc-q35-5.2 -display none -m 512M "
63
- + s = qtest_init("-M pc-q35-rhel8.4.0 -display none -m 512M "
128
+ - s = qtest_init("-M pc-q35-5.2 -m 512M "
129
+ + s = qtest_init("-M pc-q35-rhel8.4.0 -m 512M "
64
130
"-device virtio-scsi,num_queues=8,addr=03.0 ");
65
131
66
132
qtest_outl(s, 0xcf8, 0x80001811);
67
133
diff --git a/tests/qtest/intel-hda-test.c b/tests/qtest/intel-hda-test.c
68
- index a58c98e4d1..c8387e39ce 100644
134
+ index d4a8db6fd6..1a796ec15a 100644
69
135
--- a/tests/qtest/intel-hda-test.c
70
136
+++ b/tests/qtest/intel-hda-test.c
71
137
@@ -38,7 +38,7 @@ static void test_issue542_ich6(void)
@@ -78,20 +144,20 @@ index a58c98e4d1..c8387e39ce 100644
78
144
79
145
qtest_outl(s, 0xcf8, 0x80000804);
80
146
diff --git a/tests/qtest/libqos/meson.build b/tests/qtest/libqos/meson.build
81
- index e988d15791..46f7dcb81a 100644
147
+ index 32f028872c..1e78a1a055 100644
82
148
--- a/tests/qtest/libqos/meson.build
83
149
+++ b/tests/qtest/libqos/meson.build
84
- @@ -41,7 +41,7 @@ libqos_srcs = files('../libqtest.c',
150
+ @@ -43,7 +43,7 @@ libqos_srcs = files(
85
151
'virtio-rng.c',
86
152
'virtio-scsi.c',
87
153
'virtio-serial.c',
88
154
- 'virtio-iommu.c',
89
155
+# 'virtio-iommu.c',
156
+ 'virtio-gpio.c',
157
+ 'generic-pcihost.c',
90
158
91
- # qgraph machines:
92
- 'aarch64-xlnx-zcu102-machine.c',
93
159
diff --git a/tests/qtest/lpc-ich9-test.c b/tests/qtest/lpc-ich9-test.c
94
- index fe0bef9980..7a9d51579b 100644
160
+ index 8ac95b89f7..cd2102555c 100644
95
161
--- a/tests/qtest/lpc-ich9-test.c
96
162
+++ b/tests/qtest/lpc-ich9-test.c
97
163
@@ -15,7 +15,7 @@ static void test_lp1878642_pci_bus_get_irq_level_assert(void)
@@ -104,18 +170,18 @@ index fe0bef9980..7a9d51579b 100644
104
170
105
171
qtest_outl(s, 0xcf8, 0x8000f840); /* PMBASE */
106
172
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
107
- index d25f82bb5a..67cd32def1 100644
173
+ index c07a5b1a5f..9df3f9f8b9 100644
108
174
--- a/tests/qtest/meson.build
109
175
+++ b/tests/qtest/meson.build
110
- @@ -73,7 +73,6 @@ qtests_i386 = \
176
+ @@ -82,7 +82,6 @@ qtests_i386 = \
111
177
config_all_devices.has_key('CONFIG_Q35') and \
112
178
config_all_devices.has_key('CONFIG_VIRTIO_PCI') and \
113
179
slirp.found() ? ['virtio-net-failover'] : []) + \
114
180
- (unpack_edk2_blobs ? ['bios-tables-test'] : []) + \
115
181
qtests_pci + \
182
+ qtests_cxl + \
116
183
['fdc-test',
117
- 'ide-test',
184
+ @@ -96,7 +95,6 @@ qtests_i386 = \
118
- @@ -86,7 +85,6 @@ qtests_i386 = \
119
185
'drive_del-test',
120
186
'tco-test',
121
187
'cpu-plug-test',
@@ -123,7 +189,7 @@ index d25f82bb5a..67cd32def1 100644
123
189
'vmgenid-test',
124
190
'migration-test',
125
191
'test-x86-cpuid-compat',
126
- @@ -216,7 +214,6 @@ qtests_arm = \
192
+ @@ -209,15 +207,13 @@ qtests_arm = \
127
193
128
194
# TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional
129
195
qtests_aarch64 = \
@@ -131,7 +197,16 @@ index d25f82bb5a..67cd32def1 100644
131
197
(config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-test'] : []) + \
132
198
(config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-swtpm-test'] : []) + \
133
199
(config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test', 'fuzz-xlnx-dp-test'] : []) + \
134
- @@ -231,7 +228,6 @@ qtests_s390x = \
200
+ ['arm-cpu-features',
201
+ 'numa-test',
202
+ 'boot-serial-test',
203
+ - 'migration-test',
204
+ - 'bcm2835-dma-test']
205
+ + 'migration-test']
206
+
207
+ qtests_s390x = \
208
+ (slirp.found() ? ['pxe-test', 'test-netfilter'] : []) + \
209
+ @@ -225,7 +221,6 @@ qtests_s390x = \
135
210
(config_host.has_key('CONFIG_POSIX') ? ['test-filter-redirector'] : []) + \
136
211
['boot-serial-test',
137
212
'drive_del-test',
@@ -170,7 +245,7 @@ index 10ef9d2a91..3855873050 100644
170
245
171
246
qtest_start("-device nec-usb-xhci,id=xhci"
172
247
diff --git a/tests/qtest/virtio-net-failover.c b/tests/qtest/virtio-net-failover.c
173
- index 78811f1c92..44de8af00c 100644
248
+ index 4a809590bf..1bf3fa641c 100644
174
249
--- a/tests/qtest/virtio-net-failover.c
175
250
+++ b/tests/qtest/virtio-net-failover.c
176
251
@@ -25,6 +25,7 @@
SOURCES/0012-vfio-cap-number-of-devices-that-can-be-assigned.patch CHANGED
@@ -1,4 +1,4 @@
1
- From c358fd4c224a9c3f64b4a8fff34cc6b1dc201fa0 Mon Sep 17 00:00:00 2001
1
+ From 0804844e4755377be6d2ebad578794ad9f4f3f31 Mon Sep 17 00:00:00 2001
2
2
From: Bandan Das <bsd@redhat.com>
3
3
Date: Tue, 3 Dec 2013 20:05:13 +0100
4
4
Subject: vfio: cap number of devices that can be assigned
@@ -32,20 +32,20 @@ Signed-off-by: Bandan Das <bsd@redhat.com>
32
32
2 files changed, 29 insertions(+), 1 deletion(-)
33
33
34
34
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
35
- index 67a183f17b..1e20f9fd59 100644
35
+ index 939dcc3d4a..acbc6673ce 100644
36
36
--- a/hw/vfio/pci.c
37
37
+++ b/hw/vfio/pci.c
38
- @@ -45,6 +45,9 @@
39
-
40
- #define TYPE_VFIO_PCI_NOHOTPLUG "vfio-pci-nohotplug"
38
+ @@ -48,6 +48,9 @@
39
+ /* Protected by BQL */
40
+ static KVMRouteChange vfio_route_change;
41
41
42
42
+/* RHEL only: Set once for the first assigned dev */
43
43
+static uint16_t device_limit;
44
44
+
45
45
static void vfio_disable_interrupts(VFIOPCIDevice *vdev);
46
46
static void vfio_mmap_set_enabled(VFIOPCIDevice *vdev, bool enabled);
47
-
48
- @@ -2810,9 +2813,30 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
47
+ static void vfio_msi_disable_common(VFIOPCIDevice *vdev);
48
+ @@ -2854,9 +2857,30 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
49
49
ssize_t len;
50
50
struct stat st;
51
51
int groupid;
@@ -74,10 +74,10 @@ index 67a183f17b..1e20f9fd59 100644
74
74
+ return;
75
75
+ }
76
76
+
77
- if (!vdev->vbasedev.sysfsdev) {
77
+ if (!vbasedev->sysfsdev) {
78
78
if (!(~vdev->host.domain || ~vdev->host.bus ||
79
79
~vdev->host.slot || ~vdev->host.function)) {
80
- @@ -3249,6 +3273,9 @@ static Property vfio_pci_dev_properties[] = {
80
+ @@ -3293,6 +3317,9 @@ static Property vfio_pci_dev_properties[] = {
81
81
DEFINE_PROP_BOOL("x-no-kvm-msix", VFIOPCIDevice, no_kvm_msix, false),
82
82
DEFINE_PROP_BOOL("x-no-geforce-quirks", VFIOPCIDevice,
83
83
no_geforce_quirks, false),
@@ -88,10 +88,10 @@ index 67a183f17b..1e20f9fd59 100644
88
88
false),
89
89
DEFINE_PROP_BOOL("x-no-vfio-ioeventfd", VFIOPCIDevice, no_vfio_ioeventfd,
90
90
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
91
- index 64777516d1..e0fe6ca97e 100644
91
+ index 7c236a52f4..7b7d036a8f 100644
92
92
--- a/hw/vfio/pci.h
93
93
+++ b/hw/vfio/pci.h
94
- @@ -139,6 +139,7 @@ struct VFIOPCIDevice {
94
+ @@ -140,6 +140,7 @@ struct VFIOPCIDevice {
95
95
EventNotifier err_notifier;
96
96
EventNotifier req_notifier;
97
97
int (*resetfn)(struct VFIOPCIDevice *);
SOURCES/0013-Add-support-statement-to-help-output.patch CHANGED
@@ -1,4 +1,4 @@
1
- From ba0c7a5f6b9a1f75666db6b3b795ddf03695dc26 Mon Sep 17 00:00:00 2001
1
+ From 283a0e258dc2f3b83c58e6f948bafe430cd2c1d5 Mon Sep 17 00:00:00 2001
2
2
From: Eduardo Habkost <ehabkost@redhat.com>
3
3
Date: Wed, 4 Dec 2013 18:53:17 +0100
4
4
Subject: Add support statement to -help output
@@ -21,10 +21,10 @@ Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
21
21
1 file changed, 9 insertions(+)
22
22
23
23
diff --git a/softmmu/vl.c b/softmmu/vl.c
24
- index 6f646531a0..9d5dab43d2 100644
24
+ index 5115221efe..17188df528 100644
25
25
--- a/softmmu/vl.c
26
26
+++ b/softmmu/vl.c
27
- @@ -831,9 +831,17 @@ static void version(void)
27
+ @@ -834,9 +834,17 @@ static void version(void)
28
28
QEMU_COPYRIGHT "\n");
29
29
}
30
30
@@ -42,7 +42,7 @@ index 6f646531a0..9d5dab43d2 100644
42
42
printf("usage: %s [options] [disk_image]\n\n"
43
43
"'disk_image' is a raw hard disk image for IDE hard disk 0\n\n",
44
44
g_get_prgname());
45
- @@ -859,6 +867,7 @@ static void help(int exitcode)
45
+ @@ -862,6 +870,7 @@ static void help(int exitcode)
46
46
"\n"
47
47
QEMU_HELP_BOTTOM "\n");
48
48
SOURCES/0014-Use-qemu-kvm-in-documentation-instead-of-qemu-system.patch SOURCES/0015-Use-qemu-kvm-in-documentation-instead-of-qemu-system.patch
file renamed
+4 -4
SOURCES/{0015-Use-qemu-kvm-in-documentation-instead-of-qemu-system.patch → 0014-Use-qemu-kvm-in-documentation-instead-of-qemu-system.patch} RENAMED
@@ -1,4 +1,4 @@
1
- From 4b6c8cdc52fdf94d4098d278defb3833dce1d189 Mon Sep 17 00:00:00 2001
1
+ From d8ded821aa698b3b03bd9089fbd6c2b33da87b9e Mon Sep 17 00:00:00 2001
2
2
From: Miroslav Rezanina <mrezanin@redhat.com>
3
3
Date: Wed, 8 Jul 2020 08:35:50 +0200
4
4
Subject: Use qemu-kvm in documentation instead of qemu-system-<arch>
@@ -36,10 +36,10 @@ index 52d6454b93..d74dbdeca9 100644
36
36
.. |I2C| replace:: I\ :sup:`2`\ C
37
37
.. |I2S| replace:: I\ :sup:`2`\ S
38
38
diff --git a/qemu-options.hx b/qemu-options.hx
39
- index 34e9b32a5c..924f61ab6d 100644
39
+ index 7f99d15b23..ea02ca3a45 100644
40
40
--- a/qemu-options.hx
41
41
+++ b/qemu-options.hx
42
- @@ -3233,11 +3233,11 @@ SRST
42
+ @@ -3300,11 +3300,11 @@ SRST
43
43
44
44
::
45
45
@@ -54,7 +54,7 @@ index 34e9b32a5c..924f61ab6d 100644
54
54
+ -netdev type=vhost-user,id=net0,chardev=chr0 \
55
55
+ -device virtio-net-pci,netdev=net0
56
56
57
- ``-netdev vhost-vdpa,vhostdev=/path/to/dev``
57
+ ``-netdev vhost-vdpa[,vhostdev=/path/to/dev][,vhostfd=h]``
58
58
Establish a vhost-vdpa netdev.
59
59
--
60
60
2.31.1
SOURCES/0014-globally-limit-the-maximum-number-of-CPUs.patch DELETED
@@ -1,45 +0,0 @@
1
- From 9ebfd2f6cfa8e79c92e58fd169f90cc768fb865a Mon Sep 17 00:00:00 2001
2
- From: Andrew Jones <drjones@redhat.com>
3
- Date: Tue, 21 Jan 2014 10:46:52 +0100
4
- Subject: globally limit the maximum number of CPUs
5
-
6
- We now globally limit the number of VCPUs.
7
- Especially, there is no way one can specify more than
8
- max_cpus VCPUs for a VM.
9
-
10
- This allows us the restore the ppc max_cpus limitation to the upstream
11
- default and minimize the ppc hack in kvm-all.c.
12
-
13
- Signed-off-by: David Hildenbrand <david@redhat.com>
14
- Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- Signed-off-by: Danilo Cesar Lemes de Paula <ddepaula@redhat.com>
16
- ---
17
- accel/kvm/kvm-all.c | 12 ++++++++++++
18
- 1 file changed, 12 insertions(+)
19
-
20
- diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
21
- index 5f1377ca04..fdf0e4d429 100644
22
- --- a/accel/kvm/kvm-all.c
23
- +++ b/accel/kvm/kvm-all.c
24
- @@ -2430,6 +2430,18 @@ static int kvm_init(MachineState *ms)
25
- soft_vcpus_limit = kvm_recommended_vcpus(s);
26
- hard_vcpus_limit = kvm_max_vcpus(s);
27
-
28
- +#ifdef HOST_PPC64
29
- + /*
30
- + * On POWER, the kernel advertises a soft limit based on the
31
- + * number of CPU threads on the host. We want to allow exceeding
32
- + * this for testing purposes, so we don't want to set hard limit
33
- + * to soft limit as on x86.
34
- + */
35
- +#else
36
- + /* RHEL doesn't support nr_vcpus > soft_vcpus_limit */
37
- + hard_vcpus_limit = soft_vcpus_limit;
38
- +#endif
39
- +
40
- while (nc->name) {
41
- if (nc->num > soft_vcpus_limit) {
42
- warn_report("Number of %s cpus requested (%d) exceeds "
43
- --
44
- 2.31.1
45
-
SOURCES/0015-BZ1653590-Require-at-least-64kiB-pages-for-downstrea.patch SOURCES/0017-BZ1653590-Require-at-least-64kiB-pages-for-downstrea.patch
file renamed
+2 -2
SOURCES/{0017-BZ1653590-Require-at-least-64kiB-pages-for-downstrea.patch → 0015-BZ1653590-Require-at-least-64kiB-pages-for-downstrea.patch} RENAMED
@@ -1,4 +1,4 @@
1
- From 64a06662cdea0ff62efb122be4eab506b2a842d9 Mon Sep 17 00:00:00 2001
1
+ From 9c6acadb444c9300d7c18b6939ce4f96484aeacc Mon Sep 17 00:00:00 2001
2
2
From: David Gibson <dgibson@redhat.com>
3
3
Date: Wed, 6 Feb 2019 03:58:56 +0000
4
4
Subject: BZ1653590: Require at least 64kiB pages for downstream guests & hosts
@@ -32,7 +32,7 @@ Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
32
32
1 file changed, 7 insertions(+)
33
33
34
34
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
35
- index 655ab856a0..6aa7f93df9 100644
35
+ index b4283055c1..59b88aadff 100644
36
36
--- a/hw/ppc/spapr_caps.c
37
37
+++ b/hw/ppc/spapr_caps.c
38
38
@@ -329,12 +329,19 @@ bool spapr_check_pagesize(SpaprMachineState *spapr, hwaddr pagesize,
SOURCES/0016-qcow2-Deprecation-warning-when-opening-v2-images-rw.patch SOURCES/0018-qcow2-Deprecation-warning-when-opening-v2-images-rw.patch
file renamed
+3 -3
SOURCES/{0018-qcow2-Deprecation-warning-when-opening-v2-images-rw.patch → 0016-qcow2-Deprecation-warning-when-opening-v2-images-rw.patch} RENAMED
@@ -1,4 +1,4 @@
1
- From 54f9157a918e1404f2f17ce89a9c8b9088c1bc06 Mon Sep 17 00:00:00 2001
1
+ From 02fde2a0cbd679ebd4104fe5522572c31ec23abd Mon Sep 17 00:00:00 2001
2
2
From: Kevin Wolf <kwolf@redhat.com>
3
3
Date: Fri, 20 Aug 2021 18:25:12 +0200
4
4
Subject: qcow2: Deprecation warning when opening v2 images rw
@@ -44,10 +44,10 @@ Rebase notes (6.1.0):
44
44
2 files changed, 7 insertions(+)
45
45
46
46
diff --git a/block/qcow2.c b/block/qcow2.c
47
- index b5c47931ef..a795e457ac 100644
47
+ index 4d6666d3ff..d2ba263e9d 100644
48
48
--- a/block/qcow2.c
49
49
+++ b/block/qcow2.c
50
- @@ -1337,6 +1337,12 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
50
+ @@ -1336,6 +1336,12 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
51
51
ret = -ENOTSUP;
52
52
goto fail;
53
53
}
SOURCES/0016-virtio-scsi-Reject-scsi-cd-if-data-plane-enabled-RHE.patch DELETED
@@ -1,66 +0,0 @@
1
- From b72e04cb7e417d9e1c973223747ab3a27abda8b4 Mon Sep 17 00:00:00 2001
2
- From: Fam Zheng <famz@redhat.com>
3
- Date: Wed, 14 Jun 2017 15:37:01 +0200
4
- Subject: virtio-scsi: Reject scsi-cd if data plane enabled [RHEL only]
5
-
6
- RH-Author: Fam Zheng <famz@redhat.com>
7
- Message-id: <20170614153701.14757-1-famz@redhat.com>
8
- Patchwork-id: 75613
9
- O-Subject: [RHV-7.4 qemu-kvm-rhev PATCH v3] virtio-scsi: Reject scsi-cd if data plane enabled [RHEL only]
10
- Bugzilla: 1378816
11
- RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
12
- RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
13
- RH-Acked-by: Max Reitz <mreitz@redhat.com>
14
-
15
- We need a fix for RHEL 7.4 and 7.3.z, but unfortunately upstream isn't
16
- ready. If it were, the changes will be too invasive. To have an idea:
17
-
18
- https://lists.gnu.org/archive/html/qemu-devel/2017-05/msg05400.html
19
-
20
- is an incomplete attempt to fix part of the issue, and the remaining
21
- work unfortunately involve even more complex changes.
22
-
23
- As a band-aid, this partially reverts the effect of ef8875b
24
- (virtio-scsi: Remove op blocker for dataplane, since v2.7). We cannot
25
- simply revert that commit as a whole because we already shipped it in
26
- qemu-kvm-rhev 7.3, since when, block jobs has been possible. We should
27
- only block what has been broken. Also, faithfully reverting the above
28
- commit means adding back the removed op blocker, but that is not enough,
29
- because it still crashes when inserting media into an initially empty
30
- scsi-cd.
31
-
32
- All in all, scsi-cd on virtio-scsi-dataplane has basically been unusable
33
- unless the scsi-cd never enters an empty state, so, disable it
34
- altogether. Otherwise it would be much more difficult to avoid
35
- crashing.
36
-
37
- Signed-off-by: Fam Zheng <famz@redhat.com>
38
- Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
39
- Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
40
- ---
41
- hw/scsi/virtio-scsi.c | 9 +++++++++
42
- 1 file changed, 9 insertions(+)
43
-
44
- diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
45
- index 34a968ecfb..7f6da33a8a 100644
46
- --- a/hw/scsi/virtio-scsi.c
47
- +++ b/hw/scsi/virtio-scsi.c
48
- @@ -896,6 +896,15 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,
49
- AioContext *old_context;
50
- int ret;
51
-
52
- + /* XXX: Remove this check once block backend is capable of handling
53
- + * AioContext change upon eject/insert.
54
- + * s->ctx is NULL if ioeventfd is off, s->ctx is qemu_get_aio_context() if
55
- + * data plane is not used, both cases are safe for scsi-cd. */
56
- + if (s->ctx && s->ctx != qemu_get_aio_context() &&
57
- + object_dynamic_cast(OBJECT(dev), "scsi-cd")) {
58
- + error_setg(errp, "scsi-cd is not supported by data plane");
59
- + return;
60
- + }
61
- if (s->ctx && !s->dataplane_fenced) {
62
- if (blk_op_is_blocked(sd->conf.blk, BLOCK_OP_TYPE_DATAPLANE, errp)) {
63
- return;
64
- --
65
- 2.31.1
66
-
SOURCES/0018-Addd-7.2-compat-bits-for-RHEL-9.1-machine-type.patch ADDED
@@ -0,0 +1,26 @@
1
+ From 21ed34787b9492c2cfe3d8fc12a32748bcf02307 Mon Sep 17 00:00:00 2001
2
+ From: Miroslav Rezanina <mrezanin@redhat.com>
3
+ Date: Wed, 9 Nov 2022 07:08:32 -0500
4
+ Subject: Addd 7.2 compat bits for RHEL 9.1 machine type
5
+
6
+ Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7
+ ---
8
+ hw/core/machine.c | 2 ++
9
+ 1 file changed, 2 insertions(+)
10
+
11
+ diff --git a/hw/core/machine.c b/hw/core/machine.c
12
+ index 9edec1ca05..3d851d34da 100644
13
+ --- a/hw/core/machine.c
14
+ +++ b/hw/core/machine.c
15
+ @@ -54,6 +54,8 @@ GlobalProperty hw_compat_rhel_9_1[] = {
16
+ { "arm-gicv3-common", "force-8-bit-prio", "on" },
17
+ /* hw_compat_rhel_9_1 from hw_compat_7_0 */
18
+ { "nvme-ns", "eui64-default", "on"},
19
+ + /* hw_compat_rhel_9_1 from hw_compat_7_1 */
20
+ + { "virtio-device", "queue_reset", "false" },
21
+ };
22
+ const size_t hw_compat_rhel_9_1_len = G_N_ELEMENTS(hw_compat_rhel_9_1);
23
+
24
+ --
25
+ 2.31.1
26
+
SOURCES/0019-WRB-Introduce-RHEL-9.0.0-hw-compat-structure.patch DELETED
@@ -1,135 +0,0 @@
1
- From 1d6439527aa6ccabb58208c94417778ccc19de39 Mon Sep 17 00:00:00 2001
2
- From: Miroslav Rezanina <mrezanin@redhat.com>
3
- Date: Wed, 9 Feb 2022 04:16:25 -0500
4
- Subject: WRB: Introduce RHEL 9.0.0 hw compat structure
5
-
6
- General compatibility structure for post RHEL 9.0.0 rebase.
7
-
8
- Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9
- ---
10
- hw/core/machine.c | 9 +++++++++
11
- hw/i386/pc.c | 6 ++++++
12
- hw/i386/pc_piix.c | 4 ++++
13
- hw/i386/pc_q35.c | 4 ++++
14
- hw/s390x/s390-virtio-ccw.c | 2 ++
15
- include/hw/boards.h | 3 +++
16
- include/hw/i386/pc.h | 3 +++
17
- 7 files changed, 31 insertions(+)
18
-
19
- diff --git a/hw/core/machine.c b/hw/core/machine.c
20
- index 28989b6e7b..dffc3ef4ab 100644
21
- --- a/hw/core/machine.c
22
- +++ b/hw/core/machine.c
23
- @@ -53,6 +53,15 @@ GlobalProperty hw_compat_rhel_8_6[] = {
24
- };
25
- const size_t hw_compat_rhel_8_6_len = G_N_ELEMENTS(hw_compat_rhel_8_6);
26
-
27
- +/*
28
- + * Mostly the same as hw_compat_6_2
29
- + */
30
- +GlobalProperty hw_compat_rhel_9_0[] = {
31
- + /* hw_compat_rhel_9_0 from hw_compat_6_2 */
32
- + { "PIIX4_PM", "x-not-migrate-acpi-index", "on"},
33
- +};
34
- +const size_t hw_compat_rhel_9_0_len = G_N_ELEMENTS(hw_compat_rhel_9_0);
35
- +
36
- /*
37
- * Mostly the same as hw_compat_6_0 and hw_compat_6_1
38
- */
39
- diff --git a/hw/i386/pc.c b/hw/i386/pc.c
40
- index 263d882af6..0886cfe3fe 100644
41
- --- a/hw/i386/pc.c
42
- +++ b/hw/i386/pc.c
43
- @@ -391,6 +391,12 @@ GlobalProperty pc_rhel_compat[] = {
44
- };
45
- const size_t pc_rhel_compat_len = G_N_ELEMENTS(pc_rhel_compat);
46
-
47
- +GlobalProperty pc_rhel_9_0_compat[] = {
48
- + /* pc_rhel_9_0_compat from pc_compat_6_2 */
49
- + { "virtio-mem", "unplugged-inaccessible", "off" },
50
- +};
51
- +const size_t pc_rhel_9_0_compat_len = G_N_ELEMENTS(pc_rhel_9_0_compat);
52
- +
53
- GlobalProperty pc_rhel_8_5_compat[] = {
54
- /* pc_rhel_8_5_compat from pc_compat_6_0 */
55
- { "qemu64" "-" TYPE_X86_CPU, "family", "6" },
56
- diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
57
- index 0cacc0d623..dc987fe93b 100644
58
- --- a/hw/i386/pc_piix.c
59
- +++ b/hw/i386/pc_piix.c
60
- @@ -1014,6 +1014,10 @@ static void pc_machine_rhel760_options(MachineClass *m)
61
- pcmc->kvmclock_create_always = false;
62
- /* From pc_i440fx_5_1_machine_options() */
63
- pcmc->pci_root_uid = 1;
64
- + compat_props_add(m->compat_props, hw_compat_rhel_9_0,
65
- + hw_compat_rhel_9_0_len);
66
- + compat_props_add(m->compat_props, pc_rhel_9_0_compat,
67
- + pc_rhel_9_0_compat_len);
68
- compat_props_add(m->compat_props, hw_compat_rhel_8_6,
69
- hw_compat_rhel_8_6_len);
70
- compat_props_add(m->compat_props, hw_compat_rhel_8_5,
71
- diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
72
- index 157160e069..52c253c570 100644
73
- --- a/hw/i386/pc_q35.c
74
- +++ b/hw/i386/pc_q35.c
75
- @@ -669,6 +669,10 @@ static void pc_q35_machine_rhel900_options(MachineClass *m)
76
- m->desc = "RHEL-9.0.0 PC (Q35 + ICH9, 2009)";
77
- pcmc->smbios_stream_product = "RHEL";
78
- pcmc->smbios_stream_version = "9.0.0";
79
- + compat_props_add(m->compat_props, hw_compat_rhel_9_0,
80
- + hw_compat_rhel_9_0_len);
81
- + compat_props_add(m->compat_props, pc_rhel_9_0_compat,
82
- + pc_rhel_9_0_compat_len);
83
- }
84
-
85
- DEFINE_PC_MACHINE(q35_rhel900, "pc-q35-rhel9.0.0", pc_q35_init_rhel900,
86
- diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
87
- index 465a2a09d2..08e0f6a79b 100644
88
- --- a/hw/s390x/s390-virtio-ccw.c
89
- +++ b/hw/s390x/s390-virtio-ccw.c
90
- @@ -1118,12 +1118,14 @@ static void ccw_machine_2_4_class_options(MachineClass *mc)
91
- DEFINE_CCW_MACHINE(2_4, "2.4", false);
92
- #endif
93
-
94
- +
95
- static void ccw_machine_rhel900_instance_options(MachineState *machine)
96
- {
97
- }
98
-
99
- static void ccw_machine_rhel900_class_options(MachineClass *mc)
100
- {
101
- + compat_props_add(mc->compat_props, hw_compat_rhel_9_0, hw_compat_rhel_9_0_len);
102
- }
103
- DEFINE_CCW_MACHINE(rhel900, "rhel9.0.0", true);
104
-
105
- diff --git a/include/hw/boards.h b/include/hw/boards.h
106
- index d1555665df..635e45dd71 100644
107
- --- a/include/hw/boards.h
108
- +++ b/include/hw/boards.h
109
- @@ -451,6 +451,9 @@ extern const size_t hw_compat_2_2_len;
110
- extern GlobalProperty hw_compat_2_1[];
111
- extern const size_t hw_compat_2_1_len;
112
-
113
- +extern GlobalProperty hw_compat_rhel_9_0[];
114
- +extern const size_t hw_compat_rhel_9_0_len;
115
- +
116
- extern GlobalProperty hw_compat_rhel_8_6[];
117
- extern const size_t hw_compat_rhel_8_6_len;
118
-
119
- diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
120
- index 419a6ec24b..a492c420b5 100644
121
- --- a/include/hw/i386/pc.h
122
- +++ b/include/hw/i386/pc.h
123
- @@ -292,6 +292,9 @@ extern const size_t pc_compat_1_4_len;
124
- extern GlobalProperty pc_rhel_compat[];
125
- extern const size_t pc_rhel_compat_len;
126
-
127
- +extern GlobalProperty pc_rhel_9_0_compat[];
128
- +extern const size_t pc_rhel_9_0_compat_len;
129
- +
130
- extern GlobalProperty pc_rhel_8_5_compat[];
131
- extern const size_t pc_rhel_8_5_compat_len;
132
-
133
- --
134
- 2.31.1
135
-
SOURCES/0019-redhat-Update-s390x-machine-type-compatibility-for-Q.patch ADDED
@@ -0,0 +1,47 @@
1
+ From 27c188c6a4cbd908269cf06affd24025708ecb5c Mon Sep 17 00:00:00 2001
2
+ From: Thomas Huth <thuth@redhat.com>
3
+ Date: Thu, 17 Nov 2022 16:47:16 +0100
4
+ Subject: redhat: Update s390x machine type compatibility for QEMU 7.2.0 update
5
+
6
+ Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2143585
7
+ Upstream Status: n/a (rhel-only)
8
+
9
+ Add the compatibility handling for the rebase from QEMU 7.1 to 7.2,
10
+ i.e. the settings from ccw_machine_7_1_class_options() and
11
+ ccw_machine_7_1_instance_options() to the rhel9.1.0 machine type
12
+ (earlier settings have been added by previous rebases already).
13
+
14
+ Signed-off-by: Thomas Huth <thuth@redhat.com>
15
+ ---
16
+ hw/s390x/s390-virtio-ccw.c | 9 +++++++++
17
+ 1 file changed, 9 insertions(+)
18
+
19
+ diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
20
+ index ba640e3d9e..97e868ada0 100644
21
+ --- a/hw/s390x/s390-virtio-ccw.c
22
+ +++ b/hw/s390x/s390-virtio-ccw.c
23
+ @@ -1195,12 +1195,21 @@ static void ccw_machine_rhel900_instance_options(MachineState *machine)
24
+ static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V6_2 };
25
+
26
+ s390_set_qemu_cpu_model(0x3906, 14, 2, qemu_cpu_feat);
27
+ + s390_cpudef_featoff_greater(16, 1, S390_FEAT_PAIE);
28
+ }
29
+
30
+ static void ccw_machine_rhel900_class_options(MachineClass *mc)
31
+ {
32
+ + S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc);
33
+ + static GlobalProperty compat[] = {
34
+ + { TYPE_S390_PCI_DEVICE, "interpret", "off", },
35
+ + { TYPE_S390_PCI_DEVICE, "forwarding-assist", "off", },
36
+ + };
37
+ +
38
+ + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
39
+ compat_props_add(mc->compat_props, hw_compat_rhel_9_1, hw_compat_rhel_9_1_len);
40
+ compat_props_add(mc->compat_props, hw_compat_rhel_9_0, hw_compat_rhel_9_0_len);
41
+ + s390mc->max_threads = S390_MAX_CPUS;
42
+ }
43
+ DEFINE_CCW_MACHINE(rhel900, "rhel9.0.0", true);
44
+
45
+ --
46
+ 2.31.1
47
+
SOURCES/0020-redhat-Update-s390x-machine-type-compatibility-for-r.patch DELETED
@@ -1,38 +0,0 @@
1
- From c8ad21ca31892f8798cf82508c2b2c61bf3b9895 Mon Sep 17 00:00:00 2001
2
- From: Thomas Huth <thuth@redhat.com>
3
- Date: Mon, 4 Apr 2022 12:15:50 +0200
4
- Subject: redhat: Update s390x machine type compatibility for rebase to QEMU
5
- 7.0.0
6
-
7
- RH-Author: Thomas Huth <thuth@redhat.com>
8
- RH-MergeRequest: 143: Update machine type compatibility for QEMU 7.0.0 update [s390x]
9
- RH-Commit: [23/23] 0ecf97d7bdddc50565b5779c64744b353f715cbd
10
- RH-Bugzilla: 2064782
11
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
12
- RH-Acked-by: David Hildenbrand <david@redhat.com>
13
-
14
- No s390x-specific machine class property updates required this time,
15
- only an update to the default qemu cpu model.
16
-
17
- Signed-off-by: Thomas Huth <thuth@redhat.com>
18
- ---
19
- hw/s390x/s390-virtio-ccw.c | 3 +++
20
- 1 file changed, 3 insertions(+)
21
-
22
- diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
23
- index 08e0f6a79b..4a491d4988 100644
24
- --- a/hw/s390x/s390-virtio-ccw.c
25
- +++ b/hw/s390x/s390-virtio-ccw.c
26
- @@ -1121,6 +1121,9 @@ DEFINE_CCW_MACHINE(2_4, "2.4", false);
27
-
28
- static void ccw_machine_rhel900_instance_options(MachineState *machine)
29
- {
30
- + static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V6_2 };
31
- +
32
- + s390_set_qemu_cpu_model(0x3906, 14, 2, qemu_cpu_feat);
33
- }
34
-
35
- static void ccw_machine_rhel900_class_options(MachineClass *mc)
36
- --
37
- 2.31.1
38
-
SOURCES/0020-redhat-aarch64-add-rhel9.2.0-virt-machine-type.patch ADDED
@@ -0,0 +1,43 @@
1
+ From c1a21266d8bed27f1ef1f705818fde5f9350b73f Mon Sep 17 00:00:00 2001
2
+ From: Cornelia Huck <cohuck@redhat.com>
3
+ Date: Wed, 23 Nov 2022 14:15:37 +0100
4
+ Subject: redhat: aarch64: add rhel9.2.0 virt machine type
5
+
6
+ Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2131982
7
+ Upstream: RHEL only
8
+
9
+ Signed-off-by: Cornelia Huck <cohuck@redhat.com>
10
+ ---
11
+ hw/arm/virt.c | 9 ++++++++-
12
+ 1 file changed, 8 insertions(+), 1 deletion(-)
13
+
14
+ diff --git a/hw/arm/virt.c b/hw/arm/virt.c
15
+ index dfcab40a73..0a94f31dd1 100644
16
+ --- a/hw/arm/virt.c
17
+ +++ b/hw/arm/virt.c
18
+ @@ -3518,14 +3518,21 @@ static void rhel_machine_init(void)
19
+ }
20
+ type_init(rhel_machine_init);
21
+
22
+ +static void rhel920_virt_options(MachineClass *mc)
23
+ +{
24
+ +}
25
+ +DEFINE_RHEL_MACHINE_AS_LATEST(9, 2, 0)
26
+ +
27
+ static void rhel900_virt_options(MachineClass *mc)
28
+ {
29
+ VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
30
+
31
+ + rhel920_virt_options(mc);
32
+ +
33
+ compat_props_add(mc->compat_props, arm_rhel_compat, arm_rhel_compat_len);
34
+ compat_props_add(mc->compat_props, hw_compat_rhel_9_1, hw_compat_rhel_9_1_len);
35
+
36
+ /* Disable FEAT_LPA2 since old kernels (<= v5.12) don't boot with that feature */
37
+ vmc->no_tcg_lpa2 = true;
38
+ }
39
+ -DEFINE_RHEL_MACHINE_AS_LATEST(9, 0, 0)
40
+ +DEFINE_RHEL_MACHINE(9, 0, 0)
41
+ --
42
+ 2.31.1
43
+
SOURCES/0021-pc-Move-s3-s4-suspend-disabling-to-compat.patch DELETED
@@ -1,70 +0,0 @@
1
- From 38b89dc24551258b630f09d1c654b6c72b265c79 Mon Sep 17 00:00:00 2001
2
- From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
3
- Date: Thu, 14 Apr 2022 14:58:43 +0100
4
- Subject: pc: Move s3/s4 suspend disabling to compat
5
-
6
- RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
7
- RH-MergeRequest: 155: 7.0 machine type fixes (x86)
8
- RH-Commit: [26/26] 7d666032d5f5dab1444ebba085f92f2de4e86699
9
- RH-Bugzilla: 2064771
10
-
11
- Our downstream patches currently have tweaks in the C code to disable
12
- s3/s4; Thomas pointed out we can just set the property.
13
-
14
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
15
- ---
16
- hw/acpi/ich9.c | 4 ++--
17
- hw/acpi/piix4.c | 4 ++--
18
- hw/i386/pc.c | 6 ++++++
19
- 3 files changed, 10 insertions(+), 4 deletions(-)
20
-
21
- diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
22
- index de1e401cdf..bd9bbade70 100644
23
- --- a/hw/acpi/ich9.c
24
- +++ b/hw/acpi/ich9.c
25
- @@ -435,8 +435,8 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm)
26
- static const uint32_t gpe0_len = ICH9_PMIO_GPE0_LEN;
27
- pm->acpi_memory_hotplug.is_enabled = true;
28
- pm->cpu_hotplug_legacy = true;
29
- - pm->disable_s3 = 1;
30
- - pm->disable_s4 = 1;
31
- + pm->disable_s3 = 0;
32
- + pm->disable_s4 = 0;
33
- pm->s4_val = 2;
34
- pm->use_acpi_hotplug_bridge = true;
35
- pm->keep_pci_slot_hpc = true;
36
- diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
37
- index 28544e78c3..2fb2b43248 100644
38
- --- a/hw/acpi/piix4.c
39
- +++ b/hw/acpi/piix4.c
40
- @@ -653,8 +653,8 @@ static void piix4_send_gpe(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
41
-
42
- static Property piix4_pm_properties[] = {
43
- DEFINE_PROP_UINT32("smb_io_base", PIIX4PMState, smb_io_base, 0),
44
- - DEFINE_PROP_UINT8(ACPI_PM_PROP_S3_DISABLED, PIIX4PMState, disable_s3, 1),
45
- - DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_DISABLED, PIIX4PMState, disable_s4, 1),
46
- + DEFINE_PROP_UINT8(ACPI_PM_PROP_S3_DISABLED, PIIX4PMState, disable_s3, 0),
47
- + DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_DISABLED, PIIX4PMState, disable_s4, 0),
48
- DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
49
- DEFINE_PROP_BOOL(ACPI_PM_PROP_ACPI_PCIHP_BRIDGE, PIIX4PMState,
50
- use_acpi_hotplug_bridge, true),
51
- diff --git a/hw/i386/pc.c b/hw/i386/pc.c
52
- index 0886cfe3fe..f98f842f80 100644
53
- --- a/hw/i386/pc.c
54
- +++ b/hw/i386/pc.c
55
- @@ -380,6 +380,12 @@ const size_t pc_compat_1_4_len = G_N_ELEMENTS(pc_compat_1_4);
56
- * machine type.
57
- */
58
- GlobalProperty pc_rhel_compat[] = {
59
- + /* we don't support s3/s4 suspend */
60
- + { "PIIX4_PM", "disable_s3", "1" },
61
- + { "PIIX4_PM", "disable_s4", "1" },
62
- + { "ICH9-LPC", "disable_s3", "1" },
63
- + { "ICH9-LPC", "disable_s4", "1" },
64
- +
65
- { TYPE_X86_CPU, "host-phys-bits", "on" },
66
- { TYPE_X86_CPU, "host-phys-bits-limit", "48" },
67
- { TYPE_X86_CPU, "vmx-entry-load-perf-global-ctrl", "off" },
68
- --
69
- 2.31.1
70
-
SOURCES/0021-redhat-Add-new-rhel-9.2.0-s390x-machine-type.patch ADDED
@@ -0,0 +1,62 @@
1
+ From a932b8d4296066be01613ada84241b501488f99f Mon Sep 17 00:00:00 2001
2
+ From: Thomas Huth <thuth@redhat.com>
3
+ Date: Thu, 17 Nov 2022 17:03:24 +0100
4
+ Subject: redhat: Add new rhel-9.2.0 s390x machine type
5
+
6
+ Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2136473
7
+ Upstream Status: n/a (rhel-only)
8
+
9
+ RHEL 9.2 will be an EUS release - we want to have a new machine
10
+ type here to make sure that we have a spot where we can wire up
11
+ fixes later.
12
+
13
+ Signed-off-by: Thomas Huth <thuth@redhat.com>
14
+ ---
15
+ hw/s390x/s390-virtio-ccw.c | 15 ++++++++++++++-
16
+ 1 file changed, 14 insertions(+), 1 deletion(-)
17
+
18
+ diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
19
+ index 97e868ada0..aa142a1a4e 100644
20
+ --- a/hw/s390x/s390-virtio-ccw.c
21
+ +++ b/hw/s390x/s390-virtio-ccw.c
22
+ @@ -1190,10 +1190,21 @@ DEFINE_CCW_MACHINE(2_4, "2.4", false);
23
+ #endif
24
+
25
+
26
+ +static void ccw_machine_rhel920_instance_options(MachineState *machine)
27
+ +{
28
+ +}
29
+ +
30
+ +static void ccw_machine_rhel920_class_options(MachineClass *mc)
31
+ +{
32
+ +}
33
+ +DEFINE_CCW_MACHINE(rhel920, "rhel9.2.0", true);
34
+ +
35
+ static void ccw_machine_rhel900_instance_options(MachineState *machine)
36
+ {
37
+ static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V6_2 };
38
+
39
+ + ccw_machine_rhel920_instance_options(machine);
40
+ +
41
+ s390_set_qemu_cpu_model(0x3906, 14, 2, qemu_cpu_feat);
42
+ s390_cpudef_featoff_greater(16, 1, S390_FEAT_PAIE);
43
+ }
44
+ @@ -1206,12 +1217,14 @@ static void ccw_machine_rhel900_class_options(MachineClass *mc)
45
+ { TYPE_S390_PCI_DEVICE, "forwarding-assist", "off", },
46
+ };
47
+
48
+ + ccw_machine_rhel920_class_options(mc);
49
+ +
50
+ compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
51
+ compat_props_add(mc->compat_props, hw_compat_rhel_9_1, hw_compat_rhel_9_1_len);
52
+ compat_props_add(mc->compat_props, hw_compat_rhel_9_0, hw_compat_rhel_9_0_len);
53
+ s390mc->max_threads = S390_MAX_CPUS;
54
+ }
55
+ -DEFINE_CCW_MACHINE(rhel900, "rhel9.0.0", true);
56
+ +DEFINE_CCW_MACHINE(rhel900, "rhel9.0.0", false);
57
+
58
+ static void ccw_machine_rhel860_instance_options(MachineState *machine)
59
+ {
60
+ --
61
+ 2.31.1
62
+
SOURCES/0022-x86-rhel-9.2.0-machine-type.patch ADDED
@@ -0,0 +1,75 @@
1
+ From f33ca8aed4744238230f1f2cc47df77aa4c9e0ac Mon Sep 17 00:00:00 2001
2
+ From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
3
+ Date: Thu, 17 Nov 2022 12:36:30 +0000
4
+ Subject: x86: rhel 9.2.0 machine type
5
+
6
+ Add a 9.2.0 x86 machine type, and fix up the compatibility
7
+ for 9.0.0 and older.
8
+
9
+ pc_compat_7_1 and pc_compat_7_0 are both empty upstream so there's
10
+ nothing to do there.
11
+
12
+ Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
13
+ ---
14
+ hw/i386/pc_piix.c | 1 +
15
+ hw/i386/pc_q35.c | 21 ++++++++++++++++++++-
16
+ 2 files changed, 21 insertions(+), 1 deletion(-)
17
+
18
+ diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
19
+ index 173a1fd10b..fc06877344 100644
20
+ --- a/hw/i386/pc_piix.c
21
+ +++ b/hw/i386/pc_piix.c
22
+ @@ -944,6 +944,7 @@ static void pc_machine_rhel760_options(MachineClass *m)
23
+ /* From pc_i440fx_5_1_machine_options() */
24
+ pcmc->pci_root_uid = 1;
25
+ pcmc->legacy_no_rng_seed = true;
26
+ + pcmc->enforce_amd_1tb_hole = false;
27
+ compat_props_add(m->compat_props, hw_compat_rhel_9_1,
28
+ hw_compat_rhel_9_1_len);
29
+ compat_props_add(m->compat_props, hw_compat_rhel_9_0,
30
+ diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
31
+ index 97c3630021..52cfe3bf45 100644
32
+ --- a/hw/i386/pc_q35.c
33
+ +++ b/hw/i386/pc_q35.c
34
+ @@ -692,6 +692,23 @@ static void pc_q35_machine_rhel_options(MachineClass *m)
35
+ compat_props_add(m->compat_props, pc_rhel_compat, pc_rhel_compat_len);
36
+ }
37
+
38
+ +static void pc_q35_init_rhel920(MachineState *machine)
39
+ +{
40
+ + pc_q35_init(machine);
41
+ +}
42
+ +
43
+ +static void pc_q35_machine_rhel920_options(MachineClass *m)
44
+ +{
45
+ + PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
46
+ + pc_q35_machine_rhel_options(m);
47
+ + m->desc = "RHEL-9.2.0 PC (Q35 + ICH9, 2009)";
48
+ + pcmc->smbios_stream_product = "RHEL";
49
+ + pcmc->smbios_stream_version = "9.2.0";
50
+ +}
51
+ +
52
+ +DEFINE_PC_MACHINE(q35_rhel920, "pc-q35-rhel9.2.0", pc_q35_init_rhel920,
53
+ + pc_q35_machine_rhel920_options);
54
+ +
55
+ static void pc_q35_init_rhel900(MachineState *machine)
56
+ {
57
+ pc_q35_init(machine);
58
+ @@ -700,11 +717,13 @@ static void pc_q35_init_rhel900(MachineState *machine)
59
+ static void pc_q35_machine_rhel900_options(MachineClass *m)
60
+ {
61
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
62
+ - pc_q35_machine_rhel_options(m);
63
+ + pc_q35_machine_rhel920_options(m);
64
+ m->desc = "RHEL-9.0.0 PC (Q35 + ICH9, 2009)";
65
+ + m->alias = NULL;
66
+ pcmc->smbios_stream_product = "RHEL";
67
+ pcmc->smbios_stream_version = "9.0.0";
68
+ pcmc->legacy_no_rng_seed = true;
69
+ + pcmc->enforce_amd_1tb_hole = false;
70
+ compat_props_add(m->compat_props, hw_compat_rhel_9_1,
71
+ hw_compat_rhel_9_1_len);
72
+ compat_props_add(m->compat_props, hw_compat_rhel_9_0,
73
+ --
74
+ 2.31.1
75
+
SOURCES/kvm-Add-dirty-sync-missed-zero-copy-migration-stat.patch DELETED
@@ -1,87 +0,0 @@
1
- From ac346634c5731407baa9de709dbd4d5cc6f45301 Mon Sep 17 00:00:00 2001
2
- From: Leonardo Bras <leobras@redhat.com>
3
- Date: Mon, 11 Jul 2022 18:11:12 -0300
4
- Subject: [PATCH 02/11] Add dirty-sync-missed-zero-copy migration stat
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Leonardo Brás <leobras@redhat.com>
10
- RH-MergeRequest: 111: zero-copy-send fixes & improvements
11
- RH-Commit: [2/6] 115035fd0a4e4b9439c91fb0f5d1a2f9244ba369 (LeoBras/centos-qemu-kvm)
12
- RH-Bugzilla: 2107466
13
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
14
- RH-Acked-by: Thomas Huth <thuth@redhat.com>
15
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
16
-
17
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
18
- Acked-by: Markus Armbruster <armbru@redhat.com>
19
- Acked-by: Peter Xu <peterx@redhat.com>
20
- Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
21
- Message-Id: <20220711211112.18951-3-leobras@redhat.com>
22
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
23
- (cherry picked from commit cf20c897338067ab4b70a4596fdccaf90c7e29a1)
24
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
25
- ---
26
- migration/migration.c | 2 ++
27
- monitor/hmp-cmds.c | 5 +++++
28
- qapi/migration.json | 7 ++++++-
29
- 3 files changed, 13 insertions(+), 1 deletion(-)
30
-
31
- diff --git a/migration/migration.c b/migration/migration.c
32
- index 8fb3eae910..3a3a7a4a50 100644
33
- --- a/migration/migration.c
34
- +++ b/migration/migration.c
35
- @@ -1017,6 +1017,8 @@ static void populate_ram_info(MigrationInfo *info, MigrationState *s)
36
- info->ram->normal_bytes = ram_counters.normal * page_size;
37
- info->ram->mbps = s->mbps;
38
- info->ram->dirty_sync_count = ram_counters.dirty_sync_count;
39
- + info->ram->dirty_sync_missed_zero_copy =
40
- + ram_counters.dirty_sync_missed_zero_copy;
41
- info->ram->postcopy_requests = ram_counters.postcopy_requests;
42
- info->ram->page_size = page_size;
43
- info->ram->multifd_bytes = ram_counters.multifd_bytes;
44
- diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
45
- index 634968498b..9cec01de38 100644
46
- --- a/monitor/hmp-cmds.c
47
- +++ b/monitor/hmp-cmds.c
48
- @@ -305,6 +305,11 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
49
- monitor_printf(mon, "postcopy ram: %" PRIu64 " kbytes\n",
50
- info->ram->postcopy_bytes >> 10);
51
- }
52
- + if (info->ram->dirty_sync_missed_zero_copy) {
53
- + monitor_printf(mon,
54
- + "Zero-copy-send fallbacks happened: %" PRIu64 " times\n",
55
- + info->ram->dirty_sync_missed_zero_copy);
56
- + }
57
- }
58
-
59
- if (info->has_disk) {
60
- diff --git a/qapi/migration.json b/qapi/migration.json
61
- index 5105790cd0..9b38b3c21c 100644
62
- --- a/qapi/migration.json
63
- +++ b/qapi/migration.json
64
- @@ -55,6 +55,10 @@
65
- # @postcopy-bytes: The number of bytes sent during the post-copy phase
66
- # (since 7.0).
67
- #
68
- +# @dirty-sync-missed-zero-copy: Number of times dirty RAM synchronization could
69
- +# not avoid copying dirty pages. This is between
70
- +# 0 and @dirty-sync-count * @multifd-channels.
71
- +# (since 7.1)
72
- # Since: 0.14
73
- ##
74
- { 'struct': 'MigrationStats',
75
- @@ -65,7 +69,8 @@
76
- 'postcopy-requests' : 'int', 'page-size' : 'int',
77
- 'multifd-bytes' : 'uint64', 'pages-per-second' : 'uint64',
78
- 'precopy-bytes' : 'uint64', 'downtime-bytes' : 'uint64',
79
- - 'postcopy-bytes' : 'uint64' } }
80
- + 'postcopy-bytes' : 'uint64',
81
- + 'dirty-sync-missed-zero-copy' : 'uint64' } }
82
-
83
- ##
84
- # @XBZRLECacheStats:
85
- --
86
- 2.31.1
87
-
SOURCES/kvm-Enable-virtio-iommu-pci-on-aarch64.patch DELETED
@@ -1,41 +0,0 @@
1
- From 85781b8745fa1581a66f64011d61a4f0c4e103dc Mon Sep 17 00:00:00 2001
2
- From: Eric Auger <eric.auger@redhat.com>
3
- Date: Fri, 6 May 2022 17:03:11 +0200
4
- Subject: [PATCH 3/5] Enable virtio-iommu-pci on aarch64
5
-
6
- RH-Author: Eric Auger <eric.auger@redhat.com>
7
- RH-MergeRequest: 83: Enable virtio-iommu-pci on aarch64
8
- RH-Commit: [1/1] 23e5c0832e52c66adf5fd6daccdc3edddc7ecb8b (eauger1/centos-qemu-kvm)
9
- RH-Bugzilla: 1477099
10
- RH-Acked-by: Gavin Shan <gshan@redhat.com>
11
- RH-Acked-by: Andrew Jones <drjones@redhat.com>
12
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
13
-
14
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1477099
15
- Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=45128798
16
- Upstream Status: RHEL-only
17
- Tested: With virtio-net-pci and virtio-block-pci
18
-
19
- let's enable the virtio-iommu-pci device on aarch64 by
20
- turning CONFIG_VIRTIO_IOMMU on.
21
-
22
- Signed-off-by: Eric Auger <eric.auger@redhat.com>
23
- ---
24
- configs/devices/aarch64-softmmu/aarch64-rh-devices.mak | 1 +
25
- 1 file changed, 1 insertion(+)
26
-
27
- diff --git a/configs/devices/aarch64-softmmu/aarch64-rh-devices.mak b/configs/devices/aarch64-softmmu/aarch64-rh-devices.mak
28
- index 187938573f..1618d31b89 100644
29
- --- a/configs/devices/aarch64-softmmu/aarch64-rh-devices.mak
30
- +++ b/configs/devices/aarch64-softmmu/aarch64-rh-devices.mak
31
- @@ -23,6 +23,7 @@ CONFIG_VFIO_PCI=y
32
- CONFIG_VIRTIO_MMIO=y
33
- CONFIG_VIRTIO_PCI=y
34
- CONFIG_VIRTIO_MEM=y
35
- +CONFIG_VIRTIO_IOMMU=y
36
- CONFIG_XIO3130=y
37
- CONFIG_NVDIMM=y
38
- CONFIG_ACPI_APEI=y
39
- --
40
- 2.31.1
41
-
SOURCES/kvm-Enable-virtio-iommu-pci-on-x86_64.patch DELETED
@@ -1,41 +0,0 @@
1
- From c531a39171201f8a1d063e6af752e5d629c1b4bf Mon Sep 17 00:00:00 2001
2
- From: Eric Auger <eric.auger@redhat.com>
3
- Date: Thu, 9 Jun 2022 11:35:18 +0200
4
- Subject: [PATCH 4/6] Enable virtio-iommu-pci on x86_64
5
-
6
- RH-Author: Eric Auger <eric.auger@redhat.com>
7
- RH-MergeRequest: 100: Enable virtio-iommu-pci on x86_64
8
- RH-Commit: [1/1] a164af477efc7cb9d3d76a0e644f198f7c9fb2b5 (eauger1/centos-qemu-kvm)
9
- RH-Bugzilla: 2094252
10
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
- RH-Acked-by: MST <mst@redhat.com>
12
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
13
-
14
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2094252
15
- Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=45871185
16
- Upstream Status: RHEL-only
17
- Tested: With virtio-net-pci and virtio-block-pci
18
-
19
- let's enable the virtio-iommu-pci device on x86_64 by
20
- turning CONFIG_VIRTIO_IOMMU on.
21
-
22
- Signed-off-by: Eric Auger <eric.auger@redhat.com>
23
- ---
24
- configs/devices/x86_64-softmmu/x86_64-rh-devices.mak | 1 +
25
- 1 file changed, 1 insertion(+)
26
-
27
- diff --git a/configs/devices/x86_64-softmmu/x86_64-rh-devices.mak b/configs/devices/x86_64-softmmu/x86_64-rh-devices.mak
28
- index d0c9e66641..3850b9de72 100644
29
- --- a/configs/devices/x86_64-softmmu/x86_64-rh-devices.mak
30
- +++ b/configs/devices/x86_64-softmmu/x86_64-rh-devices.mak
31
- @@ -90,6 +90,7 @@ CONFIG_VHOST_USER_BLK=y
32
- CONFIG_VIRTIO_MEM=y
33
- CONFIG_VIRTIO_PCI=y
34
- CONFIG_VIRTIO_VGA=y
35
- +CONFIG_VIRTIO_IOMMU=y
36
- CONFIG_VMMOUSE=y
37
- CONFIG_VMPORT=y
38
- CONFIG_VTD=y
39
- --
40
- 2.31.1
41
-
SOURCES/kvm-Introduce-event-loop-base-abstract-class.patch DELETED
@@ -1,503 +0,0 @@
1
- From 1163da281c178359dd7e1cf1ced5c98caa600f8e Mon Sep 17 00:00:00 2001
2
- From: Nicolas Saenz Julienne <nsaenzju@redhat.com>
3
- Date: Mon, 25 Apr 2022 09:57:21 +0200
4
- Subject: [PATCH 01/16] Introduce event-loop-base abstract class
5
-
6
- RH-Author: Nicolas Saenz Julienne <nsaenzju@redhat.com>
7
- RH-MergeRequest: 93: util/thread-pool: Expose minimum and maximum size
8
- RH-Commit: [1/3] 5817205d8f56cc4aa98bd5963ecac54a59bad990
9
- RH-Bugzilla: 2031024
10
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
12
- RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
13
-
14
- Introduce the 'event-loop-base' abstract class, it'll hold the
15
- properties common to all event loops and provide the necessary hooks for
16
- their creation and maintenance. Then have iothread inherit from it.
17
-
18
- EventLoopBaseClass is defined as user creatable and provides a hook for
19
- its children to attach themselves to the user creatable class 'complete'
20
- function. It also provides an update_params() callback to propagate
21
- property changes onto its children.
22
-
23
- The new 'event-loop-base' class will live in the root directory. It is
24
- built on its own using the 'link_whole' option (there are no direct
25
- function dependencies between the class and its children, it all happens
26
- trough 'constructor' magic). And also imposes new compilation
27
- dependencies:
28
-
29
- qom <- event-loop-base <- blockdev (iothread.c)
30
-
31
- And in subsequent patches:
32
-
33
- qom <- event-loop-base <- qemuutil (util/main-loop.c)
34
-
35
- All this forced some amount of reordering in meson.build:
36
-
37
- - Moved qom build definition before qemuutil. Doing it the other way
38
- around (i.e. moving qemuutil after qom) isn't possible as a lot of
39
- core libraries that live in between the two depend on it.
40
-
41
- - Process the 'hw' subdir earlier, as it introduces files into the
42
- 'qom' source set.
43
-
44
- No functional changes intended.
45
-
46
- Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
47
- Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
48
- Acked-by: Markus Armbruster <armbru@redhat.com>
49
- Message-id: 20220425075723.20019-2-nsaenzju@redhat.com
50
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
51
- (cherry picked from commit 7d5983e3c8c40b1d0668faba31d79905c4fadd7d)
52
- ---
53
- event-loop-base.c | 104 +++++++++++++++++++++++++++++++
54
- include/sysemu/event-loop-base.h | 36 +++++++++++
55
- include/sysemu/iothread.h | 6 +-
56
- iothread.c | 65 ++++++-------------
57
- meson.build | 23 ++++---
58
- qapi/qom.json | 22 +++++--
59
- 6 files changed, 192 insertions(+), 64 deletions(-)
60
- create mode 100644 event-loop-base.c
61
- create mode 100644 include/sysemu/event-loop-base.h
62
-
63
- diff --git a/event-loop-base.c b/event-loop-base.c
64
- new file mode 100644
65
- index 0000000000..a924c73a7c
66
- --- /dev/null
67
- +++ b/event-loop-base.c
68
- @@ -0,0 +1,104 @@
69
- +/*
70
- + * QEMU event-loop base
71
- + *
72
- + * Copyright (C) 2022 Red Hat Inc
73
- + *
74
- + * Authors:
75
- + * Stefan Hajnoczi <stefanha@redhat.com>
76
- + * Nicolas Saenz Julienne <nsaenzju@redhat.com>
77
- + *
78
- + * This work is licensed under the terms of the GNU GPL, version 2 or later.
79
- + * See the COPYING file in the top-level directory.
80
- + */
81
- +
82
- +#include "qemu/osdep.h"
83
- +#include "qom/object_interfaces.h"
84
- +#include "qapi/error.h"
85
- +#include "sysemu/event-loop-base.h"
86
- +
87
- +typedef struct {
88
- + const char *name;
89
- + ptrdiff_t offset; /* field's byte offset in EventLoopBase struct */
90
- +} EventLoopBaseParamInfo;
91
- +
92
- +static EventLoopBaseParamInfo aio_max_batch_info = {
93
- + "aio-max-batch", offsetof(EventLoopBase, aio_max_batch),
94
- +};
95
- +
96
- +static void event_loop_base_get_param(Object *obj, Visitor *v,
97
- + const char *name, void *opaque, Error **errp)
98
- +{
99
- + EventLoopBase *event_loop_base = EVENT_LOOP_BASE(obj);
100
- + EventLoopBaseParamInfo *info = opaque;
101
- + int64_t *field = (void *)event_loop_base + info->offset;
102
- +
103
- + visit_type_int64(v, name, field, errp);
104
- +}
105
- +
106
- +static void event_loop_base_set_param(Object *obj, Visitor *v,
107
- + const char *name, void *opaque, Error **errp)
108
- +{
109
- + EventLoopBaseClass *bc = EVENT_LOOP_BASE_GET_CLASS(obj);
110
- + EventLoopBase *base = EVENT_LOOP_BASE(obj);
111
- + EventLoopBaseParamInfo *info = opaque;
112
- + int64_t *field = (void *)base + info->offset;
113
- + int64_t value;
114
- +
115
- + if (!visit_type_int64(v, name, &value, errp)) {
116
- + return;
117
- + }
118
- +
119
- + if (value < 0) {
120
- + error_setg(errp, "%s value must be in range [0, %" PRId64 "]",
121
- + info->name, INT64_MAX);
122
- + return;
123
- + }
124
- +
125
- + *field = value;
126
- +
127
- + if (bc->update_params) {
128
- + bc->update_params(base, errp);
129
- + }
130
- +
131
- + return;
132
- +}
133
- +
134
- +static void event_loop_base_complete(UserCreatable *uc, Error **errp)
135
- +{
136
- + EventLoopBaseClass *bc = EVENT_LOOP_BASE_GET_CLASS(uc);
137
- + EventLoopBase *base = EVENT_LOOP_BASE(uc);
138
- +
139
- + if (bc->init) {
140
- + bc->init(base, errp);
141
- + }
142
- +}
143
- +
144
- +static void event_loop_base_class_init(ObjectClass *klass, void *class_data)
145
- +{
146
- + UserCreatableClass *ucc = USER_CREATABLE_CLASS(klass);
147
- + ucc->complete = event_loop_base_complete;
148
- +
149
- + object_class_property_add(klass, "aio-max-batch", "int",
150
- + event_loop_base_get_param,
151
- + event_loop_base_set_param,
152
- + NULL, &aio_max_batch_info);
153
- +}
154
- +
155
- +static const TypeInfo event_loop_base_info = {
156
- + .name = TYPE_EVENT_LOOP_BASE,
157
- + .parent = TYPE_OBJECT,
158
- + .instance_size = sizeof(EventLoopBase),
159
- + .class_size = sizeof(EventLoopBaseClass),
160
- + .class_init = event_loop_base_class_init,
161
- + .abstract = true,
162
- + .interfaces = (InterfaceInfo[]) {
163
- + { TYPE_USER_CREATABLE },
164
- + { }
165
- + }
166
- +};
167
- +
168
- +static void register_types(void)
169
- +{
170
- + type_register_static(&event_loop_base_info);
171
- +}
172
- +type_init(register_types);
173
- diff --git a/include/sysemu/event-loop-base.h b/include/sysemu/event-loop-base.h
174
- new file mode 100644
175
- index 0000000000..8e77d8b69f
176
- --- /dev/null
177
- +++ b/include/sysemu/event-loop-base.h
178
- @@ -0,0 +1,36 @@
179
- +/*
180
- + * QEMU event-loop backend
181
- + *
182
- + * Copyright (C) 2022 Red Hat Inc
183
- + *
184
- + * Authors:
185
- + * Nicolas Saenz Julienne <nsaenzju@redhat.com>
186
- + *
187
- + * This work is licensed under the terms of the GNU GPL, version 2 or later.
188
- + * See the COPYING file in the top-level directory.
189
- + */
190
- +#ifndef QEMU_EVENT_LOOP_BASE_H
191
- +#define QEMU_EVENT_LOOP_BASE_H
192
- +
193
- +#include "qom/object.h"
194
- +#include "block/aio.h"
195
- +#include "qemu/typedefs.h"
196
- +
197
- +#define TYPE_EVENT_LOOP_BASE "event-loop-base"
198
- +OBJECT_DECLARE_TYPE(EventLoopBase, EventLoopBaseClass,
199
- + EVENT_LOOP_BASE)
200
- +
201
- +struct EventLoopBaseClass {
202
- + ObjectClass parent_class;
203
- +
204
- + void (*init)(EventLoopBase *base, Error **errp);
205
- + void (*update_params)(EventLoopBase *base, Error **errp);
206
- +};
207
- +
208
- +struct EventLoopBase {
209
- + Object parent;
210
- +
211
- + /* AioContext AIO engine parameters */
212
- + int64_t aio_max_batch;
213
- +};
214
- +#endif
215
- diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h
216
- index 7f714bd136..8f8601d6ab 100644
217
- --- a/include/sysemu/iothread.h
218
- +++ b/include/sysemu/iothread.h
219
- @@ -17,11 +17,12 @@
220
- #include "block/aio.h"
221
- #include "qemu/thread.h"
222
- #include "qom/object.h"
223
- +#include "sysemu/event-loop-base.h"
224
-
225
- #define TYPE_IOTHREAD "iothread"
226
-
227
- struct IOThread {
228
- - Object parent_obj;
229
- + EventLoopBase parent_obj;
230
-
231
- QemuThread thread;
232
- AioContext *ctx;
233
- @@ -37,9 +38,6 @@ struct IOThread {
234
- int64_t poll_max_ns;
235
- int64_t poll_grow;
236
- int64_t poll_shrink;
237
- -
238
- - /* AioContext AIO engine parameters */
239
- - int64_t aio_max_batch;
240
- };
241
- typedef struct IOThread IOThread;
242
-
243
- diff --git a/iothread.c b/iothread.c
244
- index 0f98af0f2a..8fa2f3bfb8 100644
245
- --- a/iothread.c
246
- +++ b/iothread.c
247
- @@ -17,6 +17,7 @@
248
- #include "qemu/module.h"
249
- #include "block/aio.h"
250
- #include "block/block.h"
251
- +#include "sysemu/event-loop-base.h"
252
- #include "sysemu/iothread.h"
253
- #include "qapi/error.h"
254
- #include "qapi/qapi-commands-misc.h"
255
- @@ -152,10 +153,15 @@ static void iothread_init_gcontext(IOThread *iothread)
256
- iothread->main_loop = g_main_loop_new(iothread->worker_context, TRUE);
257
- }
258
-
259
- -static void iothread_set_aio_context_params(IOThread *iothread, Error **errp)
260
- +static void iothread_set_aio_context_params(EventLoopBase *base, Error **errp)
261
- {
262
- + IOThread *iothread = IOTHREAD(base);
263
- ERRP_GUARD();
264
-
265
- + if (!iothread->ctx) {
266
- + return;
267
- + }
268
- +
269
- aio_context_set_poll_params(iothread->ctx,
270
- iothread->poll_max_ns,
271
- iothread->poll_grow,
272
- @@ -166,14 +172,15 @@ static void iothread_set_aio_context_params(IOThread *iothread, Error **errp)
273
- }
274
-
275
- aio_context_set_aio_params(iothread->ctx,
276
- - iothread->aio_max_batch,
277
- + iothread->parent_obj.aio_max_batch,
278
- errp);
279
- }
280
-
281
- -static void iothread_complete(UserCreatable *obj, Error **errp)
282
- +
283
- +static void iothread_init(EventLoopBase *base, Error **errp)
284
- {
285
- Error *local_error = NULL;
286
- - IOThread *iothread = IOTHREAD(obj);
287
- + IOThread *iothread = IOTHREAD(base);
288
- char *thread_name;
289
-
290
- iothread->stopping = false;
291
- @@ -189,7 +196,7 @@ static void iothread_complete(UserCreatable *obj, Error **errp)
292
- */
293
- iothread_init_gcontext(iothread);
294
-
295
- - iothread_set_aio_context_params(iothread, &local_error);
296
- + iothread_set_aio_context_params(base, &local_error);
297
- if (local_error) {
298
- error_propagate(errp, local_error);
299
- aio_context_unref(iothread->ctx);
300
- @@ -201,7 +208,7 @@ static void iothread_complete(UserCreatable *obj, Error **errp)
301
- * to inherit.
302
- */
303
- thread_name = g_strdup_printf("IO %s",
304
- - object_get_canonical_path_component(OBJECT(obj)));
305
- + object_get_canonical_path_component(OBJECT(base)));
306
- qemu_thread_create(&iothread->thread, thread_name, iothread_run,
307
- iothread, QEMU_THREAD_JOINABLE);
308
- g_free(thread_name);
309
- @@ -226,9 +233,6 @@ static IOThreadParamInfo poll_grow_info = {
310
- static IOThreadParamInfo poll_shrink_info = {
311
- "poll-shrink", offsetof(IOThread, poll_shrink),
312
- };
313
- -static IOThreadParamInfo aio_max_batch_info = {
314
- - "aio-max-batch", offsetof(IOThread, aio_max_batch),
315
- -};
316
-
317
- static void iothread_get_param(Object *obj, Visitor *v,
318
- const char *name, IOThreadParamInfo *info, Error **errp)
319
- @@ -288,35 +292,12 @@ static void iothread_set_poll_param(Object *obj, Visitor *v,
320
- }
321
- }
322
-
323
- -static void iothread_get_aio_param(Object *obj, Visitor *v,
324
- - const char *name, void *opaque, Error **errp)
325
- -{
326
- - IOThreadParamInfo *info = opaque;
327
- -
328
- - iothread_get_param(obj, v, name, info, errp);
329
- -}
330
- -
331
- -static void iothread_set_aio_param(Object *obj, Visitor *v,
332
- - const char *name, void *opaque, Error **errp)
333
- -{
334
- - IOThread *iothread = IOTHREAD(obj);
335
- - IOThreadParamInfo *info = opaque;
336
- -
337
- - if (!iothread_set_param(obj, v, name, info, errp)) {
338
- - return;
339
- - }
340
- -
341
- - if (iothread->ctx) {
342
- - aio_context_set_aio_params(iothread->ctx,
343
- - iothread->aio_max_batch,
344
- - errp);
345
- - }
346
- -}
347
- -
348
- static void iothread_class_init(ObjectClass *klass, void *class_data)
349
- {
350
- - UserCreatableClass *ucc = USER_CREATABLE_CLASS(klass);
351
- - ucc->complete = iothread_complete;
352
- + EventLoopBaseClass *bc = EVENT_LOOP_BASE_CLASS(klass);
353
- +
354
- + bc->init = iothread_init;
355
- + bc->update_params = iothread_set_aio_context_params;
356
-
357
- object_class_property_add(klass, "poll-max-ns", "int",
358
- iothread_get_poll_param,
359
- @@ -330,23 +311,15 @@ static void iothread_class_init(ObjectClass *klass, void *class_data)
360
- iothread_get_poll_param,
361
- iothread_set_poll_param,
362
- NULL, &poll_shrink_info);
363
- - object_class_property_add(klass, "aio-max-batch", "int",
364
- - iothread_get_aio_param,
365
- - iothread_set_aio_param,
366
- - NULL, &aio_max_batch_info);
367
- }
368
-
369
- static const TypeInfo iothread_info = {
370
- .name = TYPE_IOTHREAD,
371
- - .parent = TYPE_OBJECT,
372
- + .parent = TYPE_EVENT_LOOP_BASE,
373
- .class_init = iothread_class_init,
374
- .instance_size = sizeof(IOThread),
375
- .instance_init = iothread_instance_init,
376
- .instance_finalize = iothread_instance_finalize,
377
- - .interfaces = (InterfaceInfo[]) {
378
- - {TYPE_USER_CREATABLE},
379
- - {}
380
- - },
381
- };
382
-
383
- static void iothread_register_types(void)
384
- @@ -383,7 +356,7 @@ static int query_one_iothread(Object *object, void *opaque)
385
- info->poll_max_ns = iothread->poll_max_ns;
386
- info->poll_grow = iothread->poll_grow;
387
- info->poll_shrink = iothread->poll_shrink;
388
- - info->aio_max_batch = iothread->aio_max_batch;
389
- + info->aio_max_batch = iothread->parent_obj.aio_max_batch;
390
-
391
- QAPI_LIST_APPEND(*tail, info);
392
- return 0;
393
- diff --git a/meson.build b/meson.build
394
- index 6f7e430f0f..b9c919a55e 100644
395
- --- a/meson.build
396
- +++ b/meson.build
397
- @@ -2804,6 +2804,7 @@ subdir('qom')
398
- subdir('authz')
399
- subdir('crypto')
400
- subdir('ui')
401
- +subdir('hw')
402
-
403
-
404
- if enable_modules
405
- @@ -2811,6 +2812,18 @@ if enable_modules
406
- modulecommon = declare_dependency(link_whole: libmodulecommon, compile_args: '-DBUILD_DSO')
407
- endif
408
-
409
- +qom_ss = qom_ss.apply(config_host, strict: false)
410
- +libqom = static_library('qom', qom_ss.sources() + genh,
411
- + dependencies: [qom_ss.dependencies()],
412
- + name_suffix: 'fa')
413
- +qom = declare_dependency(link_whole: libqom)
414
- +
415
- +event_loop_base = files('event-loop-base.c')
416
- +event_loop_base = static_library('event-loop-base', sources: event_loop_base + genh,
417
- + build_by_default: true)
418
- +event_loop_base = declare_dependency(link_whole: event_loop_base,
419
- + dependencies: [qom])
420
- +
421
- stub_ss = stub_ss.apply(config_all, strict: false)
422
-
423
- util_ss.add_all(trace_ss)
424
- @@ -2897,7 +2910,6 @@ subdir('monitor')
425
- subdir('net')
426
- subdir('replay')
427
- subdir('semihosting')
428
- -subdir('hw')
429
- subdir('tcg')
430
- subdir('fpu')
431
- subdir('accel')
432
- @@ -3022,13 +3034,6 @@ qemu_syms = custom_target('qemu.syms', output: 'qemu.syms',
433
- capture: true,
434
- command: [undefsym, nm, '@INPUT@'])
435
-
436
- -qom_ss = qom_ss.apply(config_host, strict: false)
437
- -libqom = static_library('qom', qom_ss.sources() + genh,
438
- - dependencies: [qom_ss.dependencies()],
439
- - name_suffix: 'fa')
440
- -
441
- -qom = declare_dependency(link_whole: libqom)
442
- -
443
- authz_ss = authz_ss.apply(config_host, strict: false)
444
- libauthz = static_library('authz', authz_ss.sources() + genh,
445
- dependencies: [authz_ss.dependencies()],
446
- @@ -3081,7 +3086,7 @@ libblockdev = static_library('blockdev', blockdev_ss.sources() + genh,
447
- build_by_default: false)
448
-
449
- blockdev = declare_dependency(link_whole: [libblockdev],
450
- - dependencies: [block])
451
- + dependencies: [block, event_loop_base])
452
-
453
- qmp_ss = qmp_ss.apply(config_host, strict: false)
454
- libqmp = static_library('qmp', qmp_ss.sources() + genh,
455
- diff --git a/qapi/qom.json b/qapi/qom.json
456
- index eeb5395ff3..a2439533c5 100644
457
- --- a/qapi/qom.json
458
- +++ b/qapi/qom.json
459
- @@ -499,6 +499,20 @@
460
- '*repeat': 'bool',
461
- '*grab-toggle': 'GrabToggleKeys' } }
462
-
463
- +##
464
- +# @EventLoopBaseProperties:
465
- +#
466
- +# Common properties for event loops
467
- +#
468
- +# @aio-max-batch: maximum number of requests in a batch for the AIO engine,
469
- +# 0 means that the engine will use its default.
470
- +# (default: 0)
471
- +#
472
- +# Since: 7.1
473
- +##
474
- +{ 'struct': 'EventLoopBaseProperties',
475
- + 'data': { '*aio-max-batch': 'int' } }
476
- +
477
- ##
478
- # @IothreadProperties:
479
- #
480
- @@ -516,17 +530,15 @@
481
- # algorithm detects it is spending too long polling without
482
- # encountering events. 0 selects a default behaviour (default: 0)
483
- #
484
- -# @aio-max-batch: maximum number of requests in a batch for the AIO engine,
485
- -# 0 means that the engine will use its default
486
- -# (default:0, since 6.1)
487
- +# The @aio-max-batch option is available since 6.1.
488
- #
489
- # Since: 2.0
490
- ##
491
- { 'struct': 'IothreadProperties',
492
- + 'base': 'EventLoopBaseProperties',
493
- 'data': { '*poll-max-ns': 'int',
494
- '*poll-grow': 'int',
495
- - '*poll-shrink': 'int',
496
- - '*aio-max-batch': 'int' } }
497
- + '*poll-shrink': 'int' } }
498
-
499
- ##
500
- # @MemoryBackendProperties:
501
- --
502
- 2.31.1
503
-
SOURCES/kvm-KVM-keep-track-of-running-ioctls.patch ADDED
@@ -0,0 +1,82 @@
1
+ From 6aebc271d95f9c59cb63c923b6ce35f16fce10e4 Mon Sep 17 00:00:00 2001
2
+ From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
3
+ Date: Mon, 16 Jan 2023 07:17:23 -0500
4
+ Subject: [PATCH 30/31] KVM: keep track of running ioctls
5
+
6
+ RH-Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
7
+ RH-MergeRequest: 138: accel: introduce accelerator blocker API
8
+ RH-Bugzilla: 1979276
9
+ RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
10
+ RH-Acked-by: David Hildenbrand <david@redhat.com>
11
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
+ RH-Commit: [2/3] f566f81dda26ae733008f32261ecd1253ec1796d (eesposit/qemu-kvm)
13
+
14
+ Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1979276
15
+
16
+ commit a27dd2de68f37ba96fe164a42121daa5f0750afc
17
+ Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
18
+ Date: Fri Nov 11 10:47:57 2022 -0500
19
+
20
+ KVM: keep track of running ioctls
21
+
22
+ Using the new accel-blocker API, mark where ioctls are being called
23
+ in KVM. Next, we will implement the critical section that will take
24
+ care of performing memslots modifications atomically, therefore
25
+ preventing any new ioctl from running and allowing the running ones
26
+ to finish.
27
+
28
+ Signed-off-by: David Hildenbrand <david@redhat.com>
29
+ Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
30
+ Message-Id: <20221111154758.1372674-3-eesposit@redhat.com>
31
+ Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
32
+
33
+ Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
34
+ ---
35
+ accel/kvm/kvm-all.c | 7 +++++++
36
+ 1 file changed, 7 insertions(+)
37
+
38
+ diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
39
+ index f99b0becd8..ff660fd469 100644
40
+ --- a/accel/kvm/kvm-all.c
41
+ +++ b/accel/kvm/kvm-all.c
42
+ @@ -2310,6 +2310,7 @@ static int kvm_init(MachineState *ms)
43
+ assert(TARGET_PAGE_SIZE <= qemu_real_host_page_size());
44
+
45
+ s->sigmask_len = 8;
46
+ + accel_blocker_init();
47
+
48
+ #ifdef KVM_CAP_SET_GUEST_DEBUG
49
+ QTAILQ_INIT(&s->kvm_sw_breakpoints);
50
+ @@ -3014,7 +3015,9 @@ int kvm_vm_ioctl(KVMState *s, int type, ...)
51
+ va_end(ap);
52
+
53
+ trace_kvm_vm_ioctl(type, arg);
54
+ + accel_ioctl_begin();
55
+ ret = ioctl(s->vmfd, type, arg);
56
+ + accel_ioctl_end();
57
+ if (ret == -1) {
58
+ ret = -errno;
59
+ }
60
+ @@ -3032,7 +3035,9 @@ int kvm_vcpu_ioctl(CPUState *cpu, int type, ...)
61
+ va_end(ap);
62
+
63
+ trace_kvm_vcpu_ioctl(cpu->cpu_index, type, arg);
64
+ + accel_cpu_ioctl_begin(cpu);
65
+ ret = ioctl(cpu->kvm_fd, type, arg);
66
+ + accel_cpu_ioctl_end(cpu);
67
+ if (ret == -1) {
68
+ ret = -errno;
69
+ }
70
+ @@ -3050,7 +3055,9 @@ int kvm_device_ioctl(int fd, int type, ...)
71
+ va_end(ap);
72
+
73
+ trace_kvm_device_ioctl(fd, type, arg);
74
+ + accel_ioctl_begin();
75
+ ret = ioctl(fd, type, arg);
76
+ + accel_ioctl_end();
77
+ if (ret == -1) {
78
+ ret = -errno;
79
+ }
80
+ --
81
+ 2.31.1
82
+
SOURCES/kvm-QIOChannel-Add-flags-on-io_writev-and-introduce-io_f.patch DELETED
@@ -1,420 +0,0 @@
1
- From cda3fcf14f2883fea633e25256f6c14a71271adf Mon Sep 17 00:00:00 2001
2
- From: Leonardo Bras <leobras@redhat.com>
3
- Date: Fri, 13 May 2022 03:28:31 -0300
4
- Subject: [PATCH 08/18] QIOChannel: Add flags on io_writev and introduce
5
- io_flush callback
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Leonardo Brás <leobras@redhat.com>
11
- RH-MergeRequest: 95: MSG_ZEROCOPY + Multifd
12
- RH-Commit: [2/11] 06acfb6b0cb2c25733c2eb198011f7623b5a7024 (LeoBras/centos-qemu-kvm)
13
- RH-Bugzilla: 1968509
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
16
- RH-Acked-by: Peter Xu <peterx@redhat.com>
17
-
18
- Add flags to io_writev and introduce io_flush as optional callback to
19
- QIOChannelClass, allowing the implementation of zero copy writes by
20
- subclasses.
21
-
22
- How to use them:
23
- - Write data using qio_channel_writev*(...,QIO_CHANNEL_WRITE_FLAG_ZERO_COPY),
24
- - Wait write completion with qio_channel_flush().
25
-
26
- Notes:
27
- As some zero copy write implementations work asynchronously, it's
28
- recommended to keep the write buffer untouched until the return of
29
- qio_channel_flush(), to avoid the risk of sending an updated buffer
30
- instead of the buffer state during write.
31
-
32
- As io_flush callback is optional, if a subclass does not implement it, then:
33
- - io_flush will return 0 without changing anything.
34
-
35
- Also, some functions like qio_channel_writev_full_all() were adapted to
36
- receive a flag parameter. That allows shared code between zero copy and
37
- non-zero copy writev, and also an easier implementation on new flags.
38
-
39
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
40
- Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
41
- Reviewed-by: Peter Xu <peterx@redhat.com>
42
- Reviewed-by: Juan Quintela <quintela@redhat.com>
43
- Message-Id: <20220513062836.965425-3-leobras@redhat.com>
44
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
45
- (cherry picked from commit b88651cb4d4fa416fdbb6afaf5b26ec8c035eaad)
46
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
47
- ---
48
- chardev/char-io.c | 2 +-
49
- hw/remote/mpqemu-link.c | 2 +-
50
- include/io/channel.h | 38 +++++++++++++++++++++-
51
- io/channel-buffer.c | 1 +
52
- io/channel-command.c | 1 +
53
- io/channel-file.c | 1 +
54
- io/channel-socket.c | 2 ++
55
- io/channel-tls.c | 1 +
56
- io/channel-websock.c | 1 +
57
- io/channel.c | 49 +++++++++++++++++++++++------
58
- migration/rdma.c | 1 +
59
- scsi/pr-manager-helper.c | 2 +-
60
- tests/unit/test-io-channel-socket.c | 1 +
61
- 13 files changed, 88 insertions(+), 14 deletions(-)
62
-
63
- diff --git a/chardev/char-io.c b/chardev/char-io.c
64
- index 8ced184160..4451128cba 100644
65
- --- a/chardev/char-io.c
66
- +++ b/chardev/char-io.c
67
- @@ -122,7 +122,7 @@ int io_channel_send_full(QIOChannel *ioc,
68
-
69
- ret = qio_channel_writev_full(
70
- ioc, &iov, 1,
71
- - fds, nfds, NULL);
72
- + fds, nfds, 0, NULL);
73
- if (ret == QIO_CHANNEL_ERR_BLOCK) {
74
- if (offset) {
75
- return offset;
76
- diff --git a/hw/remote/mpqemu-link.c b/hw/remote/mpqemu-link.c
77
- index 7e841820e5..e8f556bd27 100644
78
- --- a/hw/remote/mpqemu-link.c
79
- +++ b/hw/remote/mpqemu-link.c
80
- @@ -69,7 +69,7 @@ bool mpqemu_msg_send(MPQemuMsg *msg, QIOChannel *ioc, Error **errp)
81
- }
82
-
83
- if (!qio_channel_writev_full_all(ioc, send, G_N_ELEMENTS(send),
84
- - fds, nfds, errp)) {
85
- + fds, nfds, 0, errp)) {
86
- ret = true;
87
- } else {
88
- trace_mpqemu_send_io_error(msg->cmd, msg->size, nfds);
89
- diff --git a/include/io/channel.h b/include/io/channel.h
90
- index 88988979f8..c680ee7480 100644
91
- --- a/include/io/channel.h
92
- +++ b/include/io/channel.h
93
- @@ -32,12 +32,15 @@ OBJECT_DECLARE_TYPE(QIOChannel, QIOChannelClass,
94
-
95
- #define QIO_CHANNEL_ERR_BLOCK -2
96
-
97
- +#define QIO_CHANNEL_WRITE_FLAG_ZERO_COPY 0x1
98
- +
99
- typedef enum QIOChannelFeature QIOChannelFeature;
100
-
101
- enum QIOChannelFeature {
102
- QIO_CHANNEL_FEATURE_FD_PASS,
103
- QIO_CHANNEL_FEATURE_SHUTDOWN,
104
- QIO_CHANNEL_FEATURE_LISTEN,
105
- + QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY,
106
- };
107
-
108
-
109
- @@ -104,6 +107,7 @@ struct QIOChannelClass {
110
- size_t niov,
111
- int *fds,
112
- size_t nfds,
113
- + int flags,
114
- Error **errp);
115
- ssize_t (*io_readv)(QIOChannel *ioc,
116
- const struct iovec *iov,
117
- @@ -136,6 +140,8 @@ struct QIOChannelClass {
118
- IOHandler *io_read,
119
- IOHandler *io_write,
120
- void *opaque);
121
- + int (*io_flush)(QIOChannel *ioc,
122
- + Error **errp);
123
- };
124
-
125
- /* General I/O handling functions */
126
- @@ -228,6 +234,7 @@ ssize_t qio_channel_readv_full(QIOChannel *ioc,
127
- * @niov: the length of the @iov array
128
- * @fds: an array of file handles to send
129
- * @nfds: number of file handles in @fds
130
- + * @flags: write flags (QIO_CHANNEL_WRITE_FLAG_*)
131
- * @errp: pointer to a NULL-initialized error object
132
- *
133
- * Write data to the IO channel, reading it from the
134
- @@ -260,6 +267,7 @@ ssize_t qio_channel_writev_full(QIOChannel *ioc,
135
- size_t niov,
136
- int *fds,
137
- size_t nfds,
138
- + int flags,
139
- Error **errp);
140
-
141
- /**
142
- @@ -837,6 +845,7 @@ int qio_channel_readv_full_all(QIOChannel *ioc,
143
- * @niov: the length of the @iov array
144
- * @fds: an array of file handles to send
145
- * @nfds: number of file handles in @fds
146
- + * @flags: write flags (QIO_CHANNEL_WRITE_FLAG_*)
147
- * @errp: pointer to a NULL-initialized error object
148
- *
149
- *
150
- @@ -846,6 +855,14 @@ int qio_channel_readv_full_all(QIOChannel *ioc,
151
- * to be written, yielding from the current coroutine
152
- * if required.
153
- *
154
- + * If QIO_CHANNEL_WRITE_FLAG_ZERO_COPY is passed in flags,
155
- + * instead of waiting for all requested data to be written,
156
- + * this function will wait until it's all queued for writing.
157
- + * In this case, if the buffer gets changed between queueing and
158
- + * sending, the updated buffer will be sent. If this is not a
159
- + * desired behavior, it's suggested to call qio_channel_flush()
160
- + * before reusing the buffer.
161
- + *
162
- * Returns: 0 if all bytes were written, or -1 on error
163
- */
164
-
165
- @@ -853,6 +870,25 @@ int qio_channel_writev_full_all(QIOChannel *ioc,
166
- const struct iovec *iov,
167
- size_t niov,
168
- int *fds, size_t nfds,
169
- - Error **errp);
170
- + int flags, Error **errp);
171
- +
172
- +/**
173
- + * qio_channel_flush:
174
- + * @ioc: the channel object
175
- + * @errp: pointer to a NULL-initialized error object
176
- + *
177
- + * Will block until every packet queued with
178
- + * qio_channel_writev_full() + QIO_CHANNEL_WRITE_FLAG_ZERO_COPY
179
- + * is sent, or return in case of any error.
180
- + *
181
- + * If not implemented, acts as a no-op, and returns 0.
182
- + *
183
- + * Returns -1 if any error is found,
184
- + * 1 if every send failed to use zero copy.
185
- + * 0 otherwise.
186
- + */
187
- +
188
- +int qio_channel_flush(QIOChannel *ioc,
189
- + Error **errp);
190
-
191
- #endif /* QIO_CHANNEL_H */
192
- diff --git a/io/channel-buffer.c b/io/channel-buffer.c
193
- index baa4e2b089..bf52011be2 100644
194
- --- a/io/channel-buffer.c
195
- +++ b/io/channel-buffer.c
196
- @@ -81,6 +81,7 @@ static ssize_t qio_channel_buffer_writev(QIOChannel *ioc,
197
- size_t niov,
198
- int *fds,
199
- size_t nfds,
200
- + int flags,
201
- Error **errp)
202
- {
203
- QIOChannelBuffer *bioc = QIO_CHANNEL_BUFFER(ioc);
204
- diff --git a/io/channel-command.c b/io/channel-command.c
205
- index 338da73ade..54560464ae 100644
206
- --- a/io/channel-command.c
207
- +++ b/io/channel-command.c
208
- @@ -258,6 +258,7 @@ static ssize_t qio_channel_command_writev(QIOChannel *ioc,
209
- size_t niov,
210
- int *fds,
211
- size_t nfds,
212
- + int flags,
213
- Error **errp)
214
- {
215
- QIOChannelCommand *cioc = QIO_CHANNEL_COMMAND(ioc);
216
- diff --git a/io/channel-file.c b/io/channel-file.c
217
- index d7cf6d278f..ef6807a6be 100644
218
- --- a/io/channel-file.c
219
- +++ b/io/channel-file.c
220
- @@ -114,6 +114,7 @@ static ssize_t qio_channel_file_writev(QIOChannel *ioc,
221
- size_t niov,
222
- int *fds,
223
- size_t nfds,
224
- + int flags,
225
- Error **errp)
226
- {
227
- QIOChannelFile *fioc = QIO_CHANNEL_FILE(ioc);
228
- diff --git a/io/channel-socket.c b/io/channel-socket.c
229
- index 7a8d9f69c9..a1be2197ca 100644
230
- --- a/io/channel-socket.c
231
- +++ b/io/channel-socket.c
232
- @@ -525,6 +525,7 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
233
- size_t niov,
234
- int *fds,
235
- size_t nfds,
236
- + int flags,
237
- Error **errp)
238
- {
239
- QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc);
240
- @@ -620,6 +621,7 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
241
- size_t niov,
242
- int *fds,
243
- size_t nfds,
244
- + int flags,
245
- Error **errp)
246
- {
247
- QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc);
248
- diff --git a/io/channel-tls.c b/io/channel-tls.c
249
- index 2ae1b92fc0..4ce890a538 100644
250
- --- a/io/channel-tls.c
251
- +++ b/io/channel-tls.c
252
- @@ -301,6 +301,7 @@ static ssize_t qio_channel_tls_writev(QIOChannel *ioc,
253
- size_t niov,
254
- int *fds,
255
- size_t nfds,
256
- + int flags,
257
- Error **errp)
258
- {
259
- QIOChannelTLS *tioc = QIO_CHANNEL_TLS(ioc);
260
- diff --git a/io/channel-websock.c b/io/channel-websock.c
261
- index 55145a6a8c..9619906ac3 100644
262
- --- a/io/channel-websock.c
263
- +++ b/io/channel-websock.c
264
- @@ -1127,6 +1127,7 @@ static ssize_t qio_channel_websock_writev(QIOChannel *ioc,
265
- size_t niov,
266
- int *fds,
267
- size_t nfds,
268
- + int flags,
269
- Error **errp)
270
- {
271
- QIOChannelWebsock *wioc = QIO_CHANNEL_WEBSOCK(ioc);
272
- diff --git a/io/channel.c b/io/channel.c
273
- index e8b019dc36..0640941ac5 100644
274
- --- a/io/channel.c
275
- +++ b/io/channel.c
276
- @@ -72,18 +72,32 @@ ssize_t qio_channel_writev_full(QIOChannel *ioc,
277
- size_t niov,
278
- int *fds,
279
- size_t nfds,
280
- + int flags,
281
- Error **errp)
282
- {
283
- QIOChannelClass *klass = QIO_CHANNEL_GET_CLASS(ioc);
284
-
285
- - if ((fds || nfds) &&
286
- - !qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_FD_PASS)) {
287
- + if (fds || nfds) {
288
- + if (!qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_FD_PASS)) {
289
- + error_setg_errno(errp, EINVAL,
290
- + "Channel does not support file descriptor passing");
291
- + return -1;
292
- + }
293
- + if (flags & QIO_CHANNEL_WRITE_FLAG_ZERO_COPY) {
294
- + error_setg_errno(errp, EINVAL,
295
- + "Zero Copy does not support file descriptor passing");
296
- + return -1;
297
- + }
298
- + }
299
- +
300
- + if ((flags & QIO_CHANNEL_WRITE_FLAG_ZERO_COPY) &&
301
- + !qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY)) {
302
- error_setg_errno(errp, EINVAL,
303
- - "Channel does not support file descriptor passing");
304
- + "Requested Zero Copy feature is not available");
305
- return -1;
306
- }
307
-
308
- - return klass->io_writev(ioc, iov, niov, fds, nfds, errp);
309
- + return klass->io_writev(ioc, iov, niov, fds, nfds, flags, errp);
310
- }
311
-
312
-
313
- @@ -217,14 +231,14 @@ int qio_channel_writev_all(QIOChannel *ioc,
314
- size_t niov,
315
- Error **errp)
316
- {
317
- - return qio_channel_writev_full_all(ioc, iov, niov, NULL, 0, errp);
318
- + return qio_channel_writev_full_all(ioc, iov, niov, NULL, 0, 0, errp);
319
- }
320
-
321
- int qio_channel_writev_full_all(QIOChannel *ioc,
322
- const struct iovec *iov,
323
- size_t niov,
324
- int *fds, size_t nfds,
325
- - Error **errp)
326
- + int flags, Error **errp)
327
- {
328
- int ret = -1;
329
- struct iovec *local_iov = g_new(struct iovec, niov);
330
- @@ -237,8 +251,10 @@ int qio_channel_writev_full_all(QIOChannel *ioc,
331
-
332
- while (nlocal_iov > 0) {
333
- ssize_t len;
334
- - len = qio_channel_writev_full(ioc, local_iov, nlocal_iov, fds, nfds,
335
- - errp);
336
- +
337
- + len = qio_channel_writev_full(ioc, local_iov, nlocal_iov, fds,
338
- + nfds, flags, errp);
339
- +
340
- if (len == QIO_CHANNEL_ERR_BLOCK) {
341
- if (qemu_in_coroutine()) {
342
- qio_channel_yield(ioc, G_IO_OUT);
343
- @@ -277,7 +293,7 @@ ssize_t qio_channel_writev(QIOChannel *ioc,
344
- size_t niov,
345
- Error **errp)
346
- {
347
- - return qio_channel_writev_full(ioc, iov, niov, NULL, 0, errp);
348
- + return qio_channel_writev_full(ioc, iov, niov, NULL, 0, 0, errp);
349
- }
350
-
351
-
352
- @@ -297,7 +313,7 @@ ssize_t qio_channel_write(QIOChannel *ioc,
353
- Error **errp)
354
- {
355
- struct iovec iov = { .iov_base = (char *)buf, .iov_len = buflen };
356
- - return qio_channel_writev_full(ioc, &iov, 1, NULL, 0, errp);
357
- + return qio_channel_writev_full(ioc, &iov, 1, NULL, 0, 0, errp);
358
- }
359
-
360
-
361
- @@ -473,6 +489,19 @@ off_t qio_channel_io_seek(QIOChannel *ioc,
362
- return klass->io_seek(ioc, offset, whence, errp);
363
- }
364
-
365
- +int qio_channel_flush(QIOChannel *ioc,
366
- + Error **errp)
367
- +{
368
- + QIOChannelClass *klass = QIO_CHANNEL_GET_CLASS(ioc);
369
- +
370
- + if (!klass->io_flush ||
371
- + !qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY)) {
372
- + return 0;
373
- + }
374
- +
375
- + return klass->io_flush(ioc, errp);
376
- +}
377
- +
378
-
379
- static void qio_channel_restart_read(void *opaque)
380
- {
381
- diff --git a/migration/rdma.c b/migration/rdma.c
382
- index ef1e65ec36..672d1958a9 100644
383
- --- a/migration/rdma.c
384
- +++ b/migration/rdma.c
385
- @@ -2840,6 +2840,7 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *ioc,
386
- size_t niov,
387
- int *fds,
388
- size_t nfds,
389
- + int flags,
390
- Error **errp)
391
- {
392
- QIOChannelRDMA *rioc = QIO_CHANNEL_RDMA(ioc);
393
- diff --git a/scsi/pr-manager-helper.c b/scsi/pr-manager-helper.c
394
- index 451c7631b7..3be52a98d5 100644
395
- --- a/scsi/pr-manager-helper.c
396
- +++ b/scsi/pr-manager-helper.c
397
- @@ -77,7 +77,7 @@ static int pr_manager_helper_write(PRManagerHelper *pr_mgr,
398
- iov.iov_base = (void *)buf;
399
- iov.iov_len = sz;
400
- n_written = qio_channel_writev_full(QIO_CHANNEL(pr_mgr->ioc), &iov, 1,
401
- - nfds ? &fd : NULL, nfds, errp);
402
- + nfds ? &fd : NULL, nfds, 0, errp);
403
-
404
- if (n_written <= 0) {
405
- assert(n_written != QIO_CHANNEL_ERR_BLOCK);
406
- diff --git a/tests/unit/test-io-channel-socket.c b/tests/unit/test-io-channel-socket.c
407
- index c49eec1f03..6713886d02 100644
408
- --- a/tests/unit/test-io-channel-socket.c
409
- +++ b/tests/unit/test-io-channel-socket.c
410
- @@ -444,6 +444,7 @@ static void test_io_channel_unix_fd_pass(void)
411
- G_N_ELEMENTS(iosend),
412
- fdsend,
413
- G_N_ELEMENTS(fdsend),
414
- + 0,
415
- &error_abort);
416
-
417
- qio_channel_readv_full(dst,
418
- --
419
- 2.35.3
420
-
SOURCES/kvm-QIOChannelSocket-Add-support-for-MSG_ZEROCOPY-IPV6.patch DELETED
@@ -1,56 +0,0 @@
1
- From cb6dc39a5e5d2d981b4b1e983042b3fbb529d5d1 Mon Sep 17 00:00:00 2001
2
- From: Leonardo Bras <leobras@redhat.com>
3
- Date: Thu, 4 Aug 2022 04:10:43 -0300
4
- Subject: [PATCH 06/11] QIOChannelSocket: Add support for MSG_ZEROCOPY + IPV6
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Leonardo Brás <leobras@redhat.com>
10
- RH-MergeRequest: 111: zero-copy-send fixes & improvements
11
- RH-Commit: [6/6] 2eb1aba8ebf267a6f67cfba2e489dc88619c7fd4 (LeoBras/centos-qemu-kvm)
12
- RH-Bugzilla: 2107466
13
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
14
- RH-Acked-by: Thomas Huth <thuth@redhat.com>
15
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
16
-
17
- For using MSG_ZEROCOPY, there are two steps:
18
- 1 - io_writev() the packet, which enqueues the packet for sending, and
19
- 2 - io_flush(), which gets confirmation that all packets got correctly sent
20
-
21
- Currently, if MSG_ZEROCOPY is used to send packets over IPV6, no error will
22
- be reported in (1), but it will fail in the first time (2) happens.
23
-
24
- This happens because (2) currently checks for cmsg_level & cmsg_type
25
- associated with IPV4 only, before reporting any error.
26
-
27
- Add checks for cmsg_level & cmsg_type associated with IPV6, and thus enable
28
- support for MSG_ZEROCOPY + IPV6
29
-
30
- Fixes: 2bc58ffc29 ("QIOChannelSocket: Implement io_writev zero copy flag & io_flush for CONFIG_LINUX")
31
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
32
- Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
33
- (cherry picked from commit 5258a7e2c0677d16e9e1d06845f60171adf0b290)
34
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
35
- ---
36
- io/channel-socket.c | 4 ++--
37
- 1 file changed, 2 insertions(+), 2 deletions(-)
38
-
39
- diff --git a/io/channel-socket.c b/io/channel-socket.c
40
- index eb7baa2184..efd5f60808 100644
41
- --- a/io/channel-socket.c
42
- +++ b/io/channel-socket.c
43
- @@ -747,8 +747,8 @@ static int qio_channel_socket_flush(QIOChannel *ioc,
44
- }
45
-
46
- cm = CMSG_FIRSTHDR(&msg);
47
- - if (cm->cmsg_level != SOL_IP &&
48
- - cm->cmsg_type != IP_RECVERR) {
49
- + if (cm->cmsg_level != SOL_IP && cm->cmsg_type != IP_RECVERR &&
50
- + cm->cmsg_level != SOL_IPV6 && cm->cmsg_type != IPV6_RECVERR) {
51
- error_setg_errno(errp, EPROTOTYPE,
52
- "Wrong cmsg in errqueue");
53
- return -1;
54
- --
55
- 2.31.1
56
-
SOURCES/kvm-QIOChannelSocket-Fix-zero-copy-flush-returning-code-.patch DELETED
@@ -1,65 +0,0 @@
1
- From 678981c6bb7c964e1591f6f8aba49e9602f64852 Mon Sep 17 00:00:00 2001
2
- From: Leonardo Bras <leobras@redhat.com>
3
- Date: Mon, 11 Jul 2022 18:11:11 -0300
4
- Subject: [PATCH 01/11] QIOChannelSocket: Fix zero-copy flush returning code 1
5
- when nothing sent
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Leonardo Brás <leobras@redhat.com>
11
- RH-MergeRequest: 111: zero-copy-send fixes & improvements
12
- RH-Commit: [1/6] cebc887cb61de1572d8ae3232cde45e80c339404 (LeoBras/centos-qemu-kvm)
13
- RH-Bugzilla: 2107466
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Thomas Huth <thuth@redhat.com>
16
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
17
-
18
- If flush is called when no buffer was sent with MSG_ZEROCOPY, it currently
19
- returns 1. This return code should be used only when Linux fails to use
20
- MSG_ZEROCOPY on a lot of sendmsg().
21
-
22
- Fix this by returning early from flush if no sendmsg(...,MSG_ZEROCOPY)
23
- was attempted.
24
-
25
- Fixes: 2bc58ffc2926 ("QIOChannelSocket: Implement io_writev zero copy flag & io_flush for CONFIG_LINUX")
26
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
27
- Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
28
- Acked-by: Daniel P. Berrangé <berrange@redhat.com>
29
- Reviewed-by: Juan Quintela <quintela@redhat.com>
30
- Reviewed-by: Peter Xu <peterx@redhat.com>
31
- Message-Id: <20220711211112.18951-2-leobras@redhat.com>
32
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
33
- (cherry picked from commit 927f93e099c4f9184e60a1bc61624ac2d04d0223)
34
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
35
- ---
36
- io/channel-socket.c | 8 +++++++-
37
- 1 file changed, 7 insertions(+), 1 deletion(-)
38
-
39
- diff --git a/io/channel-socket.c b/io/channel-socket.c
40
- index 8ae8b212cf..eb7baa2184 100644
41
- --- a/io/channel-socket.c
42
- +++ b/io/channel-socket.c
43
- @@ -717,12 +717,18 @@ static int qio_channel_socket_flush(QIOChannel *ioc,
44
- struct cmsghdr *cm;
45
- char control[CMSG_SPACE(sizeof(*serr))];
46
- int received;
47
- - int ret = 1;
48
- + int ret;
49
- +
50
- + if (sioc->zero_copy_queued == sioc->zero_copy_sent) {
51
- + return 0;
52
- + }
53
-
54
- msg.msg_control = control;
55
- msg.msg_controllen = sizeof(control);
56
- memset(control, 0, sizeof(control));
57
-
58
- + ret = 1;
59
- +
60
- while (sioc->zero_copy_sent < sioc->zero_copy_queued) {
61
- received = recvmsg(sioc->fd, &msg, MSG_ERRQUEUE);
62
- if (received < 0) {
63
- --
64
- 2.31.1
65
-
SOURCES/kvm-QIOChannelSocket-Fix-zero-copy-send-so-socket-flush-.patch DELETED
@@ -1,58 +0,0 @@
1
- From e70f01749addd7d0b7aa7fa4fdedb664f98e6b9b Mon Sep 17 00:00:00 2001
2
- From: Leonardo Bras <leobras@redhat.com>
3
- Date: Mon, 20 Jun 2022 02:39:43 -0300
4
- Subject: [PATCH 16/18] QIOChannelSocket: Fix zero-copy send so socket flush
5
- works
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Leonardo Brás <leobras@redhat.com>
11
- RH-MergeRequest: 95: MSG_ZEROCOPY + Multifd
12
- RH-Commit: [10/11] a2dfac987e24026b1a78e90b86234ca206b6401f (LeoBras/centos-qemu-kvm)
13
- RH-Bugzilla: 1968509
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
16
- RH-Acked-by: Peter Xu <peterx@redhat.com>
17
-
18
- Somewhere between v6 and v7 the of the zero-copy-send patchset a crucial
19
- part of the flushing mechanism got missing: incrementing zero_copy_queued.
20
-
21
- Without that, the flushing interface becomes a no-op, and there is no
22
- guarantee the buffer is really sent.
23
-
24
- This can go as bad as causing a corruption in RAM during migration.
25
-
26
- Fixes: 2bc58ffc2926 ("QIOChannelSocket: Implement io_writev zero copy flag & io_flush for CONFIG_LINUX")
27
- Reported-by: 徐闯 <xuchuangxclwt@bytedance.com>
28
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
29
- Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
30
- Reviewed-by: Peter Xu <peterx@redhat.com>
31
- Reviewed-by: Juan Quintela <quintela@redhat.com>
32
- Signed-off-by: Juan Quintela <quintela@redhat.com>
33
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
34
- (cherry picked from commit 4f5a09714c983a3471fd12e3c7f3196e95c650c1)
35
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
36
- ---
37
- io/channel-socket.c | 5 +++++
38
- 1 file changed, 5 insertions(+)
39
-
40
- diff --git a/io/channel-socket.c b/io/channel-socket.c
41
- index 7490e5943d..8ae8b212cf 100644
42
- --- a/io/channel-socket.c
43
- +++ b/io/channel-socket.c
44
- @@ -612,6 +612,11 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
45
- "Unable to write to socket");
46
- return -1;
47
- }
48
- +
49
- + if (flags & QIO_CHANNEL_WRITE_FLAG_ZERO_COPY) {
50
- + sioc->zero_copy_queued++;
51
- + }
52
- +
53
- return ret;
54
- }
55
- #else /* WIN32 */
56
- --
57
- 2.35.3
58
-
SOURCES/kvm-QIOChannelSocket-Implement-io_writev-zero-copy-flag-.patch DELETED
@@ -1,249 +0,0 @@
1
- From 4aeba0365d30dabe2e70dc172683f0878a4a9621 Mon Sep 17 00:00:00 2001
2
- From: Leonardo Bras <leobras@redhat.com>
3
- Date: Fri, 13 May 2022 03:28:32 -0300
4
- Subject: [PATCH 09/18] QIOChannelSocket: Implement io_writev zero copy flag &
5
- io_flush for CONFIG_LINUX
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Leonardo Brás <leobras@redhat.com>
11
- RH-MergeRequest: 95: MSG_ZEROCOPY + Multifd
12
- RH-Commit: [3/11] 9afeac1f5ac7675624660a0281726c09c8321180 (LeoBras/centos-qemu-kvm)
13
- RH-Bugzilla: 1968509
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
16
- RH-Acked-by: Peter Xu <peterx@redhat.com>
17
-
18
- For CONFIG_LINUX, implement the new zero copy flag and the optional callback
19
- io_flush on QIOChannelSocket, but enables it only when MSG_ZEROCOPY
20
- feature is available in the host kernel, which is checked on
21
- qio_channel_socket_connect_sync()
22
-
23
- qio_channel_socket_flush() was implemented by counting how many times
24
- sendmsg(...,MSG_ZEROCOPY) was successfully called, and then reading the
25
- socket's error queue, in order to find how many of them finished sending.
26
- Flush will loop until those counters are the same, or until some error occurs.
27
-
28
- Notes on using writev() with QIO_CHANNEL_WRITE_FLAG_ZERO_COPY:
29
- 1: Buffer
30
- - As MSG_ZEROCOPY tells the kernel to use the same user buffer to avoid copying,
31
- some caution is necessary to avoid overwriting any buffer before it's sent.
32
- If something like this happen, a newer version of the buffer may be sent instead.
33
- - If this is a problem, it's recommended to call qio_channel_flush() before freeing
34
- or re-using the buffer.
35
-
36
- 2: Locked memory
37
- - When using MSG_ZERCOCOPY, the buffer memory will be locked after queued, and
38
- unlocked after it's sent.
39
- - Depending on the size of each buffer, and how often it's sent, it may require
40
- a larger amount of locked memory than usually available to non-root user.
41
- - If the required amount of locked memory is not available, writev_zero_copy
42
- will return an error, which can abort an operation like migration,
43
- - Because of this, when an user code wants to add zero copy as a feature, it
44
- requires a mechanism to disable it, so it can still be accessible to less
45
- privileged users.
46
-
47
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
48
- Reviewed-by: Peter Xu <peterx@redhat.com>
49
- Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
50
- Reviewed-by: Juan Quintela <quintela@redhat.com>
51
- Message-Id: <20220513062836.965425-4-leobras@redhat.com>
52
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
53
- (cherry picked from commit 2bc58ffc2926a4efdd03edfb5909861fefc68c3d)
54
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
55
- ---
56
- include/io/channel-socket.h | 2 +
57
- io/channel-socket.c | 116 ++++++++++++++++++++++++++++++++++--
58
- 2 files changed, 114 insertions(+), 4 deletions(-)
59
-
60
- diff --git a/include/io/channel-socket.h b/include/io/channel-socket.h
61
- index e747e63514..513c428fe4 100644
62
- --- a/include/io/channel-socket.h
63
- +++ b/include/io/channel-socket.h
64
- @@ -47,6 +47,8 @@ struct QIOChannelSocket {
65
- socklen_t localAddrLen;
66
- struct sockaddr_storage remoteAddr;
67
- socklen_t remoteAddrLen;
68
- + ssize_t zero_copy_queued;
69
- + ssize_t zero_copy_sent;
70
- };
71
-
72
-
73
- diff --git a/io/channel-socket.c b/io/channel-socket.c
74
- index a1be2197ca..fbd2214d20 100644
75
- --- a/io/channel-socket.c
76
- +++ b/io/channel-socket.c
77
- @@ -26,6 +26,14 @@
78
- #include "io/channel-watch.h"
79
- #include "trace.h"
80
- #include "qapi/clone-visitor.h"
81
- +#ifdef CONFIG_LINUX
82
- +#include <linux/errqueue.h>
83
- +#include <sys/socket.h>
84
- +
85
- +#if (defined(MSG_ZEROCOPY) && defined(SO_ZEROCOPY))
86
- +#define QEMU_MSG_ZEROCOPY
87
- +#endif
88
- +#endif
89
-
90
- #define SOCKET_MAX_FDS 16
91
-
92
- @@ -55,6 +63,8 @@ qio_channel_socket_new(void)
93
-
94
- sioc = QIO_CHANNEL_SOCKET(object_new(TYPE_QIO_CHANNEL_SOCKET));
95
- sioc->fd = -1;
96
- + sioc->zero_copy_queued = 0;
97
- + sioc->zero_copy_sent = 0;
98
-
99
- ioc = QIO_CHANNEL(sioc);
100
- qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN);
101
- @@ -154,6 +164,16 @@ int qio_channel_socket_connect_sync(QIOChannelSocket *ioc,
102
- return -1;
103
- }
104
-
105
- +#ifdef QEMU_MSG_ZEROCOPY
106
- + int ret, v = 1;
107
- + ret = setsockopt(fd, SOL_SOCKET, SO_ZEROCOPY, &v, sizeof(v));
108
- + if (ret == 0) {
109
- + /* Zero copy available on host */
110
- + qio_channel_set_feature(QIO_CHANNEL(ioc),
111
- + QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY);
112
- + }
113
- +#endif
114
- +
115
- return 0;
116
- }
117
-
118
- @@ -534,6 +554,7 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
119
- char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)];
120
- size_t fdsize = sizeof(int) * nfds;
121
- struct cmsghdr *cmsg;
122
- + int sflags = 0;
123
-
124
- memset(control, 0, CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS));
125
-
126
- @@ -558,15 +579,31 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
127
- memcpy(CMSG_DATA(cmsg), fds, fdsize);
128
- }
129
-
130
- +#ifdef QEMU_MSG_ZEROCOPY
131
- + if (flags & QIO_CHANNEL_WRITE_FLAG_ZERO_COPY) {
132
- + sflags = MSG_ZEROCOPY;
133
- + }
134
- +#endif
135
- +
136
- retry:
137
- - ret = sendmsg(sioc->fd, &msg, 0);
138
- + ret = sendmsg(sioc->fd, &msg, sflags);
139
- if (ret <= 0) {
140
- - if (errno == EAGAIN) {
141
- + switch (errno) {
142
- + case EAGAIN:
143
- return QIO_CHANNEL_ERR_BLOCK;
144
- - }
145
- - if (errno == EINTR) {
146
- + case EINTR:
147
- goto retry;
148
- +#ifdef QEMU_MSG_ZEROCOPY
149
- + case ENOBUFS:
150
- + if (sflags & MSG_ZEROCOPY) {
151
- + error_setg_errno(errp, errno,
152
- + "Process can't lock enough memory for using MSG_ZEROCOPY");
153
- + return -1;
154
- + }
155
- + break;
156
- +#endif
157
- }
158
- +
159
- error_setg_errno(errp, errno,
160
- "Unable to write to socket");
161
- return -1;
162
- @@ -660,6 +697,74 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
163
- }
164
- #endif /* WIN32 */
165
-
166
- +
167
- +#ifdef QEMU_MSG_ZEROCOPY
168
- +static int qio_channel_socket_flush(QIOChannel *ioc,
169
- + Error **errp)
170
- +{
171
- + QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc);
172
- + struct msghdr msg = {};
173
- + struct sock_extended_err *serr;
174
- + struct cmsghdr *cm;
175
- + char control[CMSG_SPACE(sizeof(*serr))];
176
- + int received;
177
- + int ret = 1;
178
- +
179
- + msg.msg_control = control;
180
- + msg.msg_controllen = sizeof(control);
181
- + memset(control, 0, sizeof(control));
182
- +
183
- + while (sioc->zero_copy_sent < sioc->zero_copy_queued) {
184
- + received = recvmsg(sioc->fd, &msg, MSG_ERRQUEUE);
185
- + if (received < 0) {
186
- + switch (errno) {
187
- + case EAGAIN:
188
- + /* Nothing on errqueue, wait until something is available */
189
- + qio_channel_wait(ioc, G_IO_ERR);
190
- + continue;
191
- + case EINTR:
192
- + continue;
193
- + default:
194
- + error_setg_errno(errp, errno,
195
- + "Unable to read errqueue");
196
- + return -1;
197
- + }
198
- + }
199
- +
200
- + cm = CMSG_FIRSTHDR(&msg);
201
- + if (cm->cmsg_level != SOL_IP &&
202
- + cm->cmsg_type != IP_RECVERR) {
203
- + error_setg_errno(errp, EPROTOTYPE,
204
- + "Wrong cmsg in errqueue");
205
- + return -1;
206
- + }
207
- +
208
- + serr = (void *) CMSG_DATA(cm);
209
- + if (serr->ee_errno != SO_EE_ORIGIN_NONE) {
210
- + error_setg_errno(errp, serr->ee_errno,
211
- + "Error on socket");
212
- + return -1;
213
- + }
214
- + if (serr->ee_origin != SO_EE_ORIGIN_ZEROCOPY) {
215
- + error_setg_errno(errp, serr->ee_origin,
216
- + "Error not from zero copy");
217
- + return -1;
218
- + }
219
- +
220
- + /* No errors, count successfully finished sendmsg()*/
221
- + sioc->zero_copy_sent += serr->ee_data - serr->ee_info + 1;
222
- +
223
- + /* If any sendmsg() succeeded using zero copy, return 0 at the end */
224
- + if (serr->ee_code != SO_EE_CODE_ZEROCOPY_COPIED) {
225
- + ret = 0;
226
- + }
227
- + }
228
- +
229
- + return ret;
230
- +}
231
- +
232
- +#endif /* QEMU_MSG_ZEROCOPY */
233
- +
234
- static int
235
- qio_channel_socket_set_blocking(QIOChannel *ioc,
236
- bool enabled,
237
- @@ -790,6 +895,9 @@ static void qio_channel_socket_class_init(ObjectClass *klass,
238
- ioc_klass->io_set_delay = qio_channel_socket_set_delay;
239
- ioc_klass->io_create_watch = qio_channel_socket_create_watch;
240
- ioc_klass->io_set_aio_fd_handler = qio_channel_socket_set_aio_fd_handler;
241
- +#ifdef QEMU_MSG_ZEROCOPY
242
- + ioc_klass->io_flush = qio_channel_socket_flush;
243
- +#endif
244
- }
245
-
246
- static const TypeInfo qio_channel_socket_info = {
247
- --
248
- 2.35.3
249
-
SOURCES/kvm-QIOChannelSocket-Introduce-assert-and-reduce-ifdefs-.patch DELETED
@@ -1,82 +0,0 @@
1
- From 60bf942a58db12c821f2a6a49e2e0b04b99bec30 Mon Sep 17 00:00:00 2001
2
- From: Leonardo Bras <leobras@redhat.com>
3
- Date: Mon, 20 Jun 2022 02:39:42 -0300
4
- Subject: [PATCH 15/18] QIOChannelSocket: Introduce assert and reduce ifdefs to
5
- improve readability
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Leonardo Brás <leobras@redhat.com>
11
- RH-MergeRequest: 95: MSG_ZEROCOPY + Multifd
12
- RH-Commit: [9/11] eaa02d68301852ccc98bdacc7387d8d03be1cb05 (LeoBras/centos-qemu-kvm)
13
- RH-Bugzilla: 1968509
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
16
- RH-Acked-by: Peter Xu <peterx@redhat.com>
17
-
18
- During implementation of MSG_ZEROCOPY feature, a lot of #ifdefs were
19
- introduced, particularly at qio_channel_socket_writev().
20
-
21
- Rewrite some of those changes so it's easier to read.
22
-
23
- Also, introduce an assert to help detect incorrect zero-copy usage is when
24
- it's disabled on build.
25
-
26
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
27
- Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
28
- Reviewed-by: Juan Quintela <quintela@redhat.com>
29
- Reviewed-by: Peter Xu <peterx@redhat.com>
30
- Signed-off-by: Juan Quintela <quintela@redhat.com>
31
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
32
- dgilbert: Fixed up thinko'd g_assert_unreachable->g_assert_not_reached
33
- (cherry picked from commit 803ca43e4c7fcf32f9f68c118301ccd0c83ece3f)
34
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
35
- ---
36
- io/channel-socket.c | 14 +++++++++-----
37
- 1 file changed, 9 insertions(+), 5 deletions(-)
38
-
39
- diff --git a/io/channel-socket.c b/io/channel-socket.c
40
- index fbd2214d20..7490e5943d 100644
41
- --- a/io/channel-socket.c
42
- +++ b/io/channel-socket.c
43
- @@ -579,11 +579,17 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
44
- memcpy(CMSG_DATA(cmsg), fds, fdsize);
45
- }
46
-
47
- -#ifdef QEMU_MSG_ZEROCOPY
48
- if (flags & QIO_CHANNEL_WRITE_FLAG_ZERO_COPY) {
49
- +#ifdef QEMU_MSG_ZEROCOPY
50
- sflags = MSG_ZEROCOPY;
51
- - }
52
- +#else
53
- + /*
54
- + * We expect QIOChannel class entry point to have
55
- + * blocked this code path already
56
- + */
57
- + g_assert_not_reached();
58
- #endif
59
- + }
60
-
61
- retry:
62
- ret = sendmsg(sioc->fd, &msg, sflags);
63
- @@ -593,15 +599,13 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
64
- return QIO_CHANNEL_ERR_BLOCK;
65
- case EINTR:
66
- goto retry;
67
- -#ifdef QEMU_MSG_ZEROCOPY
68
- case ENOBUFS:
69
- - if (sflags & MSG_ZEROCOPY) {
70
- + if (flags & QIO_CHANNEL_WRITE_FLAG_ZERO_COPY) {
71
- error_setg_errno(errp, errno,
72
- "Process can't lock enough memory for using MSG_ZEROCOPY");
73
- return -1;
74
- }
75
- break;
76
- -#endif
77
- }
78
-
79
- error_setg_errno(errp, errno,
80
- --
81
- 2.35.3
82
-
SOURCES/kvm-RHEL-only-AArch64-Drop-unsupported-CPU-types.patch DELETED
@@ -1,237 +0,0 @@
1
- From 055edf068196622a3e1868c9e4c991d410272a6d Mon Sep 17 00:00:00 2001
2
- From: Andrew Jones <drjones@redhat.com>
3
- Date: Wed, 15 Jun 2022 15:28:27 +0200
4
- Subject: [PATCH 03/18] RHEL-only: AArch64: Drop unsupported CPU types
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Daniel P. Berrangé <berrange@redhat.com>
10
- RH-MergeRequest: 94: i386, aarch64, s390x: deprecate many named CPU models
11
- RH-Commit: [3/6] 21f54c86dc87e5e75a64459b5a385686bc09640c (berrange/centos-src-qemu)
12
- RH-Bugzilla: 2060839
13
- RH-Acked-by: Thomas Huth <thuth@redhat.com>
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2066824
18
- Upstream Status: RHEL only
19
-
20
- We only need to support AArch64 cpu types and we only need three
21
- types:
22
- 1) A base type to use with TCG, i.e. a cpu type with only base
23
- features. 'cortex-a57' serves this role and is currently used
24
- by libguestfs.
25
- 2) The 'max' type, which is for both KVM and TCG and is good for
26
- tests that just specify 'max' but run under both. 'max' with
27
- TCG also provides the VM with all the CPU features TCG
28
- supports, which is good for VMs that need features not
29
- provided by the basic cortex-a57.
30
- 3) The host type which is used with KVM.
31
-
32
- Signed-off-by: Andrew Jones <drjones@redhat.com>
33
- ---
34
- hw/arm/virt.c | 4 ++++
35
- target/arm/cpu64.c | 6 ++++++
36
- target/arm/cpu_tcg.c | 12 ++----------
37
- tests/qtest/arm-cpu-features.c | 6 ++++++
38
- 4 files changed, 18 insertions(+), 10 deletions(-)
39
-
40
- diff --git a/hw/arm/virt.c b/hw/arm/virt.c
41
- index 95d012d6eb..74119976d3 100644
42
- --- a/hw/arm/virt.c
43
- +++ b/hw/arm/virt.c
44
- @@ -239,12 +239,16 @@ static const int a15irqmap[] = {
45
- };
46
-
47
- static const char *valid_cpus[] = {
48
- +#if 0 /* Disabled for Red Hat Enterprise Linux */
49
- ARM_CPU_TYPE_NAME("cortex-a7"),
50
- ARM_CPU_TYPE_NAME("cortex-a15"),
51
- ARM_CPU_TYPE_NAME("cortex-a53"),
52
- +#endif /* disabled for RHEL */
53
- ARM_CPU_TYPE_NAME("cortex-a57"),
54
- +#if 0 /* Disabled for Red Hat Enterprise Linux */
55
- ARM_CPU_TYPE_NAME("cortex-a72"),
56
- ARM_CPU_TYPE_NAME("a64fx"),
57
- +#endif /* disabled for RHEL */
58
- ARM_CPU_TYPE_NAME("host"),
59
- ARM_CPU_TYPE_NAME("max"),
60
- };
61
- diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
62
- index eb44c05822..e80b831073 100644
63
- --- a/target/arm/cpu64.c
64
- +++ b/target/arm/cpu64.c
65
- @@ -146,6 +146,7 @@ static void aarch64_a57_initfn(Object *obj)
66
- define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo);
67
- }
68
-
69
- +#if 0 /* Disabled for Red Hat Enterprise Linux */
70
- static void aarch64_a53_initfn(Object *obj)
71
- {
72
- ARMCPU *cpu = ARM_CPU(obj);
73
- @@ -249,6 +250,7 @@ static void aarch64_a72_initfn(Object *obj)
74
- cpu->gic_vprebits = 5;
75
- define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo);
76
- }
77
- +#endif /* disabled for RHEL */
78
-
79
- void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp)
80
- {
81
- @@ -923,6 +925,7 @@ static void aarch64_max_initfn(Object *obj)
82
- qdev_property_add_static(DEVICE(obj), &arm_cpu_lpa2_property);
83
- }
84
-
85
- +#if 0 /* Disabled for Red Hat Enterprise Linux */
86
- static void aarch64_a64fx_initfn(Object *obj)
87
- {
88
- ARMCPU *cpu = ARM_CPU(obj);
89
- @@ -969,12 +972,15 @@ static void aarch64_a64fx_initfn(Object *obj)
90
-
91
- /* TODO: Add A64FX specific HPC extension registers */
92
- }
93
- +#endif /* disabled for RHEL */
94
-
95
- static const ARMCPUInfo aarch64_cpus[] = {
96
- { .name = "cortex-a57", .initfn = aarch64_a57_initfn },
97
- +#if 0 /* Disabled for Red Hat Enterprise Linux */
98
- { .name = "cortex-a53", .initfn = aarch64_a53_initfn },
99
- { .name = "cortex-a72", .initfn = aarch64_a72_initfn },
100
- { .name = "a64fx", .initfn = aarch64_a64fx_initfn },
101
- +#endif /* disabled for RHEL */
102
- { .name = "max", .initfn = aarch64_max_initfn },
103
- #if defined(CONFIG_KVM) || defined(CONFIG_HVF)
104
- { .name = "host", .initfn = aarch64_host_initfn },
105
- diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
106
- index 3826fa5122..74727fc92c 100644
107
- --- a/target/arm/cpu_tcg.c
108
- +++ b/target/arm/cpu_tcg.c
109
- @@ -19,10 +19,10 @@
110
- #include "hw/boards.h"
111
- #endif
112
-
113
- +#if 0 /* Disabled for Red Hat Enterprise Linux */
114
- /* CPU models. These are not needed for the AArch64 linux-user build. */
115
- #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
116
-
117
- -#if 0 /* Disabled for Red Hat Enterprise Linux */
118
- #if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG)
119
- static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
120
- {
121
- @@ -376,7 +376,6 @@ static void cortex_a9_initfn(Object *obj)
122
- cpu->ccsidr[1] = 0x200fe019; /* 16k L1 icache. */
123
- define_arm_cp_regs(cpu, cortexa9_cp_reginfo);
124
- }
125
- -#endif /* disabled for RHEL */
126
-
127
- #ifndef CONFIG_USER_ONLY
128
- static uint64_t a15_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
129
- @@ -402,7 +401,6 @@ static const ARMCPRegInfo cortexa15_cp_reginfo[] = {
130
- REGINFO_SENTINEL
131
- };
132
-
133
- -#if 0 /* Disabled for Red Hat Enterprise Linux */
134
- static void cortex_a7_initfn(Object *obj)
135
- {
136
- ARMCPU *cpu = ARM_CPU(obj);
137
- @@ -448,7 +446,6 @@ static void cortex_a7_initfn(Object *obj)
138
- cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */
139
- define_arm_cp_regs(cpu, cortexa15_cp_reginfo); /* Same as A15 */
140
- }
141
- -#endif /* disabled for RHEL */
142
-
143
- static void cortex_a15_initfn(Object *obj)
144
- {
145
- @@ -492,7 +489,6 @@ static void cortex_a15_initfn(Object *obj)
146
- define_arm_cp_regs(cpu, cortexa15_cp_reginfo);
147
- }
148
-
149
- -#if 0 /* Disabled for Red Hat Enterprise Linux */
150
- static void cortex_m0_initfn(Object *obj)
151
- {
152
- ARMCPU *cpu = ARM_CPU(obj);
153
- @@ -933,7 +929,6 @@ static void arm_v7m_class_init(ObjectClass *oc, void *data)
154
-
155
- cc->gdb_core_xml_file = "arm-m-profile.xml";
156
- }
157
- -#endif /* disabled for RHEL */
158
-
159
- #ifndef TARGET_AARCH64
160
- /*
161
- @@ -1013,7 +1008,6 @@ static void arm_max_initfn(Object *obj)
162
- #endif /* !TARGET_AARCH64 */
163
-
164
- static const ARMCPUInfo arm_tcg_cpus[] = {
165
- -#if 0 /* Disabled for Red Hat Enterprise Linux */
166
- { .name = "arm926", .initfn = arm926_initfn },
167
- { .name = "arm946", .initfn = arm946_initfn },
168
- { .name = "arm1026", .initfn = arm1026_initfn },
169
- @@ -1029,9 +1023,7 @@ static const ARMCPUInfo arm_tcg_cpus[] = {
170
- { .name = "cortex-a7", .initfn = cortex_a7_initfn },
171
- { .name = "cortex-a8", .initfn = cortex_a8_initfn },
172
- { .name = "cortex-a9", .initfn = cortex_a9_initfn },
173
- -#endif /* disabled for RHEL */
174
- { .name = "cortex-a15", .initfn = cortex_a15_initfn },
175
- -#if 0 /* Disabled for Red Hat Enterprise Linux */
176
- { .name = "cortex-m0", .initfn = cortex_m0_initfn,
177
- .class_init = arm_v7m_class_init },
178
- { .name = "cortex-m3", .initfn = cortex_m3_initfn,
179
- @@ -1062,7 +1054,6 @@ static const ARMCPUInfo arm_tcg_cpus[] = {
180
- { .name = "pxa270-b1", .initfn = pxa270b1_initfn },
181
- { .name = "pxa270-c0", .initfn = pxa270c0_initfn },
182
- { .name = "pxa270-c5", .initfn = pxa270c5_initfn },
183
- -#endif /* disabled for RHEL */
184
- #ifndef TARGET_AARCH64
185
- { .name = "max", .initfn = arm_max_initfn },
186
- #endif
187
- @@ -1090,3 +1081,4 @@ static void arm_tcg_cpu_register_types(void)
188
- type_init(arm_tcg_cpu_register_types)
189
-
190
- #endif /* !CONFIG_USER_ONLY || !TARGET_AARCH64 */
191
- +#endif /* disabled for RHEL */
192
- diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
193
- index f76652143a..fe2a0a070d 100644
194
- --- a/tests/qtest/arm-cpu-features.c
195
- +++ b/tests/qtest/arm-cpu-features.c
196
- @@ -440,8 +440,10 @@ static void test_query_cpu_model_expansion(const void *data)
197
- assert_error(qts, "host", "The CPU type 'host' requires KVM", NULL);
198
-
199
- /* Test expected feature presence/absence for some cpu types */
200
- +#if 0 /* Disabled for Red Hat Enterprise Linux */
201
- assert_has_feature_enabled(qts, "cortex-a15", "pmu");
202
- assert_has_not_feature(qts, "cortex-a15", "aarch64");
203
- +#endif /* disabled for RHEL */
204
-
205
- /* Enabling and disabling pmu should always work. */
206
- assert_has_feature_enabled(qts, "max", "pmu");
207
- @@ -458,6 +460,7 @@ static void test_query_cpu_model_expansion(const void *data)
208
- assert_has_feature_enabled(qts, "cortex-a57", "pmu");
209
- assert_has_feature_enabled(qts, "cortex-a57", "aarch64");
210
-
211
- +#if 0 /* Disabled for Red Hat Enterprise Linux */
212
- assert_has_feature_enabled(qts, "a64fx", "pmu");
213
- assert_has_feature_enabled(qts, "a64fx", "aarch64");
214
- /*
215
- @@ -470,6 +473,7 @@ static void test_query_cpu_model_expansion(const void *data)
216
- "{ 'sve384': true }");
217
- assert_error(qts, "a64fx", "cannot enable sve640",
218
- "{ 'sve640': true }");
219
- +#endif /* disabled for RHEL */
220
-
221
- sve_tests_default(qts, "max");
222
- pauth_tests_default(qts, "max");
223
- @@ -505,9 +509,11 @@ static void test_query_cpu_model_expansion_kvm(const void *data)
224
- QDict *resp;
225
- char *error;
226
-
227
- +#if 0 /* Disabled for Red Hat Enterprise Linux */
228
- assert_error(qts, "cortex-a15",
229
- "We cannot guarantee the CPU type 'cortex-a15' works "
230
- "with KVM on this host", NULL);
231
- +#endif /* disabled for RHEL */
232
-
233
- assert_has_feature_enabled(qts, "host", "aarch64");
234
-
235
- --
236
- 2.35.3
237
-
SOURCES/kvm-RHEL-only-tests-avocado-Switch-aarch64-tests-from-a5.patch DELETED
@@ -1,95 +0,0 @@
1
- From d710394f68eb0b6116dd8ac76f619c192e0d5972 Mon Sep 17 00:00:00 2001
2
- From: Andrew Jones <drjones@redhat.com>
3
- Date: Wed, 15 Jun 2022 15:28:27 +0200
4
- Subject: [PATCH 02/18] RHEL-only: tests/avocado: Switch aarch64 tests from a53
5
- to a57
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Daniel P. Berrangé <berrange@redhat.com>
11
- RH-MergeRequest: 94: i386, aarch64, s390x: deprecate many named CPU models
12
- RH-Commit: [2/6] e85ef69b42c411a6997e4da10ba05176368769b3 (berrange/centos-src-qemu)
13
- RH-Bugzilla: 2060839
14
- RH-Acked-by: Thomas Huth <thuth@redhat.com>
15
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
16
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
17
-
18
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2066824
19
- Upstream Status: RHEL only
20
-
21
- We plan to remove the cortex-a53 from the supported cpu types. Switch
22
- all avocado tests that use it to the cortex-a57, which will work the
23
- same and we intend to keep. We don't want to try and upstream this
24
- change since the better upstream change would be to switch from the
25
- a53 to 'max', but the upstream tests also need to use later guest
26
- kernels to use 'max' (see qemu upstream commit 0942820408dc
27
- ("hw/arm/virt: Disable LPA2 for -machine virt-6.2")
28
-
29
- Signed-off-by: Andrew Jones <drjones@redhat.com>
30
- ---
31
- tests/avocado/replay_kernel.py | 2 +-
32
- tests/avocado/reverse_debugging.py | 2 +-
33
- tests/avocado/tcg_plugins.py | 6 +++---
34
- 3 files changed, 5 insertions(+), 5 deletions(-)
35
-
36
- diff --git a/tests/avocado/replay_kernel.py b/tests/avocado/replay_kernel.py
37
- index 0b2b0dc692..3a7b5f0748 100644
38
- --- a/tests/avocado/replay_kernel.py
39
- +++ b/tests/avocado/replay_kernel.py
40
- @@ -147,7 +147,7 @@ def test_aarch64_virt(self):
41
- """
42
- :avocado: tags=arch:aarch64
43
- :avocado: tags=machine:virt
44
- - :avocado: tags=cpu:cortex-a53
45
- + :avocado: tags=cpu:cortex-a57
46
- """
47
- kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
48
- '/linux/releases/29/Everything/aarch64/os/images/pxeboot'
49
- diff --git a/tests/avocado/reverse_debugging.py b/tests/avocado/reverse_debugging.py
50
- index d2921e70c3..66d185ed42 100644
51
- --- a/tests/avocado/reverse_debugging.py
52
- +++ b/tests/avocado/reverse_debugging.py
53
- @@ -198,7 +198,7 @@ def test_aarch64_virt(self):
54
- """
55
- :avocado: tags=arch:aarch64
56
- :avocado: tags=machine:virt
57
- - :avocado: tags=cpu:cortex-a53
58
- + :avocado: tags=cpu:cortex-a57
59
- """
60
- kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
61
- '/linux/releases/29/Everything/aarch64/os/images/pxeboot'
62
- diff --git a/tests/avocado/tcg_plugins.py b/tests/avocado/tcg_plugins.py
63
- index 642d2e49e3..93b3afd823 100644
64
- --- a/tests/avocado/tcg_plugins.py
65
- +++ b/tests/avocado/tcg_plugins.py
66
- @@ -68,7 +68,7 @@ def test_aarch64_virt_insn(self):
67
- :avocado: tags=accel:tcg
68
- :avocado: tags=arch:aarch64
69
- :avocado: tags=machine:virt
70
- - :avocado: tags=cpu:cortex-a53
71
- + :avocado: tags=cpu:cortex-a57
72
- """
73
- kernel_path = self._grab_aarch64_kernel()
74
- kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
75
- @@ -94,7 +94,7 @@ def test_aarch64_virt_insn_icount(self):
76
- :avocado: tags=accel:tcg
77
- :avocado: tags=arch:aarch64
78
- :avocado: tags=machine:virt
79
- - :avocado: tags=cpu:cortex-a53
80
- + :avocado: tags=cpu:cortex-a57
81
- """
82
- kernel_path = self._grab_aarch64_kernel()
83
- kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
84
- @@ -120,7 +120,7 @@ def test_aarch64_virt_mem_icount(self):
85
- :avocado: tags=accel:tcg
86
- :avocado: tags=arch:aarch64
87
- :avocado: tags=machine:virt
88
- - :avocado: tags=cpu:cortex-a53
89
- + :avocado: tags=cpu:cortex-a57
90
- """
91
- kernel_path = self._grab_aarch64_kernel()
92
- kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
93
- --
94
- 2.35.3
95
-
SOURCES/kvm-Revert-globally-limit-the-maximum-number-of-CPUs.patch DELETED
@@ -1,58 +0,0 @@
1
- From 5ab8613582fd56b847fe75750acb5b7255900b35 Mon Sep 17 00:00:00 2001
2
- From: Vitaly Kuznetsov <vkuznets@redhat.com>
3
- Date: Thu, 9 Jun 2022 11:55:15 +0200
4
- Subject: [PATCH 15/16] Revert "globally limit the maximum number of CPUs"
5
-
6
- RH-Author: Vitaly Kuznetsov <vkuznets@redhat.com>
7
- RH-MergeRequest: 99: Revert "globally limit the maximum number of CPUs"
8
- RH-Commit: [1/1] 13100d4a2209b2190a3654c1f9cf4ebade1e8d24 (vkuznets/qemu-kvm-c9s)
9
- RH-Bugzilla: 2094270
10
- RH-Acked-by: Andrew Jones <drjones@redhat.com>
11
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
12
- RH-Acked-by: Thomas Huth <thuth@redhat.com>
13
-
14
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2094270
15
- Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=45871149
16
- Upstream Status: RHEL-only
17
- Tested: with upstream kernel
18
-
19
- Downstream QEMU carries a patch that sets the hard limit of possible vCPUs
20
- to the value that the KVM code of the kernel recommends as soft limit.
21
- Upstream KVM code has been changed recently to not use an arbitrary soft
22
- limit anymore, but to cap the value on the amount of available physical
23
- CPUs of the host. This defeats the purpose of the downstream change in
24
- QEMU completely. Drop the downstream-only patch to allow CPU overcommit.
25
-
26
- This reverts commit 6669f6fa677d43144f39d6ad59725b7ba622f1c2.
27
-
28
- Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
29
- ---
30
- accel/kvm/kvm-all.c | 12 ------------
31
- 1 file changed, 12 deletions(-)
32
-
33
- diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
34
- index fdf0e4d429..5f1377ca04 100644
35
- --- a/accel/kvm/kvm-all.c
36
- +++ b/accel/kvm/kvm-all.c
37
- @@ -2430,18 +2430,6 @@ static int kvm_init(MachineState *ms)
38
- soft_vcpus_limit = kvm_recommended_vcpus(s);
39
- hard_vcpus_limit = kvm_max_vcpus(s);
40
-
41
- -#ifdef HOST_PPC64
42
- - /*
43
- - * On POWER, the kernel advertises a soft limit based on the
44
- - * number of CPU threads on the host. We want to allow exceeding
45
- - * this for testing purposes, so we don't want to set hard limit
46
- - * to soft limit as on x86.
47
- - */
48
- -#else
49
- - /* RHEL doesn't support nr_vcpus > soft_vcpus_limit */
50
- - hard_vcpus_limit = soft_vcpus_limit;
51
- -#endif
52
- -
53
- while (nc->name) {
54
- if (nc->num > soft_vcpus_limit) {
55
- warn_report("Number of %s cpus requested (%d) exceeds "
56
- --
57
- 2.31.1
58
-
SOURCES/kvm-Revert-migration-Simplify-unqueue_page.patch DELETED
@@ -1,134 +0,0 @@
1
- From 5ea59b17866add54e5ae8c76d3cb472c67e1fa91 Mon Sep 17 00:00:00 2001
2
- From: Thomas Huth <thuth@redhat.com>
3
- Date: Tue, 2 Aug 2022 08:19:49 +0200
4
- Subject: [PATCH 32/32] Revert "migration: Simplify unqueue_page()"
5
-
6
- RH-Author: Thomas Huth <thuth@redhat.com>
7
- RH-MergeRequest: 112: Fix postcopy migration on s390x
8
- RH-Commit: [2/2] 3913c9ed3f27f4b66245913da29d0c46db0c6567 (thuth/qemu-kvm-cs9)
9
- RH-Bugzilla: 2099934
10
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
11
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
12
- RH-Acked-by: David Hildenbrand <david@redhat.com>
13
- RH-Acked-by: Peter Xu <peterx@redhat.com>
14
-
15
- This reverts commit cfd66f30fb0f735df06ff4220e5000290a43dad3.
16
-
17
- The simplification of unqueue_page() introduced a bug that sometimes
18
- breaks migration on s390x hosts.
19
-
20
- The problem is not fully understood yet, but since we are already in
21
- the freeze for QEMU 7.1 and we need something working there, let's
22
- revert this patch for the upcoming release. The optimization can be
23
- redone later again in a proper way if necessary.
24
-
25
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2099934
26
- Signed-off-by: Thomas Huth <thuth@redhat.com>
27
- Message-Id: <20220802061949.331576-1-thuth@redhat.com>
28
- Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
29
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
30
- (cherry picked from commit 777f53c75983dd10756f5dbfc8af50fe11da81c1)
31
- Conflicts:
32
- migration/trace-events
33
- (trivial contextual conflict)
34
- Signed-off-by: Thomas Huth <thuth@redhat.com>
35
- ---
36
- migration/ram.c | 37 ++++++++++++++++++++++++++-----------
37
- migration/trace-events | 3 ++-
38
- 2 files changed, 28 insertions(+), 12 deletions(-)
39
-
40
- diff --git a/migration/ram.c b/migration/ram.c
41
- index fb6db54642..ee40e4a718 100644
42
- --- a/migration/ram.c
43
- +++ b/migration/ram.c
44
- @@ -1548,7 +1548,6 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset)
45
- {
46
- struct RAMSrcPageRequest *entry;
47
- RAMBlock *block = NULL;
48
- - size_t page_size;
49
-
50
- if (!postcopy_has_request(rs)) {
51
- return NULL;
52
- @@ -1565,13 +1564,10 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset)
53
- entry = QSIMPLEQ_FIRST(&rs->src_page_requests);
54
- block = entry->rb;
55
- *offset = entry->offset;
56
- - page_size = qemu_ram_pagesize(block);
57
- - /* Each page request should only be multiple page size of the ramblock */
58
- - assert((entry->len % page_size) == 0);
59
-
60
- - if (entry->len > page_size) {
61
- - entry->len -= page_size;
62
- - entry->offset += page_size;
63
- + if (entry->len > TARGET_PAGE_SIZE) {
64
- + entry->len -= TARGET_PAGE_SIZE;
65
- + entry->offset += TARGET_PAGE_SIZE;
66
- } else {
67
- memory_region_unref(block->mr);
68
- QSIMPLEQ_REMOVE_HEAD(&rs->src_page_requests, next_req);
69
- @@ -1579,9 +1575,6 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset)
70
- migration_consume_urgent_request();
71
- }
72
-
73
- - trace_unqueue_page(block->idstr, *offset,
74
- - test_bit((*offset >> TARGET_PAGE_BITS), block->bmap));
75
- -
76
- return block;
77
- }
78
-
79
- @@ -1956,8 +1949,30 @@ static bool get_queued_page(RAMState *rs, PageSearchStatus *pss)
80
- {
81
- RAMBlock *block;
82
- ram_addr_t offset;
83
- + bool dirty;
84
- +
85
- + do {
86
- + block = unqueue_page(rs, &offset);
87
- + /*
88
- + * We're sending this page, and since it's postcopy nothing else
89
- + * will dirty it, and we must make sure it doesn't get sent again
90
- + * even if this queue request was received after the background
91
- + * search already sent it.
92
- + */
93
- + if (block) {
94
- + unsigned long page;
95
- +
96
- + page = offset >> TARGET_PAGE_BITS;
97
- + dirty = test_bit(page, block->bmap);
98
- + if (!dirty) {
99
- + trace_get_queued_page_not_dirty(block->idstr, (uint64_t)offset,
100
- + page);
101
- + } else {
102
- + trace_get_queued_page(block->idstr, (uint64_t)offset, page);
103
- + }
104
- + }
105
-
106
- - block = unqueue_page(rs, &offset);
107
- + } while (block && !dirty);
108
-
109
- if (!block) {
110
- /*
111
- diff --git a/migration/trace-events b/migration/trace-events
112
- index 1aec580e92..09d61ed1f4 100644
113
- --- a/migration/trace-events
114
- +++ b/migration/trace-events
115
- @@ -85,6 +85,8 @@ put_qlist_end(const char *field_name, const char *vmsd_name) "%s(%s)"
116
- qemu_file_fclose(void) ""
117
-
118
- # ram.c
119
- +get_queued_page(const char *block_name, uint64_t tmp_offset, unsigned long page_abs) "%s/0x%" PRIx64 " page_abs=0x%lx"
120
- +get_queued_page_not_dirty(const char *block_name, uint64_t tmp_offset, unsigned long page_abs) "%s/0x%" PRIx64 " page_abs=0x%lx"
121
- migration_bitmap_sync_start(void) ""
122
- migration_bitmap_sync_end(uint64_t dirty_pages) "dirty_pages %" PRIu64
123
- migration_bitmap_clear_dirty(char *str, uint64_t start, uint64_t size, unsigned long page) "rb %s start 0x%"PRIx64" size 0x%"PRIx64" page 0x%lx"
124
- @@ -110,7 +112,6 @@ ram_save_iterate_big_wait(uint64_t milliconds, int iterations) "big wait: %" PRI
125
- ram_load_complete(int ret, uint64_t seq_iter) "exit_code %d seq iteration %" PRIu64
126
- ram_write_tracking_ramblock_start(const char *block_id, size_t page_size, void *addr, size_t length) "%s: page_size: %zu addr: %p length: %zu"
127
- ram_write_tracking_ramblock_stop(const char *block_id, size_t page_size, void *addr, size_t length) "%s: page_size: %zu addr: %p length: %zu"
128
- -unqueue_page(char *block, uint64_t offset, bool dirty) "ramblock '%s' offset 0x%"PRIx64" dirty %d"
129
-
130
- # multifd.c
131
- multifd_new_send_channel_async(uint8_t id) "channel %u"
132
- --
133
- 2.31.1
134
-
SOURCES/kvm-Revert-vhost-user-Introduce-nested-event-loop-in-vho.patch ADDED
@@ -0,0 +1,140 @@
1
+ From 0c19fb7c4a22a30830152b224b2e66963f829a7a Mon Sep 17 00:00:00 2001
2
+ From: Greg Kurz <groug@kaod.org>
3
+ Date: Thu, 19 Jan 2023 18:24:24 +0100
4
+ Subject: [PATCH 19/20] Revert "vhost-user: Introduce nested event loop in
5
+ vhost_user_read()"
6
+ MIME-Version: 1.0
7
+ Content-Type: text/plain; charset=UTF-8
8
+ Content-Transfer-Encoding: 8bit
9
+
10
+ RH-Author: Laurent Vivier <lvivier@redhat.com>
11
+ RH-MergeRequest: 146: Fix vhost-user with dpdk
12
+ RH-Bugzilla: 2155173
13
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
14
+ RH-Acked-by: Greg Kurz (RH) <gkurz@redhat.com>
15
+ RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
16
+ RH-Commit: [2/2] 9b67041f92f29f70b7ccb41d8087801e4e4e38af (lvivier/qemu-kvm-centos)
17
+
18
+ This reverts commit a7f523c7d114d445c5d83aecdba3efc038e5a692.
19
+
20
+ The nested event loop is broken by design. It's only user was removed.
21
+ Drop the code as well so that nobody ever tries to use it again.
22
+
23
+ I had to fix a couple of trivial conflicts around return values because
24
+ of 025faa872bcf ("vhost-user: stick to -errno error return convention").
25
+
26
+ Signed-off-by: Greg Kurz <groug@kaod.org>
27
+ Message-Id: <20230119172424.478268-3-groug@kaod.org>
28
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
29
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
30
+ Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
31
+ (cherry picked from commit 4382138f642f69fdbc79ebf4e93d84be8061191f)
32
+ Signed-off-by: Laurent Vivier <lvivier@redhat.com>
33
+ ---
34
+ hw/virtio/vhost-user.c | 65 ++++--------------------------------------
35
+ 1 file changed, 5 insertions(+), 60 deletions(-)
36
+
37
+ diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
38
+ index 0ac00eb901..7cb49c50f9 100644
39
+ --- a/hw/virtio/vhost-user.c
40
+ +++ b/hw/virtio/vhost-user.c
41
+ @@ -305,19 +305,8 @@ static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg)
42
+ return 0;
43
+ }
44
+
45
+ -struct vhost_user_read_cb_data {
46
+ - struct vhost_dev *dev;
47
+ - VhostUserMsg *msg;
48
+ - GMainLoop *loop;
49
+ - int ret;
50
+ -};
51
+ -
52
+ -static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition,
53
+ - gpointer opaque)
54
+ +static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
55
+ {
56
+ - struct vhost_user_read_cb_data *data = opaque;
57
+ - struct vhost_dev *dev = data->dev;
58
+ - VhostUserMsg *msg = data->msg;
59
+ struct vhost_user *u = dev->opaque;
60
+ CharBackend *chr = u->user->chr;
61
+ uint8_t *p = (uint8_t *) msg;
62
+ @@ -325,8 +314,7 @@ static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition,
63
+
64
+ r = vhost_user_read_header(dev, msg);
65
+ if (r < 0) {
66
+ - data->ret = r;
67
+ - goto end;
68
+ + return r;
69
+ }
70
+
71
+ /* validate message size is sane */
72
+ @@ -334,8 +322,7 @@ static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition,
73
+ error_report("Failed to read msg header."
74
+ " Size %d exceeds the maximum %zu.", msg->hdr.size,
75
+ VHOST_USER_PAYLOAD_SIZE);
76
+ - data->ret = -EPROTO;
77
+ - goto end;
78
+ + return -EPROTO;
79
+ }
80
+
81
+ if (msg->hdr.size) {
82
+ @@ -346,53 +333,11 @@ static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition,
83
+ int saved_errno = errno;
84
+ error_report("Failed to read msg payload."
85
+ " Read %d instead of %d.", r, msg->hdr.size);
86
+ - data->ret = r < 0 ? -saved_errno : -EIO;
87
+ - goto end;
88
+ + return r < 0 ? -saved_errno : -EIO;
89
+ }
90
+ }
91
+
92
+ -end:
93
+ - g_main_loop_quit(data->loop);
94
+ - return G_SOURCE_REMOVE;
95
+ -}
96
+ -
97
+ -static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
98
+ -{
99
+ - struct vhost_user *u = dev->opaque;
100
+ - CharBackend *chr = u->user->chr;
101
+ - GMainContext *prev_ctxt = chr->chr->gcontext;
102
+ - GMainContext *ctxt = g_main_context_new();
103
+ - GMainLoop *loop = g_main_loop_new(ctxt, FALSE);
104
+ - struct vhost_user_read_cb_data data = {
105
+ - .dev = dev,
106
+ - .loop = loop,
107
+ - .msg = msg,
108
+ - .ret = 0
109
+ - };
110
+ -
111
+ - /*
112
+ - * We want to be able to monitor the slave channel fd while waiting
113
+ - * for chr I/O. This requires an event loop, but we can't nest the
114
+ - * one to which chr is currently attached : its fd handlers might not
115
+ - * be prepared for re-entrancy. So we create a new one and switch chr
116
+ - * to use it.
117
+ - */
118
+ - qemu_chr_be_update_read_handlers(chr->chr, ctxt);
119
+ - qemu_chr_fe_add_watch(chr, G_IO_IN | G_IO_HUP, vhost_user_read_cb, &data);
120
+ -
121
+ - g_main_loop_run(loop);
122
+ -
123
+ - /*
124
+ - * Restore the previous event loop context. This also destroys/recreates
125
+ - * event sources : this guarantees that all pending events in the original
126
+ - * context that have been processed by the nested loop are purged.
127
+ - */
128
+ - qemu_chr_be_update_read_handlers(chr->chr, prev_ctxt);
129
+ -
130
+ - g_main_loop_unref(loop);
131
+ - g_main_context_unref(ctxt);
132
+ -
133
+ - return data.ret;
134
+ + return 0;
135
+ }
136
+
137
+ static int process_message_reply(struct vhost_dev *dev,
138
+ --
139
+ 2.31.1
140
+
SOURCES/kvm-Revert-vhost-user-Monitor-slave-channel-in-vhost_use.patch ADDED
@@ -0,0 +1,143 @@
1
+ From 9fb47ad317ad8cdda9960190d499ad6c3a9817f0 Mon Sep 17 00:00:00 2001
2
+ From: Greg Kurz <groug@kaod.org>
3
+ Date: Thu, 19 Jan 2023 18:24:23 +0100
4
+ Subject: [PATCH 18/20] Revert "vhost-user: Monitor slave channel in
5
+ vhost_user_read()"
6
+ MIME-Version: 1.0
7
+ Content-Type: text/plain; charset=UTF-8
8
+ Content-Transfer-Encoding: 8bit
9
+
10
+ RH-Author: Laurent Vivier <lvivier@redhat.com>
11
+ RH-MergeRequest: 146: Fix vhost-user with dpdk
12
+ RH-Bugzilla: 2155173
13
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
14
+ RH-Acked-by: Greg Kurz (RH) <gkurz@redhat.com>
15
+ RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
16
+ RH-Commit: [1/2] c583a7f121ca9c93c9a2ad17bf0ccf5c1241dc99 (lvivier/qemu-kvm-centos)
17
+
18
+ This reverts commit db8a3772e300c1a656331a92da0785d81667dc81.
19
+
20
+ Motivation : this is breaking vhost-user with DPDK as reported in [0].
21
+
22
+ Received unexpected msg type. Expected 22 received 40
23
+ Fail to update device iotlb
24
+ Received unexpected msg type. Expected 40 received 22
25
+ Received unexpected msg type. Expected 22 received 11
26
+ Fail to update device iotlb
27
+ Received unexpected msg type. Expected 11 received 22
28
+ vhost VQ 1 ring restore failed: -71: Protocol error (71)
29
+ Received unexpected msg type. Expected 22 received 11
30
+ Fail to update device iotlb
31
+ Received unexpected msg type. Expected 11 received 22
32
+ vhost VQ 0 ring restore failed: -71: Protocol error (71)
33
+ unable to start vhost net: 71: falling back on userspace virtio
34
+
35
+ The failing sequence that leads to the first error is :
36
+ - QEMU sends a VHOST_USER_GET_STATUS (40) request to DPDK on the master
37
+ socket
38
+ - QEMU starts a nested event loop in order to wait for the
39
+ VHOST_USER_GET_STATUS response and to be able to process messages from
40
+ the slave channel
41
+ - DPDK sends a couple of legitimate IOTLB miss messages on the slave
42
+ channel
43
+ - QEMU processes each IOTLB request and sends VHOST_USER_IOTLB_MSG (22)
44
+ updates on the master socket
45
+ - QEMU assumes to receive a response for the latest VHOST_USER_IOTLB_MSG
46
+ but it gets the response for the VHOST_USER_GET_STATUS instead
47
+
48
+ The subsequent errors have the same root cause : the nested event loop
49
+ breaks the order by design. It lures QEMU to expect responses to the
50
+ latest message sent on the master socket to arrive first.
51
+
52
+ Since this was only needed for DAX enablement which is still not merged
53
+ upstream, just drop the code for now. A working solution will have to
54
+ be merged later on. Likely protect the master socket with a mutex
55
+ and service the slave channel with a separate thread, as discussed with
56
+ Maxime in the mail thread below.
57
+
58
+ [0] https://lore.kernel.org/qemu-devel/43145ede-89dc-280e-b953-6a2b436de395@redhat.com/
59
+
60
+ Reported-by: Yanghang Liu <yanghliu@redhat.com>
61
+ Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2155173
62
+ Signed-off-by: Greg Kurz <groug@kaod.org>
63
+ Message-Id: <20230119172424.478268-2-groug@kaod.org>
64
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
65
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
66
+ Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
67
+ Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
68
+ (cherry picked from commit f340a59d5a852d75ae34555723694c7e8eafbd0c)
69
+ Signed-off-by: Laurent Vivier <lvivier@redhat.com>
70
+ ---
71
+ hw/virtio/vhost-user.c | 35 +++--------------------------------
72
+ 1 file changed, 3 insertions(+), 32 deletions(-)
73
+
74
+ diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
75
+ index 8f635844af..0ac00eb901 100644
76
+ --- a/hw/virtio/vhost-user.c
77
+ +++ b/hw/virtio/vhost-user.c
78
+ @@ -356,35 +356,6 @@ end:
79
+ return G_SOURCE_REMOVE;
80
+ }
81
+
82
+ -static gboolean slave_read(QIOChannel *ioc, GIOCondition condition,
83
+ - gpointer opaque);
84
+ -
85
+ -/*
86
+ - * This updates the read handler to use a new event loop context.
87
+ - * Event sources are removed from the previous context : this ensures
88
+ - * that events detected in the previous context are purged. They will
89
+ - * be re-detected and processed in the new context.
90
+ - */
91
+ -static void slave_update_read_handler(struct vhost_dev *dev,
92
+ - GMainContext *ctxt)
93
+ -{
94
+ - struct vhost_user *u = dev->opaque;
95
+ -
96
+ - if (!u->slave_ioc) {
97
+ - return;
98
+ - }
99
+ -
100
+ - if (u->slave_src) {
101
+ - g_source_destroy(u->slave_src);
102
+ - g_source_unref(u->slave_src);
103
+ - }
104
+ -
105
+ - u->slave_src = qio_channel_add_watch_source(u->slave_ioc,
106
+ - G_IO_IN | G_IO_HUP,
107
+ - slave_read, dev, NULL,
108
+ - ctxt);
109
+ -}
110
+ -
111
+ static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
112
+ {
113
+ struct vhost_user *u = dev->opaque;
114
+ @@ -406,7 +377,6 @@ static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
115
+ * be prepared for re-entrancy. So we create a new one and switch chr
116
+ * to use it.
117
+ */
118
+ - slave_update_read_handler(dev, ctxt);
119
+ qemu_chr_be_update_read_handlers(chr->chr, ctxt);
120
+ qemu_chr_fe_add_watch(chr, G_IO_IN | G_IO_HUP, vhost_user_read_cb, &data);
121
+
122
+ @@ -418,7 +388,6 @@ static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
123
+ * context that have been processed by the nested loop are purged.
124
+ */
125
+ qemu_chr_be_update_read_handlers(chr->chr, prev_ctxt);
126
+ - slave_update_read_handler(dev, NULL);
127
+
128
+ g_main_loop_unref(loop);
129
+ g_main_context_unref(ctxt);
130
+ @@ -1802,7 +1771,9 @@ static int vhost_setup_slave_channel(struct vhost_dev *dev)
131
+ return -ECONNREFUSED;
132
+ }
133
+ u->slave_ioc = ioc;
134
+ - slave_update_read_handler(dev, NULL);
135
+ + u->slave_src = qio_channel_add_watch_source(u->slave_ioc,
136
+ + G_IO_IN | G_IO_HUP,
137
+ + slave_read, dev, NULL, NULL);
138
+
139
+ if (reply_supported) {
140
+ msg.hdr.flags |= VHOST_USER_NEED_REPLY_MASK;
141
+ --
142
+ 2.31.1
143
+
SOURCES/kvm-Revert-virtio-scsi-Reject-scsi-cd-if-data-plane-enab.patch DELETED
@@ -1,51 +0,0 @@
1
- From 733acef2caea0758edd74fb634b095ce09bf5914 Mon Sep 17 00:00:00 2001
2
- From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
3
- Date: Mon, 9 May 2022 03:46:23 -0400
4
- Subject: [PATCH 15/16] Revert "virtio-scsi: Reject scsi-cd if data plane
5
- enabled [RHEL only]"
6
-
7
- RH-Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
8
- RH-MergeRequest: 91: Revert "virtio-scsi: Reject scsi-cd if data plane enabled [RHEL only]"
9
- RH-Commit: [1/1] 1af55d792bc9166e5c86272afe8093c76ab41bb4 (eesposit/qemu-kvm)
10
- RH-Bugzilla: 1995710
11
- RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
12
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
13
- RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
14
-
15
- This reverts commit 4e17b1126e.
16
-
17
- Over time AioContext usage and coverage has increased, and now block
18
- backend is capable of handling AioContext change upon eject and insert.
19
- Therefore the above downstream-only commit is not necessary anymore,
20
- and can be safely reverted.
21
-
22
- X-downstream-only: true
23
-
24
- Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
25
- ---
26
- hw/scsi/virtio-scsi.c | 9 ---------
27
- 1 file changed, 9 deletions(-)
28
-
29
- diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
30
- index 2450c9438c..db54d104be 100644
31
- --- a/hw/scsi/virtio-scsi.c
32
- +++ b/hw/scsi/virtio-scsi.c
33
- @@ -937,15 +937,6 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,
34
- AioContext *old_context;
35
- int ret;
36
-
37
- - /* XXX: Remove this check once block backend is capable of handling
38
- - * AioContext change upon eject/insert.
39
- - * s->ctx is NULL if ioeventfd is off, s->ctx is qemu_get_aio_context() if
40
- - * data plane is not used, both cases are safe for scsi-cd. */
41
- - if (s->ctx && s->ctx != qemu_get_aio_context() &&
42
- - object_dynamic_cast(OBJECT(dev), "scsi-cd")) {
43
- - error_setg(errp, "scsi-cd is not supported by data plane");
44
- - return;
45
- - }
46
- if (s->ctx && !s->dataplane_fenced) {
47
- if (blk_op_is_blocked(sd->conf.blk, BLOCK_OP_TYPE_DATAPLANE, errp)) {
48
- return;
49
- --
50
- 2.31.1
51
-
SOURCES/kvm-accel-introduce-accelerator-blocker-API.patch ADDED
@@ -0,0 +1,348 @@
1
+ From ae2077fd5d351a68c313c64f07fb225dff694a8f Mon Sep 17 00:00:00 2001
2
+ From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
3
+ Date: Mon, 16 Jan 2023 07:16:41 -0500
4
+ Subject: [PATCH 29/31] accel: introduce accelerator blocker API
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
10
+ RH-MergeRequest: 138: accel: introduce accelerator blocker API
11
+ RH-Bugzilla: 1979276
12
+ RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
13
+ RH-Acked-by: David Hildenbrand <david@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [1/3] 56b07cd7db516c5066e6d66b4695064fdf73abbf (eesposit/qemu-kvm)
16
+
17
+ Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1979276
18
+
19
+ commit bd688fc93120fb3e28aa70e3dfdf567ccc1e0bc1
20
+ Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
21
+ Date: Fri Nov 11 10:47:56 2022 -0500
22
+
23
+ accel: introduce accelerator blocker API
24
+
25
+ This API allows the accelerators to prevent vcpus from issuing
26
+ new ioctls while execting a critical section marked with the
27
+ accel_ioctl_inhibit_begin/end functions.
28
+
29
+ Note that all functions submitting ioctls must mark where the
30
+ ioctl is being called with accel_{cpu_}ioctl_begin/end().
31
+
32
+ This API requires the caller to always hold the BQL.
33
+ API documentation is in sysemu/accel-blocker.h
34
+
35
+ Internally, it uses a QemuLockCnt together with a per-CPU QemuLockCnt
36
+ (to minimize cache line bouncing) to keep avoid that new ioctls
37
+ run when the critical section starts, and a QemuEvent to wait
38
+ that all running ioctls finish.
39
+
40
+ Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
41
+ Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
42
+ Message-Id: <20221111154758.1372674-2-eesposit@redhat.com>
43
+ Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
44
+
45
+ Conflicts:
46
+ util/meson.build: "interval-tree.c" does not exist
47
+
48
+ Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
49
+ ---
50
+ accel/accel-blocker.c | 154 +++++++++++++++++++++++++++++++++
51
+ accel/meson.build | 2 +-
52
+ hw/core/cpu-common.c | 2 +
53
+ include/hw/core/cpu.h | 3 +
54
+ include/sysemu/accel-blocker.h | 56 ++++++++++++
55
+ util/meson.build | 2 +-
56
+ 6 files changed, 217 insertions(+), 2 deletions(-)
57
+ create mode 100644 accel/accel-blocker.c
58
+ create mode 100644 include/sysemu/accel-blocker.h
59
+
60
+ diff --git a/accel/accel-blocker.c b/accel/accel-blocker.c
61
+ new file mode 100644
62
+ index 0000000000..1e7f423462
63
+ --- /dev/null
64
+ +++ b/accel/accel-blocker.c
65
+ @@ -0,0 +1,154 @@
66
+ +/*
67
+ + * Lock to inhibit accelerator ioctls
68
+ + *
69
+ + * Copyright (c) 2022 Red Hat Inc.
70
+ + *
71
+ + * Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
72
+ + *
73
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
74
+ + * of this software and associated documentation files (the "Software"), to deal
75
+ + * in the Software without restriction, including without limitation the rights
76
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
77
+ + * copies of the Software, and to permit persons to whom the Software is
78
+ + * furnished to do so, subject to the following conditions:
79
+ + *
80
+ + * The above copyright notice and this permission notice shall be included in
81
+ + * all copies or substantial portions of the Software.
82
+ + *
83
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
84
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
85
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
86
+ + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
87
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
88
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
89
+ + * THE SOFTWARE.
90
+ + */
91
+ +
92
+ +#include "qemu/osdep.h"
93
+ +#include "qemu/thread.h"
94
+ +#include "qemu/main-loop.h"
95
+ +#include "hw/core/cpu.h"
96
+ +#include "sysemu/accel-blocker.h"
97
+ +
98
+ +static QemuLockCnt accel_in_ioctl_lock;
99
+ +static QemuEvent accel_in_ioctl_event;
100
+ +
101
+ +void accel_blocker_init(void)
102
+ +{
103
+ + qemu_lockcnt_init(&accel_in_ioctl_lock);
104
+ + qemu_event_init(&accel_in_ioctl_event, false);
105
+ +}
106
+ +
107
+ +void accel_ioctl_begin(void)
108
+ +{
109
+ + if (likely(qemu_mutex_iothread_locked())) {
110
+ + return;
111
+ + }
112
+ +
113
+ + /* block if lock is taken in kvm_ioctl_inhibit_begin() */
114
+ + qemu_lockcnt_inc(&accel_in_ioctl_lock);
115
+ +}
116
+ +
117
+ +void accel_ioctl_end(void)
118
+ +{
119
+ + if (likely(qemu_mutex_iothread_locked())) {
120
+ + return;
121
+ + }
122
+ +
123
+ + qemu_lockcnt_dec(&accel_in_ioctl_lock);
124
+ + /* change event to SET. If event was BUSY, wake up all waiters */
125
+ + qemu_event_set(&accel_in_ioctl_event);
126
+ +}
127
+ +
128
+ +void accel_cpu_ioctl_begin(CPUState *cpu)
129
+ +{
130
+ + if (unlikely(qemu_mutex_iothread_locked())) {
131
+ + return;
132
+ + }
133
+ +
134
+ + /* block if lock is taken in kvm_ioctl_inhibit_begin() */
135
+ + qemu_lockcnt_inc(&cpu->in_ioctl_lock);
136
+ +}
137
+ +
138
+ +void accel_cpu_ioctl_end(CPUState *cpu)
139
+ +{
140
+ + if (unlikely(qemu_mutex_iothread_locked())) {
141
+ + return;
142
+ + }
143
+ +
144
+ + qemu_lockcnt_dec(&cpu->in_ioctl_lock);
145
+ + /* change event to SET. If event was BUSY, wake up all waiters */
146
+ + qemu_event_set(&accel_in_ioctl_event);
147
+ +}
148
+ +
149
+ +static bool accel_has_to_wait(void)
150
+ +{
151
+ + CPUState *cpu;
152
+ + bool needs_to_wait = false;
153
+ +
154
+ + CPU_FOREACH(cpu) {
155
+ + if (qemu_lockcnt_count(&cpu->in_ioctl_lock)) {
156
+ + /* exit the ioctl, if vcpu is running it */
157
+ + qemu_cpu_kick(cpu);
158
+ + needs_to_wait = true;
159
+ + }
160
+ + }
161
+ +
162
+ + return needs_to_wait || qemu_lockcnt_count(&accel_in_ioctl_lock);
163
+ +}
164
+ +
165
+ +void accel_ioctl_inhibit_begin(void)
166
+ +{
167
+ + CPUState *cpu;
168
+ +
169
+ + /*
170
+ + * We allow to inhibit only when holding the BQL, so we can identify
171
+ + * when an inhibitor wants to issue an ioctl easily.
172
+ + */
173
+ + g_assert(qemu_mutex_iothread_locked());
174
+ +
175
+ + /* Block further invocations of the ioctls outside the BQL. */
176
+ + CPU_FOREACH(cpu) {
177
+ + qemu_lockcnt_lock(&cpu->in_ioctl_lock);
178
+ + }
179
+ + qemu_lockcnt_lock(&accel_in_ioctl_lock);
180
+ +
181
+ + /* Keep waiting until there are running ioctls */
182
+ + while (true) {
183
+ +
184
+ + /* Reset event to FREE. */
185
+ + qemu_event_reset(&accel_in_ioctl_event);
186
+ +
187
+ + if (accel_has_to_wait()) {
188
+ + /*
189
+ + * If event is still FREE, and there are ioctls still in progress,
190
+ + * wait.
191
+ + *
192
+ + * If an ioctl finishes before qemu_event_wait(), it will change
193
+ + * the event state to SET. This will prevent qemu_event_wait() from
194
+ + * blocking, but it's not a problem because if other ioctls are
195
+ + * still running the loop will iterate once more and reset the event
196
+ + * status to FREE so that it can wait properly.
197
+ + *
198
+ + * If an ioctls finishes while qemu_event_wait() is blocking, then
199
+ + * it will be waken up, but also here the while loop makes sure
200
+ + * to re-enter the wait if there are other running ioctls.
201
+ + */
202
+ + qemu_event_wait(&accel_in_ioctl_event);
203
+ + } else {
204
+ + /* No ioctl is running */
205
+ + return;
206
+ + }
207
+ + }
208
+ +}
209
+ +
210
+ +void accel_ioctl_inhibit_end(void)
211
+ +{
212
+ + CPUState *cpu;
213
+ +
214
+ + qemu_lockcnt_unlock(&accel_in_ioctl_lock);
215
+ + CPU_FOREACH(cpu) {
216
+ + qemu_lockcnt_unlock(&cpu->in_ioctl_lock);
217
+ + }
218
+ +}
219
+ +
220
+ diff --git a/accel/meson.build b/accel/meson.build
221
+ index 259c35c4c8..061332610f 100644
222
+ --- a/accel/meson.build
223
+ +++ b/accel/meson.build
224
+ @@ -1,4 +1,4 @@
225
+ -specific_ss.add(files('accel-common.c'))
226
+ +specific_ss.add(files('accel-common.c', 'accel-blocker.c'))
227
+ softmmu_ss.add(files('accel-softmmu.c'))
228
+ user_ss.add(files('accel-user.c'))
229
+
230
+ diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
231
+ index f9fdd46b9d..8d6a4b1b65 100644
232
+ --- a/hw/core/cpu-common.c
233
+ +++ b/hw/core/cpu-common.c
234
+ @@ -237,6 +237,7 @@ static void cpu_common_initfn(Object *obj)
235
+ cpu->nr_threads = 1;
236
+
237
+ qemu_mutex_init(&cpu->work_mutex);
238
+ + qemu_lockcnt_init(&cpu->in_ioctl_lock);
239
+ QSIMPLEQ_INIT(&cpu->work_list);
240
+ QTAILQ_INIT(&cpu->breakpoints);
241
+ QTAILQ_INIT(&cpu->watchpoints);
242
+ @@ -248,6 +249,7 @@ static void cpu_common_finalize(Object *obj)
243
+ {
244
+ CPUState *cpu = CPU(obj);
245
+
246
+ + qemu_lockcnt_destroy(&cpu->in_ioctl_lock);
247
+ qemu_mutex_destroy(&cpu->work_mutex);
248
+ }
249
+
250
+ diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
251
+ index 8830546121..2417597236 100644
252
+ --- a/include/hw/core/cpu.h
253
+ +++ b/include/hw/core/cpu.h
254
+ @@ -398,6 +398,9 @@ struct CPUState {
255
+ uint32_t kvm_fetch_index;
256
+ uint64_t dirty_pages;
257
+
258
+ + /* Use by accel-block: CPU is executing an ioctl() */
259
+ + QemuLockCnt in_ioctl_lock;
260
+ +
261
+ /* Used for events with 'vcpu' and *without* the 'disabled' properties */
262
+ DECLARE_BITMAP(trace_dstate_delayed, CPU_TRACE_DSTATE_MAX_EVENTS);
263
+ DECLARE_BITMAP(trace_dstate, CPU_TRACE_DSTATE_MAX_EVENTS);
264
+ diff --git a/include/sysemu/accel-blocker.h b/include/sysemu/accel-blocker.h
265
+ new file mode 100644
266
+ index 0000000000..72020529ef
267
+ --- /dev/null
268
+ +++ b/include/sysemu/accel-blocker.h
269
+ @@ -0,0 +1,56 @@
270
+ +/*
271
+ + * Accelerator blocking API, to prevent new ioctls from starting and wait the
272
+ + * running ones finish.
273
+ + * This mechanism differs from pause/resume_all_vcpus() in that it does not
274
+ + * release the BQL.
275
+ + *
276
+ + * Copyright (c) 2022 Red Hat Inc.
277
+ + *
278
+ + * Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
279
+ + *
280
+ + * This work is licensed under the terms of the GNU GPL, version 2 or later.
281
+ + * See the COPYING file in the top-level directory.
282
+ + */
283
+ +#ifndef ACCEL_BLOCKER_H
284
+ +#define ACCEL_BLOCKER_H
285
+ +
286
+ +#include "qemu/osdep.h"
287
+ +#include "sysemu/cpus.h"
288
+ +
289
+ +extern void accel_blocker_init(void);
290
+ +
291
+ +/*
292
+ + * accel_{cpu_}ioctl_begin/end:
293
+ + * Mark when ioctl is about to run or just finished.
294
+ + *
295
+ + * accel_{cpu_}ioctl_begin will block after accel_ioctl_inhibit_begin() is
296
+ + * called, preventing new ioctls to run. They will continue only after
297
+ + * accel_ioctl_inibith_end().
298
+ + */
299
+ +extern void accel_ioctl_begin(void);
300
+ +extern void accel_ioctl_end(void);
301
+ +extern void accel_cpu_ioctl_begin(CPUState *cpu);
302
+ +extern void accel_cpu_ioctl_end(CPUState *cpu);
303
+ +
304
+ +/*
305
+ + * accel_ioctl_inhibit_begin: start critical section
306
+ + *
307
+ + * This function makes sure that:
308
+ + * 1) incoming accel_{cpu_}ioctl_begin() calls block
309
+ + * 2) wait that all ioctls that were already running reach
310
+ + * accel_{cpu_}ioctl_end(), kicking vcpus if necessary.
311
+ + *
312
+ + * This allows the caller to access shared data or perform operations without
313
+ + * worrying of concurrent vcpus accesses.
314
+ + */
315
+ +extern void accel_ioctl_inhibit_begin(void);
316
+ +
317
+ +/*
318
+ + * accel_ioctl_inhibit_end: end critical section started by
319
+ + * accel_ioctl_inhibit_begin()
320
+ + *
321
+ + * This function allows blocked accel_{cpu_}ioctl_begin() to continue.
322
+ + */
323
+ +extern void accel_ioctl_inhibit_end(void);
324
+ +
325
+ +#endif /* ACCEL_BLOCKER_H */
326
+ diff --git a/util/meson.build b/util/meson.build
327
+ index 25b9b61f98..85a5504c4d 100644
328
+ --- a/util/meson.build
329
+ +++ b/util/meson.build
330
+ @@ -57,6 +57,7 @@ util_ss.add(files('guest-random.c'))
331
+ util_ss.add(files('yank.c'))
332
+ util_ss.add(files('int128.c'))
333
+ util_ss.add(files('memalign.c'))
334
+ +util_ss.add(files('lockcnt.c'))
335
+
336
+ if have_user
337
+ util_ss.add(files('selfmap.c'))
338
+ @@ -71,7 +72,6 @@ endif
339
+ if have_block or have_ga
340
+ util_ss.add(files('aiocb.c', 'async.c'))
341
+ util_ss.add(files('base64.c'))
342
+ - util_ss.add(files('lockcnt.c'))
343
+ util_ss.add(files('main-loop.c'))
344
+ util_ss.add(files('qemu-coroutine.c', 'qemu-coroutine-lock.c', 'qemu-coroutine-io.c'))
345
+ util_ss.add(files('coroutine-@0@.c'.format(config_host['CONFIG_COROUTINE_BACKEND'])))
346
+ --
347
+ 2.31.1
348
+
SOURCES/kvm-accel-tcg-Test-CPUJumpCache-in-tb_jmp_cache_clear_pa.patch ADDED
@@ -0,0 +1,58 @@
1
+ From ab68e13b7628f2348d41a4518a92508542af712f Mon Sep 17 00:00:00 2001
2
+ From: Eric Auger <eric.auger@redhat.com>
3
+ Date: Fri, 3 Feb 2023 18:15:10 +0100
4
+ Subject: [PATCH 05/20] accel/tcg: Test CPUJumpCache in tb_jmp_cache_clear_page
5
+
6
+ RH-Author: Eric Auger <eric.auger@redhat.com>
7
+ RH-MergeRequest: 144: accel/tcg: Test CPUJumpCache in tb_jmp_cache_clear_page
8
+ RH-Bugzilla: 2165280
9
+ RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
10
+ RH-Acked-by: Gavin Shan <gshan@redhat.com>
11
+ RH-Acked-by: Shaoqin Huang <None>
12
+ RH-Commit: [1/1] 5b0863c34ba06c01c4e343d1ecd72402779c7de3 (eauger1/centos-qemu-kvm)
13
+
14
+ Bugzilla: https://bugzilla.redhat.com/2165280
15
+ Upstream: yes
16
+ Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=50530041
17
+ Test: 'kvm unit test ./run_tests.sh -g debug' does not SIGSEV anymore
18
+
19
+ After commit 4e4fa6c12d ("accel/tcg: Complete cpu initialization
20
+ before registration"), it looks the CPUJumpCache pointer can be NULL.
21
+ This causes a SIGSEV when running debug-wp-migration kvm unit test.
22
+
23
+ At the first place it should be clarified why this TCG code is called
24
+ with KVM acceleration. This may hide another bug.
25
+
26
+ Fixes: 4e4fa6c12d ("accel/tcg: Complete cpu initialization before registration")
27
+ Signed-off-by: Eric Auger <eric.auger@redhat.com>
28
+ Message-Id: <20230203171510.2867451-1-eric.auger@redhat.com>
29
+ Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
30
+ (cherry picked from commit 99ab4d500af638ba3ebb20e8aa89d72201b70860)
31
+ Signed-off-by: Eric Auger <eric.auger@redhat.com>
32
+ ---
33
+ accel/tcg/cputlb.c | 7 ++++++-
34
+ 1 file changed, 6 insertions(+), 1 deletion(-)
35
+
36
+ diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
37
+ index 6f1c00682b..4244b0e4e3 100644
38
+ --- a/accel/tcg/cputlb.c
39
+ +++ b/accel/tcg/cputlb.c
40
+ @@ -100,9 +100,14 @@ static void tlb_window_reset(CPUTLBDesc *desc, int64_t ns,
41
+
42
+ static void tb_jmp_cache_clear_page(CPUState *cpu, target_ulong page_addr)
43
+ {
44
+ - int i, i0 = tb_jmp_cache_hash_page(page_addr);
45
+ CPUJumpCache *jc = cpu->tb_jmp_cache;
46
+ + int i, i0;
47
+
48
+ + if (unlikely(!jc)) {
49
+ + return;
50
+ + }
51
+ +
52
+ + i0 = tb_jmp_cache_hash_page(page_addr);
53
+ for (i = 0; i < TB_JMP_PAGE_SIZE; i++) {
54
+ qatomic_set(&jc->array[i0 + i].tb, NULL);
55
+ }
56
+ --
57
+ 2.31.1
58
+
SOURCES/kvm-block-Call-drain-callbacks-only-once.patch ADDED
@@ -0,0 +1,250 @@
1
+ From 9bb9cafd736057fd2a8ebfa6f5769668f125fbe6 Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Fri, 18 Nov 2022 18:41:06 +0100
4
+ Subject: [PATCH 24/31] block: Call drain callbacks only once
5
+
6
+ RH-Author: Stefano Garzarella <sgarzare@redhat.com>
7
+ RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
8
+ RH-Bugzilla: 2155112
9
+ RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
10
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
11
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
12
+ RH-Commit: [12/16] ea9a433dc01d1b8539a2d4ea12887f2a3ce830ea (sgarzarella/qemu-kvm-c-9-s)
13
+
14
+ We only need to call both the BlockDriver's callback and the parent
15
+ callbacks when going from undrained to drained or vice versa. A second
16
+ drain section doesn't make a difference for the driver or the parent,
17
+ they weren't supposed to send new requests before and after the second
18
+ drain.
19
+
20
+ One thing that gets in the way is the 'ignore_bds_parents' parameter in
21
+ bdrv_do_drained_begin_quiesce() and bdrv_do_drained_end(): It means that
22
+ bdrv_drain_all_begin() increases bs->quiesce_counter, but does not
23
+ quiesce the parent through BdrvChildClass callbacks. If an additional
24
+ drain section is started now, bs->quiesce_counter will be non-zero, but
25
+ we would still need to quiesce the parent through BdrvChildClass in
26
+ order to keep things consistent (and unquiesce it on the matching
27
+ bdrv_drained_end(), even though the counter would not reach 0 yet as
28
+ long as the bdrv_drain_all() section is still active).
29
+
30
+ Instead of keeping track of this, let's just get rid of the parameter.
31
+ It was introduced in commit 6cd5c9d7b2d as an optimisation so that
32
+ during bdrv_drain_all(), we wouldn't recursively drain all parents up to
33
+ the root for each node, resulting in quadratic complexity. As it happens,
34
+ calling the callbacks only once solves the same problem, so as of this
35
+ patch, we'll still have O(n) complexity and ignore_bds_parents is not
36
+ needed any more.
37
+
38
+ This patch only ignores the 'ignore_bds_parents' parameter. It will be
39
+ removed in a separate patch.
40
+
41
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
42
+ Reviewed-by: Hanna Reitz <hreitz@redhat.com>
43
+ Message-Id: <20221118174110.55183-12-kwolf@redhat.com>
44
+ Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
45
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
46
+ (cherry picked from commit 57e05be343f33f4e5899a8d8946a8596d68424a1)
47
+ Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
48
+ ---
49
+ block.c | 25 +++++++------------------
50
+ block/io.c | 30 ++++++++++++++++++------------
51
+ include/block/block_int-common.h | 8 ++++----
52
+ tests/unit/test-bdrv-drain.c | 16 ++++++++++------
53
+ 4 files changed, 39 insertions(+), 40 deletions(-)
54
+
55
+ diff --git a/block.c b/block.c
56
+ index e0e3b21790..5a583e260d 100644
57
+ --- a/block.c
58
+ +++ b/block.c
59
+ @@ -2824,7 +2824,6 @@ static void bdrv_replace_child_noperm(BdrvChild *child,
60
+ {
61
+ BlockDriverState *old_bs = child->bs;
62
+ int new_bs_quiesce_counter;
63
+ - int drain_saldo;
64
+
65
+ assert(!child->frozen);
66
+ assert(old_bs != new_bs);
67
+ @@ -2834,16 +2833,13 @@ static void bdrv_replace_child_noperm(BdrvChild *child,
68
+ assert(bdrv_get_aio_context(old_bs) == bdrv_get_aio_context(new_bs));
69
+ }
70
+
71
+ - new_bs_quiesce_counter = (new_bs ? new_bs->quiesce_counter : 0);
72
+ - drain_saldo = new_bs_quiesce_counter - child->parent_quiesce_counter;
73
+ -
74
+ /*
75
+ * If the new child node is drained but the old one was not, flush
76
+ * all outstanding requests to the old child node.
77
+ */
78
+ - while (drain_saldo > 0 && child->klass->drained_begin) {
79
+ + new_bs_quiesce_counter = (new_bs ? new_bs->quiesce_counter : 0);
80
+ + if (new_bs_quiesce_counter && !child->quiesced_parent) {
81
+ bdrv_parent_drained_begin_single(child, true);
82
+ - drain_saldo--;
83
+ }
84
+
85
+ if (old_bs) {
86
+ @@ -2859,16 +2855,6 @@ static void bdrv_replace_child_noperm(BdrvChild *child,
87
+ if (new_bs) {
88
+ assert_bdrv_graph_writable(new_bs);
89
+ QLIST_INSERT_HEAD(&new_bs->parents, child, next_parent);
90
+ -
91
+ - /*
92
+ - * Polling in bdrv_parent_drained_begin_single() may have led to the new
93
+ - * node's quiesce_counter having been decreased. Not a problem, we just
94
+ - * need to recognize this here and then invoke drained_end appropriately
95
+ - * more often.
96
+ - */
97
+ - assert(new_bs->quiesce_counter <= new_bs_quiesce_counter);
98
+ - drain_saldo += new_bs->quiesce_counter - new_bs_quiesce_counter;
99
+ -
100
+ if (child->klass->attach) {
101
+ child->klass->attach(child);
102
+ }
103
+ @@ -2877,10 +2863,13 @@ static void bdrv_replace_child_noperm(BdrvChild *child,
104
+ /*
105
+ * If the old child node was drained but the new one is not, allow
106
+ * requests to come in only after the new node has been attached.
107
+ + *
108
+ + * Update new_bs_quiesce_counter because bdrv_parent_drained_begin_single()
109
+ + * polls, which could have changed the value.
110
+ */
111
+ - while (drain_saldo < 0 && child->klass->drained_end) {
112
+ + new_bs_quiesce_counter = (new_bs ? new_bs->quiesce_counter : 0);
113
+ + if (!new_bs_quiesce_counter && child->quiesced_parent) {
114
+ bdrv_parent_drained_end_single(child);
115
+ - drain_saldo++;
116
+ }
117
+ }
118
+
119
+ diff --git a/block/io.c b/block/io.c
120
+ index 75224480d0..87d6f22ec4 100644
121
+ --- a/block/io.c
122
+ +++ b/block/io.c
123
+ @@ -62,8 +62,9 @@ void bdrv_parent_drained_end_single(BdrvChild *c)
124
+ {
125
+ IO_OR_GS_CODE();
126
+
127
+ - assert(c->parent_quiesce_counter > 0);
128
+ - c->parent_quiesce_counter--;
129
+ + assert(c->quiesced_parent);
130
+ + c->quiesced_parent = false;
131
+ +
132
+ if (c->klass->drained_end) {
133
+ c->klass->drained_end(c);
134
+ }
135
+ @@ -110,7 +111,10 @@ void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll)
136
+ {
137
+ AioContext *ctx = bdrv_child_get_parent_aio_context(c);
138
+ IO_OR_GS_CODE();
139
+ - c->parent_quiesce_counter++;
140
+ +
141
+ + assert(!c->quiesced_parent);
142
+ + c->quiesced_parent = true;
143
+ +
144
+ if (c->klass->drained_begin) {
145
+ c->klass->drained_begin(c);
146
+ }
147
+ @@ -358,11 +362,12 @@ void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
148
+ /* Stop things in parent-to-child order */
149
+ if (qatomic_fetch_inc(&bs->quiesce_counter) == 0) {
150
+ aio_disable_external(bdrv_get_aio_context(bs));
151
+ - }
152
+
153
+ - bdrv_parent_drained_begin(bs, parent, ignore_bds_parents);
154
+ - if (bs->drv && bs->drv->bdrv_drain_begin) {
155
+ - bs->drv->bdrv_drain_begin(bs);
156
+ + /* TODO Remove ignore_bds_parents, we don't consider it any more */
157
+ + bdrv_parent_drained_begin(bs, parent, false);
158
+ + if (bs->drv && bs->drv->bdrv_drain_begin) {
159
+ + bs->drv->bdrv_drain_begin(bs);
160
+ + }
161
+ }
162
+ }
163
+
164
+ @@ -413,13 +418,14 @@ static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent,
165
+ assert(bs->quiesce_counter > 0);
166
+
167
+ /* Re-enable things in child-to-parent order */
168
+ - if (bs->drv && bs->drv->bdrv_drain_end) {
169
+ - bs->drv->bdrv_drain_end(bs);
170
+ - }
171
+ - bdrv_parent_drained_end(bs, parent, ignore_bds_parents);
172
+ -
173
+ old_quiesce_counter = qatomic_fetch_dec(&bs->quiesce_counter);
174
+ if (old_quiesce_counter == 1) {
175
+ + if (bs->drv && bs->drv->bdrv_drain_end) {
176
+ + bs->drv->bdrv_drain_end(bs);
177
+ + }
178
+ + /* TODO Remove ignore_bds_parents, we don't consider it any more */
179
+ + bdrv_parent_drained_end(bs, parent, false);
180
+ +
181
+ aio_enable_external(bdrv_get_aio_context(bs));
182
+ }
183
+ }
184
+ diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
185
+ index 791dddfd7d..a6bc6b7fe9 100644
186
+ --- a/include/block/block_int-common.h
187
+ +++ b/include/block/block_int-common.h
188
+ @@ -980,13 +980,13 @@ struct BdrvChild {
189
+ bool frozen;
190
+
191
+ /*
192
+ - * How many times the parent of this child has been drained
193
+ + * True if the parent of this child has been drained by this BdrvChild
194
+ * (through klass->drained_*).
195
+ - * Usually, this is equal to bs->quiesce_counter (potentially
196
+ - * reduced by bdrv_drain_all_count). It may differ while the
197
+ + *
198
+ + * It is generally true if bs->quiesce_counter > 0. It may differ while the
199
+ * child is entering or leaving a drained section.
200
+ */
201
+ - int parent_quiesce_counter;
202
+ + bool quiesced_parent;
203
+
204
+ QLIST_ENTRY(BdrvChild) next;
205
+ QLIST_ENTRY(BdrvChild) next_parent;
206
+ diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c
207
+ index dda08de8db..172bc6debc 100644
208
+ --- a/tests/unit/test-bdrv-drain.c
209
+ +++ b/tests/unit/test-bdrv-drain.c
210
+ @@ -296,7 +296,11 @@ static void test_quiesce_common(enum drain_type drain_type, bool recursive)
211
+
212
+ do_drain_begin(drain_type, bs);
213
+
214
+ - g_assert_cmpint(bs->quiesce_counter, ==, 1);
215
+ + if (drain_type == BDRV_DRAIN_ALL) {
216
+ + g_assert_cmpint(bs->quiesce_counter, ==, 2);
217
+ + } else {
218
+ + g_assert_cmpint(bs->quiesce_counter, ==, 1);
219
+ + }
220
+ g_assert_cmpint(backing->quiesce_counter, ==, !!recursive);
221
+
222
+ do_drain_end(drain_type, bs);
223
+ @@ -348,8 +352,8 @@ static void test_nested(void)
224
+
225
+ for (outer = 0; outer < DRAIN_TYPE_MAX; outer++) {
226
+ for (inner = 0; inner < DRAIN_TYPE_MAX; inner++) {
227
+ - int backing_quiesce = (outer != BDRV_DRAIN) +
228
+ - (inner != BDRV_DRAIN);
229
+ + int backing_quiesce = (outer == BDRV_DRAIN_ALL) +
230
+ + (inner == BDRV_DRAIN_ALL);
231
+
232
+ g_assert_cmpint(bs->quiesce_counter, ==, 0);
233
+ g_assert_cmpint(backing->quiesce_counter, ==, 0);
234
+ @@ -359,10 +363,10 @@ static void test_nested(void)
235
+ do_drain_begin(outer, bs);
236
+ do_drain_begin(inner, bs);
237
+
238
+ - g_assert_cmpint(bs->quiesce_counter, ==, 2);
239
+ + g_assert_cmpint(bs->quiesce_counter, ==, 2 + !!backing_quiesce);
240
+ g_assert_cmpint(backing->quiesce_counter, ==, backing_quiesce);
241
+ - g_assert_cmpint(s->drain_count, ==, 2);
242
+ - g_assert_cmpint(backing_s->drain_count, ==, backing_quiesce);
243
+ + g_assert_cmpint(s->drain_count, ==, 1);
244
+ + g_assert_cmpint(backing_s->drain_count, ==, !!backing_quiesce);
245
+
246
+ do_drain_end(inner, bs);
247
+ do_drain_end(outer, bs);
248
+ --
249
+ 2.31.1
250
+
SOURCES/kvm-block-Don-t-poll-in-bdrv_replace_child_noperm.patch ADDED
@@ -0,0 +1,298 @@
1
+ From 150ef3356cc6732fede7ca059168fc0565ed0b76 Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Fri, 18 Nov 2022 18:41:09 +0100
4
+ Subject: [PATCH 27/31] block: Don't poll in bdrv_replace_child_noperm()
5
+
6
+ RH-Author: Stefano Garzarella <sgarzare@redhat.com>
7
+ RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
8
+ RH-Bugzilla: 2155112
9
+ RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
10
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
11
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
12
+ RH-Commit: [15/16] 5fc7d6b703a2d6c1118d875056f0afbd6ba5cca9 (sgarzarella/qemu-kvm-c-9-s)
13
+
14
+ In order to make sure that bdrv_replace_child_noperm() doesn't have to
15
+ poll any more, get rid of the bdrv_parent_drained_begin_single() call.
16
+
17
+ This is possible now because we can require that the parent is already
18
+ drained through the child in question when the function is called and we
19
+ don't call the parent drain callbacks more than once.
20
+
21
+ The additional drain calls needed in callers cause the test case to run
22
+ its code in the drain handler too early (bdrv_attach_child() drains
23
+ now), so modify it to only enable the code after the test setup has
24
+ completed.
25
+
26
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
27
+ Message-Id: <20221118174110.55183-15-kwolf@redhat.com>
28
+ Reviewed-by: Hanna Reitz <hreitz@redhat.com>
29
+ Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
30
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
31
+ (cherry picked from commit 23987471285a26397e3152a9244b652445fd36c4)
32
+ Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
33
+ ---
34
+ block.c | 103 ++++++++++++++++++++++++++++++-----
35
+ block/io.c | 2 +-
36
+ include/block/block-io.h | 8 +++
37
+ tests/unit/test-bdrv-drain.c | 10 ++++
38
+ 4 files changed, 108 insertions(+), 15 deletions(-)
39
+
40
+ diff --git a/block.c b/block.c
41
+ index af31a94863..65588d313a 100644
42
+ --- a/block.c
43
+ +++ b/block.c
44
+ @@ -2407,6 +2407,20 @@ static void bdrv_replace_child_abort(void *opaque)
45
+
46
+ GLOBAL_STATE_CODE();
47
+ /* old_bs reference is transparently moved from @s to @s->child */
48
+ + if (!s->child->bs) {
49
+ + /*
50
+ + * The parents were undrained when removing old_bs from the child. New
51
+ + * requests can't have been made, though, because the child was empty.
52
+ + *
53
+ + * TODO Make bdrv_replace_child_noperm() transactionable to avoid
54
+ + * undraining the parent in the first place. Once this is done, having
55
+ + * new_bs drained when calling bdrv_replace_child_tran() is not a
56
+ + * requirement any more.
57
+ + */
58
+ + bdrv_parent_drained_begin_single(s->child, false);
59
+ + assert(!bdrv_parent_drained_poll_single(s->child));
60
+ + }
61
+ + assert(s->child->quiesced_parent);
62
+ bdrv_replace_child_noperm(s->child, s->old_bs);
63
+ bdrv_unref(new_bs);
64
+ }
65
+ @@ -2422,12 +2436,19 @@ static TransactionActionDrv bdrv_replace_child_drv = {
66
+ *
67
+ * Note: real unref of old_bs is done only on commit.
68
+ *
69
+ + * Both @child->bs and @new_bs (if non-NULL) must be drained. @new_bs must be
70
+ + * kept drained until the transaction is completed.
71
+ + *
72
+ * The function doesn't update permissions, caller is responsible for this.
73
+ */
74
+ static void bdrv_replace_child_tran(BdrvChild *child, BlockDriverState *new_bs,
75
+ Transaction *tran)
76
+ {
77
+ BdrvReplaceChildState *s = g_new(BdrvReplaceChildState, 1);
78
+ +
79
+ + assert(child->quiesced_parent);
80
+ + assert(!new_bs || new_bs->quiesce_counter);
81
+ +
82
+ *s = (BdrvReplaceChildState) {
83
+ .child = child,
84
+ .old_bs = child->bs,
85
+ @@ -2819,6 +2840,14 @@ uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission qapi_perm)
86
+ return permissions[qapi_perm];
87
+ }
88
+
89
+ +/*
90
+ + * Replaces the node that a BdrvChild points to without updating permissions.
91
+ + *
92
+ + * If @new_bs is non-NULL, the parent of @child must already be drained through
93
+ + * @child.
94
+ + *
95
+ + * This function does not poll.
96
+ + */
97
+ static void bdrv_replace_child_noperm(BdrvChild *child,
98
+ BlockDriverState *new_bs)
99
+ {
100
+ @@ -2826,6 +2855,28 @@ static void bdrv_replace_child_noperm(BdrvChild *child,
101
+ int new_bs_quiesce_counter;
102
+
103
+ assert(!child->frozen);
104
+ +
105
+ + /*
106
+ + * If we want to change the BdrvChild to point to a drained node as its new
107
+ + * child->bs, we need to make sure that its new parent is drained, too. In
108
+ + * other words, either child->quiesce_parent must already be true or we must
109
+ + * be able to set it and keep the parent's quiesce_counter consistent with
110
+ + * that, but without polling or starting new requests (this function
111
+ + * guarantees that it doesn't poll, and starting new requests would be
112
+ + * against the invariants of drain sections).
113
+ + *
114
+ + * To keep things simple, we pick the first option (child->quiesce_parent
115
+ + * must already be true). We also generalise the rule a bit to make it
116
+ + * easier to verify in callers and more likely to be covered in test cases:
117
+ + * The parent must be quiesced through this child even if new_bs isn't
118
+ + * currently drained.
119
+ + *
120
+ + * The only exception is for callers that always pass new_bs == NULL. In
121
+ + * this case, we obviously never need to consider the case of a drained
122
+ + * new_bs, so we can keep the callers simpler by allowing them not to drain
123
+ + * the parent.
124
+ + */
125
+ + assert(!new_bs || child->quiesced_parent);
126
+ assert(old_bs != new_bs);
127
+ GLOBAL_STATE_CODE();
128
+
129
+ @@ -2833,15 +2884,6 @@ static void bdrv_replace_child_noperm(BdrvChild *child,
130
+ assert(bdrv_get_aio_context(old_bs) == bdrv_get_aio_context(new_bs));
131
+ }
132
+
133
+ - /*
134
+ - * If the new child node is drained but the old one was not, flush
135
+ - * all outstanding requests to the old child node.
136
+ - */
137
+ - new_bs_quiesce_counter = (new_bs ? new_bs->quiesce_counter : 0);
138
+ - if (new_bs_quiesce_counter && !child->quiesced_parent) {
139
+ - bdrv_parent_drained_begin_single(child, true);
140
+ - }
141
+ -
142
+ if (old_bs) {
143
+ if (child->klass->detach) {
144
+ child->klass->detach(child);
145
+ @@ -2861,11 +2903,9 @@ static void bdrv_replace_child_noperm(BdrvChild *child,
146
+ }
147
+
148
+ /*
149
+ - * If the old child node was drained but the new one is not, allow
150
+ - * requests to come in only after the new node has been attached.
151
+ - *
152
+ - * Update new_bs_quiesce_counter because bdrv_parent_drained_begin_single()
153
+ - * polls, which could have changed the value.
154
+ + * If the parent was drained through this BdrvChild previously, but new_bs
155
+ + * is not drained, allow requests to come in only after the new node has
156
+ + * been attached.
157
+ */
158
+ new_bs_quiesce_counter = (new_bs ? new_bs->quiesce_counter : 0);
159
+ if (!new_bs_quiesce_counter && child->quiesced_parent) {
160
+ @@ -3002,6 +3042,24 @@ static BdrvChild *bdrv_attach_child_common(BlockDriverState *child_bs,
161
+ }
162
+
163
+ bdrv_ref(child_bs);
164
+ + /*
165
+ + * Let every new BdrvChild start with a drained parent. Inserting the child
166
+ + * in the graph with bdrv_replace_child_noperm() will undrain it if
167
+ + * @child_bs is not drained.
168
+ + *
169
+ + * The child was only just created and is not yet visible in global state
170
+ + * until bdrv_replace_child_noperm() inserts it into the graph, so nobody
171
+ + * could have sent requests and polling is not necessary.
172
+ + *
173
+ + * Note that this means that the parent isn't fully drained yet, we only
174
+ + * stop new requests from coming in. This is fine, we don't care about the
175
+ + * old requests here, they are not for this child. If another place enters a
176
+ + * drain section for the same parent, but wants it to be fully quiesced, it
177
+ + * will not run most of the the code in .drained_begin() again (which is not
178
+ + * a problem, we already did this), but it will still poll until the parent
179
+ + * is fully quiesced, so it will not be negatively affected either.
180
+ + */
181
+ + bdrv_parent_drained_begin_single(new_child, false);
182
+ bdrv_replace_child_noperm(new_child, child_bs);
183
+
184
+ BdrvAttachChildCommonState *s = g_new(BdrvAttachChildCommonState, 1);
185
+ @@ -5059,12 +5117,24 @@ static void bdrv_remove_child(BdrvChild *child, Transaction *tran)
186
+ }
187
+
188
+ if (child->bs) {
189
+ + BlockDriverState *bs = child->bs;
190
+ + bdrv_drained_begin(bs);
191
+ bdrv_replace_child_tran(child, NULL, tran);
192
+ + bdrv_drained_end(bs);
193
+ }
194
+
195
+ tran_add(tran, &bdrv_remove_child_drv, child);
196
+ }
197
+
198
+ +static void undrain_on_clean_cb(void *opaque)
199
+ +{
200
+ + bdrv_drained_end(opaque);
201
+ +}
202
+ +
203
+ +static TransactionActionDrv undrain_on_clean = {
204
+ + .clean = undrain_on_clean_cb,
205
+ +};
206
+ +
207
+ static int bdrv_replace_node_noperm(BlockDriverState *from,
208
+ BlockDriverState *to,
209
+ bool auto_skip, Transaction *tran,
210
+ @@ -5074,6 +5144,11 @@ static int bdrv_replace_node_noperm(BlockDriverState *from,
211
+
212
+ GLOBAL_STATE_CODE();
213
+
214
+ + bdrv_drained_begin(from);
215
+ + bdrv_drained_begin(to);
216
+ + tran_add(tran, &undrain_on_clean, from);
217
+ + tran_add(tran, &undrain_on_clean, to);
218
+ +
219
+ QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) {
220
+ assert(c->bs == from);
221
+ if (!should_update_child(c, to)) {
222
+ diff --git a/block/io.c b/block/io.c
223
+ index 5e9150d92c..ae64830eac 100644
224
+ --- a/block/io.c
225
+ +++ b/block/io.c
226
+ @@ -81,7 +81,7 @@ static void bdrv_parent_drained_end(BlockDriverState *bs, BdrvChild *ignore)
227
+ }
228
+ }
229
+
230
+ -static bool bdrv_parent_drained_poll_single(BdrvChild *c)
231
+ +bool bdrv_parent_drained_poll_single(BdrvChild *c)
232
+ {
233
+ if (c->klass->drained_poll) {
234
+ return c->klass->drained_poll(c);
235
+ diff --git a/include/block/block-io.h b/include/block/block-io.h
236
+ index 8f5e75756a..65e6d2569b 100644
237
+ --- a/include/block/block-io.h
238
+ +++ b/include/block/block-io.h
239
+ @@ -292,6 +292,14 @@ bdrv_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos);
240
+ */
241
+ void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll);
242
+
243
+ +/**
244
+ + * bdrv_parent_drained_poll_single:
245
+ + *
246
+ + * Returns true if there is any pending activity to cease before @c can be
247
+ + * called quiesced, false otherwise.
248
+ + */
249
+ +bool bdrv_parent_drained_poll_single(BdrvChild *c);
250
+ +
251
+ /**
252
+ * bdrv_parent_drained_end_single:
253
+ *
254
+ diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c
255
+ index 172bc6debc..2686a8acee 100644
256
+ --- a/tests/unit/test-bdrv-drain.c
257
+ +++ b/tests/unit/test-bdrv-drain.c
258
+ @@ -1654,6 +1654,7 @@ static void test_drop_intermediate_poll(void)
259
+
260
+
261
+ typedef struct BDRVReplaceTestState {
262
+ + bool setup_completed;
263
+ bool was_drained;
264
+ bool was_undrained;
265
+ bool has_read;
266
+ @@ -1738,6 +1739,10 @@ static void bdrv_replace_test_drain_begin(BlockDriverState *bs)
267
+ {
268
+ BDRVReplaceTestState *s = bs->opaque;
269
+
270
+ + if (!s->setup_completed) {
271
+ + return;
272
+ + }
273
+ +
274
+ if (!s->drain_count) {
275
+ s->drain_co = qemu_coroutine_create(bdrv_replace_test_drain_co, bs);
276
+ bdrv_inc_in_flight(bs);
277
+ @@ -1769,6 +1774,10 @@ static void bdrv_replace_test_drain_end(BlockDriverState *bs)
278
+ {
279
+ BDRVReplaceTestState *s = bs->opaque;
280
+
281
+ + if (!s->setup_completed) {
282
+ + return;
283
+ + }
284
+ +
285
+ g_assert(s->drain_count > 0);
286
+ if (!--s->drain_count) {
287
+ s->was_undrained = true;
288
+ @@ -1867,6 +1876,7 @@ static void do_test_replace_child_mid_drain(int old_drain_count,
289
+ bdrv_ref(old_child_bs);
290
+ bdrv_attach_child(parent_bs, old_child_bs, "child", &child_of_bds,
291
+ BDRV_CHILD_COW, &error_abort);
292
+ + parent_s->setup_completed = true;
293
+
294
+ for (i = 0; i < old_drain_count; i++) {
295
+ bdrv_drained_begin(old_child_bs);
296
+ --
297
+ 2.31.1
298
+
SOURCES/kvm-block-Don-t-use-subtree-drains-in-bdrv_drop_intermed.patch ADDED
@@ -0,0 +1,54 @@
1
+ From 6af6de77dace29aa8548b3649dc9c6163740ac86 Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Fri, 18 Nov 2022 18:41:03 +0100
4
+ Subject: [PATCH 21/31] block: Don't use subtree drains in
5
+ bdrv_drop_intermediate()
6
+
7
+ RH-Author: Stefano Garzarella <sgarzare@redhat.com>
8
+ RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
9
+ RH-Bugzilla: 2155112
10
+ RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
11
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
12
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
13
+ RH-Commit: [9/16] 3c06fa826f262558f57d38b0155500c2e8e23a53 (sgarzarella/qemu-kvm-c-9-s)
14
+
15
+ Instead of using a subtree drain from the top node (which also drains
16
+ child nodes of base that we're not even interested in), use a normal
17
+ drain for base, which automatically drains all of the parents, too.
18
+
19
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
20
+ Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
21
+ Reviewed-by: Hanna Reitz <hreitz@redhat.com>
22
+ Message-Id: <20221118174110.55183-9-kwolf@redhat.com>
23
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
24
+ (cherry picked from commit 631086deefc32690ee56efed1c5b891dec31ae37)
25
+ Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
26
+ ---
27
+ block.c | 4 ++--
28
+ 1 file changed, 2 insertions(+), 2 deletions(-)
29
+
30
+ diff --git a/block.c b/block.c
31
+ index cb5e96b1cf..b3449a312e 100644
32
+ --- a/block.c
33
+ +++ b/block.c
34
+ @@ -5586,7 +5586,7 @@ int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base,
35
+ GLOBAL_STATE_CODE();
36
+
37
+ bdrv_ref(top);
38
+ - bdrv_subtree_drained_begin(top);
39
+ + bdrv_drained_begin(base);
40
+
41
+ if (!top->drv || !base->drv) {
42
+ goto exit;
43
+ @@ -5659,7 +5659,7 @@ int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base,
44
+
45
+ ret = 0;
46
+ exit:
47
+ - bdrv_subtree_drained_end(top);
48
+ + bdrv_drained_end(base);
49
+ bdrv_unref(top);
50
+ return ret;
51
+ }
52
+ --
53
+ 2.31.1
54
+
SOURCES/kvm-block-Drain-individual-nodes-during-reopen.patch ADDED
@@ -0,0 +1,157 @@
1
+ From ad52cb621daad45d3c2a0e2e670d6ca2e16690bd Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Fri, 18 Nov 2022 18:41:02 +0100
4
+ Subject: [PATCH 20/31] block: Drain individual nodes during reopen
5
+
6
+ RH-Author: Stefano Garzarella <sgarzare@redhat.com>
7
+ RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
8
+ RH-Bugzilla: 2155112
9
+ RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
10
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
11
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
12
+ RH-Commit: [8/16] 5441b6f0ae9102ef40d1093e1db3084eea81e3b0 (sgarzarella/qemu-kvm-c-9-s)
13
+
14
+ bdrv_reopen() and friends use subtree drains as a lazy way of covering
15
+ all the nodes they touch. Turns out that this lazy way is a lot more
16
+ complicated than just draining the nodes individually, even not
17
+ accounting for the additional complexity in the drain mechanism itself.
18
+
19
+ Simplify the code by switching to draining the individual nodes that are
20
+ already managed in the BlockReopenQueue anyway.
21
+
22
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
23
+ Message-Id: <20221118174110.55183-8-kwolf@redhat.com>
24
+ Reviewed-by: Hanna Reitz <hreitz@redhat.com>
25
+ Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
26
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
27
+ (cherry picked from commit d22933acd2f470eeef779e4d444e848f76dcfaf8)
28
+ Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
29
+ ---
30
+ block.c | 16 +++++++++-------
31
+ block/replication.c | 6 ------
32
+ blockdev.c | 13 -------------
33
+ 3 files changed, 9 insertions(+), 26 deletions(-)
34
+
35
+ diff --git a/block.c b/block.c
36
+ index 46df410b07..cb5e96b1cf 100644
37
+ --- a/block.c
38
+ +++ b/block.c
39
+ @@ -4150,7 +4150,7 @@ static bool bdrv_recurse_has_child(BlockDriverState *bs,
40
+ * returns a pointer to bs_queue, which is either the newly allocated
41
+ * bs_queue, or the existing bs_queue being used.
42
+ *
43
+ - * bs must be drained between bdrv_reopen_queue() and bdrv_reopen_multiple().
44
+ + * bs is drained here and undrained by bdrv_reopen_queue_free().
45
+ *
46
+ * To be called with bs->aio_context locked.
47
+ */
48
+ @@ -4172,12 +4172,10 @@ static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
49
+ int flags;
50
+ QemuOpts *opts;
51
+
52
+ - /* Make sure that the caller remembered to use a drained section. This is
53
+ - * important to avoid graph changes between the recursive queuing here and
54
+ - * bdrv_reopen_multiple(). */
55
+ - assert(bs->quiesce_counter > 0);
56
+ GLOBAL_STATE_CODE();
57
+
58
+ + bdrv_drained_begin(bs);
59
+ +
60
+ if (bs_queue == NULL) {
61
+ bs_queue = g_new0(BlockReopenQueue, 1);
62
+ QTAILQ_INIT(bs_queue);
63
+ @@ -4328,6 +4326,12 @@ void bdrv_reopen_queue_free(BlockReopenQueue *bs_queue)
64
+ if (bs_queue) {
65
+ BlockReopenQueueEntry *bs_entry, *next;
66
+ QTAILQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) {
67
+ + AioContext *ctx = bdrv_get_aio_context(bs_entry->state.bs);
68
+ +
69
+ + aio_context_acquire(ctx);
70
+ + bdrv_drained_end(bs_entry->state.bs);
71
+ + aio_context_release(ctx);
72
+ +
73
+ qobject_unref(bs_entry->state.explicit_options);
74
+ qobject_unref(bs_entry->state.options);
75
+ g_free(bs_entry);
76
+ @@ -4475,7 +4479,6 @@ int bdrv_reopen(BlockDriverState *bs, QDict *opts, bool keep_old_opts,
77
+
78
+ GLOBAL_STATE_CODE();
79
+
80
+ - bdrv_subtree_drained_begin(bs);
81
+ queue = bdrv_reopen_queue(NULL, bs, opts, keep_old_opts);
82
+
83
+ if (ctx != qemu_get_aio_context()) {
84
+ @@ -4486,7 +4489,6 @@ int bdrv_reopen(BlockDriverState *bs, QDict *opts, bool keep_old_opts,
85
+ if (ctx != qemu_get_aio_context()) {
86
+ aio_context_acquire(ctx);
87
+ }
88
+ - bdrv_subtree_drained_end(bs);
89
+
90
+ return ret;
91
+ }
92
+ diff --git a/block/replication.c b/block/replication.c
93
+ index f1eed25e43..c62f48a874 100644
94
+ --- a/block/replication.c
95
+ +++ b/block/replication.c
96
+ @@ -374,9 +374,6 @@ static void reopen_backing_file(BlockDriverState *bs, bool writable,
97
+ s->orig_secondary_read_only = bdrv_is_read_only(secondary_disk->bs);
98
+ }
99
+
100
+ - bdrv_subtree_drained_begin(hidden_disk->bs);
101
+ - bdrv_subtree_drained_begin(secondary_disk->bs);
102
+ -
103
+ if (s->orig_hidden_read_only) {
104
+ QDict *opts = qdict_new();
105
+ qdict_put_bool(opts, BDRV_OPT_READ_ONLY, !writable);
106
+ @@ -401,9 +398,6 @@ static void reopen_backing_file(BlockDriverState *bs, bool writable,
107
+ aio_context_acquire(ctx);
108
+ }
109
+ }
110
+ -
111
+ - bdrv_subtree_drained_end(hidden_disk->bs);
112
+ - bdrv_subtree_drained_end(secondary_disk->bs);
113
+ }
114
+
115
+ static void backup_job_cleanup(BlockDriverState *bs)
116
+ diff --git a/blockdev.c b/blockdev.c
117
+ index 3f1dec6242..8ffb3d9537 100644
118
+ --- a/blockdev.c
119
+ +++ b/blockdev.c
120
+ @@ -3547,8 +3547,6 @@ fail:
121
+ void qmp_blockdev_reopen(BlockdevOptionsList *reopen_list, Error **errp)
122
+ {
123
+ BlockReopenQueue *queue = NULL;
124
+ - GSList *drained = NULL;
125
+ - GSList *p;
126
+
127
+ /* Add each one of the BDS that we want to reopen to the queue */
128
+ for (; reopen_list != NULL; reopen_list = reopen_list->next) {
129
+ @@ -3585,9 +3583,7 @@ void qmp_blockdev_reopen(BlockdevOptionsList *reopen_list, Error **errp)
130
+ ctx = bdrv_get_aio_context(bs);
131
+ aio_context_acquire(ctx);
132
+
133
+ - bdrv_subtree_drained_begin(bs);
134
+ queue = bdrv_reopen_queue(queue, bs, qdict, false);
135
+ - drained = g_slist_prepend(drained, bs);
136
+
137
+ aio_context_release(ctx);
138
+ }
139
+ @@ -3598,15 +3594,6 @@ void qmp_blockdev_reopen(BlockdevOptionsList *reopen_list, Error **errp)
140
+
141
+ fail:
142
+ bdrv_reopen_queue_free(queue);
143
+ - for (p = drained; p; p = p->next) {
144
+ - BlockDriverState *bs = p->data;
145
+ - AioContext *ctx = bdrv_get_aio_context(bs);
146
+ -
147
+ - aio_context_acquire(ctx);
148
+ - bdrv_subtree_drained_end(bs);
149
+ - aio_context_release(ctx);
150
+ - }
151
+ - g_slist_free(drained);
152
+ }
153
+
154
+ void qmp_blockdev_del(const char *node_name, Error **errp)
155
+ --
156
+ 2.31.1
157
+
SOURCES/kvm-block-Drop-out-of-coroutine-in-bdrv_do_drained_begin.patch ADDED
@@ -0,0 +1,96 @@
1
+ From 9a789d104a4a69031ad95d7fad6380ab21e82503 Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Fri, 18 Nov 2022 18:41:08 +0100
4
+ Subject: [PATCH 26/31] block: Drop out of coroutine in
5
+ bdrv_do_drained_begin_quiesce()
6
+
7
+ RH-Author: Stefano Garzarella <sgarzare@redhat.com>
8
+ RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
9
+ RH-Bugzilla: 2155112
10
+ RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
11
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
12
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
13
+ RH-Commit: [14/16] c9266663b822f703e55b6a07de98ceb56e69e924 (sgarzarella/qemu-kvm-c-9-s)
14
+
15
+ The next patch adds a parent drain to bdrv_attach_child_common(), which
16
+ shouldn't be, but is currently called from coroutines in some cases (e.g.
17
+ .bdrv_co_create implementations generally open new nodes). Therefore,
18
+ the assertion that we're not in a coroutine doesn't hold true any more.
19
+
20
+ We could just remove the assertion because there is nothing in the
21
+ function that should be in conflict with running in a coroutine, but
22
+ just to be on the safe side, we can reverse the caller relationship
23
+ between bdrv_do_drained_begin() and bdrv_do_drained_begin_quiesce() so
24
+ that the latter also just drops out of coroutine context and we can
25
+ still be certain in the future that any drain code doesn't run in
26
+ coroutines.
27
+
28
+ As a nice side effect, the structure of bdrv_do_drained_begin() is now
29
+ symmetrical with bdrv_do_drained_end().
30
+
31
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
32
+ Message-Id: <20221118174110.55183-14-kwolf@redhat.com>
33
+ Reviewed-by: Hanna Reitz <hreitz@redhat.com>
34
+ Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
35
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
36
+ (cherry picked from commit 05c272ff0cf1b16cc3606f746182dd99b774f553)
37
+ Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
38
+ ---
39
+ block/io.c | 25 ++++++++++++-------------
40
+ 1 file changed, 12 insertions(+), 13 deletions(-)
41
+
42
+ diff --git a/block/io.c b/block/io.c
43
+ index 2e9503df6a..5e9150d92c 100644
44
+ --- a/block/io.c
45
+ +++ b/block/io.c
46
+ @@ -346,10 +346,15 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
47
+ }
48
+ }
49
+
50
+ -void bdrv_do_drained_begin_quiesce(BlockDriverState *bs, BdrvChild *parent)
51
+ +static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
52
+ + bool poll)
53
+ {
54
+ IO_OR_GS_CODE();
55
+ - assert(!qemu_in_coroutine());
56
+ +
57
+ + if (qemu_in_coroutine()) {
58
+ + bdrv_co_yield_to_drain(bs, true, parent, poll);
59
+ + return;
60
+ + }
61
+
62
+ /* Stop things in parent-to-child order */
63
+ if (qatomic_fetch_inc(&bs->quiesce_counter) == 0) {
64
+ @@ -359,17 +364,6 @@ void bdrv_do_drained_begin_quiesce(BlockDriverState *bs, BdrvChild *parent)
65
+ bs->drv->bdrv_drain_begin(bs);
66
+ }
67
+ }
68
+ -}
69
+ -
70
+ -static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
71
+ - bool poll)
72
+ -{
73
+ - if (qemu_in_coroutine()) {
74
+ - bdrv_co_yield_to_drain(bs, true, parent, poll);
75
+ - return;
76
+ - }
77
+ -
78
+ - bdrv_do_drained_begin_quiesce(bs, parent);
79
+
80
+ /*
81
+ * Wait for drained requests to finish.
82
+ @@ -385,6 +379,11 @@ static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
83
+ }
84
+ }
85
+
86
+ +void bdrv_do_drained_begin_quiesce(BlockDriverState *bs, BdrvChild *parent)
87
+ +{
88
+ + bdrv_do_drained_begin(bs, parent, false);
89
+ +}
90
+ +
91
+ void bdrv_drained_begin(BlockDriverState *bs)
92
+ {
93
+ IO_OR_GS_CODE();
94
+ --
95
+ 2.31.1
96
+
SOURCES/kvm-block-Fix-locking-for-bdrv_reopen_queue_child.patch ADDED
@@ -0,0 +1,67 @@
1
+ From e790b4c20a5124239fe93e91fbc87745e5f2cea6 Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Fri, 18 Nov 2022 18:41:01 +0100
4
+ Subject: [PATCH 19/31] block: Fix locking for bdrv_reopen_queue_child()
5
+
6
+ RH-Author: Stefano Garzarella <sgarzare@redhat.com>
7
+ RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
8
+ RH-Bugzilla: 2155112
9
+ RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
10
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
11
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
12
+ RH-Commit: [7/16] 46bb54506c4400b9a1bf66b6bd7987ff67260003 (sgarzarella/qemu-kvm-c-9-s)
13
+
14
+ Callers don't agree whether bdrv_reopen_queue_child() should be called
15
+ with the AioContext lock held or not. Standardise on holding the lock
16
+ (as done by QMP blockdev-reopen and the replication block driver) and
17
+ fix bdrv_reopen() to do the same.
18
+
19
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
20
+ Message-Id: <20221118174110.55183-7-kwolf@redhat.com>
21
+ Reviewed-by: Hanna Reitz <hreitz@redhat.com>
22
+ Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
23
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
24
+ (cherry picked from commit 2e117866d7c96cc17e84cd2946fee1bf3292d814)
25
+ Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
26
+ ---
27
+ block.c | 7 +++++--
28
+ 1 file changed, 5 insertions(+), 2 deletions(-)
29
+
30
+ diff --git a/block.c b/block.c
31
+ index 7999fd08c5..46df410b07 100644
32
+ --- a/block.c
33
+ +++ b/block.c
34
+ @@ -4151,6 +4151,8 @@ static bool bdrv_recurse_has_child(BlockDriverState *bs,
35
+ * bs_queue, or the existing bs_queue being used.
36
+ *
37
+ * bs must be drained between bdrv_reopen_queue() and bdrv_reopen_multiple().
38
+ + *
39
+ + * To be called with bs->aio_context locked.
40
+ */
41
+ static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
42
+ BlockDriverState *bs,
43
+ @@ -4309,6 +4311,7 @@ static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
44
+ return bs_queue;
45
+ }
46
+
47
+ +/* To be called with bs->aio_context locked */
48
+ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue,
49
+ BlockDriverState *bs,
50
+ QDict *options, bool keep_old_opts)
51
+ @@ -4473,11 +4476,11 @@ int bdrv_reopen(BlockDriverState *bs, QDict *opts, bool keep_old_opts,
52
+ GLOBAL_STATE_CODE();
53
+
54
+ bdrv_subtree_drained_begin(bs);
55
+ + queue = bdrv_reopen_queue(NULL, bs, opts, keep_old_opts);
56
+ +
57
+ if (ctx != qemu_get_aio_context()) {
58
+ aio_context_release(ctx);
59
+ }
60
+ -
61
+ - queue = bdrv_reopen_queue(NULL, bs, opts, keep_old_opts);
62
+ ret = bdrv_reopen_multiple(queue, errp);
63
+
64
+ if (ctx != qemu_get_aio_context()) {
65
+ --
66
+ 2.31.1
67
+
SOURCES/kvm-block-Improve-empty-format-specific-info-dump.patch ADDED
@@ -0,0 +1,132 @@
1
+ From 074c89b05dae971c7118cb769fd34e22135c8f4c Mon Sep 17 00:00:00 2001
2
+ From: Hanna Reitz <hreitz@redhat.com>
3
+ Date: Mon, 20 Jun 2022 18:26:53 +0200
4
+ Subject: [PATCH 06/20] block: Improve empty format-specific info dump
5
+
6
+ RH-Author: Hanna Czenczek <hreitz@redhat.com>
7
+ RH-MergeRequest: 145: Show protocol-level information in qemu-img info
8
+ RH-Bugzilla: 1860292
9
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
10
+ RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
11
+ RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
12
+ RH-Commit: [1/12] be551e83f426e620e673302198b51368bfd324ce (hreitz/qemu-kvm-c-9-s)
13
+
14
+ When a block driver supports obtaining format-specific information, but
15
+ that object only contains optional fields, it is possible that none of
16
+ them are present, so that dump_qobject() (called by
17
+ bdrv_image_info_specific_dump()) will not print anything.
18
+
19
+ The callers of bdrv_image_info_specific_dump() put a header above this
20
+ information ("Format specific information:\n"), which will look strange
21
+ when there is nothing below. Modify bdrv_image_info_specific_dump() to
22
+ print this header instead of its callers, and only if there is indeed
23
+ something to be printed.
24
+
25
+ Signed-off-by: Hanna Reitz <hreitz@redhat.com>
26
+ Message-Id: <20220620162704.80987-2-hreitz@redhat.com>
27
+ Reviewed-by: Kevin Wolf <kwolf@redhat.com>
28
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
29
+ (cherry picked from commit 3716470b24f0f63090d59bcf28ad8fe6fb7835bd)
30
+ Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
31
+ ---
32
+ block/qapi.c | 41 +++++++++++++++++++++++++++++++++++++----
33
+ include/block/qapi.h | 3 ++-
34
+ qemu-io-cmds.c | 4 ++--
35
+ 3 files changed, 41 insertions(+), 7 deletions(-)
36
+
37
+ diff --git a/block/qapi.c b/block/qapi.c
38
+ index cf557e3aea..51202b470a 100644
39
+ --- a/block/qapi.c
40
+ +++ b/block/qapi.c
41
+ @@ -777,7 +777,35 @@ static void dump_qdict(int indentation, QDict *dict)
42
+ }
43
+ }
44
+
45
+ -void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec)
46
+ +/*
47
+ + * Return whether dumping the given QObject with dump_qobject() would
48
+ + * yield an empty dump, i.e. not print anything.
49
+ + */
50
+ +static bool qobject_is_empty_dump(const QObject *obj)
51
+ +{
52
+ + switch (qobject_type(obj)) {
53
+ + case QTYPE_QNUM:
54
+ + case QTYPE_QSTRING:
55
+ + case QTYPE_QBOOL:
56
+ + return false;
57
+ +
58
+ + case QTYPE_QDICT:
59
+ + return qdict_size(qobject_to(QDict, obj)) == 0;
60
+ +
61
+ + case QTYPE_QLIST:
62
+ + return qlist_empty(qobject_to(QList, obj));
63
+ +
64
+ + default:
65
+ + abort();
66
+ + }
67
+ +}
68
+ +
69
+ +/**
70
+ + * Dumps the given ImageInfoSpecific object in a human-readable form,
71
+ + * prepending an optional prefix if the dump is not empty.
72
+ + */
73
+ +void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec,
74
+ + const char *prefix)
75
+ {
76
+ QObject *obj, *data;
77
+ Visitor *v = qobject_output_visitor_new(&obj);
78
+ @@ -785,7 +813,12 @@ void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec)
79
+ visit_type_ImageInfoSpecific(v, NULL, &info_spec, &error_abort);
80
+ visit_complete(v, &obj);
81
+ data = qdict_get(qobject_to(QDict, obj), "data");
82
+ - dump_qobject(1, data);
83
+ + if (!qobject_is_empty_dump(data)) {
84
+ + if (prefix) {
85
+ + qemu_printf("%s", prefix);
86
+ + }
87
+ + dump_qobject(1, data);
88
+ + }
89
+ qobject_unref(obj);
90
+ visit_free(v);
91
+ }
92
+ @@ -866,7 +899,7 @@ void bdrv_image_info_dump(ImageInfo *info)
93
+ }
94
+
95
+ if (info->has_format_specific) {
96
+ - qemu_printf("Format specific information:\n");
97
+ - bdrv_image_info_specific_dump(info->format_specific);
98
+ + bdrv_image_info_specific_dump(info->format_specific,
99
+ + "Format specific information:\n");
100
+ }
101
+ }
102
+ diff --git a/include/block/qapi.h b/include/block/qapi.h
103
+ index 22c7807c89..c09859ea78 100644
104
+ --- a/include/block/qapi.h
105
+ +++ b/include/block/qapi.h
106
+ @@ -40,6 +40,7 @@ void bdrv_query_image_info(BlockDriverState *bs,
107
+ Error **errp);
108
+
109
+ void bdrv_snapshot_dump(QEMUSnapshotInfo *sn);
110
+ -void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec);
111
+ +void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec,
112
+ + const char *prefix);
113
+ void bdrv_image_info_dump(ImageInfo *info);
114
+ #endif
115
+ diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
116
+ index 952dc940f1..f4a374528e 100644
117
+ --- a/qemu-io-cmds.c
118
+ +++ b/qemu-io-cmds.c
119
+ @@ -1825,8 +1825,8 @@ static int info_f(BlockBackend *blk, int argc, char **argv)
120
+ return -EIO;
121
+ }
122
+ if (spec_info) {
123
+ - printf("Format specific information:\n");
124
+ - bdrv_image_info_specific_dump(spec_info);
125
+ + bdrv_image_info_specific_dump(spec_info,
126
+ + "Format specific information:\n");
127
+ qapi_free_ImageInfoSpecific(spec_info);
128
+ }
129
+
130
+ --
131
+ 2.31.1
132
+
SOURCES/kvm-block-Inline-bdrv_drain_invoke.patch ADDED
@@ -0,0 +1,81 @@
1
+ From 1808e560396872173f787f8e338e9837a4c3d626 Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Fri, 18 Nov 2022 18:41:00 +0100
4
+ Subject: [PATCH 18/31] block: Inline bdrv_drain_invoke()
5
+
6
+ RH-Author: Stefano Garzarella <sgarzare@redhat.com>
7
+ RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
8
+ RH-Bugzilla: 2155112
9
+ RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
10
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
11
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
12
+ RH-Commit: [6/16] 2c7473a36360eb43d94b967deb12308cb5ea0d3b (sgarzarella/qemu-kvm-c-9-s)
13
+
14
+ bdrv_drain_invoke() has now two entirely separate cases that share no
15
+ code any more and are selected depending on a bool parameter. Each case
16
+ has only one caller. Just inline the function.
17
+
18
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
19
+ Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
20
+ Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
21
+ Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
22
+ Reviewed-by: Hanna Reitz <hreitz@redhat.com>
23
+ Message-Id: <20221118174110.55183-6-kwolf@redhat.com>
24
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
25
+ (cherry picked from commit c7bc05f78ab31fb02fc9635f60b9bd22efc8d121)
26
+ Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
27
+ ---
28
+ block/io.c | 23 ++++++-----------------
29
+ 1 file changed, 6 insertions(+), 17 deletions(-)
30
+
31
+ diff --git a/block/io.c b/block/io.c
32
+ index f4ca62b034..a25103be6f 100644
33
+ --- a/block/io.c
34
+ +++ b/block/io.c
35
+ @@ -242,21 +242,6 @@ typedef struct {
36
+ bool ignore_bds_parents;
37
+ } BdrvCoDrainData;
38
+
39
+ -/* Recursively call BlockDriver.bdrv_drain_begin/end callbacks */
40
+ -static void bdrv_drain_invoke(BlockDriverState *bs, bool begin)
41
+ -{
42
+ - if (!bs->drv || (begin && !bs->drv->bdrv_drain_begin) ||
43
+ - (!begin && !bs->drv->bdrv_drain_end)) {
44
+ - return;
45
+ - }
46
+ -
47
+ - if (begin) {
48
+ - bs->drv->bdrv_drain_begin(bs);
49
+ - } else {
50
+ - bs->drv->bdrv_drain_end(bs);
51
+ - }
52
+ -}
53
+ -
54
+ /* Returns true if BDRV_POLL_WHILE() should go into a blocking aio_poll() */
55
+ bool bdrv_drain_poll(BlockDriverState *bs, bool recursive,
56
+ BdrvChild *ignore_parent, bool ignore_bds_parents)
57
+ @@ -390,7 +375,9 @@ void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
58
+ }
59
+
60
+ bdrv_parent_drained_begin(bs, parent, ignore_bds_parents);
61
+ - bdrv_drain_invoke(bs, true);
62
+ + if (bs->drv && bs->drv->bdrv_drain_begin) {
63
+ + bs->drv->bdrv_drain_begin(bs);
64
+ + }
65
+ }
66
+
67
+ static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
68
+ @@ -461,7 +448,9 @@ static void bdrv_do_drained_end(BlockDriverState *bs, bool recursive,
69
+ assert(bs->quiesce_counter > 0);
70
+
71
+ /* Re-enable things in child-to-parent order */
72
+ - bdrv_drain_invoke(bs, false);
73
+ + if (bs->drv && bs->drv->bdrv_drain_end) {
74
+ + bs->drv->bdrv_drain_end(bs);
75
+ + }
76
+ bdrv_parent_drained_end(bs, parent, ignore_bds_parents);
77
+
78
+ old_quiesce_counter = qatomic_fetch_dec(&bs->quiesce_counter);
79
+ --
80
+ 2.31.1
81
+
SOURCES/kvm-block-Remove-drained_end_counter.patch ADDED
@@ -0,0 +1,433 @@
1
+ From 3009e49f242ab371ffad35bb29c2c26ddfac75d4 Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Fri, 18 Nov 2022 18:40:59 +0100
4
+ Subject: [PATCH 17/31] block: Remove drained_end_counter
5
+
6
+ RH-Author: Stefano Garzarella <sgarzare@redhat.com>
7
+ RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
8
+ RH-Bugzilla: 2155112
9
+ RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
10
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
11
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
12
+ RH-Commit: [5/16] 5589e3f05dece5394a05641f7f42096e8dc62bdb (sgarzarella/qemu-kvm-c-9-s)
13
+
14
+ drained_end_counter is unused now, nobody changes its value any more. It
15
+ can be removed.
16
+
17
+ In cases where we had two almost identical functions that only differed
18
+ in whether the caller passes drained_end_counter, or whether they would
19
+ poll for a local drained_end_counter to reach 0, these become a single
20
+ function.
21
+
22
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
23
+ Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
24
+ Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
25
+ Message-Id: <20221118174110.55183-5-kwolf@redhat.com>
26
+ Reviewed-by: Hanna Reitz <hreitz@redhat.com>
27
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
28
+ (cherry picked from commit 2f65df6e16dea2d6e7212fa675f4779d9281e26f)
29
+ Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
30
+ ---
31
+ block.c | 5 +-
32
+ block/block-backend.c | 4 +-
33
+ block/io.c | 98 ++++++++------------------------
34
+ blockjob.c | 2 +-
35
+ include/block/block-io.h | 24 --------
36
+ include/block/block_int-common.h | 6 +-
37
+ 6 files changed, 30 insertions(+), 109 deletions(-)
38
+
39
+ diff --git a/block.c b/block.c
40
+ index 16a62a329c..7999fd08c5 100644
41
+ --- a/block.c
42
+ +++ b/block.c
43
+ @@ -1235,11 +1235,10 @@ static bool bdrv_child_cb_drained_poll(BdrvChild *child)
44
+ return bdrv_drain_poll(bs, false, NULL, false);
45
+ }
46
+
47
+ -static void bdrv_child_cb_drained_end(BdrvChild *child,
48
+ - int *drained_end_counter)
49
+ +static void bdrv_child_cb_drained_end(BdrvChild *child)
50
+ {
51
+ BlockDriverState *bs = child->opaque;
52
+ - bdrv_drained_end_no_poll(bs, drained_end_counter);
53
+ + bdrv_drained_end(bs);
54
+ }
55
+
56
+ static int bdrv_child_cb_inactivate(BdrvChild *child)
57
+ diff --git a/block/block-backend.c b/block/block-backend.c
58
+ index d98a96ff37..feaf2181fa 100644
59
+ --- a/block/block-backend.c
60
+ +++ b/block/block-backend.c
61
+ @@ -129,7 +129,7 @@ static void blk_root_inherit_options(BdrvChildRole role, bool parent_is_format,
62
+ }
63
+ static void blk_root_drained_begin(BdrvChild *child);
64
+ static bool blk_root_drained_poll(BdrvChild *child);
65
+ -static void blk_root_drained_end(BdrvChild *child, int *drained_end_counter);
66
+ +static void blk_root_drained_end(BdrvChild *child);
67
+
68
+ static void blk_root_change_media(BdrvChild *child, bool load);
69
+ static void blk_root_resize(BdrvChild *child);
70
+ @@ -2556,7 +2556,7 @@ static bool blk_root_drained_poll(BdrvChild *child)
71
+ return busy || !!blk->in_flight;
72
+ }
73
+
74
+ -static void blk_root_drained_end(BdrvChild *child, int *drained_end_counter)
75
+ +static void blk_root_drained_end(BdrvChild *child)
76
+ {
77
+ BlockBackend *blk = child->opaque;
78
+ assert(blk->quiesce_counter);
79
+ diff --git a/block/io.c b/block/io.c
80
+ index c2ed4b2af9..f4ca62b034 100644
81
+ --- a/block/io.c
82
+ +++ b/block/io.c
83
+ @@ -58,28 +58,19 @@ static void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore,
84
+ }
85
+ }
86
+
87
+ -static void bdrv_parent_drained_end_single_no_poll(BdrvChild *c,
88
+ - int *drained_end_counter)
89
+ +void bdrv_parent_drained_end_single(BdrvChild *c)
90
+ {
91
+ + IO_OR_GS_CODE();
92
+ +
93
+ assert(c->parent_quiesce_counter > 0);
94
+ c->parent_quiesce_counter--;
95
+ if (c->klass->drained_end) {
96
+ - c->klass->drained_end(c, drained_end_counter);
97
+ + c->klass->drained_end(c);
98
+ }
99
+ }
100
+
101
+ -void bdrv_parent_drained_end_single(BdrvChild *c)
102
+ -{
103
+ - int drained_end_counter = 0;
104
+ - AioContext *ctx = bdrv_child_get_parent_aio_context(c);
105
+ - IO_OR_GS_CODE();
106
+ - bdrv_parent_drained_end_single_no_poll(c, &drained_end_counter);
107
+ - AIO_WAIT_WHILE(ctx, qatomic_read(&drained_end_counter) > 0);
108
+ -}
109
+ -
110
+ static void bdrv_parent_drained_end(BlockDriverState *bs, BdrvChild *ignore,
111
+ - bool ignore_bds_parents,
112
+ - int *drained_end_counter)
113
+ + bool ignore_bds_parents)
114
+ {
115
+ BdrvChild *c;
116
+
117
+ @@ -87,7 +78,7 @@ static void bdrv_parent_drained_end(BlockDriverState *bs, BdrvChild *ignore,
118
+ if (c == ignore || (ignore_bds_parents && c->klass->parent_is_bds)) {
119
+ continue;
120
+ }
121
+ - bdrv_parent_drained_end_single_no_poll(c, drained_end_counter);
122
+ + bdrv_parent_drained_end_single(c);
123
+ }
124
+ }
125
+
126
+ @@ -249,12 +240,10 @@ typedef struct {
127
+ bool poll;
128
+ BdrvChild *parent;
129
+ bool ignore_bds_parents;
130
+ - int *drained_end_counter;
131
+ } BdrvCoDrainData;
132
+
133
+ /* Recursively call BlockDriver.bdrv_drain_begin/end callbacks */
134
+ -static void bdrv_drain_invoke(BlockDriverState *bs, bool begin,
135
+ - int *drained_end_counter)
136
+ +static void bdrv_drain_invoke(BlockDriverState *bs, bool begin)
137
+ {
138
+ if (!bs->drv || (begin && !bs->drv->bdrv_drain_begin) ||
139
+ (!begin && !bs->drv->bdrv_drain_end)) {
140
+ @@ -305,8 +294,7 @@ static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
141
+ BdrvChild *parent, bool ignore_bds_parents,
142
+ bool poll);
143
+ static void bdrv_do_drained_end(BlockDriverState *bs, bool recursive,
144
+ - BdrvChild *parent, bool ignore_bds_parents,
145
+ - int *drained_end_counter);
146
+ + BdrvChild *parent, bool ignore_bds_parents);
147
+
148
+ static void bdrv_co_drain_bh_cb(void *opaque)
149
+ {
150
+ @@ -319,14 +307,12 @@ static void bdrv_co_drain_bh_cb(void *opaque)
151
+ aio_context_acquire(ctx);
152
+ bdrv_dec_in_flight(bs);
153
+ if (data->begin) {
154
+ - assert(!data->drained_end_counter);
155
+ bdrv_do_drained_begin(bs, data->recursive, data->parent,
156
+ data->ignore_bds_parents, data->poll);
157
+ } else {
158
+ assert(!data->poll);
159
+ bdrv_do_drained_end(bs, data->recursive, data->parent,
160
+ - data->ignore_bds_parents,
161
+ - data->drained_end_counter);
162
+ + data->ignore_bds_parents);
163
+ }
164
+ aio_context_release(ctx);
165
+ } else {
166
+ @@ -342,8 +328,7 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
167
+ bool begin, bool recursive,
168
+ BdrvChild *parent,
169
+ bool ignore_bds_parents,
170
+ - bool poll,
171
+ - int *drained_end_counter)
172
+ + bool poll)
173
+ {
174
+ BdrvCoDrainData data;
175
+ Coroutine *self = qemu_coroutine_self();
176
+ @@ -363,7 +348,6 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
177
+ .parent = parent,
178
+ .ignore_bds_parents = ignore_bds_parents,
179
+ .poll = poll,
180
+ - .drained_end_counter = drained_end_counter,
181
+ };
182
+
183
+ if (bs) {
184
+ @@ -406,7 +390,7 @@ void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
185
+ }
186
+
187
+ bdrv_parent_drained_begin(bs, parent, ignore_bds_parents);
188
+ - bdrv_drain_invoke(bs, true, NULL);
189
+ + bdrv_drain_invoke(bs, true);
190
+ }
191
+
192
+ static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
193
+ @@ -417,7 +401,7 @@ static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
194
+
195
+ if (qemu_in_coroutine()) {
196
+ bdrv_co_yield_to_drain(bs, true, recursive, parent, ignore_bds_parents,
197
+ - poll, NULL);
198
+ + poll);
199
+ return;
200
+ }
201
+
202
+ @@ -461,38 +445,24 @@ void bdrv_subtree_drained_begin(BlockDriverState *bs)
203
+
204
+ /**
205
+ * This function does not poll, nor must any of its recursively called
206
+ - * functions. The *drained_end_counter pointee will be incremented
207
+ - * once for every background operation scheduled, and decremented once
208
+ - * the operation settles. Therefore, the pointer must remain valid
209
+ - * until the pointee reaches 0. That implies that whoever sets up the
210
+ - * pointee has to poll until it is 0.
211
+ - *
212
+ - * We use atomic operations to access *drained_end_counter, because
213
+ - * (1) when called from bdrv_set_aio_context_ignore(), the subgraph of
214
+ - * @bs may contain nodes in different AioContexts,
215
+ - * (2) bdrv_drain_all_end() uses the same counter for all nodes,
216
+ - * regardless of which AioContext they are in.
217
+ + * functions.
218
+ */
219
+ static void bdrv_do_drained_end(BlockDriverState *bs, bool recursive,
220
+ - BdrvChild *parent, bool ignore_bds_parents,
221
+ - int *drained_end_counter)
222
+ + BdrvChild *parent, bool ignore_bds_parents)
223
+ {
224
+ BdrvChild *child;
225
+ int old_quiesce_counter;
226
+
227
+ - assert(drained_end_counter != NULL);
228
+ -
229
+ if (qemu_in_coroutine()) {
230
+ bdrv_co_yield_to_drain(bs, false, recursive, parent, ignore_bds_parents,
231
+ - false, drained_end_counter);
232
+ + false);
233
+ return;
234
+ }
235
+ assert(bs->quiesce_counter > 0);
236
+
237
+ /* Re-enable things in child-to-parent order */
238
+ - bdrv_drain_invoke(bs, false, drained_end_counter);
239
+ - bdrv_parent_drained_end(bs, parent, ignore_bds_parents,
240
+ - drained_end_counter);
241
+ + bdrv_drain_invoke(bs, false);
242
+ + bdrv_parent_drained_end(bs, parent, ignore_bds_parents);
243
+
244
+ old_quiesce_counter = qatomic_fetch_dec(&bs->quiesce_counter);
245
+ if (old_quiesce_counter == 1) {
246
+ @@ -503,32 +473,21 @@ static void bdrv_do_drained_end(BlockDriverState *bs, bool recursive,
247
+ assert(!ignore_bds_parents);
248
+ bs->recursive_quiesce_counter--;
249
+ QLIST_FOREACH(child, &bs->children, next) {
250
+ - bdrv_do_drained_end(child->bs, true, child, ignore_bds_parents,
251
+ - drained_end_counter);
252
+ + bdrv_do_drained_end(child->bs, true, child, ignore_bds_parents);
253
+ }
254
+ }
255
+ }
256
+
257
+ void bdrv_drained_end(BlockDriverState *bs)
258
+ {
259
+ - int drained_end_counter = 0;
260
+ IO_OR_GS_CODE();
261
+ - bdrv_do_drained_end(bs, false, NULL, false, &drained_end_counter);
262
+ - BDRV_POLL_WHILE(bs, qatomic_read(&drained_end_counter) > 0);
263
+ -}
264
+ -
265
+ -void bdrv_drained_end_no_poll(BlockDriverState *bs, int *drained_end_counter)
266
+ -{
267
+ - IO_CODE();
268
+ - bdrv_do_drained_end(bs, false, NULL, false, drained_end_counter);
269
+ + bdrv_do_drained_end(bs, false, NULL, false);
270
+ }
271
+
272
+ void bdrv_subtree_drained_end(BlockDriverState *bs)
273
+ {
274
+ - int drained_end_counter = 0;
275
+ IO_OR_GS_CODE();
276
+ - bdrv_do_drained_end(bs, true, NULL, false, &drained_end_counter);
277
+ - BDRV_POLL_WHILE(bs, qatomic_read(&drained_end_counter) > 0);
278
+ + bdrv_do_drained_end(bs, true, NULL, false);
279
+ }
280
+
281
+ void bdrv_apply_subtree_drain(BdrvChild *child, BlockDriverState *new_parent)
282
+ @@ -543,16 +502,12 @@ void bdrv_apply_subtree_drain(BdrvChild *child, BlockDriverState *new_parent)
283
+
284
+ void bdrv_unapply_subtree_drain(BdrvChild *child, BlockDriverState *old_parent)
285
+ {
286
+ - int drained_end_counter = 0;
287
+ int i;
288
+ IO_OR_GS_CODE();
289
+
290
+ for (i = 0; i < old_parent->recursive_quiesce_counter; i++) {
291
+ - bdrv_do_drained_end(child->bs, true, child, false,
292
+ - &drained_end_counter);
293
+ + bdrv_do_drained_end(child->bs, true, child, false);
294
+ }
295
+ -
296
+ - BDRV_POLL_WHILE(child->bs, qatomic_read(&drained_end_counter) > 0);
297
+ }
298
+
299
+ void bdrv_drain(BlockDriverState *bs)
300
+ @@ -610,7 +565,7 @@ void bdrv_drain_all_begin(void)
301
+ GLOBAL_STATE_CODE();
302
+
303
+ if (qemu_in_coroutine()) {
304
+ - bdrv_co_yield_to_drain(NULL, true, false, NULL, true, true, NULL);
305
+ + bdrv_co_yield_to_drain(NULL, true, false, NULL, true, true);
306
+ return;
307
+ }
308
+
309
+ @@ -649,22 +604,19 @@ void bdrv_drain_all_begin(void)
310
+
311
+ void bdrv_drain_all_end_quiesce(BlockDriverState *bs)
312
+ {
313
+ - int drained_end_counter = 0;
314
+ GLOBAL_STATE_CODE();
315
+
316
+ g_assert(bs->quiesce_counter > 0);
317
+ g_assert(!bs->refcnt);
318
+
319
+ while (bs->quiesce_counter) {
320
+ - bdrv_do_drained_end(bs, false, NULL, true, &drained_end_counter);
321
+ + bdrv_do_drained_end(bs, false, NULL, true);
322
+ }
323
+ - BDRV_POLL_WHILE(bs, qatomic_read(&drained_end_counter) > 0);
324
+ }
325
+
326
+ void bdrv_drain_all_end(void)
327
+ {
328
+ BlockDriverState *bs = NULL;
329
+ - int drained_end_counter = 0;
330
+ GLOBAL_STATE_CODE();
331
+
332
+ /*
333
+ @@ -680,13 +632,11 @@ void bdrv_drain_all_end(void)
334
+ AioContext *aio_context = bdrv_get_aio_context(bs);
335
+
336
+ aio_context_acquire(aio_context);
337
+ - bdrv_do_drained_end(bs, false, NULL, true, &drained_end_counter);
338
+ + bdrv_do_drained_end(bs, false, NULL, true);
339
+ aio_context_release(aio_context);
340
+ }
341
+
342
+ assert(qemu_get_current_aio_context() == qemu_get_aio_context());
343
+ - AIO_WAIT_WHILE(NULL, qatomic_read(&drained_end_counter) > 0);
344
+ -
345
+ assert(bdrv_drain_all_count > 0);
346
+ bdrv_drain_all_count--;
347
+ }
348
+ diff --git a/blockjob.c b/blockjob.c
349
+ index f51d4e18f3..0ab721e139 100644
350
+ --- a/blockjob.c
351
+ +++ b/blockjob.c
352
+ @@ -120,7 +120,7 @@ static bool child_job_drained_poll(BdrvChild *c)
353
+ }
354
+ }
355
+
356
+ -static void child_job_drained_end(BdrvChild *c, int *drained_end_counter)
357
+ +static void child_job_drained_end(BdrvChild *c)
358
+ {
359
+ BlockJob *job = c->opaque;
360
+ job_resume(&job->job);
361
+ diff --git a/include/block/block-io.h b/include/block/block-io.h
362
+ index b099d7db45..054e964c9b 100644
363
+ --- a/include/block/block-io.h
364
+ +++ b/include/block/block-io.h
365
+ @@ -237,21 +237,6 @@ int coroutine_fn bdrv_co_copy_range(BdrvChild *src, int64_t src_offset,
366
+ int64_t bytes, BdrvRequestFlags read_flags,
367
+ BdrvRequestFlags write_flags);
368
+
369
+ -/**
370
+ - * bdrv_drained_end_no_poll:
371
+ - *
372
+ - * Same as bdrv_drained_end(), but do not poll for the subgraph to
373
+ - * actually become unquiesced. Therefore, no graph changes will occur
374
+ - * with this function.
375
+ - *
376
+ - * *drained_end_counter is incremented for every background operation
377
+ - * that is scheduled, and will be decremented for every operation once
378
+ - * it settles. The caller must poll until it reaches 0. The counter
379
+ - * should be accessed using atomic operations only.
380
+ - */
381
+ -void bdrv_drained_end_no_poll(BlockDriverState *bs, int *drained_end_counter);
382
+ -
383
+ -
384
+ /*
385
+ * "I/O or GS" API functions. These functions can run without
386
+ * the BQL, but only in one specific iothread/main loop.
387
+ @@ -311,9 +296,6 @@ void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll);
388
+ * bdrv_parent_drained_end_single:
389
+ *
390
+ * End a quiesced section for the parent of @c.
391
+ - *
392
+ - * This polls @bs's AioContext until all scheduled sub-drained_ends
393
+ - * have settled, which may result in graph changes.
394
+ */
395
+ void bdrv_parent_drained_end_single(BdrvChild *c);
396
+
397
+ @@ -361,12 +343,6 @@ void bdrv_subtree_drained_begin(BlockDriverState *bs);
398
+ * bdrv_drained_end:
399
+ *
400
+ * End a quiescent section started by bdrv_drained_begin().
401
+ - *
402
+ - * This polls @bs's AioContext until all scheduled sub-drained_ends
403
+ - * have settled. On one hand, that may result in graph changes. On
404
+ - * the other, this requires that the caller either runs in the main
405
+ - * loop; or that all involved nodes (@bs and all of its parents) are
406
+ - * in the caller's AioContext.
407
+ */
408
+ void bdrv_drained_end(BlockDriverState *bs);
409
+
410
+ diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
411
+ index 40d646d1ed..2b97576f6d 100644
412
+ --- a/include/block/block_int-common.h
413
+ +++ b/include/block/block_int-common.h
414
+ @@ -939,15 +939,11 @@ struct BdrvChildClass {
415
+ * These functions must not change the graph (and therefore also must not
416
+ * call aio_poll(), which could change the graph indirectly).
417
+ *
418
+ - * If drained_end() schedules background operations, it must atomically
419
+ - * increment *drained_end_counter for each such operation and atomically
420
+ - * decrement it once the operation has settled.
421
+ - *
422
+ * Note that this can be nested. If drained_begin() was called twice, new
423
+ * I/O is allowed only after drained_end() was called twice, too.
424
+ */
425
+ void (*drained_begin)(BdrvChild *child);
426
+ - void (*drained_end)(BdrvChild *child, int *drained_end_counter);
427
+ + void (*drained_end)(BdrvChild *child);
428
+
429
+ /*
430
+ * Returns whether the parent has pending requests for the child. This
431
+ --
432
+ 2.31.1
433
+
SOURCES/kvm-block-Remove-ignore_bds_parents-parameter-from-drain.patch ADDED
@@ -0,0 +1,274 @@
1
+ From 0dc7990533cef41e58579ee96315aca1fdc44ea1 Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Fri, 18 Nov 2022 18:41:07 +0100
4
+ Subject: [PATCH 25/31] block: Remove ignore_bds_parents parameter from
5
+ drain_begin/end.
6
+
7
+ RH-Author: Stefano Garzarella <sgarzare@redhat.com>
8
+ RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
9
+ RH-Bugzilla: 2155112
10
+ RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
11
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
12
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
13
+ RH-Commit: [13/16] 1ed88d975a9569bffeb33ad847874417780ce408 (sgarzarella/qemu-kvm-c-9-s)
14
+
15
+ ignore_bds_parents is now ignored during drain_begin and drain_end, so
16
+ we can just remove it there. It is still a valid optimisation for
17
+ drain_all in bdrv_drained_poll(), so leave it around there.
18
+
19
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
20
+ Message-Id: <20221118174110.55183-13-kwolf@redhat.com>
21
+ Reviewed-by: Hanna Reitz <hreitz@redhat.com>
22
+ Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
23
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
24
+ (cherry picked from commit a82a3bd135078d14f1bb4b5e50f51e77d3748270)
25
+ Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
26
+ ---
27
+ block.c | 2 +-
28
+ block/io.c | 58 +++++++++++++++-------------------------
29
+ include/block/block-io.h | 3 +--
30
+ 3 files changed, 24 insertions(+), 39 deletions(-)
31
+
32
+ diff --git a/block.c b/block.c
33
+ index 5a583e260d..af31a94863 100644
34
+ --- a/block.c
35
+ +++ b/block.c
36
+ @@ -1226,7 +1226,7 @@ static char *bdrv_child_get_parent_desc(BdrvChild *c)
37
+ static void bdrv_child_cb_drained_begin(BdrvChild *child)
38
+ {
39
+ BlockDriverState *bs = child->opaque;
40
+ - bdrv_do_drained_begin_quiesce(bs, NULL, false);
41
+ + bdrv_do_drained_begin_quiesce(bs, NULL);
42
+ }
43
+
44
+ static bool bdrv_child_cb_drained_poll(BdrvChild *child)
45
+ diff --git a/block/io.c b/block/io.c
46
+ index 87d6f22ec4..2e9503df6a 100644
47
+ --- a/block/io.c
48
+ +++ b/block/io.c
49
+ @@ -45,13 +45,12 @@ static void bdrv_parent_cb_resize(BlockDriverState *bs);
50
+ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
51
+ int64_t offset, int64_t bytes, BdrvRequestFlags flags);
52
+
53
+ -static void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore,
54
+ - bool ignore_bds_parents)
55
+ +static void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore)
56
+ {
57
+ BdrvChild *c, *next;
58
+
59
+ QLIST_FOREACH_SAFE(c, &bs->parents, next_parent, next) {
60
+ - if (c == ignore || (ignore_bds_parents && c->klass->parent_is_bds)) {
61
+ + if (c == ignore) {
62
+ continue;
63
+ }
64
+ bdrv_parent_drained_begin_single(c, false);
65
+ @@ -70,13 +69,12 @@ void bdrv_parent_drained_end_single(BdrvChild *c)
66
+ }
67
+ }
68
+
69
+ -static void bdrv_parent_drained_end(BlockDriverState *bs, BdrvChild *ignore,
70
+ - bool ignore_bds_parents)
71
+ +static void bdrv_parent_drained_end(BlockDriverState *bs, BdrvChild *ignore)
72
+ {
73
+ BdrvChild *c;
74
+
75
+ QLIST_FOREACH(c, &bs->parents, next_parent) {
76
+ - if (c == ignore || (ignore_bds_parents && c->klass->parent_is_bds)) {
77
+ + if (c == ignore) {
78
+ continue;
79
+ }
80
+ bdrv_parent_drained_end_single(c);
81
+ @@ -242,7 +240,6 @@ typedef struct {
82
+ bool begin;
83
+ bool poll;
84
+ BdrvChild *parent;
85
+ - bool ignore_bds_parents;
86
+ } BdrvCoDrainData;
87
+
88
+ /* Returns true if BDRV_POLL_WHILE() should go into a blocking aio_poll() */
89
+ @@ -269,9 +266,8 @@ static bool bdrv_drain_poll_top_level(BlockDriverState *bs,
90
+ }
91
+
92
+ static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
93
+ - bool ignore_bds_parents, bool poll);
94
+ -static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent,
95
+ - bool ignore_bds_parents);
96
+ + bool poll);
97
+ +static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent);
98
+
99
+ static void bdrv_co_drain_bh_cb(void *opaque)
100
+ {
101
+ @@ -284,11 +280,10 @@ static void bdrv_co_drain_bh_cb(void *opaque)
102
+ aio_context_acquire(ctx);
103
+ bdrv_dec_in_flight(bs);
104
+ if (data->begin) {
105
+ - bdrv_do_drained_begin(bs, data->parent, data->ignore_bds_parents,
106
+ - data->poll);
107
+ + bdrv_do_drained_begin(bs, data->parent, data->poll);
108
+ } else {
109
+ assert(!data->poll);
110
+ - bdrv_do_drained_end(bs, data->parent, data->ignore_bds_parents);
111
+ + bdrv_do_drained_end(bs, data->parent);
112
+ }
113
+ aio_context_release(ctx);
114
+ } else {
115
+ @@ -303,7 +298,6 @@ static void bdrv_co_drain_bh_cb(void *opaque)
116
+ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
117
+ bool begin,
118
+ BdrvChild *parent,
119
+ - bool ignore_bds_parents,
120
+ bool poll)
121
+ {
122
+ BdrvCoDrainData data;
123
+ @@ -321,7 +315,6 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
124
+ .done = false,
125
+ .begin = begin,
126
+ .parent = parent,
127
+ - .ignore_bds_parents = ignore_bds_parents,
128
+ .poll = poll,
129
+ };
130
+
131
+ @@ -353,8 +346,7 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
132
+ }
133
+ }
134
+
135
+ -void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
136
+ - BdrvChild *parent, bool ignore_bds_parents)
137
+ +void bdrv_do_drained_begin_quiesce(BlockDriverState *bs, BdrvChild *parent)
138
+ {
139
+ IO_OR_GS_CODE();
140
+ assert(!qemu_in_coroutine());
141
+ @@ -362,9 +354,7 @@ void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
142
+ /* Stop things in parent-to-child order */
143
+ if (qatomic_fetch_inc(&bs->quiesce_counter) == 0) {
144
+ aio_disable_external(bdrv_get_aio_context(bs));
145
+ -
146
+ - /* TODO Remove ignore_bds_parents, we don't consider it any more */
147
+ - bdrv_parent_drained_begin(bs, parent, false);
148
+ + bdrv_parent_drained_begin(bs, parent);
149
+ if (bs->drv && bs->drv->bdrv_drain_begin) {
150
+ bs->drv->bdrv_drain_begin(bs);
151
+ }
152
+ @@ -372,14 +362,14 @@ void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
153
+ }
154
+
155
+ static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
156
+ - bool ignore_bds_parents, bool poll)
157
+ + bool poll)
158
+ {
159
+ if (qemu_in_coroutine()) {
160
+ - bdrv_co_yield_to_drain(bs, true, parent, ignore_bds_parents, poll);
161
+ + bdrv_co_yield_to_drain(bs, true, parent, poll);
162
+ return;
163
+ }
164
+
165
+ - bdrv_do_drained_begin_quiesce(bs, parent, ignore_bds_parents);
166
+ + bdrv_do_drained_begin_quiesce(bs, parent);
167
+
168
+ /*
169
+ * Wait for drained requests to finish.
170
+ @@ -391,7 +381,6 @@ static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
171
+ * nodes.
172
+ */
173
+ if (poll) {
174
+ - assert(!ignore_bds_parents);
175
+ BDRV_POLL_WHILE(bs, bdrv_drain_poll_top_level(bs, parent));
176
+ }
177
+ }
178
+ @@ -399,20 +388,19 @@ static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
179
+ void bdrv_drained_begin(BlockDriverState *bs)
180
+ {
181
+ IO_OR_GS_CODE();
182
+ - bdrv_do_drained_begin(bs, NULL, false, true);
183
+ + bdrv_do_drained_begin(bs, NULL, true);
184
+ }
185
+
186
+ /**
187
+ * This function does not poll, nor must any of its recursively called
188
+ * functions.
189
+ */
190
+ -static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent,
191
+ - bool ignore_bds_parents)
192
+ +static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent)
193
+ {
194
+ int old_quiesce_counter;
195
+
196
+ if (qemu_in_coroutine()) {
197
+ - bdrv_co_yield_to_drain(bs, false, parent, ignore_bds_parents, false);
198
+ + bdrv_co_yield_to_drain(bs, false, parent, false);
199
+ return;
200
+ }
201
+ assert(bs->quiesce_counter > 0);
202
+ @@ -423,9 +411,7 @@ static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent,
203
+ if (bs->drv && bs->drv->bdrv_drain_end) {
204
+ bs->drv->bdrv_drain_end(bs);
205
+ }
206
+ - /* TODO Remove ignore_bds_parents, we don't consider it any more */
207
+ - bdrv_parent_drained_end(bs, parent, false);
208
+ -
209
+ + bdrv_parent_drained_end(bs, parent);
210
+ aio_enable_external(bdrv_get_aio_context(bs));
211
+ }
212
+ }
213
+ @@ -433,7 +419,7 @@ static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent,
214
+ void bdrv_drained_end(BlockDriverState *bs)
215
+ {
216
+ IO_OR_GS_CODE();
217
+ - bdrv_do_drained_end(bs, NULL, false);
218
+ + bdrv_do_drained_end(bs, NULL);
219
+ }
220
+
221
+ void bdrv_drain(BlockDriverState *bs)
222
+ @@ -491,7 +477,7 @@ void bdrv_drain_all_begin(void)
223
+ GLOBAL_STATE_CODE();
224
+
225
+ if (qemu_in_coroutine()) {
226
+ - bdrv_co_yield_to_drain(NULL, true, NULL, true, true);
227
+ + bdrv_co_yield_to_drain(NULL, true, NULL, true);
228
+ return;
229
+ }
230
+
231
+ @@ -516,7 +502,7 @@ void bdrv_drain_all_begin(void)
232
+ AioContext *aio_context = bdrv_get_aio_context(bs);
233
+
234
+ aio_context_acquire(aio_context);
235
+ - bdrv_do_drained_begin(bs, NULL, true, false);
236
+ + bdrv_do_drained_begin(bs, NULL, false);
237
+ aio_context_release(aio_context);
238
+ }
239
+
240
+ @@ -536,7 +522,7 @@ void bdrv_drain_all_end_quiesce(BlockDriverState *bs)
241
+ g_assert(!bs->refcnt);
242
+
243
+ while (bs->quiesce_counter) {
244
+ - bdrv_do_drained_end(bs, NULL, true);
245
+ + bdrv_do_drained_end(bs, NULL);
246
+ }
247
+ }
248
+
249
+ @@ -558,7 +544,7 @@ void bdrv_drain_all_end(void)
250
+ AioContext *aio_context = bdrv_get_aio_context(bs);
251
+
252
+ aio_context_acquire(aio_context);
253
+ - bdrv_do_drained_end(bs, NULL, true);
254
+ + bdrv_do_drained_end(bs, NULL);
255
+ aio_context_release(aio_context);
256
+ }
257
+
258
+ diff --git a/include/block/block-io.h b/include/block/block-io.h
259
+ index 9c36a16a1f..8f5e75756a 100644
260
+ --- a/include/block/block-io.h
261
+ +++ b/include/block/block-io.h
262
+ @@ -329,8 +329,7 @@ void bdrv_drained_begin(BlockDriverState *bs);
263
+ * Quiesces a BDS like bdrv_drained_begin(), but does not wait for already
264
+ * running requests to complete.
265
+ */
266
+ -void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
267
+ - BdrvChild *parent, bool ignore_bds_parents);
268
+ +void bdrv_do_drained_begin_quiesce(BlockDriverState *bs, BdrvChild *parent);
269
+
270
+ /**
271
+ * bdrv_drained_end:
272
+ --
273
+ 2.31.1
274
+
SOURCES/kvm-block-Remove-poll-parameter-from-bdrv_parent_drained.patch ADDED
@@ -0,0 +1,106 @@
1
+ From 60b66881fb972e1cdff1cd7b4c865e5e21c141b0 Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Fri, 18 Nov 2022 18:41:10 +0100
4
+ Subject: [PATCH 28/31] block: Remove poll parameter from
5
+ bdrv_parent_drained_begin_single()
6
+
7
+ RH-Author: Stefano Garzarella <sgarzare@redhat.com>
8
+ RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
9
+ RH-Bugzilla: 2155112
10
+ RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
11
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
12
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
13
+ RH-Commit: [16/16] fd526cc9e5bebeb256cfa56d23ec596f26caa37a (sgarzarella/qemu-kvm-c-9-s)
14
+
15
+ All callers of bdrv_parent_drained_begin_single() pass poll=false now,
16
+ so we don't need the parameter any more.
17
+
18
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
19
+ Message-Id: <20221118174110.55183-16-kwolf@redhat.com>
20
+ Reviewed-by: Hanna Reitz <hreitz@redhat.com>
21
+ Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
22
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
23
+ (cherry picked from commit 606ed756c1d69cba4822be8923248d2fd714f069)
24
+ Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
25
+ ---
26
+ block.c | 4 ++--
27
+ block/io.c | 8 ++------
28
+ include/block/block-io.h | 5 ++---
29
+ 3 files changed, 6 insertions(+), 11 deletions(-)
30
+
31
+ diff --git a/block.c b/block.c
32
+ index 65588d313a..0d78711416 100644
33
+ --- a/block.c
34
+ +++ b/block.c
35
+ @@ -2417,7 +2417,7 @@ static void bdrv_replace_child_abort(void *opaque)
36
+ * new_bs drained when calling bdrv_replace_child_tran() is not a
37
+ * requirement any more.
38
+ */
39
+ - bdrv_parent_drained_begin_single(s->child, false);
40
+ + bdrv_parent_drained_begin_single(s->child);
41
+ assert(!bdrv_parent_drained_poll_single(s->child));
42
+ }
43
+ assert(s->child->quiesced_parent);
44
+ @@ -3059,7 +3059,7 @@ static BdrvChild *bdrv_attach_child_common(BlockDriverState *child_bs,
45
+ * a problem, we already did this), but it will still poll until the parent
46
+ * is fully quiesced, so it will not be negatively affected either.
47
+ */
48
+ - bdrv_parent_drained_begin_single(new_child, false);
49
+ + bdrv_parent_drained_begin_single(new_child);
50
+ bdrv_replace_child_noperm(new_child, child_bs);
51
+
52
+ BdrvAttachChildCommonState *s = g_new(BdrvAttachChildCommonState, 1);
53
+ diff --git a/block/io.c b/block/io.c
54
+ index ae64830eac..38e57d1f67 100644
55
+ --- a/block/io.c
56
+ +++ b/block/io.c
57
+ @@ -53,7 +53,7 @@ static void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore)
58
+ if (c == ignore) {
59
+ continue;
60
+ }
61
+ - bdrv_parent_drained_begin_single(c, false);
62
+ + bdrv_parent_drained_begin_single(c);
63
+ }
64
+ }
65
+
66
+ @@ -105,9 +105,8 @@ static bool bdrv_parent_drained_poll(BlockDriverState *bs, BdrvChild *ignore,
67
+ return busy;
68
+ }
69
+
70
+ -void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll)
71
+ +void bdrv_parent_drained_begin_single(BdrvChild *c)
72
+ {
73
+ - AioContext *ctx = bdrv_child_get_parent_aio_context(c);
74
+ IO_OR_GS_CODE();
75
+
76
+ assert(!c->quiesced_parent);
77
+ @@ -116,9 +115,6 @@ void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll)
78
+ if (c->klass->drained_begin) {
79
+ c->klass->drained_begin(c);
80
+ }
81
+ - if (poll) {
82
+ - AIO_WAIT_WHILE(ctx, bdrv_parent_drained_poll_single(c));
83
+ - }
84
+ }
85
+
86
+ static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src)
87
+ diff --git a/include/block/block-io.h b/include/block/block-io.h
88
+ index 65e6d2569b..92aaa7c1e9 100644
89
+ --- a/include/block/block-io.h
90
+ +++ b/include/block/block-io.h
91
+ @@ -287,10 +287,9 @@ bdrv_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos);
92
+ /**
93
+ * bdrv_parent_drained_begin_single:
94
+ *
95
+ - * Begin a quiesced section for the parent of @c. If @poll is true, wait for
96
+ - * any pending activity to cease.
97
+ + * Begin a quiesced section for the parent of @c.
98
+ */
99
+ -void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll);
100
+ +void bdrv_parent_drained_begin_single(BdrvChild *c);
101
+
102
+ /**
103
+ * bdrv_parent_drained_poll_single:
104
+ --
105
+ 2.31.1
106
+
SOURCES/kvm-block-Remove-subtree-drains.patch ADDED
@@ -0,0 +1,896 @@
1
+ From 79063522861cb2baf921b204bcdf4c3bfb5697f4 Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Fri, 18 Nov 2022 18:41:05 +0100
4
+ Subject: [PATCH 23/31] block: Remove subtree drains
5
+
6
+ RH-Author: Stefano Garzarella <sgarzare@redhat.com>
7
+ RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
8
+ RH-Bugzilla: 2155112
9
+ RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
10
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
11
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
12
+ RH-Commit: [11/16] d92f5041cceeeec49a65441b22d20f692c0f1c77 (sgarzarella/qemu-kvm-c-9-s)
13
+
14
+ Subtree drains are not used any more. Remove them.
15
+
16
+ After this, BdrvChildClass.attach/detach() don't poll any more.
17
+
18
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
19
+ Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
20
+ Reviewed-by: Hanna Reitz <hreitz@redhat.com>
21
+ Message-Id: <20221118174110.55183-11-kwolf@redhat.com>
22
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
23
+ (cherry picked from commit 299403aedaeb7f08d8e98aa8614b29d4e5546066)
24
+ Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
25
+ ---
26
+ block.c | 20 +--
27
+ block/io.c | 121 +++-----------
28
+ include/block/block-io.h | 18 +--
29
+ include/block/block_int-common.h | 1 -
30
+ include/block/block_int-io.h | 12 --
31
+ tests/unit/test-bdrv-drain.c | 261 ++-----------------------------
32
+ 6 files changed, 44 insertions(+), 389 deletions(-)
33
+
34
+ diff --git a/block.c b/block.c
35
+ index 5330e89903..e0e3b21790 100644
36
+ --- a/block.c
37
+ +++ b/block.c
38
+ @@ -1232,7 +1232,7 @@ static void bdrv_child_cb_drained_begin(BdrvChild *child)
39
+ static bool bdrv_child_cb_drained_poll(BdrvChild *child)
40
+ {
41
+ BlockDriverState *bs = child->opaque;
42
+ - return bdrv_drain_poll(bs, false, NULL, false);
43
+ + return bdrv_drain_poll(bs, NULL, false);
44
+ }
45
+
46
+ static void bdrv_child_cb_drained_end(BdrvChild *child)
47
+ @@ -1482,8 +1482,6 @@ static void bdrv_child_cb_attach(BdrvChild *child)
48
+ assert(!bs->file);
49
+ bs->file = child;
50
+ }
51
+ -
52
+ - bdrv_apply_subtree_drain(child, bs);
53
+ }
54
+
55
+ static void bdrv_child_cb_detach(BdrvChild *child)
56
+ @@ -1494,8 +1492,6 @@ static void bdrv_child_cb_detach(BdrvChild *child)
57
+ bdrv_backing_detach(child);
58
+ }
59
+
60
+ - bdrv_unapply_subtree_drain(child, bs);
61
+ -
62
+ assert_bdrv_graph_writable(bs);
63
+ QLIST_REMOVE(child, next);
64
+ if (child == bs->backing) {
65
+ @@ -2851,9 +2847,6 @@ static void bdrv_replace_child_noperm(BdrvChild *child,
66
+ }
67
+
68
+ if (old_bs) {
69
+ - /* Detach first so that the recursive drain sections coming from @child
70
+ - * are already gone and we only end the drain sections that came from
71
+ - * elsewhere. */
72
+ if (child->klass->detach) {
73
+ child->klass->detach(child);
74
+ }
75
+ @@ -2868,17 +2861,14 @@ static void bdrv_replace_child_noperm(BdrvChild *child,
76
+ QLIST_INSERT_HEAD(&new_bs->parents, child, next_parent);
77
+
78
+ /*
79
+ - * Detaching the old node may have led to the new node's
80
+ - * quiesce_counter having been decreased. Not a problem, we
81
+ - * just need to recognize this here and then invoke
82
+ - * drained_end appropriately more often.
83
+ + * Polling in bdrv_parent_drained_begin_single() may have led to the new
84
+ + * node's quiesce_counter having been decreased. Not a problem, we just
85
+ + * need to recognize this here and then invoke drained_end appropriately
86
+ + * more often.
87
+ */
88
+ assert(new_bs->quiesce_counter <= new_bs_quiesce_counter);
89
+ drain_saldo += new_bs->quiesce_counter - new_bs_quiesce_counter;
90
+
91
+ - /* Attach only after starting new drained sections, so that recursive
92
+ - * drain sections coming from @child don't get an extra .drained_begin
93
+ - * callback. */
94
+ if (child->klass->attach) {
95
+ child->klass->attach(child);
96
+ }
97
+ diff --git a/block/io.c b/block/io.c
98
+ index a25103be6f..75224480d0 100644
99
+ --- a/block/io.c
100
+ +++ b/block/io.c
101
+ @@ -236,17 +236,15 @@ typedef struct {
102
+ BlockDriverState *bs;
103
+ bool done;
104
+ bool begin;
105
+ - bool recursive;
106
+ bool poll;
107
+ BdrvChild *parent;
108
+ bool ignore_bds_parents;
109
+ } BdrvCoDrainData;
110
+
111
+ /* Returns true if BDRV_POLL_WHILE() should go into a blocking aio_poll() */
112
+ -bool bdrv_drain_poll(BlockDriverState *bs, bool recursive,
113
+ - BdrvChild *ignore_parent, bool ignore_bds_parents)
114
+ +bool bdrv_drain_poll(BlockDriverState *bs, BdrvChild *ignore_parent,
115
+ + bool ignore_bds_parents)
116
+ {
117
+ - BdrvChild *child, *next;
118
+ IO_OR_GS_CODE();
119
+
120
+ if (bdrv_parent_drained_poll(bs, ignore_parent, ignore_bds_parents)) {
121
+ @@ -257,29 +255,19 @@ bool bdrv_drain_poll(BlockDriverState *bs, bool recursive,
122
+ return true;
123
+ }
124
+
125
+ - if (recursive) {
126
+ - assert(!ignore_bds_parents);
127
+ - QLIST_FOREACH_SAFE(child, &bs->children, next, next) {
128
+ - if (bdrv_drain_poll(child->bs, recursive, child, false)) {
129
+ - return true;
130
+ - }
131
+ - }
132
+ - }
133
+ -
134
+ return false;
135
+ }
136
+
137
+ -static bool bdrv_drain_poll_top_level(BlockDriverState *bs, bool recursive,
138
+ +static bool bdrv_drain_poll_top_level(BlockDriverState *bs,
139
+ BdrvChild *ignore_parent)
140
+ {
141
+ - return bdrv_drain_poll(bs, recursive, ignore_parent, false);
142
+ + return bdrv_drain_poll(bs, ignore_parent, false);
143
+ }
144
+
145
+ -static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
146
+ - BdrvChild *parent, bool ignore_bds_parents,
147
+ - bool poll);
148
+ -static void bdrv_do_drained_end(BlockDriverState *bs, bool recursive,
149
+ - BdrvChild *parent, bool ignore_bds_parents);
150
+ +static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
151
+ + bool ignore_bds_parents, bool poll);
152
+ +static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent,
153
+ + bool ignore_bds_parents);
154
+
155
+ static void bdrv_co_drain_bh_cb(void *opaque)
156
+ {
157
+ @@ -292,12 +280,11 @@ static void bdrv_co_drain_bh_cb(void *opaque)
158
+ aio_context_acquire(ctx);
159
+ bdrv_dec_in_flight(bs);
160
+ if (data->begin) {
161
+ - bdrv_do_drained_begin(bs, data->recursive, data->parent,
162
+ - data->ignore_bds_parents, data->poll);
163
+ + bdrv_do_drained_begin(bs, data->parent, data->ignore_bds_parents,
164
+ + data->poll);
165
+ } else {
166
+ assert(!data->poll);
167
+ - bdrv_do_drained_end(bs, data->recursive, data->parent,
168
+ - data->ignore_bds_parents);
169
+ + bdrv_do_drained_end(bs, data->parent, data->ignore_bds_parents);
170
+ }
171
+ aio_context_release(ctx);
172
+ } else {
173
+ @@ -310,7 +297,7 @@ static void bdrv_co_drain_bh_cb(void *opaque)
174
+ }
175
+
176
+ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
177
+ - bool begin, bool recursive,
178
+ + bool begin,
179
+ BdrvChild *parent,
180
+ bool ignore_bds_parents,
181
+ bool poll)
182
+ @@ -329,7 +316,6 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
183
+ .bs = bs,
184
+ .done = false,
185
+ .begin = begin,
186
+ - .recursive = recursive,
187
+ .parent = parent,
188
+ .ignore_bds_parents = ignore_bds_parents,
189
+ .poll = poll,
190
+ @@ -380,29 +366,16 @@ void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
191
+ }
192
+ }
193
+
194
+ -static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
195
+ - BdrvChild *parent, bool ignore_bds_parents,
196
+ - bool poll)
197
+ +static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
198
+ + bool ignore_bds_parents, bool poll)
199
+ {
200
+ - BdrvChild *child, *next;
201
+ -
202
+ if (qemu_in_coroutine()) {
203
+ - bdrv_co_yield_to_drain(bs, true, recursive, parent, ignore_bds_parents,
204
+ - poll);
205
+ + bdrv_co_yield_to_drain(bs, true, parent, ignore_bds_parents, poll);
206
+ return;
207
+ }
208
+
209
+ bdrv_do_drained_begin_quiesce(bs, parent, ignore_bds_parents);
210
+
211
+ - if (recursive) {
212
+ - assert(!ignore_bds_parents);
213
+ - bs->recursive_quiesce_counter++;
214
+ - QLIST_FOREACH_SAFE(child, &bs->children, next, next) {
215
+ - bdrv_do_drained_begin(child->bs, true, child, ignore_bds_parents,
216
+ - false);
217
+ - }
218
+ - }
219
+ -
220
+ /*
221
+ * Wait for drained requests to finish.
222
+ *
223
+ @@ -414,35 +387,27 @@ static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
224
+ */
225
+ if (poll) {
226
+ assert(!ignore_bds_parents);
227
+ - BDRV_POLL_WHILE(bs, bdrv_drain_poll_top_level(bs, recursive, parent));
228
+ + BDRV_POLL_WHILE(bs, bdrv_drain_poll_top_level(bs, parent));
229
+ }
230
+ }
231
+
232
+ void bdrv_drained_begin(BlockDriverState *bs)
233
+ {
234
+ IO_OR_GS_CODE();
235
+ - bdrv_do_drained_begin(bs, false, NULL, false, true);
236
+ -}
237
+ -
238
+ -void bdrv_subtree_drained_begin(BlockDriverState *bs)
239
+ -{
240
+ - IO_OR_GS_CODE();
241
+ - bdrv_do_drained_begin(bs, true, NULL, false, true);
242
+ + bdrv_do_drained_begin(bs, NULL, false, true);
243
+ }
244
+
245
+ /**
246
+ * This function does not poll, nor must any of its recursively called
247
+ * functions.
248
+ */
249
+ -static void bdrv_do_drained_end(BlockDriverState *bs, bool recursive,
250
+ - BdrvChild *parent, bool ignore_bds_parents)
251
+ +static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent,
252
+ + bool ignore_bds_parents)
253
+ {
254
+ - BdrvChild *child;
255
+ int old_quiesce_counter;
256
+
257
+ if (qemu_in_coroutine()) {
258
+ - bdrv_co_yield_to_drain(bs, false, recursive, parent, ignore_bds_parents,
259
+ - false);
260
+ + bdrv_co_yield_to_drain(bs, false, parent, ignore_bds_parents, false);
261
+ return;
262
+ }
263
+ assert(bs->quiesce_counter > 0);
264
+ @@ -457,46 +422,12 @@ static void bdrv_do_drained_end(BlockDriverState *bs, bool recursive,
265
+ if (old_quiesce_counter == 1) {
266
+ aio_enable_external(bdrv_get_aio_context(bs));
267
+ }
268
+ -
269
+ - if (recursive) {
270
+ - assert(!ignore_bds_parents);
271
+ - bs->recursive_quiesce_counter--;
272
+ - QLIST_FOREACH(child, &bs->children, next) {
273
+ - bdrv_do_drained_end(child->bs, true, child, ignore_bds_parents);
274
+ - }
275
+ - }
276
+ }
277
+
278
+ void bdrv_drained_end(BlockDriverState *bs)
279
+ {
280
+ IO_OR_GS_CODE();
281
+ - bdrv_do_drained_end(bs, false, NULL, false);
282
+ -}
283
+ -
284
+ -void bdrv_subtree_drained_end(BlockDriverState *bs)
285
+ -{
286
+ - IO_OR_GS_CODE();
287
+ - bdrv_do_drained_end(bs, true, NULL, false);
288
+ -}
289
+ -
290
+ -void bdrv_apply_subtree_drain(BdrvChild *child, BlockDriverState *new_parent)
291
+ -{
292
+ - int i;
293
+ - IO_OR_GS_CODE();
294
+ -
295
+ - for (i = 0; i < new_parent->recursive_quiesce_counter; i++) {
296
+ - bdrv_do_drained_begin(child->bs, true, child, false, true);
297
+ - }
298
+ -}
299
+ -
300
+ -void bdrv_unapply_subtree_drain(BdrvChild *child, BlockDriverState *old_parent)
301
+ -{
302
+ - int i;
303
+ - IO_OR_GS_CODE();
304
+ -
305
+ - for (i = 0; i < old_parent->recursive_quiesce_counter; i++) {
306
+ - bdrv_do_drained_end(child->bs, true, child, false);
307
+ - }
308
+ + bdrv_do_drained_end(bs, NULL, false);
309
+ }
310
+
311
+ void bdrv_drain(BlockDriverState *bs)
312
+ @@ -529,7 +460,7 @@ static bool bdrv_drain_all_poll(void)
313
+ while ((bs = bdrv_next_all_states(bs))) {
314
+ AioContext *aio_context = bdrv_get_aio_context(bs);
315
+ aio_context_acquire(aio_context);
316
+ - result |= bdrv_drain_poll(bs, false, NULL, true);
317
+ + result |= bdrv_drain_poll(bs, NULL, true);
318
+ aio_context_release(aio_context);
319
+ }
320
+
321
+ @@ -554,7 +485,7 @@ void bdrv_drain_all_begin(void)
322
+ GLOBAL_STATE_CODE();
323
+
324
+ if (qemu_in_coroutine()) {
325
+ - bdrv_co_yield_to_drain(NULL, true, false, NULL, true, true);
326
+ + bdrv_co_yield_to_drain(NULL, true, NULL, true, true);
327
+ return;
328
+ }
329
+
330
+ @@ -579,7 +510,7 @@ void bdrv_drain_all_begin(void)
331
+ AioContext *aio_context = bdrv_get_aio_context(bs);
332
+
333
+ aio_context_acquire(aio_context);
334
+ - bdrv_do_drained_begin(bs, false, NULL, true, false);
335
+ + bdrv_do_drained_begin(bs, NULL, true, false);
336
+ aio_context_release(aio_context);
337
+ }
338
+
339
+ @@ -599,7 +530,7 @@ void bdrv_drain_all_end_quiesce(BlockDriverState *bs)
340
+ g_assert(!bs->refcnt);
341
+
342
+ while (bs->quiesce_counter) {
343
+ - bdrv_do_drained_end(bs, false, NULL, true);
344
+ + bdrv_do_drained_end(bs, NULL, true);
345
+ }
346
+ }
347
+
348
+ @@ -621,7 +552,7 @@ void bdrv_drain_all_end(void)
349
+ AioContext *aio_context = bdrv_get_aio_context(bs);
350
+
351
+ aio_context_acquire(aio_context);
352
+ - bdrv_do_drained_end(bs, false, NULL, true);
353
+ + bdrv_do_drained_end(bs, NULL, true);
354
+ aio_context_release(aio_context);
355
+ }
356
+
357
+ diff --git a/include/block/block-io.h b/include/block/block-io.h
358
+ index 054e964c9b..9c36a16a1f 100644
359
+ --- a/include/block/block-io.h
360
+ +++ b/include/block/block-io.h
361
+ @@ -302,8 +302,7 @@ void bdrv_parent_drained_end_single(BdrvChild *c);
362
+ /**
363
+ * bdrv_drain_poll:
364
+ *
365
+ - * Poll for pending requests in @bs, its parents (except for @ignore_parent),
366
+ - * and if @recursive is true its children as well (used for subtree drain).
367
+ + * Poll for pending requests in @bs and its parents (except for @ignore_parent).
368
+ *
369
+ * If @ignore_bds_parents is true, parents that are BlockDriverStates must
370
+ * ignore the drain request because they will be drained separately (used for
371
+ @@ -311,8 +310,8 @@ void bdrv_parent_drained_end_single(BdrvChild *c);
372
+ *
373
+ * This is part of bdrv_drained_begin.
374
+ */
375
+ -bool bdrv_drain_poll(BlockDriverState *bs, bool recursive,
376
+ - BdrvChild *ignore_parent, bool ignore_bds_parents);
377
+ +bool bdrv_drain_poll(BlockDriverState *bs, BdrvChild *ignore_parent,
378
+ + bool ignore_bds_parents);
379
+
380
+ /**
381
+ * bdrv_drained_begin:
382
+ @@ -333,12 +332,6 @@ void bdrv_drained_begin(BlockDriverState *bs);
383
+ void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
384
+ BdrvChild *parent, bool ignore_bds_parents);
385
+
386
+ -/**
387
+ - * Like bdrv_drained_begin, but recursively begins a quiesced section for
388
+ - * exclusive access to all child nodes as well.
389
+ - */
390
+ -void bdrv_subtree_drained_begin(BlockDriverState *bs);
391
+ -
392
+ /**
393
+ * bdrv_drained_end:
394
+ *
395
+ @@ -346,9 +339,4 @@ void bdrv_subtree_drained_begin(BlockDriverState *bs);
396
+ */
397
+ void bdrv_drained_end(BlockDriverState *bs);
398
+
399
+ -/**
400
+ - * End a quiescent section started by bdrv_subtree_drained_begin().
401
+ - */
402
+ -void bdrv_subtree_drained_end(BlockDriverState *bs);
403
+ -
404
+ #endif /* BLOCK_IO_H */
405
+ diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
406
+ index 2b97576f6d..791dddfd7d 100644
407
+ --- a/include/block/block_int-common.h
408
+ +++ b/include/block/block_int-common.h
409
+ @@ -1184,7 +1184,6 @@ struct BlockDriverState {
410
+
411
+ /* Accessed with atomic ops. */
412
+ int quiesce_counter;
413
+ - int recursive_quiesce_counter;
414
+
415
+ unsigned int write_gen; /* Current data generation */
416
+
417
+ diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h
418
+ index 4b0b3e17ef..8bc061ebb8 100644
419
+ --- a/include/block/block_int-io.h
420
+ +++ b/include/block/block_int-io.h
421
+ @@ -179,16 +179,4 @@ void bdrv_bsc_invalidate_range(BlockDriverState *bs,
422
+ */
423
+ void bdrv_bsc_fill(BlockDriverState *bs, int64_t offset, int64_t bytes);
424
+
425
+ -
426
+ -/*
427
+ - * "I/O or GS" API functions. These functions can run without
428
+ - * the BQL, but only in one specific iothread/main loop.
429
+ - *
430
+ - * See include/block/block-io.h for more information about
431
+ - * the "I/O or GS" API.
432
+ - */
433
+ -
434
+ -void bdrv_apply_subtree_drain(BdrvChild *child, BlockDriverState *new_parent);
435
+ -void bdrv_unapply_subtree_drain(BdrvChild *child, BlockDriverState *old_parent);
436
+ -
437
+ #endif /* BLOCK_INT_IO_H */
438
+ diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c
439
+ index 695519ee02..dda08de8db 100644
440
+ --- a/tests/unit/test-bdrv-drain.c
441
+ +++ b/tests/unit/test-bdrv-drain.c
442
+ @@ -156,7 +156,6 @@ static void call_in_coroutine(void (*entry)(void))
443
+ enum drain_type {
444
+ BDRV_DRAIN_ALL,
445
+ BDRV_DRAIN,
446
+ - BDRV_SUBTREE_DRAIN,
447
+ DRAIN_TYPE_MAX,
448
+ };
449
+
450
+ @@ -165,7 +164,6 @@ static void do_drain_begin(enum drain_type drain_type, BlockDriverState *bs)
451
+ switch (drain_type) {
452
+ case BDRV_DRAIN_ALL: bdrv_drain_all_begin(); break;
453
+ case BDRV_DRAIN: bdrv_drained_begin(bs); break;
454
+ - case BDRV_SUBTREE_DRAIN: bdrv_subtree_drained_begin(bs); break;
455
+ default: g_assert_not_reached();
456
+ }
457
+ }
458
+ @@ -175,7 +173,6 @@ static void do_drain_end(enum drain_type drain_type, BlockDriverState *bs)
459
+ switch (drain_type) {
460
+ case BDRV_DRAIN_ALL: bdrv_drain_all_end(); break;
461
+ case BDRV_DRAIN: bdrv_drained_end(bs); break;
462
+ - case BDRV_SUBTREE_DRAIN: bdrv_subtree_drained_end(bs); break;
463
+ default: g_assert_not_reached();
464
+ }
465
+ }
466
+ @@ -271,11 +268,6 @@ static void test_drv_cb_drain(void)
467
+ test_drv_cb_common(BDRV_DRAIN, false);
468
+ }
469
+
470
+ -static void test_drv_cb_drain_subtree(void)
471
+ -{
472
+ - test_drv_cb_common(BDRV_SUBTREE_DRAIN, true);
473
+ -}
474
+ -
475
+ static void test_drv_cb_co_drain_all(void)
476
+ {
477
+ call_in_coroutine(test_drv_cb_drain_all);
478
+ @@ -286,11 +278,6 @@ static void test_drv_cb_co_drain(void)
479
+ call_in_coroutine(test_drv_cb_drain);
480
+ }
481
+
482
+ -static void test_drv_cb_co_drain_subtree(void)
483
+ -{
484
+ - call_in_coroutine(test_drv_cb_drain_subtree);
485
+ -}
486
+ -
487
+ static void test_quiesce_common(enum drain_type drain_type, bool recursive)
488
+ {
489
+ BlockBackend *blk;
490
+ @@ -332,11 +319,6 @@ static void test_quiesce_drain(void)
491
+ test_quiesce_common(BDRV_DRAIN, false);
492
+ }
493
+
494
+ -static void test_quiesce_drain_subtree(void)
495
+ -{
496
+ - test_quiesce_common(BDRV_SUBTREE_DRAIN, true);
497
+ -}
498
+ -
499
+ static void test_quiesce_co_drain_all(void)
500
+ {
501
+ call_in_coroutine(test_quiesce_drain_all);
502
+ @@ -347,11 +329,6 @@ static void test_quiesce_co_drain(void)
503
+ call_in_coroutine(test_quiesce_drain);
504
+ }
505
+
506
+ -static void test_quiesce_co_drain_subtree(void)
507
+ -{
508
+ - call_in_coroutine(test_quiesce_drain_subtree);
509
+ -}
510
+ -
511
+ static void test_nested(void)
512
+ {
513
+ BlockBackend *blk;
514
+ @@ -402,158 +379,6 @@ static void test_nested(void)
515
+ blk_unref(blk);
516
+ }
517
+
518
+ -static void test_multiparent(void)
519
+ -{
520
+ - BlockBackend *blk_a, *blk_b;
521
+ - BlockDriverState *bs_a, *bs_b, *backing;
522
+ - BDRVTestState *a_s, *b_s, *backing_s;
523
+ -
524
+ - blk_a = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
525
+ - bs_a = bdrv_new_open_driver(&bdrv_test, "test-node-a", BDRV_O_RDWR,
526
+ - &error_abort);
527
+ - a_s = bs_a->opaque;
528
+ - blk_insert_bs(blk_a, bs_a, &error_abort);
529
+ -
530
+ - blk_b = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
531
+ - bs_b = bdrv_new_open_driver(&bdrv_test, "test-node-b", BDRV_O_RDWR,
532
+ - &error_abort);
533
+ - b_s = bs_b->opaque;
534
+ - blk_insert_bs(blk_b, bs_b, &error_abort);
535
+ -
536
+ - backing = bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abort);
537
+ - backing_s = backing->opaque;
538
+ - bdrv_set_backing_hd(bs_a, backing, &error_abort);
539
+ - bdrv_set_backing_hd(bs_b, backing, &error_abort);
540
+ -
541
+ - g_assert_cmpint(bs_a->quiesce_counter, ==, 0);
542
+ - g_assert_cmpint(bs_b->quiesce_counter, ==, 0);
543
+ - g_assert_cmpint(backing->quiesce_counter, ==, 0);
544
+ - g_assert_cmpint(a_s->drain_count, ==, 0);
545
+ - g_assert_cmpint(b_s->drain_count, ==, 0);
546
+ - g_assert_cmpint(backing_s->drain_count, ==, 0);
547
+ -
548
+ - do_drain_begin(BDRV_SUBTREE_DRAIN, bs_a);
549
+ -
550
+ - g_assert_cmpint(bs_a->quiesce_counter, ==, 1);
551
+ - g_assert_cmpint(bs_b->quiesce_counter, ==, 1);
552
+ - g_assert_cmpint(backing->quiesce_counter, ==, 1);
553
+ - g_assert_cmpint(a_s->drain_count, ==, 1);
554
+ - g_assert_cmpint(b_s->drain_count, ==, 1);
555
+ - g_assert_cmpint(backing_s->drain_count, ==, 1);
556
+ -
557
+ - do_drain_begin(BDRV_SUBTREE_DRAIN, bs_b);
558
+ -
559
+ - g_assert_cmpint(bs_a->quiesce_counter, ==, 2);
560
+ - g_assert_cmpint(bs_b->quiesce_counter, ==, 2);
561
+ - g_assert_cmpint(backing->quiesce_counter, ==, 2);
562
+ - g_assert_cmpint(a_s->drain_count, ==, 2);
563
+ - g_assert_cmpint(b_s->drain_count, ==, 2);
564
+ - g_assert_cmpint(backing_s->drain_count, ==, 2);
565
+ -
566
+ - do_drain_end(BDRV_SUBTREE_DRAIN, bs_b);
567
+ -
568
+ - g_assert_cmpint(bs_a->quiesce_counter, ==, 1);
569
+ - g_assert_cmpint(bs_b->quiesce_counter, ==, 1);
570
+ - g_assert_cmpint(backing->quiesce_counter, ==, 1);
571
+ - g_assert_cmpint(a_s->drain_count, ==, 1);
572
+ - g_assert_cmpint(b_s->drain_count, ==, 1);
573
+ - g_assert_cmpint(backing_s->drain_count, ==, 1);
574
+ -
575
+ - do_drain_end(BDRV_SUBTREE_DRAIN, bs_a);
576
+ -
577
+ - g_assert_cmpint(bs_a->quiesce_counter, ==, 0);
578
+ - g_assert_cmpint(bs_b->quiesce_counter, ==, 0);
579
+ - g_assert_cmpint(backing->quiesce_counter, ==, 0);
580
+ - g_assert_cmpint(a_s->drain_count, ==, 0);
581
+ - g_assert_cmpint(b_s->drain_count, ==, 0);
582
+ - g_assert_cmpint(backing_s->drain_count, ==, 0);
583
+ -
584
+ - bdrv_unref(backing);
585
+ - bdrv_unref(bs_a);
586
+ - bdrv_unref(bs_b);
587
+ - blk_unref(blk_a);
588
+ - blk_unref(blk_b);
589
+ -}
590
+ -
591
+ -static void test_graph_change_drain_subtree(void)
592
+ -{
593
+ - BlockBackend *blk_a, *blk_b;
594
+ - BlockDriverState *bs_a, *bs_b, *backing;
595
+ - BDRVTestState *a_s, *b_s, *backing_s;
596
+ -
597
+ - blk_a = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
598
+ - bs_a = bdrv_new_open_driver(&bdrv_test, "test-node-a", BDRV_O_RDWR,
599
+ - &error_abort);
600
+ - a_s = bs_a->opaque;
601
+ - blk_insert_bs(blk_a, bs_a, &error_abort);
602
+ -
603
+ - blk_b = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
604
+ - bs_b = bdrv_new_open_driver(&bdrv_test, "test-node-b", BDRV_O_RDWR,
605
+ - &error_abort);
606
+ - b_s = bs_b->opaque;
607
+ - blk_insert_bs(blk_b, bs_b, &error_abort);
608
+ -
609
+ - backing = bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abort);
610
+ - backing_s = backing->opaque;
611
+ - bdrv_set_backing_hd(bs_a, backing, &error_abort);
612
+ -
613
+ - g_assert_cmpint(bs_a->quiesce_counter, ==, 0);
614
+ - g_assert_cmpint(bs_b->quiesce_counter, ==, 0);
615
+ - g_assert_cmpint(backing->quiesce_counter, ==, 0);
616
+ - g_assert_cmpint(a_s->drain_count, ==, 0);
617
+ - g_assert_cmpint(b_s->drain_count, ==, 0);
618
+ - g_assert_cmpint(backing_s->drain_count, ==, 0);
619
+ -
620
+ - do_drain_begin(BDRV_SUBTREE_DRAIN, bs_a);
621
+ - do_drain_begin(BDRV_SUBTREE_DRAIN, bs_a);
622
+ - do_drain_begin(BDRV_SUBTREE_DRAIN, bs_a);
623
+ - do_drain_begin(BDRV_SUBTREE_DRAIN, bs_b);
624
+ - do_drain_begin(BDRV_SUBTREE_DRAIN, bs_b);
625
+ -
626
+ - bdrv_set_backing_hd(bs_b, backing, &error_abort);
627
+ - g_assert_cmpint(bs_a->quiesce_counter, ==, 5);
628
+ - g_assert_cmpint(bs_b->quiesce_counter, ==, 5);
629
+ - g_assert_cmpint(backing->quiesce_counter, ==, 5);
630
+ - g_assert_cmpint(a_s->drain_count, ==, 5);
631
+ - g_assert_cmpint(b_s->drain_count, ==, 5);
632
+ - g_assert_cmpint(backing_s->drain_count, ==, 5);
633
+ -
634
+ - bdrv_set_backing_hd(bs_b, NULL, &error_abort);
635
+ - g_assert_cmpint(bs_a->quiesce_counter, ==, 3);
636
+ - g_assert_cmpint(bs_b->quiesce_counter, ==, 2);
637
+ - g_assert_cmpint(backing->quiesce_counter, ==, 3);
638
+ - g_assert_cmpint(a_s->drain_count, ==, 3);
639
+ - g_assert_cmpint(b_s->drain_count, ==, 2);
640
+ - g_assert_cmpint(backing_s->drain_count, ==, 3);
641
+ -
642
+ - bdrv_set_backing_hd(bs_b, backing, &error_abort);
643
+ - g_assert_cmpint(bs_a->quiesce_counter, ==, 5);
644
+ - g_assert_cmpint(bs_b->quiesce_counter, ==, 5);
645
+ - g_assert_cmpint(backing->quiesce_counter, ==, 5);
646
+ - g_assert_cmpint(a_s->drain_count, ==, 5);
647
+ - g_assert_cmpint(b_s->drain_count, ==, 5);
648
+ - g_assert_cmpint(backing_s->drain_count, ==, 5);
649
+ -
650
+ - do_drain_end(BDRV_SUBTREE_DRAIN, bs_b);
651
+ - do_drain_end(BDRV_SUBTREE_DRAIN, bs_b);
652
+ - do_drain_end(BDRV_SUBTREE_DRAIN, bs_a);
653
+ - do_drain_end(BDRV_SUBTREE_DRAIN, bs_a);
654
+ - do_drain_end(BDRV_SUBTREE_DRAIN, bs_a);
655
+ -
656
+ - g_assert_cmpint(bs_a->quiesce_counter, ==, 0);
657
+ - g_assert_cmpint(bs_b->quiesce_counter, ==, 0);
658
+ - g_assert_cmpint(backing->quiesce_counter, ==, 0);
659
+ - g_assert_cmpint(a_s->drain_count, ==, 0);
660
+ - g_assert_cmpint(b_s->drain_count, ==, 0);
661
+ - g_assert_cmpint(backing_s->drain_count, ==, 0);
662
+ -
663
+ - bdrv_unref(backing);
664
+ - bdrv_unref(bs_a);
665
+ - bdrv_unref(bs_b);
666
+ - blk_unref(blk_a);
667
+ - blk_unref(blk_b);
668
+ -}
669
+ -
670
+ static void test_graph_change_drain_all(void)
671
+ {
672
+ BlockBackend *blk_a, *blk_b;
673
+ @@ -773,12 +598,6 @@ static void test_iothread_drain(void)
674
+ test_iothread_common(BDRV_DRAIN, 1);
675
+ }
676
+
677
+ -static void test_iothread_drain_subtree(void)
678
+ -{
679
+ - test_iothread_common(BDRV_SUBTREE_DRAIN, 0);
680
+ - test_iothread_common(BDRV_SUBTREE_DRAIN, 1);
681
+ -}
682
+ -
683
+
684
+ typedef struct TestBlockJob {
685
+ BlockJob common;
686
+ @@ -863,7 +682,6 @@ enum test_job_result {
687
+ enum test_job_drain_node {
688
+ TEST_JOB_DRAIN_SRC,
689
+ TEST_JOB_DRAIN_SRC_CHILD,
690
+ - TEST_JOB_DRAIN_SRC_PARENT,
691
+ };
692
+
693
+ static void test_blockjob_common_drain_node(enum drain_type drain_type,
694
+ @@ -901,9 +719,6 @@ static void test_blockjob_common_drain_node(enum drain_type drain_type,
695
+ case TEST_JOB_DRAIN_SRC_CHILD:
696
+ drain_bs = src_backing;
697
+ break;
698
+ - case TEST_JOB_DRAIN_SRC_PARENT:
699
+ - drain_bs = src_overlay;
700
+ - break;
701
+ default:
702
+ g_assert_not_reached();
703
+ }
704
+ @@ -1055,10 +870,6 @@ static void test_blockjob_common(enum drain_type drain_type, bool use_iothread,
705
+ TEST_JOB_DRAIN_SRC);
706
+ test_blockjob_common_drain_node(drain_type, use_iothread, result,
707
+ TEST_JOB_DRAIN_SRC_CHILD);
708
+ - if (drain_type == BDRV_SUBTREE_DRAIN) {
709
+ - test_blockjob_common_drain_node(drain_type, use_iothread, result,
710
+ - TEST_JOB_DRAIN_SRC_PARENT);
711
+ - }
712
+ }
713
+
714
+ static void test_blockjob_drain_all(void)
715
+ @@ -1071,11 +882,6 @@ static void test_blockjob_drain(void)
716
+ test_blockjob_common(BDRV_DRAIN, false, TEST_JOB_SUCCESS);
717
+ }
718
+
719
+ -static void test_blockjob_drain_subtree(void)
720
+ -{
721
+ - test_blockjob_common(BDRV_SUBTREE_DRAIN, false, TEST_JOB_SUCCESS);
722
+ -}
723
+ -
724
+ static void test_blockjob_error_drain_all(void)
725
+ {
726
+ test_blockjob_common(BDRV_DRAIN_ALL, false, TEST_JOB_FAIL_RUN);
727
+ @@ -1088,12 +894,6 @@ static void test_blockjob_error_drain(void)
728
+ test_blockjob_common(BDRV_DRAIN, false, TEST_JOB_FAIL_PREPARE);
729
+ }
730
+
731
+ -static void test_blockjob_error_drain_subtree(void)
732
+ -{
733
+ - test_blockjob_common(BDRV_SUBTREE_DRAIN, false, TEST_JOB_FAIL_RUN);
734
+ - test_blockjob_common(BDRV_SUBTREE_DRAIN, false, TEST_JOB_FAIL_PREPARE);
735
+ -}
736
+ -
737
+ static void test_blockjob_iothread_drain_all(void)
738
+ {
739
+ test_blockjob_common(BDRV_DRAIN_ALL, true, TEST_JOB_SUCCESS);
740
+ @@ -1104,11 +904,6 @@ static void test_blockjob_iothread_drain(void)
741
+ test_blockjob_common(BDRV_DRAIN, true, TEST_JOB_SUCCESS);
742
+ }
743
+
744
+ -static void test_blockjob_iothread_drain_subtree(void)
745
+ -{
746
+ - test_blockjob_common(BDRV_SUBTREE_DRAIN, true, TEST_JOB_SUCCESS);
747
+ -}
748
+ -
749
+ static void test_blockjob_iothread_error_drain_all(void)
750
+ {
751
+ test_blockjob_common(BDRV_DRAIN_ALL, true, TEST_JOB_FAIL_RUN);
752
+ @@ -1121,12 +916,6 @@ static void test_blockjob_iothread_error_drain(void)
753
+ test_blockjob_common(BDRV_DRAIN, true, TEST_JOB_FAIL_PREPARE);
754
+ }
755
+
756
+ -static void test_blockjob_iothread_error_drain_subtree(void)
757
+ -{
758
+ - test_blockjob_common(BDRV_SUBTREE_DRAIN, true, TEST_JOB_FAIL_RUN);
759
+ - test_blockjob_common(BDRV_SUBTREE_DRAIN, true, TEST_JOB_FAIL_PREPARE);
760
+ -}
761
+ -
762
+
763
+ typedef struct BDRVTestTopState {
764
+ BdrvChild *wait_child;
765
+ @@ -1273,14 +1062,6 @@ static void do_test_delete_by_drain(bool detach_instead_of_delete,
766
+ bdrv_drain(child_bs);
767
+ bdrv_unref(child_bs);
768
+ break;
769
+ - case BDRV_SUBTREE_DRAIN:
770
+ - /* Would have to ref/unref bs here for !detach_instead_of_delete, but
771
+ - * then the whole test becomes pointless because the graph changes
772
+ - * don't occur during the drain any more. */
773
+ - assert(detach_instead_of_delete);
774
+ - bdrv_subtree_drained_begin(bs);
775
+ - bdrv_subtree_drained_end(bs);
776
+ - break;
777
+ case BDRV_DRAIN_ALL:
778
+ bdrv_drain_all_begin();
779
+ bdrv_drain_all_end();
780
+ @@ -1315,11 +1096,6 @@ static void test_detach_by_drain(void)
781
+ do_test_delete_by_drain(true, BDRV_DRAIN);
782
+ }
783
+
784
+ -static void test_detach_by_drain_subtree(void)
785
+ -{
786
+ - do_test_delete_by_drain(true, BDRV_SUBTREE_DRAIN);
787
+ -}
788
+ -
789
+
790
+ struct detach_by_parent_data {
791
+ BlockDriverState *parent_b;
792
+ @@ -1452,7 +1228,10 @@ static void test_detach_indirect(bool by_parent_cb)
793
+ g_assert(acb != NULL);
794
+
795
+ /* Drain and check the expected result */
796
+ - bdrv_subtree_drained_begin(parent_b);
797
+ + bdrv_drained_begin(parent_b);
798
+ + bdrv_drained_begin(a);
799
+ + bdrv_drained_begin(b);
800
+ + bdrv_drained_begin(c);
801
+
802
+ g_assert(detach_by_parent_data.child_c != NULL);
803
+
804
+ @@ -1467,12 +1246,15 @@ static void test_detach_indirect(bool by_parent_cb)
805
+ g_assert(QLIST_NEXT(child_a, next) == NULL);
806
+
807
+ g_assert_cmpint(parent_a->quiesce_counter, ==, 1);
808
+ - g_assert_cmpint(parent_b->quiesce_counter, ==, 1);
809
+ + g_assert_cmpint(parent_b->quiesce_counter, ==, 3);
810
+ g_assert_cmpint(a->quiesce_counter, ==, 1);
811
+ - g_assert_cmpint(b->quiesce_counter, ==, 0);
812
+ + g_assert_cmpint(b->quiesce_counter, ==, 1);
813
+ g_assert_cmpint(c->quiesce_counter, ==, 1);
814
+
815
+ - bdrv_subtree_drained_end(parent_b);
816
+ + bdrv_drained_end(parent_b);
817
+ + bdrv_drained_end(a);
818
+ + bdrv_drained_end(b);
819
+ + bdrv_drained_end(c);
820
+
821
+ bdrv_unref(parent_b);
822
+ blk_unref(blk);
823
+ @@ -2202,70 +1984,47 @@ int main(int argc, char **argv)
824
+
825
+ g_test_add_func("/bdrv-drain/driver-cb/drain_all", test_drv_cb_drain_all);
826
+ g_test_add_func("/bdrv-drain/driver-cb/drain", test_drv_cb_drain);
827
+ - g_test_add_func("/bdrv-drain/driver-cb/drain_subtree",
828
+ - test_drv_cb_drain_subtree);
829
+
830
+ g_test_add_func("/bdrv-drain/driver-cb/co/drain_all",
831
+ test_drv_cb_co_drain_all);
832
+ g_test_add_func("/bdrv-drain/driver-cb/co/drain", test_drv_cb_co_drain);
833
+ - g_test_add_func("/bdrv-drain/driver-cb/co/drain_subtree",
834
+ - test_drv_cb_co_drain_subtree);
835
+ -
836
+
837
+ g_test_add_func("/bdrv-drain/quiesce/drain_all", test_quiesce_drain_all);
838
+ g_test_add_func("/bdrv-drain/quiesce/drain", test_quiesce_drain);
839
+ - g_test_add_func("/bdrv-drain/quiesce/drain_subtree",
840
+ - test_quiesce_drain_subtree);
841
+
842
+ g_test_add_func("/bdrv-drain/quiesce/co/drain_all",
843
+ test_quiesce_co_drain_all);
844
+ g_test_add_func("/bdrv-drain/quiesce/co/drain", test_quiesce_co_drain);
845
+ - g_test_add_func("/bdrv-drain/quiesce/co/drain_subtree",
846
+ - test_quiesce_co_drain_subtree);
847
+
848
+ g_test_add_func("/bdrv-drain/nested", test_nested);
849
+ - g_test_add_func("/bdrv-drain/multiparent", test_multiparent);
850
+
851
+ - g_test_add_func("/bdrv-drain/graph-change/drain_subtree",
852
+ - test_graph_change_drain_subtree);
853
+ g_test_add_func("/bdrv-drain/graph-change/drain_all",
854
+ test_graph_change_drain_all);
855
+
856
+ g_test_add_func("/bdrv-drain/iothread/drain_all", test_iothread_drain_all);
857
+ g_test_add_func("/bdrv-drain/iothread/drain", test_iothread_drain);
858
+ - g_test_add_func("/bdrv-drain/iothread/drain_subtree",
859
+ - test_iothread_drain_subtree);
860
+
861
+ g_test_add_func("/bdrv-drain/blockjob/drain_all", test_blockjob_drain_all);
862
+ g_test_add_func("/bdrv-drain/blockjob/drain", test_blockjob_drain);
863
+ - g_test_add_func("/bdrv-drain/blockjob/drain_subtree",
864
+ - test_blockjob_drain_subtree);
865
+
866
+ g_test_add_func("/bdrv-drain/blockjob/error/drain_all",
867
+ test_blockjob_error_drain_all);
868
+ g_test_add_func("/bdrv-drain/blockjob/error/drain",
869
+ test_blockjob_error_drain);
870
+ - g_test_add_func("/bdrv-drain/blockjob/error/drain_subtree",
871
+ - test_blockjob_error_drain_subtree);
872
+
873
+ g_test_add_func("/bdrv-drain/blockjob/iothread/drain_all",
874
+ test_blockjob_iothread_drain_all);
875
+ g_test_add_func("/bdrv-drain/blockjob/iothread/drain",
876
+ test_blockjob_iothread_drain);
877
+ - g_test_add_func("/bdrv-drain/blockjob/iothread/drain_subtree",
878
+ - test_blockjob_iothread_drain_subtree);
879
+
880
+ g_test_add_func("/bdrv-drain/blockjob/iothread/error/drain_all",
881
+ test_blockjob_iothread_error_drain_all);
882
+ g_test_add_func("/bdrv-drain/blockjob/iothread/error/drain",
883
+ test_blockjob_iothread_error_drain);
884
+ - g_test_add_func("/bdrv-drain/blockjob/iothread/error/drain_subtree",
885
+ - test_blockjob_iothread_error_drain_subtree);
886
+
887
+ g_test_add_func("/bdrv-drain/deletion/drain", test_delete_by_drain);
888
+ g_test_add_func("/bdrv-drain/detach/drain_all", test_detach_by_drain_all);
889
+ g_test_add_func("/bdrv-drain/detach/drain", test_detach_by_drain);
890
+ - g_test_add_func("/bdrv-drain/detach/drain_subtree", test_detach_by_drain_subtree);
891
+ g_test_add_func("/bdrv-drain/detach/parent_cb", test_detach_by_parent_cb);
892
+ g_test_add_func("/bdrv-drain/detach/driver_cb", test_detach_by_driver_cb);
893
+
894
+ --
895
+ 2.31.1
896
+
SOURCES/kvm-block-Revert-.bdrv_drained_begin-end-to-non-coroutin.patch ADDED
@@ -0,0 +1,302 @@
1
+ From 0e894c93cae97bb792dc483be8e295d097ebd7a1 Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Fri, 18 Nov 2022 18:40:58 +0100
4
+ Subject: [PATCH 16/31] block: Revert .bdrv_drained_begin/end to
5
+ non-coroutine_fn
6
+
7
+ RH-Author: Stefano Garzarella <sgarzare@redhat.com>
8
+ RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
9
+ RH-Bugzilla: 2155112
10
+ RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
11
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
12
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
13
+ RH-Commit: [4/16] 86d6049e40a99604e414c2572b67f74b85868832 (sgarzarella/qemu-kvm-c-9-s)
14
+
15
+ Polling during bdrv_drained_end() can be problematic (and in the future,
16
+ we may get cases for bdrv_drained_begin() where polling is forbidden,
17
+ and we don't care about already in-flight requests, but just want to
18
+ prevent new requests from arriving).
19
+
20
+ The .bdrv_drained_begin/end callbacks running in a coroutine is the only
21
+ reason why we have to do this polling, so make them non-coroutine
22
+ callbacks again. None of the callers actually yield any more.
23
+
24
+ This means that bdrv_drained_end() effectively doesn't poll any more,
25
+ even if AIO_WAIT_WHILE() loops are still there (their condition is false
26
+ from the beginning). This is generally not a problem, but in
27
+ test-bdrv-drain, some additional explicit aio_poll() calls need to be
28
+ added because the test case wants to verify the final state after BHs
29
+ have executed.
30
+
31
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
32
+ Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
33
+ Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
34
+ Reviewed-by: Hanna Reitz <hreitz@redhat.com>
35
+ Message-Id: <20221118174110.55183-4-kwolf@redhat.com>
36
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
37
+ (cherry picked from commit 5e8ac21717373cbe96ef7a91e216bf5788815d63)
38
+ Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
39
+ ---
40
+ block.c | 4 +--
41
+ block/io.c | 49 +++++---------------------------
42
+ block/qed.c | 6 ++--
43
+ block/throttle.c | 8 +++---
44
+ include/block/block_int-common.h | 10 ++++---
45
+ tests/unit/test-bdrv-drain.c | 18 ++++++------
46
+ 6 files changed, 32 insertions(+), 63 deletions(-)
47
+
48
+ diff --git a/block.c b/block.c
49
+ index ec184150a2..16a62a329c 100644
50
+ --- a/block.c
51
+ +++ b/block.c
52
+ @@ -1713,8 +1713,8 @@ static int bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv,
53
+ assert(is_power_of_2(bs->bl.request_alignment));
54
+
55
+ for (i = 0; i < bs->quiesce_counter; i++) {
56
+ - if (drv->bdrv_co_drain_begin) {
57
+ - drv->bdrv_co_drain_begin(bs);
58
+ + if (drv->bdrv_drain_begin) {
59
+ + drv->bdrv_drain_begin(bs);
60
+ }
61
+ }
62
+
63
+ diff --git a/block/io.c b/block/io.c
64
+ index b9424024f9..c2ed4b2af9 100644
65
+ --- a/block/io.c
66
+ +++ b/block/io.c
67
+ @@ -252,55 +252,20 @@ typedef struct {
68
+ int *drained_end_counter;
69
+ } BdrvCoDrainData;
70
+
71
+ -static void coroutine_fn bdrv_drain_invoke_entry(void *opaque)
72
+ -{
73
+ - BdrvCoDrainData *data = opaque;
74
+ - BlockDriverState *bs = data->bs;
75
+ -
76
+ - if (data->begin) {
77
+ - bs->drv->bdrv_co_drain_begin(bs);
78
+ - } else {
79
+ - bs->drv->bdrv_co_drain_end(bs);
80
+ - }
81
+ -
82
+ - /* Set data->done and decrement drained_end_counter before bdrv_wakeup() */
83
+ - qatomic_mb_set(&data->done, true);
84
+ - if (!data->begin) {
85
+ - qatomic_dec(data->drained_end_counter);
86
+ - }
87
+ - bdrv_dec_in_flight(bs);
88
+ -
89
+ - g_free(data);
90
+ -}
91
+ -
92
+ -/* Recursively call BlockDriver.bdrv_co_drain_begin/end callbacks */
93
+ +/* Recursively call BlockDriver.bdrv_drain_begin/end callbacks */
94
+ static void bdrv_drain_invoke(BlockDriverState *bs, bool begin,
95
+ int *drained_end_counter)
96
+ {
97
+ - BdrvCoDrainData *data;
98
+ -
99
+ - if (!bs->drv || (begin && !bs->drv->bdrv_co_drain_begin) ||
100
+ - (!begin && !bs->drv->bdrv_co_drain_end)) {
101
+ + if (!bs->drv || (begin && !bs->drv->bdrv_drain_begin) ||
102
+ + (!begin && !bs->drv->bdrv_drain_end)) {
103
+ return;
104
+ }
105
+
106
+ - data = g_new(BdrvCoDrainData, 1);
107
+ - *data = (BdrvCoDrainData) {
108
+ - .bs = bs,
109
+ - .done = false,
110
+ - .begin = begin,
111
+ - .drained_end_counter = drained_end_counter,
112
+ - };
113
+ -
114
+ - if (!begin) {
115
+ - qatomic_inc(drained_end_counter);
116
+ + if (begin) {
117
+ + bs->drv->bdrv_drain_begin(bs);
118
+ + } else {
119
+ + bs->drv->bdrv_drain_end(bs);
120
+ }
121
+ -
122
+ - /* Make sure the driver callback completes during the polling phase for
123
+ - * drain_begin. */
124
+ - bdrv_inc_in_flight(bs);
125
+ - data->co = qemu_coroutine_create(bdrv_drain_invoke_entry, data);
126
+ - aio_co_schedule(bdrv_get_aio_context(bs), data->co);
127
+ }
128
+
129
+ /* Returns true if BDRV_POLL_WHILE() should go into a blocking aio_poll() */
130
+ diff --git a/block/qed.c b/block/qed.c
131
+ index 013f826c44..c2691a85b1 100644
132
+ --- a/block/qed.c
133
+ +++ b/block/qed.c
134
+ @@ -262,7 +262,7 @@ static bool coroutine_fn qed_plug_allocating_write_reqs(BDRVQEDState *s)
135
+ assert(!s->allocating_write_reqs_plugged);
136
+ if (s->allocating_acb != NULL) {
137
+ /* Another allocating write came concurrently. This cannot happen
138
+ - * from bdrv_qed_co_drain_begin, but it can happen when the timer runs.
139
+ + * from bdrv_qed_drain_begin, but it can happen when the timer runs.
140
+ */
141
+ qemu_co_mutex_unlock(&s->table_lock);
142
+ return false;
143
+ @@ -365,7 +365,7 @@ static void bdrv_qed_attach_aio_context(BlockDriverState *bs,
144
+ }
145
+ }
146
+
147
+ -static void coroutine_fn bdrv_qed_co_drain_begin(BlockDriverState *bs)
148
+ +static void bdrv_qed_drain_begin(BlockDriverState *bs)
149
+ {
150
+ BDRVQEDState *s = bs->opaque;
151
+
152
+ @@ -1661,7 +1661,7 @@ static BlockDriver bdrv_qed = {
153
+ .bdrv_co_check = bdrv_qed_co_check,
154
+ .bdrv_detach_aio_context = bdrv_qed_detach_aio_context,
155
+ .bdrv_attach_aio_context = bdrv_qed_attach_aio_context,
156
+ - .bdrv_co_drain_begin = bdrv_qed_co_drain_begin,
157
+ + .bdrv_drain_begin = bdrv_qed_drain_begin,
158
+ };
159
+
160
+ static void bdrv_qed_init(void)
161
+ diff --git a/block/throttle.c b/block/throttle.c
162
+ index 131eba3ab4..88851c84f4 100644
163
+ --- a/block/throttle.c
164
+ +++ b/block/throttle.c
165
+ @@ -214,7 +214,7 @@ static void throttle_reopen_abort(BDRVReopenState *reopen_state)
166
+ reopen_state->opaque = NULL;
167
+ }
168
+
169
+ -static void coroutine_fn throttle_co_drain_begin(BlockDriverState *bs)
170
+ +static void throttle_drain_begin(BlockDriverState *bs)
171
+ {
172
+ ThrottleGroupMember *tgm = bs->opaque;
173
+ if (qatomic_fetch_inc(&tgm->io_limits_disabled) == 0) {
174
+ @@ -222,7 +222,7 @@ static void coroutine_fn throttle_co_drain_begin(BlockDriverState *bs)
175
+ }
176
+ }
177
+
178
+ -static void coroutine_fn throttle_co_drain_end(BlockDriverState *bs)
179
+ +static void throttle_drain_end(BlockDriverState *bs)
180
+ {
181
+ ThrottleGroupMember *tgm = bs->opaque;
182
+ assert(tgm->io_limits_disabled);
183
+ @@ -261,8 +261,8 @@ static BlockDriver bdrv_throttle = {
184
+ .bdrv_reopen_commit = throttle_reopen_commit,
185
+ .bdrv_reopen_abort = throttle_reopen_abort,
186
+
187
+ - .bdrv_co_drain_begin = throttle_co_drain_begin,
188
+ - .bdrv_co_drain_end = throttle_co_drain_end,
189
+ + .bdrv_drain_begin = throttle_drain_begin,
190
+ + .bdrv_drain_end = throttle_drain_end,
191
+
192
+ .is_filter = true,
193
+ .strong_runtime_opts = throttle_strong_runtime_opts,
194
+ diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
195
+ index 31ae91e56e..40d646d1ed 100644
196
+ --- a/include/block/block_int-common.h
197
+ +++ b/include/block/block_int-common.h
198
+ @@ -735,17 +735,19 @@ struct BlockDriver {
199
+ void (*bdrv_io_unplug)(BlockDriverState *bs);
200
+
201
+ /**
202
+ - * bdrv_co_drain_begin is called if implemented in the beginning of a
203
+ + * bdrv_drain_begin is called if implemented in the beginning of a
204
+ * drain operation to drain and stop any internal sources of requests in
205
+ * the driver.
206
+ - * bdrv_co_drain_end is called if implemented at the end of the drain.
207
+ + * bdrv_drain_end is called if implemented at the end of the drain.
208
+ *
209
+ * They should be used by the driver to e.g. manage scheduled I/O
210
+ * requests, or toggle an internal state. After the end of the drain new
211
+ * requests will continue normally.
212
+ + *
213
+ + * Implementations of both functions must not call aio_poll().
214
+ */
215
+ - void coroutine_fn (*bdrv_co_drain_begin)(BlockDriverState *bs);
216
+ - void coroutine_fn (*bdrv_co_drain_end)(BlockDriverState *bs);
217
+ + void (*bdrv_drain_begin)(BlockDriverState *bs);
218
+ + void (*bdrv_drain_end)(BlockDriverState *bs);
219
+
220
+ bool (*bdrv_supports_persistent_dirty_bitmap)(BlockDriverState *bs);
221
+ bool coroutine_fn (*bdrv_co_can_store_new_dirty_bitmap)(
222
+ diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c
223
+ index 24f34e24ad..695519ee02 100644
224
+ --- a/tests/unit/test-bdrv-drain.c
225
+ +++ b/tests/unit/test-bdrv-drain.c
226
+ @@ -46,7 +46,7 @@ static void coroutine_fn sleep_in_drain_begin(void *opaque)
227
+ bdrv_dec_in_flight(bs);
228
+ }
229
+
230
+ -static void coroutine_fn bdrv_test_co_drain_begin(BlockDriverState *bs)
231
+ +static void bdrv_test_drain_begin(BlockDriverState *bs)
232
+ {
233
+ BDRVTestState *s = bs->opaque;
234
+ s->drain_count++;
235
+ @@ -57,7 +57,7 @@ static void coroutine_fn bdrv_test_co_drain_begin(BlockDriverState *bs)
236
+ }
237
+ }
238
+
239
+ -static void coroutine_fn bdrv_test_co_drain_end(BlockDriverState *bs)
240
+ +static void bdrv_test_drain_end(BlockDriverState *bs)
241
+ {
242
+ BDRVTestState *s = bs->opaque;
243
+ s->drain_count--;
244
+ @@ -111,8 +111,8 @@ static BlockDriver bdrv_test = {
245
+ .bdrv_close = bdrv_test_close,
246
+ .bdrv_co_preadv = bdrv_test_co_preadv,
247
+
248
+ - .bdrv_co_drain_begin = bdrv_test_co_drain_begin,
249
+ - .bdrv_co_drain_end = bdrv_test_co_drain_end,
250
+ + .bdrv_drain_begin = bdrv_test_drain_begin,
251
+ + .bdrv_drain_end = bdrv_test_drain_end,
252
+
253
+ .bdrv_child_perm = bdrv_default_perms,
254
+
255
+ @@ -1703,6 +1703,7 @@ static void test_blockjob_commit_by_drained_end(void)
256
+ bdrv_drained_begin(bs_child);
257
+ g_assert(!job_has_completed);
258
+ bdrv_drained_end(bs_child);
259
+ + aio_poll(qemu_get_aio_context(), false);
260
+ g_assert(job_has_completed);
261
+
262
+ bdrv_unref(bs_parents[0]);
263
+ @@ -1858,6 +1859,7 @@ static void test_drop_intermediate_poll(void)
264
+
265
+ g_assert(!job_has_completed);
266
+ ret = bdrv_drop_intermediate(chain[1], chain[0], NULL);
267
+ + aio_poll(qemu_get_aio_context(), false);
268
+ g_assert(ret == 0);
269
+ g_assert(job_has_completed);
270
+
271
+ @@ -1946,7 +1948,7 @@ static void coroutine_fn bdrv_replace_test_drain_co(void *opaque)
272
+ * .was_drained.
273
+ * Increment .drain_count.
274
+ */
275
+ -static void coroutine_fn bdrv_replace_test_co_drain_begin(BlockDriverState *bs)
276
+ +static void bdrv_replace_test_drain_begin(BlockDriverState *bs)
277
+ {
278
+ BDRVReplaceTestState *s = bs->opaque;
279
+
280
+ @@ -1977,7 +1979,7 @@ static void coroutine_fn bdrv_replace_test_read_entry(void *opaque)
281
+ * If .drain_count reaches 0 and the node has a backing file, issue a
282
+ * read request.
283
+ */
284
+ -static void coroutine_fn bdrv_replace_test_co_drain_end(BlockDriverState *bs)
285
+ +static void bdrv_replace_test_drain_end(BlockDriverState *bs)
286
+ {
287
+ BDRVReplaceTestState *s = bs->opaque;
288
+
289
+ @@ -2002,8 +2004,8 @@ static BlockDriver bdrv_replace_test = {
290
+ .bdrv_close = bdrv_replace_test_close,
291
+ .bdrv_co_preadv = bdrv_replace_test_co_preadv,
292
+
293
+ - .bdrv_co_drain_begin = bdrv_replace_test_co_drain_begin,
294
+ - .bdrv_co_drain_end = bdrv_replace_test_co_drain_end,
295
+ + .bdrv_drain_begin = bdrv_replace_test_drain_begin,
296
+ + .bdrv_drain_end = bdrv_replace_test_drain_end,
297
+
298
+ .bdrv_child_perm = bdrv_default_perms,
299
+ };
300
+ --
301
+ 2.31.1
302
+
SOURCES/kvm-block-Split-BlockNodeInfo-off-of-ImageInfo.patch ADDED
@@ -0,0 +1,246 @@
1
+ From 54e290df4bc1c9e83be7357caed6a2b1ba4f21f0 Mon Sep 17 00:00:00 2001
2
+ From: Hanna Reitz <hreitz@redhat.com>
3
+ Date: Mon, 20 Jun 2022 18:26:56 +0200
4
+ Subject: [PATCH 09/20] block: Split BlockNodeInfo off of ImageInfo
5
+
6
+ RH-Author: Hanna Czenczek <hreitz@redhat.com>
7
+ RH-MergeRequest: 145: Show protocol-level information in qemu-img info
8
+ RH-Bugzilla: 1860292
9
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
10
+ RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
11
+ RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
12
+ RH-Commit: [4/12] fc8d69d549bb9a929db218b91697ee3ae95c1ff6 (hreitz/qemu-kvm-c-9-s)
13
+
14
+ ImageInfo sometimes contains flat information, and sometimes it does
15
+ not. Split off a BlockNodeInfo struct, which only contains information
16
+ about a single node and has no link to the backing image.
17
+
18
+ We do this so we can extend BlockNodeInfo to a BlockGraphInfo struct,
19
+ which has links to all child nodes, not just the backing node. It would
20
+ be strange to base BlockGraphInfo on ImageInfo, because then this
21
+ extended struct would have two links to the backing node (one in
22
+ BlockGraphInfo as one of all the child links, and one in ImageInfo).
23
+
24
+ Furthermore, it is quite common to ignore the backing-image field
25
+ altogether: bdrv_query_image_info() does not set it, and
26
+ bdrv_image_info_dump() does not evaluate it. That signals that we
27
+ should have different structs for describing a single node and one that
28
+ has a link to the backing image.
29
+
30
+ Still, bdrv_query_image_info() and bdrv_image_info_dump() are not
31
+ changed too much in this patch. Follow-up patches will handle them.
32
+
33
+ Signed-off-by: Hanna Reitz <hreitz@redhat.com>
34
+ Message-Id: <20220620162704.80987-5-hreitz@redhat.com>
35
+ Reviewed-by: Kevin Wolf <kwolf@redhat.com>
36
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
37
+ (cherry picked from commit a2085f8909377b6df738f6c3f7ee6db4d16da8f7)
38
+ Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
39
+ ---
40
+ block/qapi.c | 86 ++++++++++++++++++++++++++++++++------------
41
+ include/block/qapi.h | 3 ++
42
+ qapi/block-core.json | 24 +++++++++----
43
+ 3 files changed, 85 insertions(+), 28 deletions(-)
44
+
45
+ diff --git a/block/qapi.c b/block/qapi.c
46
+ index 51202b470a..e5022b4481 100644
47
+ --- a/block/qapi.c
48
+ +++ b/block/qapi.c
49
+ @@ -241,30 +241,18 @@ int bdrv_query_snapshot_info_list(BlockDriverState *bs,
50
+ }
51
+
52
+ /**
53
+ - * bdrv_query_image_info:
54
+ - * @bs: block device to examine
55
+ - * @p_info: location to store image information
56
+ - * @errp: location to store error information
57
+ - *
58
+ - * Store "flat" image information in @p_info.
59
+ - *
60
+ - * "Flat" means it does *not* query backing image information,
61
+ - * i.e. (*pinfo)->has_backing_image will be set to false and
62
+ - * (*pinfo)->backing_image to NULL even when the image does in fact have
63
+ - * a backing image.
64
+ - *
65
+ - * @p_info will be set only on success. On error, store error in @errp.
66
+ + * Helper function for other query info functions. Store information about @bs
67
+ + * in @info, setting @errp on error.
68
+ */
69
+ -void bdrv_query_image_info(BlockDriverState *bs,
70
+ - ImageInfo **p_info,
71
+ - Error **errp)
72
+ +static void bdrv_do_query_node_info(BlockDriverState *bs,
73
+ + BlockNodeInfo *info,
74
+ + Error **errp)
75
+ {
76
+ int64_t size;
77
+ const char *backing_filename;
78
+ BlockDriverInfo bdi;
79
+ int ret;
80
+ Error *err = NULL;
81
+ - ImageInfo *info;
82
+
83
+ aio_context_acquire(bdrv_get_aio_context(bs));
84
+
85
+ @@ -277,7 +265,6 @@ void bdrv_query_image_info(BlockDriverState *bs,
86
+
87
+ bdrv_refresh_filename(bs);
88
+
89
+ - info = g_new0(ImageInfo, 1);
90
+ info->filename = g_strdup(bs->filename);
91
+ info->format = g_strdup(bdrv_get_format_name(bs));
92
+ info->virtual_size = size;
93
+ @@ -298,7 +285,6 @@ void bdrv_query_image_info(BlockDriverState *bs,
94
+ info->format_specific = bdrv_get_specific_info(bs, &err);
95
+ if (err) {
96
+ error_propagate(errp, err);
97
+ - qapi_free_ImageInfo(info);
98
+ goto out;
99
+ }
100
+ info->has_format_specific = info->format_specific != NULL;
101
+ @@ -339,16 +325,72 @@ void bdrv_query_image_info(BlockDriverState *bs,
102
+ break;
103
+ default:
104
+ error_propagate(errp, err);
105
+ - qapi_free_ImageInfo(info);
106
+ goto out;
107
+ }
108
+
109
+ - *p_info = info;
110
+ -
111
+ out:
112
+ aio_context_release(bdrv_get_aio_context(bs));
113
+ }
114
+
115
+ +/**
116
+ + * bdrv_query_block_node_info:
117
+ + * @bs: block node to examine
118
+ + * @p_info: location to store node information
119
+ + * @errp: location to store error information
120
+ + *
121
+ + * Store image information about @bs in @p_info.
122
+ + *
123
+ + * @p_info will be set only on success. On error, store error in @errp.
124
+ + */
125
+ +void bdrv_query_block_node_info(BlockDriverState *bs,
126
+ + BlockNodeInfo **p_info,
127
+ + Error **errp)
128
+ +{
129
+ + BlockNodeInfo *info;
130
+ + ERRP_GUARD();
131
+ +
132
+ + info = g_new0(BlockNodeInfo, 1);
133
+ + bdrv_do_query_node_info(bs, info, errp);
134
+ + if (*errp) {
135
+ + qapi_free_BlockNodeInfo(info);
136
+ + return;
137
+ + }
138
+ +
139
+ + *p_info = info;
140
+ +}
141
+ +
142
+ +/**
143
+ + * bdrv_query_image_info:
144
+ + * @bs: block node to examine
145
+ + * @p_info: location to store image information
146
+ + * @errp: location to store error information
147
+ + *
148
+ + * Store "flat" image information in @p_info.
149
+ + *
150
+ + * "Flat" means it does *not* query backing image information,
151
+ + * i.e. (*pinfo)->has_backing_image will be set to false and
152
+ + * (*pinfo)->backing_image to NULL even when the image does in fact have
153
+ + * a backing image.
154
+ + *
155
+ + * @p_info will be set only on success. On error, store error in @errp.
156
+ + */
157
+ +void bdrv_query_image_info(BlockDriverState *bs,
158
+ + ImageInfo **p_info,
159
+ + Error **errp)
160
+ +{
161
+ + ImageInfo *info;
162
+ + ERRP_GUARD();
163
+ +
164
+ + info = g_new0(ImageInfo, 1);
165
+ + bdrv_do_query_node_info(bs, qapi_ImageInfo_base(info), errp);
166
+ + if (*errp) {
167
+ + qapi_free_ImageInfo(info);
168
+ + return;
169
+ + }
170
+ +
171
+ + *p_info = info;
172
+ +}
173
+ +
174
+ /* @p_info will be set only on success. */
175
+ static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info,
176
+ Error **errp)
177
+ diff --git a/include/block/qapi.h b/include/block/qapi.h
178
+ index c09859ea78..c7de4e3fa9 100644
179
+ --- a/include/block/qapi.h
180
+ +++ b/include/block/qapi.h
181
+ @@ -35,6 +35,9 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
182
+ int bdrv_query_snapshot_info_list(BlockDriverState *bs,
183
+ SnapshotInfoList **p_list,
184
+ Error **errp);
185
+ +void bdrv_query_block_node_info(BlockDriverState *bs,
186
+ + BlockNodeInfo **p_info,
187
+ + Error **errp);
188
+ void bdrv_query_image_info(BlockDriverState *bs,
189
+ ImageInfo **p_info,
190
+ Error **errp);
191
+ diff --git a/qapi/block-core.json b/qapi/block-core.json
192
+ index 4b9365167f..7720da0498 100644
193
+ --- a/qapi/block-core.json
194
+ +++ b/qapi/block-core.json
195
+ @@ -251,7 +251,7 @@
196
+ } }
197
+
198
+ ##
199
+ -# @ImageInfo:
200
+ +# @BlockNodeInfo:
201
+ #
202
+ # Information about a QEMU image file
203
+ #
204
+ @@ -279,22 +279,34 @@
205
+ #
206
+ # @snapshots: list of VM snapshots
207
+ #
208
+ -# @backing-image: info of the backing image (since 1.6)
209
+ -#
210
+ # @format-specific: structure supplying additional format-specific
211
+ # information (since 1.7)
212
+ #
213
+ -# Since: 1.3
214
+ +# Since: 8.0
215
+ ##
216
+ -{ 'struct': 'ImageInfo',
217
+ +{ 'struct': 'BlockNodeInfo',
218
+ 'data': {'filename': 'str', 'format': 'str', '*dirty-flag': 'bool',
219
+ '*actual-size': 'int', 'virtual-size': 'int',
220
+ '*cluster-size': 'int', '*encrypted': 'bool', '*compressed': 'bool',
221
+ '*backing-filename': 'str', '*full-backing-filename': 'str',
222
+ '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'],
223
+ - '*backing-image': 'ImageInfo',
224
+ '*format-specific': 'ImageInfoSpecific' } }
225
+
226
+ +##
227
+ +# @ImageInfo:
228
+ +#
229
+ +# Information about a QEMU image file, and potentially its backing image
230
+ +#
231
+ +# @backing-image: info of the backing image
232
+ +#
233
+ +# Since: 1.3
234
+ +##
235
+ +{ 'struct': 'ImageInfo',
236
+ + 'base': 'BlockNodeInfo',
237
+ + 'data': {
238
+ + '*backing-image': 'ImageInfo'
239
+ + } }
240
+ +
241
+ ##
242
+ # @ImageCheck:
243
+ #
244
+ --
245
+ 2.31.1
246
+
SOURCES/kvm-block-drop-bdrv_remove_filter_or_cow_child.patch ADDED
@@ -0,0 +1,70 @@
1
+ From defd6b325264d94ffb1355a8b19f9a77bd694a2f Mon Sep 17 00:00:00 2001
2
+ From: Vladimir Sementsov-Ogievskiy <vladimir.sementsov-ogievskiy@openvz.org>
3
+ Date: Mon, 7 Nov 2022 19:35:56 +0300
4
+ Subject: [PATCH 13/31] block: drop bdrv_remove_filter_or_cow_child
5
+
6
+ RH-Author: Stefano Garzarella <sgarzare@redhat.com>
7
+ RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
8
+ RH-Bugzilla: 2155112
9
+ RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
10
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
11
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
12
+ RH-Commit: [1/16] 6339edd738c3b79f8ecb6c1e012e52b6afb1a622 (sgarzarella/qemu-kvm-c-9-s)
13
+
14
+ Drop this simple wrapper used only in one place. We have too many graph
15
+ modifying functions even without it.
16
+
17
+ Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
18
+ Reviewed-by: Hanna Reitz <hreitz@redhat.com>
19
+ Message-Id: <20221107163558.618889-3-vsementsov@yandex-team.ru>
20
+ Reviewed-by: Kevin Wolf <kwolf@redhat.com>
21
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
22
+ (cherry picked from commit f38eaec4c3618dfc4a23e20435cefb5bf8325264)
23
+ Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
24
+ ---
25
+ block.c | 15 +--------------
26
+ 1 file changed, 1 insertion(+), 14 deletions(-)
27
+
28
+ diff --git a/block.c b/block.c
29
+ index a18f052374..ec184150a2 100644
30
+ --- a/block.c
31
+ +++ b/block.c
32
+ @@ -93,8 +93,6 @@ static bool bdrv_recurse_has_child(BlockDriverState *bs,
33
+ static void bdrv_replace_child_noperm(BdrvChild *child,
34
+ BlockDriverState *new_bs);
35
+ static void bdrv_remove_child(BdrvChild *child, Transaction *tran);
36
+ -static void bdrv_remove_filter_or_cow_child(BlockDriverState *bs,
37
+ - Transaction *tran);
38
+
39
+ static int bdrv_reopen_prepare(BDRVReopenState *reopen_state,
40
+ BlockReopenQueue *queue,
41
+ @@ -5073,17 +5071,6 @@ static void bdrv_remove_child(BdrvChild *child, Transaction *tran)
42
+ tran_add(tran, &bdrv_remove_child_drv, child);
43
+ }
44
+
45
+ -/*
46
+ - * A function to remove backing-chain child of @bs if exists: cow child for
47
+ - * format nodes (always .backing) and filter child for filters (may be .file or
48
+ - * .backing)
49
+ - */
50
+ -static void bdrv_remove_filter_or_cow_child(BlockDriverState *bs,
51
+ - Transaction *tran)
52
+ -{
53
+ - bdrv_remove_child(bdrv_filter_or_cow_child(bs), tran);
54
+ -}
55
+ -
56
+ static int bdrv_replace_node_noperm(BlockDriverState *from,
57
+ BlockDriverState *to,
58
+ bool auto_skip, Transaction *tran,
59
+ @@ -5168,7 +5155,7 @@ static int bdrv_replace_node_common(BlockDriverState *from,
60
+ }
61
+
62
+ if (detach_subchain) {
63
+ - bdrv_remove_filter_or_cow_child(to_cow_parent, tran);
64
+ + bdrv_remove_child(bdrv_filter_or_cow_child(to_cow_parent), tran);
65
+ }
66
+
67
+ found = g_hash_table_new(NULL, NULL);
68
+ --
69
+ 2.31.1
70
+
SOURCES/kvm-block-file-Add-file-specific-image-info.patch ADDED
@@ -0,0 +1,145 @@
1
+ From 4af86458d6bea2a6e15fd57d4d4bbe88e35f7e72 Mon Sep 17 00:00:00 2001
2
+ From: Hanna Reitz <hreitz@redhat.com>
3
+ Date: Mon, 20 Jun 2022 18:26:54 +0200
4
+ Subject: [PATCH 07/20] block/file: Add file-specific image info
5
+
6
+ RH-Author: Hanna Czenczek <hreitz@redhat.com>
7
+ RH-MergeRequest: 145: Show protocol-level information in qemu-img info
8
+ RH-Bugzilla: 1860292
9
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
10
+ RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
11
+ RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
12
+ RH-Commit: [2/12] d8cc351d6c16c41b2000e41dc555f13093a9edce (hreitz/qemu-kvm-c-9-s)
13
+
14
+ Add some (optional) information that the file driver can provide for
15
+ image files, namely the extent size hint.
16
+
17
+ Signed-off-by: Hanna Reitz <hreitz@redhat.com>
18
+ Message-Id: <20220620162704.80987-3-hreitz@redhat.com>
19
+ Reviewed-by: Kevin Wolf <kwolf@redhat.com>
20
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
21
+ (cherry picked from commit 7f36a50ab4e7d39369cac67be4ba9d6ee4081dc0)
22
+ Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
23
+ ---
24
+ block/file-posix.c | 30 ++++++++++++++++++++++++++++++
25
+ qapi/block-core.json | 26 ++++++++++++++++++++++++--
26
+ 2 files changed, 54 insertions(+), 2 deletions(-)
27
+
28
+ diff --git a/block/file-posix.c b/block/file-posix.c
29
+ index b9647c5ffc..df3da79aed 100644
30
+ --- a/block/file-posix.c
31
+ +++ b/block/file-posix.c
32
+ @@ -3095,6 +3095,34 @@ static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
33
+ return 0;
34
+ }
35
+
36
+ +static ImageInfoSpecific *raw_get_specific_info(BlockDriverState *bs,
37
+ + Error **errp)
38
+ +{
39
+ + ImageInfoSpecificFile *file_info = g_new0(ImageInfoSpecificFile, 1);
40
+ + ImageInfoSpecific *spec_info = g_new(ImageInfoSpecific, 1);
41
+ +
42
+ + *spec_info = (ImageInfoSpecific){
43
+ + .type = IMAGE_INFO_SPECIFIC_KIND_FILE,
44
+ + .u.file.data = file_info,
45
+ + };
46
+ +
47
+ +#ifdef FS_IOC_FSGETXATTR
48
+ + {
49
+ + BDRVRawState *s = bs->opaque;
50
+ + struct fsxattr attr;
51
+ + int ret;
52
+ +
53
+ + ret = ioctl(s->fd, FS_IOC_FSGETXATTR, &attr);
54
+ + if (!ret && attr.fsx_extsize != 0) {
55
+ + file_info->has_extent_size_hint = true;
56
+ + file_info->extent_size_hint = attr.fsx_extsize;
57
+ + }
58
+ + }
59
+ +#endif
60
+ +
61
+ + return spec_info;
62
+ +}
63
+ +
64
+ static BlockStatsSpecificFile get_blockstats_specific_file(BlockDriverState *bs)
65
+ {
66
+ BDRVRawState *s = bs->opaque;
67
+ @@ -3328,6 +3356,7 @@ BlockDriver bdrv_file = {
68
+ .bdrv_co_truncate = raw_co_truncate,
69
+ .bdrv_getlength = raw_getlength,
70
+ .bdrv_get_info = raw_get_info,
71
+ + .bdrv_get_specific_info = raw_get_specific_info,
72
+ .bdrv_get_allocated_file_size
73
+ = raw_get_allocated_file_size,
74
+ .bdrv_get_specific_stats = raw_get_specific_stats,
75
+ @@ -3700,6 +3729,7 @@ static BlockDriver bdrv_host_device = {
76
+ .bdrv_co_truncate = raw_co_truncate,
77
+ .bdrv_getlength = raw_getlength,
78
+ .bdrv_get_info = raw_get_info,
79
+ + .bdrv_get_specific_info = raw_get_specific_info,
80
+ .bdrv_get_allocated_file_size
81
+ = raw_get_allocated_file_size,
82
+ .bdrv_get_specific_stats = hdev_get_specific_stats,
83
+ diff --git a/qapi/block-core.json b/qapi/block-core.json
84
+ index 95ac4fa634..f5d822cbd6 100644
85
+ --- a/qapi/block-core.json
86
+ +++ b/qapi/block-core.json
87
+ @@ -139,16 +139,29 @@
88
+ '*encryption-format': 'RbdImageEncryptionFormat'
89
+ } }
90
+
91
+ +##
92
+ +# @ImageInfoSpecificFile:
93
+ +#
94
+ +# @extent-size-hint: Extent size hint (if available)
95
+ +#
96
+ +# Since: 8.0
97
+ +##
98
+ +{ 'struct': 'ImageInfoSpecificFile',
99
+ + 'data': {
100
+ + '*extent-size-hint': 'size'
101
+ + } }
102
+ +
103
+ ##
104
+ # @ImageInfoSpecificKind:
105
+ #
106
+ # @luks: Since 2.7
107
+ # @rbd: Since 6.1
108
+ +# @file: Since 8.0
109
+ #
110
+ # Since: 1.7
111
+ ##
112
+ { 'enum': 'ImageInfoSpecificKind',
113
+ - 'data': [ 'qcow2', 'vmdk', 'luks', 'rbd' ] }
114
+ + 'data': [ 'qcow2', 'vmdk', 'luks', 'rbd', 'file' ] }
115
+
116
+ ##
117
+ # @ImageInfoSpecificQCow2Wrapper:
118
+ @@ -185,6 +198,14 @@
119
+ { 'struct': 'ImageInfoSpecificRbdWrapper',
120
+ 'data': { 'data': 'ImageInfoSpecificRbd' } }
121
+
122
+ +##
123
+ +# @ImageInfoSpecificFileWrapper:
124
+ +#
125
+ +# Since: 8.0
126
+ +##
127
+ +{ 'struct': 'ImageInfoSpecificFileWrapper',
128
+ + 'data': { 'data': 'ImageInfoSpecificFile' } }
129
+ +
130
+ ##
131
+ # @ImageInfoSpecific:
132
+ #
133
+ @@ -199,7 +220,8 @@
134
+ 'qcow2': 'ImageInfoSpecificQCow2Wrapper',
135
+ 'vmdk': 'ImageInfoSpecificVmdkWrapper',
136
+ 'luks': 'ImageInfoSpecificLUKSWrapper',
137
+ - 'rbd': 'ImageInfoSpecificRbdWrapper'
138
+ + 'rbd': 'ImageInfoSpecificRbdWrapper',
139
+ + 'file': 'ImageInfoSpecificFileWrapper'
140
+ } }
141
+
142
+ ##
143
+ --
144
+ 2.31.1
145
+
SOURCES/kvm-block-qapi-Add-indentation-to-bdrv_node_info_dump.patch ADDED
@@ -0,0 +1,206 @@
1
+ From c8c282c2e1d74cfc5de6527f7e20dfc3e76b67ac Mon Sep 17 00:00:00 2001
2
+ From: Hanna Reitz <hreitz@redhat.com>
3
+ Date: Mon, 20 Jun 2022 18:27:00 +0200
4
+ Subject: [PATCH 13/20] block/qapi: Add indentation to bdrv_node_info_dump()
5
+
6
+ RH-Author: Hanna Czenczek <hreitz@redhat.com>
7
+ RH-MergeRequest: 145: Show protocol-level information in qemu-img info
8
+ RH-Bugzilla: 1860292
9
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
10
+ RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
11
+ RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
12
+ RH-Commit: [8/12] d3a697e81ab9828457198075e5815a592363c725 (hreitz/qemu-kvm-c-9-s)
13
+
14
+ In order to let qemu-img info present a block graph, add a parameter to
15
+ bdrv_node_info_dump() and bdrv_image_info_specific_dump() so that the
16
+ information of nodes below the root level can be given an indentation.
17
+
18
+ Signed-off-by: Hanna Reitz <hreitz@redhat.com>
19
+ Message-Id: <20220620162704.80987-9-hreitz@redhat.com>
20
+ Reviewed-by: Kevin Wolf <kwolf@redhat.com>
21
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
22
+ (cherry picked from commit 76c9e9750d1bd580e8ed4465f6be3a986434e7c3)
23
+ Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
24
+ ---
25
+ block/monitor/block-hmp-cmds.c | 2 +-
26
+ block/qapi.c | 47 +++++++++++++++++++---------------
27
+ include/block/qapi.h | 5 ++--
28
+ qemu-img.c | 2 +-
29
+ qemu-io-cmds.c | 3 ++-
30
+ 5 files changed, 34 insertions(+), 25 deletions(-)
31
+
32
+ diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
33
+ index aa37faa601..72824d4e2e 100644
34
+ --- a/block/monitor/block-hmp-cmds.c
35
+ +++ b/block/monitor/block-hmp-cmds.c
36
+ @@ -734,7 +734,7 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
37
+ monitor_printf(mon, "\nImages:\n");
38
+ image_info = inserted->image;
39
+ while (1) {
40
+ - bdrv_node_info_dump(qapi_ImageInfo_base(image_info));
41
+ + bdrv_node_info_dump(qapi_ImageInfo_base(image_info), 0);
42
+ if (image_info->has_backing_image) {
43
+ image_info = image_info->backing_image;
44
+ } else {
45
+ diff --git a/block/qapi.c b/block/qapi.c
46
+ index f208c21ccf..3e35603f0c 100644
47
+ --- a/block/qapi.c
48
+ +++ b/block/qapi.c
49
+ @@ -915,7 +915,8 @@ static bool qobject_is_empty_dump(const QObject *obj)
50
+ * prepending an optional prefix if the dump is not empty.
51
+ */
52
+ void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec,
53
+ - const char *prefix)
54
+ + const char *prefix,
55
+ + int indentation)
56
+ {
57
+ QObject *obj, *data;
58
+ Visitor *v = qobject_output_visitor_new(&obj);
59
+ @@ -925,48 +926,51 @@ void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec,
60
+ data = qdict_get(qobject_to(QDict, obj), "data");
61
+ if (!qobject_is_empty_dump(data)) {
62
+ if (prefix) {
63
+ - qemu_printf("%s", prefix);
64
+ + qemu_printf("%*s%s", indentation * 4, "", prefix);
65
+ }
66
+ - dump_qobject(1, data);
67
+ + dump_qobject(indentation + 1, data);
68
+ }
69
+ qobject_unref(obj);
70
+ visit_free(v);
71
+ }
72
+
73
+ -void bdrv_node_info_dump(BlockNodeInfo *info)
74
+ +void bdrv_node_info_dump(BlockNodeInfo *info, int indentation)
75
+ {
76
+ char *size_buf, *dsize_buf;
77
+ + g_autofree char *ind_s = g_strdup_printf("%*s", indentation * 4, "");
78
+ +
79
+ if (!info->has_actual_size) {
80
+ dsize_buf = g_strdup("unavailable");
81
+ } else {
82
+ dsize_buf = size_to_str(info->actual_size);
83
+ }
84
+ size_buf = size_to_str(info->virtual_size);
85
+ - qemu_printf("image: %s\n"
86
+ - "file format: %s\n"
87
+ - "virtual size: %s (%" PRId64 " bytes)\n"
88
+ - "disk size: %s\n",
89
+ - info->filename, info->format, size_buf,
90
+ - info->virtual_size,
91
+ - dsize_buf);
92
+ + qemu_printf("%simage: %s\n"
93
+ + "%sfile format: %s\n"
94
+ + "%svirtual size: %s (%" PRId64 " bytes)\n"
95
+ + "%sdisk size: %s\n",
96
+ + ind_s, info->filename,
97
+ + ind_s, info->format,
98
+ + ind_s, size_buf, info->virtual_size,
99
+ + ind_s, dsize_buf);
100
+ g_free(size_buf);
101
+ g_free(dsize_buf);
102
+
103
+ if (info->has_encrypted && info->encrypted) {
104
+ - qemu_printf("encrypted: yes\n");
105
+ + qemu_printf("%sencrypted: yes\n", ind_s);
106
+ }
107
+
108
+ if (info->has_cluster_size) {
109
+ - qemu_printf("cluster_size: %" PRId64 "\n",
110
+ - info->cluster_size);
111
+ + qemu_printf("%scluster_size: %" PRId64 "\n",
112
+ + ind_s, info->cluster_size);
113
+ }
114
+
115
+ if (info->has_dirty_flag && info->dirty_flag) {
116
+ - qemu_printf("cleanly shut down: no\n");
117
+ + qemu_printf("%scleanly shut down: no\n", ind_s);
118
+ }
119
+
120
+ if (info->has_backing_filename) {
121
+ - qemu_printf("backing file: %s", info->backing_filename);
122
+ + qemu_printf("%sbacking file: %s", ind_s, info->backing_filename);
123
+ if (!info->has_full_backing_filename) {
124
+ qemu_printf(" (cannot determine actual path)");
125
+ } else if (strcmp(info->backing_filename,
126
+ @@ -975,15 +979,16 @@ void bdrv_node_info_dump(BlockNodeInfo *info)
127
+ }
128
+ qemu_printf("\n");
129
+ if (info->has_backing_filename_format) {
130
+ - qemu_printf("backing file format: %s\n",
131
+ - info->backing_filename_format);
132
+ + qemu_printf("%sbacking file format: %s\n",
133
+ + ind_s, info->backing_filename_format);
134
+ }
135
+ }
136
+
137
+ if (info->has_snapshots) {
138
+ SnapshotInfoList *elem;
139
+
140
+ - qemu_printf("Snapshot list:\n");
141
+ + qemu_printf("%sSnapshot list:\n", ind_s);
142
+ + qemu_printf("%s", ind_s);
143
+ bdrv_snapshot_dump(NULL);
144
+ qemu_printf("\n");
145
+
146
+ @@ -1003,6 +1008,7 @@ void bdrv_node_info_dump(BlockNodeInfo *info)
147
+
148
+ pstrcpy(sn.id_str, sizeof(sn.id_str), elem->value->id);
149
+ pstrcpy(sn.name, sizeof(sn.name), elem->value->name);
150
+ + qemu_printf("%s", ind_s);
151
+ bdrv_snapshot_dump(&sn);
152
+ qemu_printf("\n");
153
+ }
154
+ @@ -1010,6 +1016,7 @@ void bdrv_node_info_dump(BlockNodeInfo *info)
155
+
156
+ if (info->has_format_specific) {
157
+ bdrv_image_info_specific_dump(info->format_specific,
158
+ - "Format specific information:\n");
159
+ + "Format specific information:\n",
160
+ + indentation);
161
+ }
162
+ }
163
+ diff --git a/include/block/qapi.h b/include/block/qapi.h
164
+ index 196436020e..38855f2ae9 100644
165
+ --- a/include/block/qapi.h
166
+ +++ b/include/block/qapi.h
167
+ @@ -49,6 +49,7 @@ void bdrv_query_block_graph_info(BlockDriverState *bs,
168
+
169
+ void bdrv_snapshot_dump(QEMUSnapshotInfo *sn);
170
+ void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec,
171
+ - const char *prefix);
172
+ -void bdrv_node_info_dump(BlockNodeInfo *info);
173
+ + const char *prefix,
174
+ + int indentation);
175
+ +void bdrv_node_info_dump(BlockNodeInfo *info, int indentation);
176
+ #endif
177
+ diff --git a/qemu-img.c b/qemu-img.c
178
+ index 3b2ca3bbcb..30b4ea58bb 100644
179
+ --- a/qemu-img.c
180
+ +++ b/qemu-img.c
181
+ @@ -2859,7 +2859,7 @@ static void dump_human_image_info_list(BlockNodeInfoList *list)
182
+ }
183
+ delim = true;
184
+
185
+ - bdrv_node_info_dump(elem->value);
186
+ + bdrv_node_info_dump(elem->value, 0);
187
+ }
188
+ }
189
+
190
+ diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
191
+ index f4a374528e..fdcb89211b 100644
192
+ --- a/qemu-io-cmds.c
193
+ +++ b/qemu-io-cmds.c
194
+ @@ -1826,7 +1826,8 @@ static int info_f(BlockBackend *blk, int argc, char **argv)
195
+ }
196
+ if (spec_info) {
197
+ bdrv_image_info_specific_dump(spec_info,
198
+ - "Format specific information:\n");
199
+ + "Format specific information:\n",
200
+ + 0);
201
+ qapi_free_ImageInfoSpecific(spec_info);
202
+ }
203
+
204
+ --
205
+ 2.31.1
206
+
SOURCES/kvm-block-qapi-Introduce-BlockGraphInfo.patch ADDED
@@ -0,0 +1,155 @@
1
+ From 0044e3848b02ef6edba5961d1f4b6297d137d207 Mon Sep 17 00:00:00 2001
2
+ From: Hanna Reitz <hreitz@redhat.com>
3
+ Date: Mon, 20 Jun 2022 18:26:59 +0200
4
+ Subject: [PATCH 12/20] block/qapi: Introduce BlockGraphInfo
5
+
6
+ RH-Author: Hanna Czenczek <hreitz@redhat.com>
7
+ RH-MergeRequest: 145: Show protocol-level information in qemu-img info
8
+ RH-Bugzilla: 1860292
9
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
10
+ RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
11
+ RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
12
+ RH-Commit: [7/12] de47bac372cd552b812c774a2f35f95923af74ff (hreitz/qemu-kvm-c-9-s)
13
+
14
+ Introduce a new QAPI type BlockGraphInfo and an associated
15
+ bdrv_query_block_graph_info() function that recursively gathers
16
+ BlockNodeInfo objects through a block graph.
17
+
18
+ A follow-up patch is going to make "qemu-img info" use this to print
19
+ information about all nodes that are (usually implicitly) opened for a
20
+ given image file.
21
+
22
+ Signed-off-by: Hanna Reitz <hreitz@redhat.com>
23
+ Message-Id: <20220620162704.80987-8-hreitz@redhat.com>
24
+ Reviewed-by: Kevin Wolf <kwolf@redhat.com>
25
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26
+ (cherry picked from commit 6cab33997b91eb86e82a6a2ae58a24f835249d4a)
27
+ Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
28
+ ---
29
+ block/qapi.c | 48 ++++++++++++++++++++++++++++++++++++++++++++
30
+ include/block/qapi.h | 3 +++
31
+ qapi/block-core.json | 35 ++++++++++++++++++++++++++++++++
32
+ 3 files changed, 86 insertions(+)
33
+
34
+ diff --git a/block/qapi.c b/block/qapi.c
35
+ index 5d0a8d2ce3..f208c21ccf 100644
36
+ --- a/block/qapi.c
37
+ +++ b/block/qapi.c
38
+ @@ -411,6 +411,54 @@ fail:
39
+ qapi_free_ImageInfo(info);
40
+ }
41
+
42
+ +/**
43
+ + * bdrv_query_block_graph_info:
44
+ + * @bs: root node to start from
45
+ + * @p_info: location to store image information
46
+ + * @errp: location to store error information
47
+ + *
48
+ + * Store image information about the graph starting from @bs in @p_info.
49
+ + *
50
+ + * @p_info will be set only on success. On error, store error in @errp.
51
+ + */
52
+ +void bdrv_query_block_graph_info(BlockDriverState *bs,
53
+ + BlockGraphInfo **p_info,
54
+ + Error **errp)
55
+ +{
56
+ + BlockGraphInfo *info;
57
+ + BlockChildInfoList **children_list_tail;
58
+ + BdrvChild *c;
59
+ + ERRP_GUARD();
60
+ +
61
+ + info = g_new0(BlockGraphInfo, 1);
62
+ + bdrv_do_query_node_info(bs, qapi_BlockGraphInfo_base(info), errp);
63
+ + if (*errp) {
64
+ + goto fail;
65
+ + }
66
+ +
67
+ + children_list_tail = &info->children;
68
+ +
69
+ + QLIST_FOREACH(c, &bs->children, next) {
70
+ + BlockChildInfo *c_info;
71
+ +
72
+ + c_info = g_new0(BlockChildInfo, 1);
73
+ + QAPI_LIST_APPEND(children_list_tail, c_info);
74
+ +
75
+ + c_info->name = g_strdup(c->name);
76
+ + bdrv_query_block_graph_info(c->bs, &c_info->info, errp);
77
+ + if (*errp) {
78
+ + goto fail;
79
+ + }
80
+ + }
81
+ +
82
+ + *p_info = info;
83
+ + return;
84
+ +
85
+ +fail:
86
+ + assert(*errp != NULL);
87
+ + qapi_free_BlockGraphInfo(info);
88
+ +}
89
+ +
90
+ /* @p_info will be set only on success. */
91
+ static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info,
92
+ Error **errp)
93
+ diff --git a/include/block/qapi.h b/include/block/qapi.h
94
+ index 2174bf8fa2..196436020e 100644
95
+ --- a/include/block/qapi.h
96
+ +++ b/include/block/qapi.h
97
+ @@ -43,6 +43,9 @@ void bdrv_query_image_info(BlockDriverState *bs,
98
+ bool flat,
99
+ bool skip_implicit_filters,
100
+ Error **errp);
101
+ +void bdrv_query_block_graph_info(BlockDriverState *bs,
102
+ + BlockGraphInfo **p_info,
103
+ + Error **errp);
104
+
105
+ void bdrv_snapshot_dump(QEMUSnapshotInfo *sn);
106
+ void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec,
107
+ diff --git a/qapi/block-core.json b/qapi/block-core.json
108
+ index 4cf2deeb6c..d703e0fb16 100644
109
+ --- a/qapi/block-core.json
110
+ +++ b/qapi/block-core.json
111
+ @@ -307,6 +307,41 @@
112
+ '*backing-image': 'ImageInfo'
113
+ } }
114
+
115
+ +##
116
+ +# @BlockChildInfo:
117
+ +#
118
+ +# Information about all nodes in the block graph starting at some node,
119
+ +# annotated with information about that node in relation to its parent.
120
+ +#
121
+ +# @name: Child name of the root node in the BlockGraphInfo struct, in its role
122
+ +# as the child of some undescribed parent node
123
+ +#
124
+ +# @info: Block graph information starting at this node
125
+ +#
126
+ +# Since: 8.0
127
+ +##
128
+ +{ 'struct': 'BlockChildInfo',
129
+ + 'data': {
130
+ + 'name': 'str',
131
+ + 'info': 'BlockGraphInfo'
132
+ + } }
133
+ +
134
+ +##
135
+ +# @BlockGraphInfo:
136
+ +#
137
+ +# Information about all nodes in a block (sub)graph in the form of BlockNodeInfo
138
+ +# data.
139
+ +# The base BlockNodeInfo struct contains the information for the (sub)graph's
140
+ +# root node.
141
+ +#
142
+ +# @children: Array of links to this node's child nodes' information
143
+ +#
144
+ +# Since: 8.0
145
+ +##
146
+ +{ 'struct': 'BlockGraphInfo',
147
+ + 'base': 'BlockNodeInfo',
148
+ + 'data': { 'children': ['BlockChildInfo'] } }
149
+ +
150
+ ##
151
+ # @ImageCheck:
152
+ #
153
+ --
154
+ 2.31.1
155
+
SOURCES/kvm-block-qapi-Let-bdrv_query_image_info-recurse.patch ADDED
@@ -0,0 +1,197 @@
1
+ From ae2c3df00d673d436fe4d8ec9103a3b76d7e6233 Mon Sep 17 00:00:00 2001
2
+ From: Hanna Reitz <hreitz@redhat.com>
3
+ Date: Mon, 20 Jun 2022 18:26:58 +0200
4
+ Subject: [PATCH 11/20] block/qapi: Let bdrv_query_image_info() recurse
5
+
6
+ RH-Author: Hanna Czenczek <hreitz@redhat.com>
7
+ RH-MergeRequest: 145: Show protocol-level information in qemu-img info
8
+ RH-Bugzilla: 1860292
9
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
10
+ RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
11
+ RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
12
+ RH-Commit: [6/12] 451a83fd682cd6dd6026c22974d18c2f12ee06e3 (hreitz/qemu-kvm-c-9-s)
13
+
14
+ There is no real reason why bdrv_query_image_info() should generally not
15
+ recurse. The ImageInfo struct has a pointer to the backing image, so it
16
+ should generally be filled, unless the caller explicitly opts out.
17
+
18
+ This moves the recursing code from bdrv_block_device_info() into
19
+ bdrv_query_image_info().
20
+
21
+ Signed-off-by: Hanna Reitz <hreitz@redhat.com>
22
+ Message-Id: <20220620162704.80987-7-hreitz@redhat.com>
23
+ Reviewed-by: Kevin Wolf <kwolf@redhat.com>
24
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
25
+ (cherry picked from commit 5d8813593f3f673fc96eed199beb35690cc46f58)
26
+
27
+ Conflicts:
28
+ block/qapi.c: Conflicts with
29
+ 54fde4ff0621c22b15cbaaa3c74301cc0dbd1c9e ("qapi block: Elide
30
+ redundant has_FOO in generated C"), which dropped
31
+ `has_backing_image`. Without that commit (and 44ea9d9be before it),
32
+ we still need to set `has_backing_image` in
33
+ `bdrv_query_image_info()`.
34
+
35
+ Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
36
+ ---
37
+ block/qapi.c | 94 +++++++++++++++++++++++++++-----------------
38
+ include/block/qapi.h | 2 +
39
+ 2 files changed, 59 insertions(+), 37 deletions(-)
40
+
41
+ diff --git a/block/qapi.c b/block/qapi.c
42
+ index ad88bf9b38..5d0a8d2ce3 100644
43
+ --- a/block/qapi.c
44
+ +++ b/block/qapi.c
45
+ @@ -47,8 +47,10 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
46
+ Error **errp)
47
+ {
48
+ ImageInfo **p_image_info;
49
+ + ImageInfo *backing_info;
50
+ BlockDriverState *bs0, *backing;
51
+ BlockDeviceInfo *info;
52
+ + ERRP_GUARD();
53
+
54
+ if (!bs->drv) {
55
+ error_setg(errp, "Block device %s is ejected", bs->node_name);
56
+ @@ -149,38 +151,21 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
57
+ bs0 = bs;
58
+ p_image_info = &info->image;
59
+ info->backing_file_depth = 0;
60
+ - while (1) {
61
+ - Error *local_err = NULL;
62
+ - bdrv_query_image_info(bs0, p_image_info, &local_err);
63
+ - if (local_err) {
64
+ - error_propagate(errp, local_err);
65
+ - qapi_free_BlockDeviceInfo(info);
66
+ - return NULL;
67
+ - }
68
+ -
69
+ - /* stop gathering data for flat output */
70
+ - if (flat) {
71
+ - break;
72
+ - }
73
+
74
+ - if (bs0->drv && bdrv_filter_or_cow_child(bs0)) {
75
+ - /*
76
+ - * Put any filtered child here (for backwards compatibility to when
77
+ - * we put bs0->backing here, which might be any filtered child).
78
+ - */
79
+ - info->backing_file_depth++;
80
+ - bs0 = bdrv_filter_or_cow_bs(bs0);
81
+ - (*p_image_info)->has_backing_image = true;
82
+ - p_image_info = &((*p_image_info)->backing_image);
83
+ - } else {
84
+ - break;
85
+ - }
86
+ + /*
87
+ + * Skip automatically inserted nodes that the user isn't aware of for
88
+ + * query-block (blk != NULL), but not for query-named-block-nodes
89
+ + */
90
+ + bdrv_query_image_info(bs0, p_image_info, flat, blk != NULL, errp);
91
+ + if (*errp) {
92
+ + qapi_free_BlockDeviceInfo(info);
93
+ + return NULL;
94
+ + }
95
+
96
+ - /* Skip automatically inserted nodes that the user isn't aware of for
97
+ - * query-block (blk != NULL), but not for query-named-block-nodes */
98
+ - if (blk) {
99
+ - bs0 = bdrv_skip_implicit_filters(bs0);
100
+ - }
101
+ + backing_info = info->image->backing_image;
102
+ + while (backing_info) {
103
+ + info->backing_file_depth++;
104
+ + backing_info = backing_info->backing_image;
105
+ }
106
+
107
+ return info;
108
+ @@ -363,19 +348,28 @@ void bdrv_query_block_node_info(BlockDriverState *bs,
109
+ * bdrv_query_image_info:
110
+ * @bs: block node to examine
111
+ * @p_info: location to store image information
112
+ + * @flat: skip backing node information
113
+ + * @skip_implicit_filters: skip implicit filters in the backing chain
114
+ * @errp: location to store error information
115
+ *
116
+ - * Store "flat" image information in @p_info.
117
+ + * Store image information in @p_info, potentially recursively covering the
118
+ + * backing chain.
119
+ *
120
+ - * "Flat" means it does *not* query backing image information,
121
+ - * i.e. (*pinfo)->has_backing_image will be set to false and
122
+ - * (*pinfo)->backing_image to NULL even when the image does in fact have
123
+ - * a backing image.
124
+ + * If @flat is true, do not query backing image information, i.e.
125
+ + * (*p_info)->has_backing_image will be set to false and
126
+ + * (*p_info)->backing_image to NULL even when the image does in fact have a
127
+ + * backing image.
128
+ + *
129
+ + * If @skip_implicit_filters is true, implicit filter nodes in the backing chain
130
+ + * will be skipped when querying backing image information.
131
+ + * (@skip_implicit_filters is ignored when @flat is true.)
132
+ *
133
+ * @p_info will be set only on success. On error, store error in @errp.
134
+ */
135
+ void bdrv_query_image_info(BlockDriverState *bs,
136
+ ImageInfo **p_info,
137
+ + bool flat,
138
+ + bool skip_implicit_filters,
139
+ Error **errp)
140
+ {
141
+ ImageInfo *info;
142
+ @@ -384,11 +378,37 @@ void bdrv_query_image_info(BlockDriverState *bs,
143
+ info = g_new0(ImageInfo, 1);
144
+ bdrv_do_query_node_info(bs, qapi_ImageInfo_base(info), errp);
145
+ if (*errp) {
146
+ - qapi_free_ImageInfo(info);
147
+ - return;
148
+ + goto fail;
149
+ + }
150
+ +
151
+ + if (!flat) {
152
+ + BlockDriverState *backing;
153
+ +
154
+ + /*
155
+ + * Use any filtered child here (for backwards compatibility to when
156
+ + * we always took bs->backing, which might be any filtered child).
157
+ + */
158
+ + backing = bdrv_filter_or_cow_bs(bs);
159
+ + if (skip_implicit_filters) {
160
+ + backing = bdrv_skip_implicit_filters(backing);
161
+ + }
162
+ +
163
+ + if (backing) {
164
+ + bdrv_query_image_info(backing, &info->backing_image, false,
165
+ + skip_implicit_filters, errp);
166
+ + if (*errp) {
167
+ + goto fail;
168
+ + }
169
+ + info->has_backing_image = true;
170
+ + }
171
+ }
172
+
173
+ *p_info = info;
174
+ + return;
175
+ +
176
+ +fail:
177
+ + assert(*errp);
178
+ + qapi_free_ImageInfo(info);
179
+ }
180
+
181
+ /* @p_info will be set only on success. */
182
+ diff --git a/include/block/qapi.h b/include/block/qapi.h
183
+ index 22198dcd0c..2174bf8fa2 100644
184
+ --- a/include/block/qapi.h
185
+ +++ b/include/block/qapi.h
186
+ @@ -40,6 +40,8 @@ void bdrv_query_block_node_info(BlockDriverState *bs,
187
+ Error **errp);
188
+ void bdrv_query_image_info(BlockDriverState *bs,
189
+ ImageInfo **p_info,
190
+ + bool flat,
191
+ + bool skip_implicit_filters,
192
+ Error **errp);
193
+
194
+ void bdrv_snapshot_dump(QEMUSnapshotInfo *sn);
195
+ --
196
+ 2.31.1
197
+
SOURCES/kvm-block-temporarily-hold-the-new-AioContext-of-bs_top-.patch ADDED
@@ -0,0 +1,99 @@
1
+ From b952c8f1da6f8597736c0e040565830139369359 Mon Sep 17 00:00:00 2001
2
+ From: Stefano Garzarella <sgarzare@redhat.com>
3
+ Date: Tue, 14 Feb 2023 18:16:21 +0100
4
+ Subject: [PATCH] block: temporarily hold the new AioContext of bs_top in
5
+ bdrv_append()
6
+
7
+ RH-Author: Stefano Garzarella <sgarzare@redhat.com>
8
+ RH-MergeRequest: 153: block: temporarily hold the new AioContext of bs_top in bdrv_append()
9
+ RH-Bugzilla: 2168209
10
+ RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
11
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
13
+ RH-Commit: [1/1] 5b190426d996e8c9f7a781bd97aee8d25756dbd3 (sgarzarella/qemu-kvm-c-9-s)
14
+
15
+ bdrv_append() is called with bs_top AioContext held, but
16
+ bdrv_attach_child_noperm() could change the AioContext of bs_top.
17
+
18
+ bdrv_replace_node_noperm() calls bdrv_drained_begin() starting from
19
+ commit 2398747128 ("block: Don't poll in bdrv_replace_child_noperm()").
20
+ bdrv_drained_begin() can call BDRV_POLL_WHILE that assumes the new lock
21
+ is taken, so let's temporarily hold the new AioContext to prevent QEMU
22
+ from failing in BDRV_POLL_WHILE when it tries to release the wrong
23
+ AioContext.
24
+
25
+ Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2168209
26
+ Reported-by: Aihua Liang <aliang@redhat.com>
27
+ Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
28
+ Message-Id: <20230214171621.11574-1-sgarzare@redhat.com>
29
+ Reviewed-by: Kevin Wolf <kwolf@redhat.com>
30
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
31
+ (cherry picked from commit 60d90bf43c169b9d1dbcb17ed794b7b02c6862b1)
32
+ Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
33
+ ---
34
+ block.c | 23 +++++++++++++++++++++++
35
+ 1 file changed, 23 insertions(+)
36
+
37
+ diff --git a/block.c b/block.c
38
+ index 0d78711416..9e1dcb9e47 100644
39
+ --- a/block.c
40
+ +++ b/block.c
41
+ @@ -5275,6 +5275,8 @@ int bdrv_drop_filter(BlockDriverState *bs, Error **errp)
42
+ * child.
43
+ *
44
+ * This function does not create any image files.
45
+ + *
46
+ + * The caller must hold the AioContext lock for @bs_top.
47
+ */
48
+ int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top,
49
+ Error **errp)
50
+ @@ -5282,11 +5284,14 @@ int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top,
51
+ int ret;
52
+ BdrvChild *child;
53
+ Transaction *tran = tran_new();
54
+ + AioContext *old_context, *new_context = NULL;
55
+
56
+ GLOBAL_STATE_CODE();
57
+
58
+ assert(!bs_new->backing);
59
+
60
+ + old_context = bdrv_get_aio_context(bs_top);
61
+ +
62
+ child = bdrv_attach_child_noperm(bs_new, bs_top, "backing",
63
+ &child_of_bds, bdrv_backing_role(bs_new),
64
+ tran, errp);
65
+ @@ -5295,6 +5300,19 @@ int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top,
66
+ goto out;
67
+ }
68
+
69
+ + /*
70
+ + * bdrv_attach_child_noperm could change the AioContext of bs_top.
71
+ + * bdrv_replace_node_noperm calls bdrv_drained_begin, so let's temporarily
72
+ + * hold the new AioContext, since bdrv_drained_begin calls BDRV_POLL_WHILE
73
+ + * that assumes the new lock is taken.
74
+ + */
75
+ + new_context = bdrv_get_aio_context(bs_top);
76
+ +
77
+ + if (old_context != new_context) {
78
+ + aio_context_release(old_context);
79
+ + aio_context_acquire(new_context);
80
+ + }
81
+ +
82
+ ret = bdrv_replace_node_noperm(bs_top, bs_new, true, tran, errp);
83
+ if (ret < 0) {
84
+ goto out;
85
+ @@ -5306,6 +5324,11 @@ out:
86
+
87
+ bdrv_refresh_limits(bs_top, NULL, NULL);
88
+
89
+ + if (new_context && old_context != new_context) {
90
+ + aio_context_release(new_context);
91
+ + aio_context_acquire(old_context);
92
+ + }
93
+ +
94
+ return ret;
95
+ }
96
+
97
+ --
98
+ 2.31.1
99
+
SOURCES/kvm-block-vmdk-Change-extent-info-type.patch ADDED
@@ -0,0 +1,140 @@
1
+ From d8caed018afb0f60f449e971398d2a8d6c2992e7 Mon Sep 17 00:00:00 2001
2
+ From: Hanna Reitz <hreitz@redhat.com>
3
+ Date: Mon, 20 Jun 2022 18:26:55 +0200
4
+ Subject: [PATCH 08/20] block/vmdk: Change extent info type
5
+
6
+ RH-Author: Hanna Czenczek <hreitz@redhat.com>
7
+ RH-MergeRequest: 145: Show protocol-level information in qemu-img info
8
+ RH-Bugzilla: 1860292
9
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
10
+ RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
11
+ RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
12
+ RH-Commit: [3/12] efe50a2797c679ce6bb5faa423047461a34e6792 (hreitz/qemu-kvm-c-9-s)
13
+
14
+ VMDK's implementation of .bdrv_get_specific_info() returns information
15
+ about its extent files, ostensibly in the form of ImageInfo objects.
16
+ However, it does not get this information through
17
+ bdrv_query_image_info(), but fills only a select few fields with custom
18
+ information that does not always match the fields' purposes.
19
+
20
+ For example, @format, which is supposed to be a block driver name, is
21
+ filled with the extent type, e.g. SPARSE or FLAT.
22
+
23
+ In ImageInfo, @compressed shows whether the data that can be seen in the
24
+ image is stored in compressed form or not. For example, a compressed
25
+ qcow2 image will store compressed data in its data file, but when
26
+ accessing the qcow2 node, you will see normal data. This is not how
27
+ VMDK uses the @compressed field for its extent files: Instead, it
28
+ signifies whether accessing the extent file will yield compressed data
29
+ (which the VMDK driver then (de-)compresses).
30
+
31
+ Create a new structure to represent the extent information. This allows
32
+ us to clarify the fields' meanings, and it clearly shows that these are
33
+ not complete ImageInfo objects. (That is, if a user wants an extent
34
+ file's ImageInfo object, they will need to query it separately, and will
35
+ not get it from ImageInfoSpecificVmdk.extents.)
36
+
37
+ Note that this removes the last use of ['ImageInfo'] (i.e. an array of
38
+ ImageInfo objects), so the QAPI generator will no longer generate
39
+ ImageInfoList by default. However, we use it in qemu-img.c, so we need
40
+ to create a dummy object to force the generate to create that type,
41
+ similarly to DummyForceArrays in machine.json (introduced in commit
42
+ 9f08c8ec73878122ad4b061ed334f0437afaaa32 ("qapi: Lazy creation of array
43
+ types")).
44
+
45
+ Signed-off-by: Hanna Reitz <hreitz@redhat.com>
46
+ Message-Id: <20220620162704.80987-4-hreitz@redhat.com>
47
+ Reviewed-by: Kevin Wolf <kwolf@redhat.com>
48
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
49
+ (cherry picked from commit 456e75171a85c19a5bfa202eefcbdc4ef1692f05)
50
+ Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
51
+ ---
52
+ block/vmdk.c | 8 ++++----
53
+ qapi/block-core.json | 38 +++++++++++++++++++++++++++++++++++++-
54
+ 2 files changed, 41 insertions(+), 5 deletions(-)
55
+
56
+ diff --git a/block/vmdk.c b/block/vmdk.c
57
+ index 26376352b9..4435b9880b 100644
58
+ --- a/block/vmdk.c
59
+ +++ b/block/vmdk.c
60
+ @@ -2901,12 +2901,12 @@ static int vmdk_has_zero_init(BlockDriverState *bs)
61
+ return 1;
62
+ }
63
+
64
+ -static ImageInfo *vmdk_get_extent_info(VmdkExtent *extent)
65
+ +static VmdkExtentInfo *vmdk_get_extent_info(VmdkExtent *extent)
66
+ {
67
+ - ImageInfo *info = g_new0(ImageInfo, 1);
68
+ + VmdkExtentInfo *info = g_new0(VmdkExtentInfo, 1);
69
+
70
+ bdrv_refresh_filename(extent->file->bs);
71
+ - *info = (ImageInfo){
72
+ + *info = (VmdkExtentInfo){
73
+ .filename = g_strdup(extent->file->bs->filename),
74
+ .format = g_strdup(extent->type),
75
+ .virtual_size = extent->sectors * BDRV_SECTOR_SIZE,
76
+ @@ -2985,7 +2985,7 @@ static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs,
77
+ int i;
78
+ BDRVVmdkState *s = bs->opaque;
79
+ ImageInfoSpecific *spec_info = g_new0(ImageInfoSpecific, 1);
80
+ - ImageInfoList **tail;
81
+ + VmdkExtentInfoList **tail;
82
+
83
+ *spec_info = (ImageInfoSpecific){
84
+ .type = IMAGE_INFO_SPECIFIC_KIND_VMDK,
85
+ diff --git a/qapi/block-core.json b/qapi/block-core.json
86
+ index f5d822cbd6..4b9365167f 100644
87
+ --- a/qapi/block-core.json
88
+ +++ b/qapi/block-core.json
89
+ @@ -124,7 +124,33 @@
90
+ 'create-type': 'str',
91
+ 'cid': 'int',
92
+ 'parent-cid': 'int',
93
+ - 'extents': ['ImageInfo']
94
+ + 'extents': ['VmdkExtentInfo']
95
+ + } }
96
+ +
97
+ +##
98
+ +# @VmdkExtentInfo:
99
+ +#
100
+ +# Information about a VMDK extent file
101
+ +#
102
+ +# @filename: Name of the extent file
103
+ +#
104
+ +# @format: Extent type (e.g. FLAT or SPARSE)
105
+ +#
106
+ +# @virtual-size: Number of bytes covered by this extent
107
+ +#
108
+ +# @cluster-size: Cluster size in bytes (for non-flat extents)
109
+ +#
110
+ +# @compressed: Whether this extent contains compressed data
111
+ +#
112
+ +# Since: 8.0
113
+ +##
114
+ +{ 'struct': 'VmdkExtentInfo',
115
+ + 'data': {
116
+ + 'filename': 'str',
117
+ + 'format': 'str',
118
+ + 'virtual-size': 'int',
119
+ + '*cluster-size': 'int',
120
+ + '*compressed': 'bool'
121
+ } }
122
+
123
+ ##
124
+ @@ -5754,3 +5780,13 @@
125
+ 'data': { 'device': 'str', '*id': 'str', '*name': 'str'},
126
+ 'returns': 'SnapshotInfo',
127
+ 'allow-preconfig': true }
128
+ +
129
+ +##
130
+ +# @DummyBlockCoreForceArrays:
131
+ +#
132
+ +# Not used by QMP; hack to let us use ImageInfoList internally
133
+ +#
134
+ +# Since: 8.0
135
+ +##
136
+ +{ 'struct': 'DummyBlockCoreForceArrays',
137
+ + 'data': { 'unused-image-info': ['ImageInfo'] } }
138
+ --
139
+ 2.31.1
140
+
SOURCES/kvm-configs-devices-aarch64-softmmu-Enable-CONFIG_VIRTIO.patch DELETED
@@ -1,41 +0,0 @@
1
- From 3a0e9bb88e82cc76ca5efc0595ce94b5dc34749e Mon Sep 17 00:00:00 2001
2
- From: Gavin Shan <gshan@redhat.com>
3
- Date: Mon, 25 Apr 2022 13:42:46 +0800
4
- Subject: [PATCH 1/2] configs/devices/aarch64-softmmu: Enable CONFIG_VIRTIO_MEM
5
-
6
- RH-Author: Gavin Shan <gshan@redhat.com>
7
- RH-MergeRequest: 80: Enable virtio-mem for aarch64
8
- RH-Commit: [1/1] 1afbd08da6d7c860da8d617a0a932d3660514878 (gwshan/qemu-rhel-9)
9
- RH-Bugzilla: 2044162
10
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
11
- RH-Acked-by: Eric Auger <eric.auger@redhat.com>
12
- RH-Acked-by: David Hildenbrand <david@redhat.com>
13
-
14
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2044162
15
-
16
- This enables virtio-mem device on aarch64 since all needed commits
17
- are ready.
18
-
19
- b1b87327a9 hw/arm/virt: Support for virtio-mem-pci
20
- 1263615efe virtio-mem: Correct default THP size for ARM64
21
-
22
- Signed-off-by: Gavin Shan <gshan@redhat.com>
23
- ---
24
- configs/devices/aarch64-softmmu/aarch64-rh-devices.mak | 1 +
25
- 1 file changed, 1 insertion(+)
26
-
27
- diff --git a/configs/devices/aarch64-softmmu/aarch64-rh-devices.mak b/configs/devices/aarch64-softmmu/aarch64-rh-devices.mak
28
- index 5f6ee1de5b..187938573f 100644
29
- --- a/configs/devices/aarch64-softmmu/aarch64-rh-devices.mak
30
- +++ b/configs/devices/aarch64-softmmu/aarch64-rh-devices.mak
31
- @@ -22,6 +22,7 @@ CONFIG_VFIO=y
32
- CONFIG_VFIO_PCI=y
33
- CONFIG_VIRTIO_MMIO=y
34
- CONFIG_VIRTIO_PCI=y
35
- +CONFIG_VIRTIO_MEM=y
36
- CONFIG_XIO3130=y
37
- CONFIG_NVDIMM=y
38
- CONFIG_ACPI_APEI=y
39
- --
40
- 2.35.1
41
-
SOURCES/kvm-coroutine-Rename-qemu_coroutine_inc-dec_pool_size.patch DELETED
@@ -1,101 +0,0 @@
1
- From e3cb8849862a9f0dd20f2913d540336a037d43c7 Mon Sep 17 00:00:00 2001
2
- From: Kevin Wolf <kwolf@redhat.com>
3
- Date: Tue, 10 May 2022 17:10:19 +0200
4
- Subject: [PATCH 07/16] coroutine: Rename qemu_coroutine_inc/dec_pool_size()
5
-
6
- RH-Author: Kevin Wolf <kwolf@redhat.com>
7
- RH-MergeRequest: 87: coroutine: Fix crashes due to too large pool batch size
8
- RH-Commit: [1/2] 6389b11f70225f221784c270d9b90c1ea43ca8fb (kmwolf/centos-qemu-kvm)
9
- RH-Bugzilla: 2079938
10
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
- RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
12
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
13
-
14
- It's true that these functions currently affect the batch size in which
15
- coroutines are reused (i.e. moved from the global release pool to the
16
- allocation pool of a specific thread), but this is a bug and will be
17
- fixed in a separate patch.
18
-
19
- In fact, the comment in the header file already just promises that it
20
- influences the pool size, so reflect this in the name of the functions.
21
- As a nice side effect, the shorter function name makes some line
22
- wrapping unnecessary.
23
-
24
- Cc: qemu-stable@nongnu.org
25
- Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26
- Message-Id: <20220510151020.105528-2-kwolf@redhat.com>
27
- Signed-off-by: Kevin Wolf <kwolf@redhat.com>
28
- (cherry picked from commit 98e3ab35054b946f7c2aba5408822532b0920b53)
29
- Signed-off-by: Kevin Wolf <kwolf@redhat.com>
30
- ---
31
- hw/block/virtio-blk.c | 6 ++----
32
- include/qemu/coroutine.h | 6 +++---
33
- util/qemu-coroutine.c | 4 ++--
34
- 3 files changed, 7 insertions(+), 9 deletions(-)
35
-
36
- diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
37
- index 540c38f829..6a1cc41877 100644
38
- --- a/hw/block/virtio-blk.c
39
- +++ b/hw/block/virtio-blk.c
40
- @@ -1215,8 +1215,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
41
- for (i = 0; i < conf->num_queues; i++) {
42
- virtio_add_queue(vdev, conf->queue_size, virtio_blk_handle_output);
43
- }
44
- - qemu_coroutine_increase_pool_batch_size(conf->num_queues * conf->queue_size
45
- - / 2);
46
- + qemu_coroutine_inc_pool_size(conf->num_queues * conf->queue_size / 2);
47
- virtio_blk_data_plane_create(vdev, conf, &s->dataplane, &err);
48
- if (err != NULL) {
49
- error_propagate(errp, err);
50
- @@ -1253,8 +1252,7 @@ static void virtio_blk_device_unrealize(DeviceState *dev)
51
- for (i = 0; i < conf->num_queues; i++) {
52
- virtio_del_queue(vdev, i);
53
- }
54
- - qemu_coroutine_decrease_pool_batch_size(conf->num_queues * conf->queue_size
55
- - / 2);
56
- + qemu_coroutine_dec_pool_size(conf->num_queues * conf->queue_size / 2);
57
- qemu_del_vm_change_state_handler(s->change);
58
- blockdev_mark_auto_del(s->blk);
59
- virtio_cleanup(vdev);
60
- diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h
61
- index c828a95ee0..5b621d1295 100644
62
- --- a/include/qemu/coroutine.h
63
- +++ b/include/qemu/coroutine.h
64
- @@ -334,12 +334,12 @@ void coroutine_fn yield_until_fd_readable(int fd);
65
- /**
66
- * Increase coroutine pool size
67
- */
68
- -void qemu_coroutine_increase_pool_batch_size(unsigned int additional_pool_size);
69
- +void qemu_coroutine_inc_pool_size(unsigned int additional_pool_size);
70
-
71
- /**
72
- - * Devcrease coroutine pool size
73
- + * Decrease coroutine pool size
74
- */
75
- -void qemu_coroutine_decrease_pool_batch_size(unsigned int additional_pool_size);
76
- +void qemu_coroutine_dec_pool_size(unsigned int additional_pool_size);
77
-
78
- #include "qemu/lockable.h"
79
-
80
- diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c
81
- index c03b2422ff..faca0ca97c 100644
82
- --- a/util/qemu-coroutine.c
83
- +++ b/util/qemu-coroutine.c
84
- @@ -205,12 +205,12 @@ AioContext *coroutine_fn qemu_coroutine_get_aio_context(Coroutine *co)
85
- return co->ctx;
86
- }
87
-
88
- -void qemu_coroutine_increase_pool_batch_size(unsigned int additional_pool_size)
89
- +void qemu_coroutine_inc_pool_size(unsigned int additional_pool_size)
90
- {
91
- qatomic_add(&pool_batch_size, additional_pool_size);
92
- }
93
-
94
- -void qemu_coroutine_decrease_pool_batch_size(unsigned int removing_pool_size)
95
- +void qemu_coroutine_dec_pool_size(unsigned int removing_pool_size)
96
- {
97
- qatomic_sub(&pool_batch_size, removing_pool_size);
98
- }
99
- --
100
- 2.31.1
101
-
SOURCES/kvm-coroutine-Revert-to-constant-batch-size.patch DELETED
@@ -1,138 +0,0 @@
1
- From 345107bfd5537b51f34aaeb97d6161858bb6feee Mon Sep 17 00:00:00 2001
2
- From: Kevin Wolf <kwolf@redhat.com>
3
- Date: Tue, 10 May 2022 17:10:20 +0200
4
- Subject: [PATCH 08/16] coroutine: Revert to constant batch size
5
-
6
- RH-Author: Kevin Wolf <kwolf@redhat.com>
7
- RH-MergeRequest: 87: coroutine: Fix crashes due to too large pool batch size
8
- RH-Commit: [2/2] 8a8a39af873854cdc8333d1a70f3479a97c3ec7a (kmwolf/centos-qemu-kvm)
9
- RH-Bugzilla: 2079938
10
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
- RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
12
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
13
-
14
- Commit 4c41c69e changed the way the coroutine pool is sized because for
15
- virtio-blk devices with a large queue size and heavy I/O, it was just
16
- too small and caused coroutines to be deleted and reallocated soon
17
- afterwards. The change made the size dynamic based on the number of
18
- queues and the queue size of virtio-blk devices.
19
-
20
- There are two important numbers here: Slightly simplified, when a
21
- coroutine terminates, it is generally stored in the global release pool
22
- up to a certain pool size, and if the pool is full, it is freed.
23
- Conversely, when allocating a new coroutine, the coroutines in the
24
- release pool are reused if the pool already has reached a certain
25
- minimum size (the batch size), otherwise we allocate new coroutines.
26
-
27
- The problem after commit 4c41c69e is that it not only increases the
28
- maximum pool size (which is the intended effect), but also the batch
29
- size for reusing coroutines (which is a bug). It means that in cases
30
- with many devices and/or a large queue size (which defaults to the
31
- number of vcpus for virtio-blk-pci), many thousand coroutines could be
32
- sitting in the release pool without being reused.
33
-
34
- This is not only a waste of memory and allocations, but it actually
35
- makes the QEMU process likely to hit the vm.max_map_count limit on Linux
36
- because each coroutine requires two mappings (its stack and the guard
37
- page for the stack), causing it to abort() in qemu_alloc_stack() because
38
- when the limit is hit, mprotect() starts to fail with ENOMEM.
39
-
40
- In order to fix the problem, change the batch size back to 64 to avoid
41
- uselessly accumulating coroutines in the release pool, but keep the
42
- dynamic maximum pool size so that coroutines aren't freed too early
43
- in heavy I/O scenarios.
44
-
45
- Note that this fix doesn't strictly make it impossible to hit the limit,
46
- but this would only happen if most of the coroutines are actually in use
47
- at the same time, not just sitting in a pool. This is the same behaviour
48
- as we already had before commit 4c41c69e. Fully preventing this would
49
- require allowing qemu_coroutine_create() to return an error, but it
50
- doesn't seem to be a scenario that people hit in practice.
51
-
52
- Cc: qemu-stable@nongnu.org
53
- Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2079938
54
- Fixes: 4c41c69e05fe28c0f95f8abd2ebf407e95a4f04b
55
- Signed-off-by: Kevin Wolf <kwolf@redhat.com>
56
- Message-Id: <20220510151020.105528-3-kwolf@redhat.com>
57
- Tested-by: Hiroki Narukawa <hnarukaw@yahoo-corp.jp>
58
- Signed-off-by: Kevin Wolf <kwolf@redhat.com>
59
- (cherry picked from commit 9ec7a59b5aad4b736871c378d30f5ef5ec51cb52)
60
-
61
- Conflicts:
62
- util/qemu-coroutine.c
63
-
64
- Trivial merge conflict because we don't have commit ac387a08 downstream.
65
-
66
- Signed-off-by: Kevin Wolf <kwolf@redhat.com>
67
- ---
68
- util/qemu-coroutine.c | 22 ++++++++++++++--------
69
- 1 file changed, 14 insertions(+), 8 deletions(-)
70
-
71
- diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c
72
- index faca0ca97c..804f672e0a 100644
73
- --- a/util/qemu-coroutine.c
74
- +++ b/util/qemu-coroutine.c
75
- @@ -20,14 +20,20 @@
76
- #include "qemu/coroutine_int.h"
77
- #include "block/aio.h"
78
-
79
- -/** Initial batch size is 64, and is increased on demand */
80
- +/**
81
- + * The minimal batch size is always 64, coroutines from the release_pool are
82
- + * reused as soon as there are 64 coroutines in it. The maximum pool size starts
83
- + * with 64 and is increased on demand so that coroutines are not deleted even if
84
- + * they are not immediately reused.
85
- + */
86
- enum {
87
- - POOL_INITIAL_BATCH_SIZE = 64,
88
- + POOL_MIN_BATCH_SIZE = 64,
89
- + POOL_INITIAL_MAX_SIZE = 64,
90
- };
91
-
92
- /** Free list to speed up creation */
93
- static QSLIST_HEAD(, Coroutine) release_pool = QSLIST_HEAD_INITIALIZER(pool);
94
- -static unsigned int pool_batch_size = POOL_INITIAL_BATCH_SIZE;
95
- +static unsigned int pool_max_size = POOL_INITIAL_MAX_SIZE;
96
- static unsigned int release_pool_size;
97
- static __thread QSLIST_HEAD(, Coroutine) alloc_pool = QSLIST_HEAD_INITIALIZER(pool);
98
- static __thread unsigned int alloc_pool_size;
99
- @@ -51,7 +57,7 @@ Coroutine *qemu_coroutine_create(CoroutineEntry *entry, void *opaque)
100
- if (CONFIG_COROUTINE_POOL) {
101
- co = QSLIST_FIRST(&alloc_pool);
102
- if (!co) {
103
- - if (release_pool_size > qatomic_read(&pool_batch_size)) {
104
- + if (release_pool_size > POOL_MIN_BATCH_SIZE) {
105
- /* Slow path; a good place to register the destructor, too. */
106
- if (!coroutine_pool_cleanup_notifier.notify) {
107
- coroutine_pool_cleanup_notifier.notify = coroutine_pool_cleanup;
108
- @@ -88,12 +94,12 @@ static void coroutine_delete(Coroutine *co)
109
- co->caller = NULL;
110
-
111
- if (CONFIG_COROUTINE_POOL) {
112
- - if (release_pool_size < qatomic_read(&pool_batch_size) * 2) {
113
- + if (release_pool_size < qatomic_read(&pool_max_size) * 2) {
114
- QSLIST_INSERT_HEAD_ATOMIC(&release_pool, co, pool_next);
115
- qatomic_inc(&release_pool_size);
116
- return;
117
- }
118
- - if (alloc_pool_size < qatomic_read(&pool_batch_size)) {
119
- + if (alloc_pool_size < qatomic_read(&pool_max_size)) {
120
- QSLIST_INSERT_HEAD(&alloc_pool, co, pool_next);
121
- alloc_pool_size++;
122
- return;
123
- @@ -207,10 +213,10 @@ AioContext *coroutine_fn qemu_coroutine_get_aio_context(Coroutine *co)
124
-
125
- void qemu_coroutine_inc_pool_size(unsigned int additional_pool_size)
126
- {
127
- - qatomic_add(&pool_batch_size, additional_pool_size);
128
- + qatomic_add(&pool_max_size, additional_pool_size);
129
- }
130
-
131
- void qemu_coroutine_dec_pool_size(unsigned int removing_pool_size)
132
- {
133
- - qatomic_sub(&pool_batch_size, removing_pool_size);
134
- + qatomic_sub(&pool_max_size, removing_pool_size);
135
- }
136
- --
137
- 2.31.1
138
-
SOURCES/kvm-coroutine-ucontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch DELETED
@@ -1,132 +0,0 @@
1
- From ffbd90e5f4eba620c7cd631b04f0ed31beb22ffa Mon Sep 17 00:00:00 2001
2
- From: Stefan Hajnoczi <stefanha@redhat.com>
3
- Date: Tue, 17 May 2022 12:07:56 +0100
4
- Subject: [PATCH 1/6] coroutine-ucontext: use QEMU_DEFINE_STATIC_CO_TLS()
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
10
- RH-MergeRequest: 89: coroutine: use coroutine TLS macros to protect thread-local variables
11
- RH-Commit: [1/3] a9782fe8e919c4bd317b7e8744c7ff57d898add3 (stefanha/centos-stream-qemu-kvm)
12
- RH-Bugzilla: 1952483
13
- RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
14
- RH-Acked-by: Eric Blake <eblake@redhat.com>
15
- RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
16
-
17
- Thread-Local Storage variables cannot be used directly from coroutine
18
- code because the compiler may optimize TLS variable accesses across
19
- qemu_coroutine_yield() calls. When the coroutine is re-entered from
20
- another thread the TLS variables from the old thread must no longer be
21
- used.
22
-
23
- Use QEMU_DEFINE_STATIC_CO_TLS() for the current and leader variables.
24
-
25
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
26
- Message-Id: <20220307153853.602859-2-stefanha@redhat.com>
27
- Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
28
- Signed-off-by: Kevin Wolf <kwolf@redhat.com>
29
- (cherry picked from commit 34145a307d849d0b6734d0222a7aa0bb9eef7407)
30
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
31
- ---
32
- util/coroutine-ucontext.c | 38 ++++++++++++++++++++++++--------------
33
- 1 file changed, 24 insertions(+), 14 deletions(-)
34
-
35
- diff --git a/util/coroutine-ucontext.c b/util/coroutine-ucontext.c
36
- index 904b375192..127d5a13c8 100644
37
- --- a/util/coroutine-ucontext.c
38
- +++ b/util/coroutine-ucontext.c
39
- @@ -25,6 +25,7 @@
40
- #include "qemu/osdep.h"
41
- #include <ucontext.h>
42
- #include "qemu/coroutine_int.h"
43
- +#include "qemu/coroutine-tls.h"
44
-
45
- #ifdef CONFIG_VALGRIND_H
46
- #include <valgrind/valgrind.h>
47
- @@ -66,8 +67,8 @@ typedef struct {
48
- /**
49
- * Per-thread coroutine bookkeeping
50
- */
51
- -static __thread CoroutineUContext leader;
52
- -static __thread Coroutine *current;
53
- +QEMU_DEFINE_STATIC_CO_TLS(Coroutine *, current);
54
- +QEMU_DEFINE_STATIC_CO_TLS(CoroutineUContext, leader);
55
-
56
- /*
57
- * va_args to makecontext() must be type 'int', so passing
58
- @@ -97,14 +98,15 @@ static inline __attribute__((always_inline))
59
- void finish_switch_fiber(void *fake_stack_save)
60
- {
61
- #ifdef CONFIG_ASAN
62
- + CoroutineUContext *leaderp = get_ptr_leader();
63
- const void *bottom_old;
64
- size_t size_old;
65
-
66
- __sanitizer_finish_switch_fiber(fake_stack_save, &bottom_old, &size_old);
67
-
68
- - if (!leader.stack) {
69
- - leader.stack = (void *)bottom_old;
70
- - leader.stack_size = size_old;
71
- + if (!leaderp->stack) {
72
- + leaderp->stack = (void *)bottom_old;
73
- + leaderp->stack_size = size_old;
74
- }
75
- #endif
76
- #ifdef CONFIG_TSAN
77
- @@ -161,8 +163,10 @@ static void coroutine_trampoline(int i0, int i1)
78
-
79
- /* Initialize longjmp environment and switch back the caller */
80
- if (!sigsetjmp(self->env, 0)) {
81
- - start_switch_fiber_asan(COROUTINE_YIELD, &fake_stack_save, leader.stack,
82
- - leader.stack_size);
83
- + CoroutineUContext *leaderp = get_ptr_leader();
84
- +
85
- + start_switch_fiber_asan(COROUTINE_YIELD, &fake_stack_save,
86
- + leaderp->stack, leaderp->stack_size);
87
- start_switch_fiber_tsan(&fake_stack_save, self, true); /* true=caller */
88
- siglongjmp(*(sigjmp_buf *)co->entry_arg, 1);
89
- }
90
- @@ -297,7 +301,7 @@ qemu_coroutine_switch(Coroutine *from_, Coroutine *to_,
91
- int ret;
92
- void *fake_stack_save = NULL;
93
-
94
- - current = to_;
95
- + set_current(to_);
96
-
97
- ret = sigsetjmp(from->env, 0);
98
- if (ret == 0) {
99
- @@ -315,18 +319,24 @@ qemu_coroutine_switch(Coroutine *from_, Coroutine *to_,
100
-
101
- Coroutine *qemu_coroutine_self(void)
102
- {
103
- - if (!current) {
104
- - current = &leader.base;
105
- + Coroutine *self = get_current();
106
- + CoroutineUContext *leaderp = get_ptr_leader();
107
- +
108
- + if (!self) {
109
- + self = &leaderp->base;
110
- + set_current(self);
111
- }
112
- #ifdef CONFIG_TSAN
113
- - if (!leader.tsan_co_fiber) {
114
- - leader.tsan_co_fiber = __tsan_get_current_fiber();
115
- + if (!leaderp->tsan_co_fiber) {
116
- + leaderp->tsan_co_fiber = __tsan_get_current_fiber();
117
- }
118
- #endif
119
- - return current;
120
- + return self;
121
- }
122
-
123
- bool qemu_in_coroutine(void)
124
- {
125
- - return current && current->caller;
126
- + Coroutine *self = get_current();
127
- +
128
- + return self && self->caller;
129
- }
130
- --
131
- 2.31.1
132
-
SOURCES/kvm-coroutine-use-QEMU_DEFINE_STATIC_CO_TLS.patch DELETED
@@ -1,139 +0,0 @@
1
- From 9c2e55d25fec6ffb21e344513b7dbeed7e21f641 Mon Sep 17 00:00:00 2001
2
- From: Stefan Hajnoczi <stefanha@redhat.com>
3
- Date: Tue, 17 May 2022 12:08:04 +0100
4
- Subject: [PATCH 2/6] coroutine: use QEMU_DEFINE_STATIC_CO_TLS()
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
10
- RH-MergeRequest: 89: coroutine: use coroutine TLS macros to protect thread-local variables
11
- RH-Commit: [2/3] 68a8847e406e2eace6ddc31b0c5676a60600d606 (stefanha/centos-stream-qemu-kvm)
12
- RH-Bugzilla: 1952483
13
- RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
14
- RH-Acked-by: Eric Blake <eblake@redhat.com>
15
- RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
16
-
17
- Thread-Local Storage variables cannot be used directly from coroutine
18
- code because the compiler may optimize TLS variable accesses across
19
- qemu_coroutine_yield() calls. When the coroutine is re-entered from
20
- another thread the TLS variables from the old thread must no longer be
21
- used.
22
-
23
- Use QEMU_DEFINE_STATIC_CO_TLS() for the current and leader variables.
24
- The alloc_pool QSLIST needs a typedef so the return value of
25
- get_ptr_alloc_pool() can be stored in a local variable.
26
-
27
- One example of why this code is necessary: a coroutine that yields
28
- before calling qemu_coroutine_create() to create another coroutine is
29
- affected by the TLS issue.
30
-
31
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
32
- Message-Id: <20220307153853.602859-3-stefanha@redhat.com>
33
- Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
34
- Signed-off-by: Kevin Wolf <kwolf@redhat.com>
35
- (cherry picked from commit ac387a08a9c9f6b36757da912f0339c25f421f90)
36
-
37
- Conflicts:
38
- - Context conflicts due to commit 5411171c3ef4 ("coroutine: Revert to
39
- constant batch size").
40
-
41
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
42
- ---
43
- util/qemu-coroutine.c | 41 ++++++++++++++++++++++++-----------------
44
- 1 file changed, 24 insertions(+), 17 deletions(-)
45
-
46
- diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c
47
- index 804f672e0a..4a8bd63ef0 100644
48
- --- a/util/qemu-coroutine.c
49
- +++ b/util/qemu-coroutine.c
50
- @@ -18,6 +18,7 @@
51
- #include "qemu/atomic.h"
52
- #include "qemu/coroutine.h"
53
- #include "qemu/coroutine_int.h"
54
- +#include "qemu/coroutine-tls.h"
55
- #include "block/aio.h"
56
-
57
- /**
58
- @@ -35,17 +36,20 @@ enum {
59
- static QSLIST_HEAD(, Coroutine) release_pool = QSLIST_HEAD_INITIALIZER(pool);
60
- static unsigned int pool_max_size = POOL_INITIAL_MAX_SIZE;
61
- static unsigned int release_pool_size;
62
- -static __thread QSLIST_HEAD(, Coroutine) alloc_pool = QSLIST_HEAD_INITIALIZER(pool);
63
- -static __thread unsigned int alloc_pool_size;
64
- -static __thread Notifier coroutine_pool_cleanup_notifier;
65
- +
66
- +typedef QSLIST_HEAD(, Coroutine) CoroutineQSList;
67
- +QEMU_DEFINE_STATIC_CO_TLS(CoroutineQSList, alloc_pool);
68
- +QEMU_DEFINE_STATIC_CO_TLS(unsigned int, alloc_pool_size);
69
- +QEMU_DEFINE_STATIC_CO_TLS(Notifier, coroutine_pool_cleanup_notifier);
70
-
71
- static void coroutine_pool_cleanup(Notifier *n, void *value)
72
- {
73
- Coroutine *co;
74
- Coroutine *tmp;
75
- + CoroutineQSList *alloc_pool = get_ptr_alloc_pool();
76
-
77
- - QSLIST_FOREACH_SAFE(co, &alloc_pool, pool_next, tmp) {
78
- - QSLIST_REMOVE_HEAD(&alloc_pool, pool_next);
79
- + QSLIST_FOREACH_SAFE(co, alloc_pool, pool_next, tmp) {
80
- + QSLIST_REMOVE_HEAD(alloc_pool, pool_next);
81
- qemu_coroutine_delete(co);
82
- }
83
- }
84
- @@ -55,27 +59,30 @@ Coroutine *qemu_coroutine_create(CoroutineEntry *entry, void *opaque)
85
- Coroutine *co = NULL;
86
-
87
- if (CONFIG_COROUTINE_POOL) {
88
- - co = QSLIST_FIRST(&alloc_pool);
89
- + CoroutineQSList *alloc_pool = get_ptr_alloc_pool();
90
- +
91
- + co = QSLIST_FIRST(alloc_pool);
92
- if (!co) {
93
- if (release_pool_size > POOL_MIN_BATCH_SIZE) {
94
- /* Slow path; a good place to register the destructor, too. */
95
- - if (!coroutine_pool_cleanup_notifier.notify) {
96
- - coroutine_pool_cleanup_notifier.notify = coroutine_pool_cleanup;
97
- - qemu_thread_atexit_add(&coroutine_pool_cleanup_notifier);
98
- + Notifier *notifier = get_ptr_coroutine_pool_cleanup_notifier();
99
- + if (!notifier->notify) {
100
- + notifier->notify = coroutine_pool_cleanup;
101
- + qemu_thread_atexit_add(notifier);
102
- }
103
-
104
- /* This is not exact; there could be a little skew between
105
- * release_pool_size and the actual size of release_pool. But
106
- * it is just a heuristic, it does not need to be perfect.
107
- */
108
- - alloc_pool_size = qatomic_xchg(&release_pool_size, 0);
109
- - QSLIST_MOVE_ATOMIC(&alloc_pool, &release_pool);
110
- - co = QSLIST_FIRST(&alloc_pool);
111
- + set_alloc_pool_size(qatomic_xchg(&release_pool_size, 0));
112
- + QSLIST_MOVE_ATOMIC(alloc_pool, &release_pool);
113
- + co = QSLIST_FIRST(alloc_pool);
114
- }
115
- }
116
- if (co) {
117
- - QSLIST_REMOVE_HEAD(&alloc_pool, pool_next);
118
- - alloc_pool_size--;
119
- + QSLIST_REMOVE_HEAD(alloc_pool, pool_next);
120
- + set_alloc_pool_size(get_alloc_pool_size() - 1);
121
- }
122
- }
123
-
124
- @@ -99,9 +106,9 @@ static void coroutine_delete(Coroutine *co)
125
- qatomic_inc(&release_pool_size);
126
- return;
127
- }
128
- - if (alloc_pool_size < qatomic_read(&pool_max_size)) {
129
- - QSLIST_INSERT_HEAD(&alloc_pool, co, pool_next);
130
- - alloc_pool_size++;
131
- + if (get_alloc_pool_size() < qatomic_read(&pool_max_size)) {
132
- + QSLIST_INSERT_HEAD(get_ptr_alloc_pool(), co, pool_next);
133
- + set_alloc_pool_size(get_alloc_pool_size() + 1);
134
- return;
135
- }
136
- }
137
- --
138
- 2.31.1
139
-
SOURCES/kvm-coroutine-win32-use-QEMU_DEFINE_STATIC_CO_TLS.patch DELETED
@@ -1,99 +0,0 @@
1
- From 336581e6e9ace3f1ddd24ad0a258db9785f9b0ed Mon Sep 17 00:00:00 2001
2
- From: Stefan Hajnoczi <stefanha@redhat.com>
3
- Date: Tue, 17 May 2022 12:08:12 +0100
4
- Subject: [PATCH 3/6] coroutine-win32: use QEMU_DEFINE_STATIC_CO_TLS()
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
10
- RH-MergeRequest: 89: coroutine: use coroutine TLS macros to protect thread-local variables
11
- RH-Commit: [3/3] 55b35dfdae1bc7d6f614ac9f81a92f5c6431f713 (stefanha/centos-stream-qemu-kvm)
12
- RH-Bugzilla: 1952483
13
- RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
14
- RH-Acked-by: Eric Blake <eblake@redhat.com>
15
- RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
16
-
17
- Thread-Local Storage variables cannot be used directly from coroutine
18
- code because the compiler may optimize TLS variable accesses across
19
- qemu_coroutine_yield() calls. When the coroutine is re-entered from
20
- another thread the TLS variables from the old thread must no longer be
21
- used.
22
-
23
- Use QEMU_DEFINE_STATIC_CO_TLS() for the current and leader variables.
24
-
25
- I think coroutine-win32.c could get away with __thread because the
26
- variables are only used in situations where either the stale value is
27
- correct (current) or outside coroutine context (loading leader when
28
- current is NULL). Due to the difficulty of being sure that this is
29
- really safe in all scenarios it seems worth converting it anyway.
30
-
31
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
32
- Message-Id: <20220307153853.602859-4-stefanha@redhat.com>
33
- Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
34
- Signed-off-by: Kevin Wolf <kwolf@redhat.com>
35
- (cherry picked from commit c1fe694357a328c807ae3cc6961c19e923448fcc)
36
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
37
- ---
38
- util/coroutine-win32.c | 18 +++++++++++++-----
39
- 1 file changed, 13 insertions(+), 5 deletions(-)
40
-
41
- diff --git a/util/coroutine-win32.c b/util/coroutine-win32.c
42
- index de6bd4fd3e..c02a62c896 100644
43
- --- a/util/coroutine-win32.c
44
- +++ b/util/coroutine-win32.c
45
- @@ -25,6 +25,7 @@
46
- #include "qemu/osdep.h"
47
- #include "qemu-common.h"
48
- #include "qemu/coroutine_int.h"
49
- +#include "qemu/coroutine-tls.h"
50
-
51
- typedef struct
52
- {
53
- @@ -34,8 +35,8 @@ typedef struct
54
- CoroutineAction action;
55
- } CoroutineWin32;
56
-
57
- -static __thread CoroutineWin32 leader;
58
- -static __thread Coroutine *current;
59
- +QEMU_DEFINE_STATIC_CO_TLS(CoroutineWin32, leader);
60
- +QEMU_DEFINE_STATIC_CO_TLS(Coroutine *, current);
61
-
62
- /* This function is marked noinline to prevent GCC from inlining it
63
- * into coroutine_trampoline(). If we allow it to do that then it
64
- @@ -52,7 +53,7 @@ qemu_coroutine_switch(Coroutine *from_, Coroutine *to_,
65
- CoroutineWin32 *from = DO_UPCAST(CoroutineWin32, base, from_);
66
- CoroutineWin32 *to = DO_UPCAST(CoroutineWin32, base, to_);
67
-
68
- - current = to_;
69
- + set_current(to_);
70
-
71
- to->action = action;
72
- SwitchToFiber(to->fiber);
73
- @@ -89,14 +90,21 @@ void qemu_coroutine_delete(Coroutine *co_)
74
-
75
- Coroutine *qemu_coroutine_self(void)
76
- {
77
- + Coroutine *current = get_current();
78
- +
79
- if (!current) {
80
- - current = &leader.base;
81
- - leader.fiber = ConvertThreadToFiber(NULL);
82
- + CoroutineWin32 *leader = get_ptr_leader();
83
- +
84
- + current = &leader->base;
85
- + set_current(current);
86
- + leader->fiber = ConvertThreadToFiber(NULL);
87
- }
88
- return current;
89
- }
90
-
91
- bool qemu_in_coroutine(void)
92
- {
93
- + Coroutine *current = get_current();
94
- +
95
- return current && current->caller;
96
- }
97
- --
98
- 2.31.1
99
-
SOURCES/kvm-hw-acpi-aml-build-Use-existing-CPU-topology-to-build.patch DELETED
@@ -1,179 +0,0 @@
1
- From 8a12049e97149056f61f7748d9869606d282d16e Mon Sep 17 00:00:00 2001
2
- From: Gavin Shan <gshan@redhat.com>
3
- Date: Wed, 11 May 2022 18:01:35 +0800
4
- Subject: [PATCH 06/16] hw/acpi/aml-build: Use existing CPU topology to build
5
- PPTT table
6
-
7
- RH-Author: Gavin Shan <gshan@redhat.com>
8
- RH-MergeRequest: 86: hw/arm/virt: Fix the default CPU topology
9
- RH-Commit: [6/6] 53fa376531c204cf706cc1a7a0499019756106cb (gwshan/qemu-rhel-9)
10
- RH-Bugzilla: 2041823
11
- RH-Acked-by: Eric Auger <eric.auger@redhat.com>
12
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
13
- RH-Acked-by: Andrew Jones <drjones@redhat.com>
14
-
15
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2041823
16
-
17
- When the PPTT table is built, the CPU topology is re-calculated, but
18
- it's unecessary because the CPU topology has been populated in
19
- virt_possible_cpu_arch_ids() on arm/virt machine.
20
-
21
- This reworks build_pptt() to avoid by reusing the existing IDs in
22
- ms->possible_cpus. Currently, the only user of build_pptt() is
23
- arm/virt machine.
24
-
25
- Signed-off-by: Gavin Shan <gshan@redhat.com>
26
- Tested-by: Yanan Wang <wangyanan55@huawei.com>
27
- Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
28
- Acked-by: Igor Mammedov <imammedo@redhat.com>
29
- Acked-by: Michael S. Tsirkin <mst@redhat.com>
30
- Message-id: 20220503140304.855514-7-gshan@redhat.com
31
- Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
32
- (cherry picked from commit ae9141d4a3265553503bf07d3574b40f84615a34)
33
- Signed-off-by: Gavin Shan <gshan@redhat.com>
34
- ---
35
- hw/acpi/aml-build.c | 111 +++++++++++++++++++-------------------------
36
- 1 file changed, 48 insertions(+), 63 deletions(-)
37
-
38
- diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
39
- index 4086879ebf..e6bfac95c7 100644
40
- --- a/hw/acpi/aml-build.c
41
- +++ b/hw/acpi/aml-build.c
42
- @@ -2002,86 +2002,71 @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
43
- const char *oem_id, const char *oem_table_id)
44
- {
45
- MachineClass *mc = MACHINE_GET_CLASS(ms);
46
- - GQueue *list = g_queue_new();
47
- - guint pptt_start = table_data->len;
48
- - guint parent_offset;
49
- - guint length, i;
50
- - int uid = 0;
51
- - int socket;
52
- + CPUArchIdList *cpus = ms->possible_cpus;
53
- + int64_t socket_id = -1, cluster_id = -1, core_id = -1;
54
- + uint32_t socket_offset = 0, cluster_offset = 0, core_offset = 0;
55
- + uint32_t pptt_start = table_data->len;
56
- + int n;
57
- AcpiTable table = { .sig = "PPTT", .rev = 2,
58
- .oem_id = oem_id, .oem_table_id = oem_table_id };
59
-
60
- acpi_table_begin(&table, table_data);
61
-
62
- - for (socket = 0; socket < ms->smp.sockets; socket++) {
63
- - g_queue_push_tail(list,
64
- - GUINT_TO_POINTER(table_data->len - pptt_start));
65
- - build_processor_hierarchy_node(
66
- - table_data,
67
- - /*
68
- - * Physical package - represents the boundary
69
- - * of a physical package
70
- - */
71
- - (1 << 0),
72
- - 0, socket, NULL, 0);
73
- - }
74
- -
75
- - if (mc->smp_props.clusters_supported) {
76
- - length = g_queue_get_length(list);
77
- - for (i = 0; i < length; i++) {
78
- - int cluster;
79
- -
80
- - parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
81
- - for (cluster = 0; cluster < ms->smp.clusters; cluster++) {
82
- - g_queue_push_tail(list,
83
- - GUINT_TO_POINTER(table_data->len - pptt_start));
84
- - build_processor_hierarchy_node(
85
- - table_data,
86
- - (0 << 0), /* not a physical package */
87
- - parent_offset, cluster, NULL, 0);
88
- - }
89
- + /*
90
- + * This works with the assumption that cpus[n].props.*_id has been
91
- + * sorted from top to down levels in mc->possible_cpu_arch_ids().
92
- + * Otherwise, the unexpected and duplicated containers will be
93
- + * created.
94
- + */
95
- + for (n = 0; n < cpus->len; n++) {
96
- + if (cpus->cpus[n].props.socket_id != socket_id) {
97
- + assert(cpus->cpus[n].props.socket_id > socket_id);
98
- + socket_id = cpus->cpus[n].props.socket_id;
99
- + cluster_id = -1;
100
- + core_id = -1;
101
- + socket_offset = table_data->len - pptt_start;
102
- + build_processor_hierarchy_node(table_data,
103
- + (1 << 0), /* Physical package */
104
- + 0, socket_id, NULL, 0);
105
- }
106
- - }
107
-
108
- - length = g_queue_get_length(list);
109
- - for (i = 0; i < length; i++) {
110
- - int core;
111
- -
112
- - parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
113
- - for (core = 0; core < ms->smp.cores; core++) {
114
- - if (ms->smp.threads > 1) {
115
- - g_queue_push_tail(list,
116
- - GUINT_TO_POINTER(table_data->len - pptt_start));
117
- - build_processor_hierarchy_node(
118
- - table_data,
119
- - (0 << 0), /* not a physical package */
120
- - parent_offset, core, NULL, 0);
121
- - } else {
122
- - build_processor_hierarchy_node(
123
- - table_data,
124
- - (1 << 1) | /* ACPI Processor ID valid */
125
- - (1 << 3), /* Node is a Leaf */
126
- - parent_offset, uid++, NULL, 0);
127
- + if (mc->smp_props.clusters_supported) {
128
- + if (cpus->cpus[n].props.cluster_id != cluster_id) {
129
- + assert(cpus->cpus[n].props.cluster_id > cluster_id);
130
- + cluster_id = cpus->cpus[n].props.cluster_id;
131
- + core_id = -1;
132
- + cluster_offset = table_data->len - pptt_start;
133
- + build_processor_hierarchy_node(table_data,
134
- + (0 << 0), /* Not a physical package */
135
- + socket_offset, cluster_id, NULL, 0);
136
- }
137
- + } else {
138
- + cluster_offset = socket_offset;
139
- }
140
- - }
141
-
142
- - length = g_queue_get_length(list);
143
- - for (i = 0; i < length; i++) {
144
- - int thread;
145
- + if (ms->smp.threads == 1) {
146
- + build_processor_hierarchy_node(table_data,
147
- + (1 << 1) | /* ACPI Processor ID valid */
148
- + (1 << 3), /* Node is a Leaf */
149
- + cluster_offset, n, NULL, 0);
150
- + } else {
151
- + if (cpus->cpus[n].props.core_id != core_id) {
152
- + assert(cpus->cpus[n].props.core_id > core_id);
153
- + core_id = cpus->cpus[n].props.core_id;
154
- + core_offset = table_data->len - pptt_start;
155
- + build_processor_hierarchy_node(table_data,
156
- + (0 << 0), /* Not a physical package */
157
- + cluster_offset, core_id, NULL, 0);
158
- + }
159
-
160
- - parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
161
- - for (thread = 0; thread < ms->smp.threads; thread++) {
162
- - build_processor_hierarchy_node(
163
- - table_data,
164
- + build_processor_hierarchy_node(table_data,
165
- (1 << 1) | /* ACPI Processor ID valid */
166
- (1 << 2) | /* Processor is a Thread */
167
- (1 << 3), /* Node is a Leaf */
168
- - parent_offset, uid++, NULL, 0);
169
- + core_offset, n, NULL, 0);
170
- }
171
- }
172
-
173
- - g_queue_free(list);
174
- acpi_table_end(linker, &table);
175
- }
176
-
177
- --
178
- 2.31.1
179
-
SOURCES/kvm-hw-arm-virt-Add-compact-highmem-property.patch ADDED
@@ -0,0 +1,169 @@
1
+ From 4ab2aff624908e49b099f00609875f4d03e9e1ec Mon Sep 17 00:00:00 2001
2
+ From: Gavin Shan <gshan@redhat.com>
3
+ Date: Wed, 21 Dec 2022 08:48:45 +0800
4
+ Subject: [PATCH 6/8] hw/arm/virt: Add 'compact-highmem' property
5
+
6
+ RH-Author: Gavin Shan <gshan@redhat.com>
7
+ RH-MergeRequest: 126: hw/arm/virt: Optimize high memory region address assignment
8
+ RH-Bugzilla: 2113840
9
+ RH-Acked-by: Eric Auger <eric.auger@redhat.com>
10
+ RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
11
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
+ RH-Commit: [6/8] 781506f3445493f05b511547370b6d88ef092457
13
+
14
+ Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2113840
15
+
16
+ After the improvement to high memory region address assignment is
17
+ applied, the memory layout can be changed, introducing possible
18
+ migration breakage. For example, VIRT_HIGH_PCIE_MMIO memory region
19
+ is disabled or enabled when the optimization is applied or not, with
20
+ the following configuration. The configuration is only achievable by
21
+ modifying the source code until more properties are added to allow
22
+ users selectively disable those high memory regions.
23
+
24
+ pa_bits = 40;
25
+ vms->highmem_redists = false;
26
+ vms->highmem_ecam = false;
27
+ vms->highmem_mmio = true;
28
+
29
+ # qemu-system-aarch64 -accel kvm -cpu host \
30
+ -machine virt-7.2,compact-highmem={on, off} \
31
+ -m 4G,maxmem=511G -monitor stdio
32
+
33
+ Region compact-highmem=off compact-highmem=on
34
+ ----------------------------------------------------------------
35
+ MEM [1GB 512GB] [1GB 512GB]
36
+ HIGH_GIC_REDISTS2 [512GB 512GB+64MB] [disabled]
37
+ HIGH_PCIE_ECAM [512GB+256MB 512GB+512MB] [disabled]
38
+ HIGH_PCIE_MMIO [disabled] [512GB 1TB]
39
+
40
+ In order to keep backwords compatibility, we need to disable the
41
+ optimization on machine, which is virt-7.1 or ealier than it. It
42
+ means the optimization is enabled by default from virt-7.2. Besides,
43
+ 'compact-highmem' property is added so that the optimization can be
44
+ explicitly enabled or disabled on all machine types by users.
45
+
46
+ Signed-off-by: Gavin Shan <gshan@redhat.com>
47
+ Reviewed-by: Eric Auger <eric.auger@redhat.com>
48
+ Reviewed-by: Cornelia Huck <cohuck@redhat.com>
49
+ Reviewed-by: Marc Zyngier <maz@kernel.org>
50
+ Tested-by: Zhenyu Zhang <zhenyzha@redhat.com>
51
+ Message-id: 20221029224307.138822-7-gshan@redhat.com
52
+ Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
53
+ (cherry picked from commit f40408a9fe5d1db70a75a33d2b26c8af8a5d57b0)
54
+ Signed-off-by: Gavin Shan <gshan@redhat.com>
55
+ Conflicts:
56
+ hw/arm/virt.c
57
+ Comment out the handlers of property 'compact-highmem' since
58
+ the property isn't exposed.
59
+ ---
60
+ docs/system/arm/virt.rst | 4 ++++
61
+ hw/arm/virt.c | 34 ++++++++++++++++++++++++++++++++++
62
+ include/hw/arm/virt.h | 1 +
63
+ 3 files changed, 39 insertions(+)
64
+
65
+ diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst
66
+ index 20442ea2c1..4454706392 100644
67
+ --- a/docs/system/arm/virt.rst
68
+ +++ b/docs/system/arm/virt.rst
69
+ @@ -94,6 +94,10 @@ highmem
70
+ address space above 32 bits. The default is ``on`` for machine types
71
+ later than ``virt-2.12``.
72
+
73
+ +compact-highmem
74
+ + Set ``on``/``off`` to enable/disable the compact layout for high memory regions.
75
+ + The default is ``on`` for machine types later than ``virt-7.2``.
76
+ +
77
+ gic-version
78
+ Specify the version of the Generic Interrupt Controller (GIC) to provide.
79
+ Valid values are:
80
+ diff --git a/hw/arm/virt.c b/hw/arm/virt.c
81
+ index 6896e0ca0f..6087511ae9 100644
82
+ --- a/hw/arm/virt.c
83
+ +++ b/hw/arm/virt.c
84
+ @@ -216,6 +216,12 @@ static const MemMapEntry base_memmap[] = {
85
+ * Note the extended_memmap is sized so that it eventually also includes the
86
+ * base_memmap entries (VIRT_HIGH_GIC_REDIST2 index is greater than the last
87
+ * index of base_memmap).
88
+ + *
89
+ + * The memory map for these Highmem IO Regions can be in legacy or compact
90
+ + * layout, depending on 'compact-highmem' property. With legacy layout, the
91
+ + * PA space for one specific region is always reserved, even if the region
92
+ + * has been disabled or doesn't fit into the PA space. However, the PA space
93
+ + * for the region won't be reserved in these circumstances with compact layout.
94
+ */
95
+ static MemMapEntry extended_memmap[] = {
96
+ /* Additional 64 MB redist region (can contain up to 512 redistributors) */
97
+ @@ -2400,6 +2406,22 @@ static void virt_set_highmem(Object *obj, bool value, Error **errp)
98
+ vms->highmem = value;
99
+ }
100
+
101
+ +#if 0 /* Disabled for Red Hat Enterprise Linux */
102
+ +static bool virt_get_compact_highmem(Object *obj, Error **errp)
103
+ +{
104
+ + VirtMachineState *vms = VIRT_MACHINE(obj);
105
+ +
106
+ + return vms->highmem_compact;
107
+ +}
108
+ +
109
+ +static void virt_set_compact_highmem(Object *obj, bool value, Error **errp)
110
+ +{
111
+ + VirtMachineState *vms = VIRT_MACHINE(obj);
112
+ +
113
+ + vms->highmem_compact = value;
114
+ +}
115
+ +#endif /* disabled for RHEL */
116
+ +
117
+ static bool virt_get_its(Object *obj, Error **errp)
118
+ {
119
+ VirtMachineState *vms = VIRT_MACHINE(obj);
120
+ @@ -3023,6 +3045,13 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
121
+ "Set on/off to enable/disable using "
122
+ "physical address space above 32 bits");
123
+
124
+ + object_class_property_add_bool(oc, "compact-highmem",
125
+ + virt_get_compact_highmem,
126
+ + virt_set_compact_highmem);
127
+ + object_class_property_set_description(oc, "compact-highmem",
128
+ + "Set on/off to enable/disable compact "
129
+ + "layout for high memory regions");
130
+ +
131
+ object_class_property_add_str(oc, "gic-version", virt_get_gic_version,
132
+ virt_set_gic_version);
133
+ object_class_property_set_description(oc, "gic-version",
134
+ @@ -3107,6 +3136,7 @@ static void virt_instance_init(Object *obj)
135
+
136
+ /* High memory is enabled by default */
137
+ vms->highmem = true;
138
+ + vms->highmem_compact = !vmc->no_highmem_compact;
139
+ vms->gic_version = VIRT_GIC_VERSION_NOSEL;
140
+
141
+ vms->highmem_ecam = !vmc->no_highmem_ecam;
142
+ @@ -3176,8 +3206,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(7, 2)
143
+
144
+ static void virt_machine_7_1_options(MachineClass *mc)
145
+ {
146
+ + VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
147
+ +
148
+ virt_machine_7_2_options(mc);
149
+ compat_props_add(mc->compat_props, hw_compat_7_1, hw_compat_7_1_len);
150
+ + /* Compact layout for high memory regions was introduced with 7.2 */
151
+ + vmc->no_highmem_compact = true;
152
+ }
153
+ DEFINE_VIRT_MACHINE(7, 1)
154
+
155
+ diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
156
+ index 15bd291311..85e7d61868 100644
157
+ --- a/include/hw/arm/virt.h
158
+ +++ b/include/hw/arm/virt.h
159
+ @@ -125,6 +125,7 @@ struct VirtMachineClass {
160
+ bool no_pmu;
161
+ bool claim_edge_triggered_timers;
162
+ bool smbios_old_sys_ver;
163
+ + bool no_highmem_compact;
164
+ bool no_highmem_ecam;
165
+ bool no_ged; /* Machines < 4.2 have no support for ACPI GED device */
166
+ bool kvm_no_adjvtime;
167
+ --
168
+ 2.31.1
169
+
SOURCES/kvm-hw-arm-virt-Add-properties-to-disable-high-memory-re.patch ADDED
@@ -0,0 +1,179 @@
1
+ From 30e86a7c4fbcdc95b74bcb2a15745cb221783091 Mon Sep 17 00:00:00 2001
2
+ From: Gavin Shan <gshan@redhat.com>
3
+ Date: Wed, 21 Dec 2022 08:48:45 +0800
4
+ Subject: [PATCH 7/8] hw/arm/virt: Add properties to disable high memory
5
+ regions
6
+
7
+ RH-Author: Gavin Shan <gshan@redhat.com>
8
+ RH-MergeRequest: 126: hw/arm/virt: Optimize high memory region address assignment
9
+ RH-Bugzilla: 2113840
10
+ RH-Acked-by: Eric Auger <eric.auger@redhat.com>
11
+ RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
12
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
13
+ RH-Commit: [7/8] 16f8762393b447a590b31c9e4d8d3c58c6bc9fa8
14
+
15
+ Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2113840
16
+
17
+ The 3 high memory regions are usually enabled by default, but they may
18
+ be not used. For example, VIRT_HIGH_GIC_REDIST2 isn't needed by GICv2.
19
+ This leads to waste in the PA space.
20
+
21
+ Add properties ("highmem-redists", "highmem-ecam", "highmem-mmio") to
22
+ allow users selectively disable them if needed. After that, the high
23
+ memory region for GICv3 or GICv4 redistributor can be disabled by user,
24
+ the number of maximal supported CPUs needs to be calculated based on
25
+ 'vms->highmem_redists'. The follow-up error message is also improved
26
+ to indicate if the high memory region for GICv3 and GICv4 has been
27
+ enabled or not.
28
+
29
+ Suggested-by: Marc Zyngier <maz@kernel.org>
30
+ Signed-off-by: Gavin Shan <gshan@redhat.com>
31
+ Reviewed-by: Marc Zyngier <maz@kernel.org>
32
+ Reviewed-by: Cornelia Huck <cohuck@redhat.com>
33
+ Reviewed-by: Eric Auger <eric.auger@redhat.com>
34
+ Message-id: 20221029224307.138822-8-gshan@redhat.com
35
+ Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
36
+ (cherry picked from commit 6a48c64eec355ab1aff694eb4522d07a8e461368)
37
+ Signed-off-by: Gavin Shan <gshan@redhat.com>
38
+ Conflicts:
39
+ hw/arm/virt.c
40
+ Comment out the handlers of the property 'highmem-redists',
41
+ 'highmem-ecam' and 'highmem-mmio' since they aren't exposed.
42
+ ---
43
+ docs/system/arm/virt.rst | 13 +++++++
44
+ hw/arm/virt.c | 75 ++++++++++++++++++++++++++++++++++++++--
45
+ 2 files changed, 86 insertions(+), 2 deletions(-)
46
+
47
+ diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst
48
+ index 4454706392..188a4f211f 100644
49
+ --- a/docs/system/arm/virt.rst
50
+ +++ b/docs/system/arm/virt.rst
51
+ @@ -98,6 +98,19 @@ compact-highmem
52
+ Set ``on``/``off`` to enable/disable the compact layout for high memory regions.
53
+ The default is ``on`` for machine types later than ``virt-7.2``.
54
+
55
+ +highmem-redists
56
+ + Set ``on``/``off`` to enable/disable the high memory region for GICv3 or
57
+ + GICv4 redistributor. The default is ``on``. Setting this to ``off`` will
58
+ + limit the maximum number of CPUs when GICv3 or GICv4 is used.
59
+ +
60
+ +highmem-ecam
61
+ + Set ``on``/``off`` to enable/disable the high memory region for PCI ECAM.
62
+ + The default is ``on`` for machine types later than ``virt-3.0``.
63
+ +
64
+ +highmem-mmio
65
+ + Set ``on``/``off`` to enable/disable the high memory region for PCI MMIO.
66
+ + The default is ``on``.
67
+ +
68
+ gic-version
69
+ Specify the version of the Generic Interrupt Controller (GIC) to provide.
70
+ Valid values are:
71
+ diff --git a/hw/arm/virt.c b/hw/arm/virt.c
72
+ index 6087511ae9..304fa0d6e7 100644
73
+ --- a/hw/arm/virt.c
74
+ +++ b/hw/arm/virt.c
75
+ @@ -2142,14 +2142,20 @@ static void machvirt_init(MachineState *machine)
76
+ if (vms->gic_version == VIRT_GIC_VERSION_2) {
77
+ virt_max_cpus = GIC_NCPU;
78
+ } else {
79
+ - virt_max_cpus = virt_redist_capacity(vms, VIRT_GIC_REDIST) +
80
+ - virt_redist_capacity(vms, VIRT_HIGH_GIC_REDIST2);
81
+ + virt_max_cpus = virt_redist_capacity(vms, VIRT_GIC_REDIST);
82
+ + if (vms->highmem_redists) {
83
+ + virt_max_cpus += virt_redist_capacity(vms, VIRT_HIGH_GIC_REDIST2);
84
+ + }
85
+ }
86
+
87
+ if (max_cpus > virt_max_cpus) {
88
+ error_report("Number of SMP CPUs requested (%d) exceeds max CPUs "
89
+ "supported by machine 'mach-virt' (%d)",
90
+ max_cpus, virt_max_cpus);
91
+ + if (vms->gic_version != VIRT_GIC_VERSION_2 && !vms->highmem_redists) {
92
+ + error_printf("Try 'highmem-redists=on' for more CPUs\n");
93
+ + }
94
+ +
95
+ exit(1);
96
+ }
97
+
98
+ @@ -2420,6 +2426,49 @@ static void virt_set_compact_highmem(Object *obj, bool value, Error **errp)
99
+
100
+ vms->highmem_compact = value;
101
+ }
102
+ +
103
+ +static bool virt_get_highmem_redists(Object *obj, Error **errp)
104
+ +{
105
+ + VirtMachineState *vms = VIRT_MACHINE(obj);
106
+ +
107
+ + return vms->highmem_redists;
108
+ +}
109
+ +
110
+ +static void virt_set_highmem_redists(Object *obj, bool value, Error **errp)
111
+ +{
112
+ + VirtMachineState *vms = VIRT_MACHINE(obj);
113
+ +
114
+ + vms->highmem_redists = value;
115
+ +}
116
+ +
117
+ +static bool virt_get_highmem_ecam(Object *obj, Error **errp)
118
+ +{
119
+ + VirtMachineState *vms = VIRT_MACHINE(obj);
120
+ +
121
+ + return vms->highmem_ecam;
122
+ +}
123
+ +
124
+ +static void virt_set_highmem_ecam(Object *obj, bool value, Error **errp)
125
+ +{
126
+ + VirtMachineState *vms = VIRT_MACHINE(obj);
127
+ +
128
+ + vms->highmem_ecam = value;
129
+ +}
130
+ +
131
+ +static bool virt_get_highmem_mmio(Object *obj, Error **errp)
132
+ +{
133
+ + VirtMachineState *vms = VIRT_MACHINE(obj);
134
+ +
135
+ + return vms->highmem_mmio;
136
+ +}
137
+ +
138
+ +static void virt_set_highmem_mmio(Object *obj, bool value, Error **errp)
139
+ +{
140
+ + VirtMachineState *vms = VIRT_MACHINE(obj);
141
+ +
142
+ + vms->highmem_mmio = value;
143
+ +}
144
+ +
145
+ #endif /* disabled for RHEL */
146
+
147
+ static bool virt_get_its(Object *obj, Error **errp)
148
+ @@ -3052,6 +3101,28 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
149
+ "Set on/off to enable/disable compact "
150
+ "layout for high memory regions");
151
+
152
+ + object_class_property_add_bool(oc, "highmem-redists",
153
+ + virt_get_highmem_redists,
154
+ + virt_set_highmem_redists);
155
+ + object_class_property_set_description(oc, "highmem-redists",
156
+ + "Set on/off to enable/disable high "
157
+ + "memory region for GICv3 or GICv4 "
158
+ + "redistributor");
159
+ +
160
+ + object_class_property_add_bool(oc, "highmem-ecam",
161
+ + virt_get_highmem_ecam,
162
+ + virt_set_highmem_ecam);
163
+ + object_class_property_set_description(oc, "highmem-ecam",
164
+ + "Set on/off to enable/disable high "
165
+ + "memory region for PCI ECAM");
166
+ +
167
+ + object_class_property_add_bool(oc, "highmem-mmio",
168
+ + virt_get_highmem_mmio,
169
+ + virt_set_highmem_mmio);
170
+ + object_class_property_set_description(oc, "highmem-mmio",
171
+ + "Set on/off to enable/disable high "
172
+ + "memory region for PCI MMIO");
173
+ +
174
+ object_class_property_add_str(oc, "gic-version", virt_get_gic_version,
175
+ virt_set_gic_version);
176
+ object_class_property_set_description(oc, "gic-version",
177
+ --
178
+ 2.31.1
179
+
SOURCES/kvm-hw-arm-virt-Consider-SMP-configuration-in-CPU-topolo.patch DELETED
@@ -1,74 +0,0 @@
1
- From 3b05d3464945295112b5d02d142422f524a52054 Mon Sep 17 00:00:00 2001
2
- From: Gavin Shan <gshan@redhat.com>
3
- Date: Wed, 11 May 2022 18:01:35 +0800
4
- Subject: [PATCH 03/16] hw/arm/virt: Consider SMP configuration in CPU topology
5
-
6
- RH-Author: Gavin Shan <gshan@redhat.com>
7
- RH-MergeRequest: 86: hw/arm/virt: Fix the default CPU topology
8
- RH-Commit: [3/6] 7125b41f038c2b1cb33377d0ef1222f1ea42b648 (gwshan/qemu-rhel-9)
9
- RH-Bugzilla: 2041823
10
- RH-Acked-by: Eric Auger <eric.auger@redhat.com>
11
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
12
- RH-Acked-by: Andrew Jones <drjones@redhat.com>
13
-
14
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2041823
15
-
16
- Currently, the SMP configuration isn't considered when the CPU
17
- topology is populated. In this case, it's impossible to provide
18
- the default CPU-to-NUMA mapping or association based on the socket
19
- ID of the given CPU.
20
-
21
- This takes account of SMP configuration when the CPU topology
22
- is populated. The die ID for the given CPU isn't assigned since
23
- it's not supported on arm/virt machine. Besides, the used SMP
24
- configuration in qtest/numa-test/aarch64_numa_cpu() is corrcted
25
- to avoid testing failure
26
-
27
- Signed-off-by: Gavin Shan <gshan@redhat.com>
28
- Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
29
- Acked-by: Igor Mammedov <imammedo@redhat.com>
30
- Message-id: 20220503140304.855514-4-gshan@redhat.com
31
- Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
32
- (cherry picked from commit c9ec4cb5e4936f980889e717524e73896b0200ed)
33
- Signed-off-by: Gavin Shan <gshan@redhat.com>
34
- ---
35
- hw/arm/virt.c | 15 ++++++++++++++-
36
- 1 file changed, 14 insertions(+), 1 deletion(-)
37
-
38
- diff --git a/hw/arm/virt.c b/hw/arm/virt.c
39
- index 8be12e121d..a87c8d396a 100644
40
- --- a/hw/arm/virt.c
41
- +++ b/hw/arm/virt.c
42
- @@ -2553,6 +2553,7 @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms)
43
- int n;
44
- unsigned int max_cpus = ms->smp.max_cpus;
45
- VirtMachineState *vms = VIRT_MACHINE(ms);
46
- + MachineClass *mc = MACHINE_GET_CLASS(vms);
47
-
48
- if (ms->possible_cpus) {
49
- assert(ms->possible_cpus->len == max_cpus);
50
- @@ -2566,8 +2567,20 @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms)
51
- ms->possible_cpus->cpus[n].type = ms->cpu_type;
52
- ms->possible_cpus->cpus[n].arch_id =
53
- virt_cpu_mp_affinity(vms, n);
54
- +
55
- + assert(!mc->smp_props.dies_supported);
56
- + ms->possible_cpus->cpus[n].props.has_socket_id = true;
57
- + ms->possible_cpus->cpus[n].props.socket_id =
58
- + n / (ms->smp.clusters * ms->smp.cores * ms->smp.threads);
59
- + ms->possible_cpus->cpus[n].props.has_cluster_id = true;
60
- + ms->possible_cpus->cpus[n].props.cluster_id =
61
- + (n / (ms->smp.cores * ms->smp.threads)) % ms->smp.clusters;
62
- + ms->possible_cpus->cpus[n].props.has_core_id = true;
63
- + ms->possible_cpus->cpus[n].props.core_id =
64
- + (n / ms->smp.threads) % ms->smp.cores;
65
- ms->possible_cpus->cpus[n].props.has_thread_id = true;
66
- - ms->possible_cpus->cpus[n].props.thread_id = n;
67
- + ms->possible_cpus->cpus[n].props.thread_id =
68
- + n % ms->smp.threads;
69
- }
70
- return ms->possible_cpus;
71
- }
72
- --
73
- 2.31.1
74
-
SOURCES/kvm-hw-arm-virt-Enable-compat-high-memory-region-address.patch ADDED
@@ -0,0 +1,51 @@
1
+ From 969ea1ff46b52c5fe6d87f2eeb1625871a2dfb2a Mon Sep 17 00:00:00 2001
2
+ From: Gavin Shan <gshan@redhat.com>
3
+ Date: Wed, 21 Dec 2022 08:48:45 +0800
4
+ Subject: [PATCH 8/8] hw/arm/virt: Enable compat high memory region address
5
+ assignment for 9.2.0 machine
6
+
7
+ RH-Author: Gavin Shan <gshan@redhat.com>
8
+ RH-MergeRequest: 126: hw/arm/virt: Optimize high memory region address assignment
9
+ RH-Bugzilla: 2113840
10
+ RH-Acked-by: Eric Auger <eric.auger@redhat.com>
11
+ RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
12
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
13
+ RH-Commit: [8/8] beda1791c0c35dce5c669efd47685302b8468032
14
+
15
+ Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2113840
16
+ Upstream: RHEL only
17
+
18
+ The compact high memory region address assignment is enabled for 9.2.0,
19
+ but it's kept as disabled for 9.0.0, to keep the backwards compatibility
20
+ on 9.0.0. Note that these newly added properties ('compact-highmem',
21
+ 'highmem-redists', 'highmem-ecam', and 'highmem-mmio') in the upstream
22
+ aren't exposed for the downstream.
23
+
24
+ Signed-off-by: Gavin Shan <gshan@redhat.com>
25
+ ---
26
+ hw/arm/virt.c | 3 +++
27
+ 1 file changed, 3 insertions(+)
28
+
29
+ diff --git a/hw/arm/virt.c b/hw/arm/virt.c
30
+ index 304fa0d6e7..e41c0b462c 100644
31
+ --- a/hw/arm/virt.c
32
+ +++ b/hw/arm/virt.c
33
+ @@ -3581,6 +3581,7 @@ static void rhel_virt_instance_init(Object *obj)
34
+
35
+ /* High memory is enabled by default */
36
+ vms->highmem = true;
37
+ + vms->highmem_compact = !vmc->no_highmem_compact;
38
+ vms->gic_version = VIRT_GIC_VERSION_NOSEL;
39
+
40
+ vms->highmem_ecam = !vmc->no_highmem_ecam;
41
+ @@ -3659,5 +3660,7 @@ static void rhel900_virt_options(MachineClass *mc)
42
+
43
+ /* Disable FEAT_LPA2 since old kernels (<= v5.12) don't boot with that feature */
44
+ vmc->no_tcg_lpa2 = true;
45
+ + /* Compact layout for high memory regions was introduced with 9.2.0 */
46
+ + vmc->no_highmem_compact = true;
47
+ }
48
+ DEFINE_RHEL_MACHINE(9, 0, 0)
49
+ --
50
+ 2.31.1
51
+
SOURCES/kvm-hw-arm-virt-Fix-CPU-s-default-NUMA-node-ID.patch DELETED
@@ -1,88 +0,0 @@
1
- From 14e49ad3b98f01c1ad6fe456469d40a96a43dc3c Mon Sep 17 00:00:00 2001
2
- From: Gavin Shan <gshan@redhat.com>
3
- Date: Wed, 11 May 2022 18:01:35 +0800
4
- Subject: [PATCH 05/16] hw/arm/virt: Fix CPU's default NUMA node ID
5
-
6
- RH-Author: Gavin Shan <gshan@redhat.com>
7
- RH-MergeRequest: 86: hw/arm/virt: Fix the default CPU topology
8
- RH-Commit: [5/6] 5336f62bc0c53c0417db1d71ef89544907bc28c0 (gwshan/qemu-rhel-9)
9
- RH-Bugzilla: 2041823
10
- RH-Acked-by: Eric Auger <eric.auger@redhat.com>
11
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
12
- RH-Acked-by: Andrew Jones <drjones@redhat.com>
13
-
14
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2041823
15
-
16
- When CPU-to-NUMA association isn't explicitly provided by users,
17
- the default one is given by mc->get_default_cpu_node_id(). However,
18
- the CPU topology isn't fully considered in the default association
19
- and this causes CPU topology broken warnings on booting Linux guest.
20
-
21
- For example, the following warning messages are observed when the
22
- Linux guest is booted with the following command lines.
23
-
24
- /home/gavin/sandbox/qemu.main/build/qemu-system-aarch64 \
25
- -accel kvm -machine virt,gic-version=host \
26
- -cpu host \
27
- -smp 6,sockets=2,cores=3,threads=1 \
28
- -m 1024M,slots=16,maxmem=64G \
29
- -object memory-backend-ram,id=mem0,size=128M \
30
- -object memory-backend-ram,id=mem1,size=128M \
31
- -object memory-backend-ram,id=mem2,size=128M \
32
- -object memory-backend-ram,id=mem3,size=128M \
33
- -object memory-backend-ram,id=mem4,size=128M \
34
- -object memory-backend-ram,id=mem4,size=384M \
35
- -numa node,nodeid=0,memdev=mem0 \
36
- -numa node,nodeid=1,memdev=mem1 \
37
- -numa node,nodeid=2,memdev=mem2 \
38
- -numa node,nodeid=3,memdev=mem3 \
39
- -numa node,nodeid=4,memdev=mem4 \
40
- -numa node,nodeid=5,memdev=mem5
41
- :
42
- alternatives: patching kernel code
43
- BUG: arch topology borken
44
- the CLS domain not a subset of the MC domain
45
- <the above error log repeats>
46
- BUG: arch topology borken
47
- the DIE domain not a subset of the NODE domain
48
-
49
- With current implementation of mc->get_default_cpu_node_id(),
50
- CPU#0 to CPU#5 are associated with NODE#0 to NODE#5 separately.
51
- That's incorrect because CPU#0/1/2 should be associated with same
52
- NUMA node because they're seated in same socket.
53
-
54
- This fixes the issue by considering the socket ID when the default
55
- CPU-to-NUMA association is provided in virt_possible_cpu_arch_ids().
56
- With this applied, no more CPU topology broken warnings are seen
57
- from the Linux guest. The 6 CPUs are associated with NODE#0/1, but
58
- there are no CPUs associated with NODE#2/3/4/5.
59
-
60
- Signed-off-by: Gavin Shan <gshan@redhat.com>
61
- Reviewed-by: Igor Mammedov <imammedo@redhat.com>
62
- Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
63
- Message-id: 20220503140304.855514-6-gshan@redhat.com
64
- Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
65
- (cherry picked from commit 4c18bc192386dfbca530e7f550e0992df657818a)
66
- Signed-off-by: Gavin Shan <gshan@redhat.com>
67
- ---
68
- hw/arm/virt.c | 4 +++-
69
- 1 file changed, 3 insertions(+), 1 deletion(-)
70
-
71
- diff --git a/hw/arm/virt.c b/hw/arm/virt.c
72
- index a87c8d396a..95d012d6eb 100644
73
- --- a/hw/arm/virt.c
74
- +++ b/hw/arm/virt.c
75
- @@ -2545,7 +2545,9 @@ virt_cpu_index_to_props(MachineState *ms, unsigned cpu_index)
76
-
77
- static int64_t virt_get_default_cpu_node_id(const MachineState *ms, int idx)
78
- {
79
- - return idx % ms->numa_state->num_nodes;
80
- + int64_t socket_id = ms->possible_cpus->cpus[idx].props.socket_id;
81
- +
82
- + return socket_id % ms->numa_state->num_nodes;
83
- }
84
-
85
- static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms)
86
- --
87
- 2.31.1
88
-
SOURCES/kvm-hw-arm-virt-Fix-missing-initialization-in-instance-c.patch DELETED
@@ -1,56 +0,0 @@
1
- From e25c40735d2f022c07481b548d20476222006657 Mon Sep 17 00:00:00 2001
2
- From: Eric Auger <eric.auger@redhat.com>
3
- Date: Wed, 4 May 2022 11:11:54 +0200
4
- Subject: [PATCH 2/5] hw/arm/virt: Fix missing initialization in
5
- instance/class_init()
6
-
7
- RH-Author: Eric Auger <eric.auger@redhat.com>
8
- RH-MergeRequest: 82: hw/arm/virt: Remove the dtb-kaslr-seed machine option
9
- RH-Commit: [2/2] 22cbbfc30cf57a09b8acfb25d8a4dff2754c630c (eauger1/centos-qemu-kvm)
10
- RH-Bugzilla: 2046029
11
- RH-Acked-by: Gavin Shan <gshan@redhat.com>
12
- RH-Acked-by: Andrew Jones <drjones@redhat.com>
13
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
14
-
15
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2046029
16
- Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=45133161
17
- Upstream Status: RHEL-only
18
- Tested: Boot RHEL guest and check migration from 8.6 to 9.1
19
- (with custom additions)
20
-
21
- During the 7.0 rebase, the initialization of highmem_mmio and
22
- highmem_redists was forgotten in rhel_virt_instance_init().
23
- Fix it to match virt_instance_init() code.
24
-
25
- Also mc->smp_props.clusters_supported was missing in
26
- rhel_machine_class_init().
27
-
28
- Signed-off-by: Eric Auger <eric.auger@redhat.com>
29
- ---
30
- hw/arm/virt.c | 3 +++
31
- 1 file changed, 3 insertions(+)
32
-
33
- diff --git a/hw/arm/virt.c b/hw/arm/virt.c
34
- index bde4f77994..8be12e121d 100644
35
- --- a/hw/arm/virt.c
36
- +++ b/hw/arm/virt.c
37
- @@ -3286,6 +3286,7 @@ static void rhel_machine_class_init(ObjectClass *oc, void *data)
38
- hc->unplug_request = virt_machine_device_unplug_request_cb;
39
- hc->unplug = virt_machine_device_unplug_cb;
40
- mc->nvdimm_supported = true;
41
- + mc->smp_props.clusters_supported = true;
42
- mc->auto_enable_numa_with_memhp = true;
43
- mc->auto_enable_numa_with_memdev = true;
44
- mc->default_ram_id = "mach-virt.ram";
45
- @@ -3366,6 +3367,8 @@ static void rhel_virt_instance_init(Object *obj)
46
- vms->gic_version = VIRT_GIC_VERSION_NOSEL;
47
-
48
- vms->highmem_ecam = !vmc->no_highmem_ecam;
49
- + vms->highmem_mmio = true;
50
- + vms->highmem_redists = true;
51
-
52
- if (vmc->no_its) {
53
- vms->its = false;
54
- --
55
- 2.31.1
56
-
SOURCES/kvm-hw-arm-virt-Improve-high-memory-region-address-assig.patch ADDED
@@ -0,0 +1,112 @@
1
+ From 1c7fad3776a14ca35b24dc2fdb262d4ddf40d6eb Mon Sep 17 00:00:00 2001
2
+ From: Gavin Shan <gshan@redhat.com>
3
+ Date: Wed, 21 Dec 2022 08:48:45 +0800
4
+ Subject: [PATCH 5/8] hw/arm/virt: Improve high memory region address
5
+ assignment
6
+
7
+ RH-Author: Gavin Shan <gshan@redhat.com>
8
+ RH-MergeRequest: 126: hw/arm/virt: Optimize high memory region address assignment
9
+ RH-Bugzilla: 2113840
10
+ RH-Acked-by: Eric Auger <eric.auger@redhat.com>
11
+ RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
12
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
13
+ RH-Commit: [5/8] 4d77fa78b5258a1bd8d30405cec5ba3311d42f92
14
+
15
+ Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2113840
16
+
17
+ There are three high memory regions, which are VIRT_HIGH_REDIST2,
18
+ VIRT_HIGH_PCIE_ECAM and VIRT_HIGH_PCIE_MMIO. Their base addresses
19
+ are floating on highest RAM address. However, they can be disabled
20
+ in several cases.
21
+
22
+ (1) One specific high memory region is likely to be disabled by
23
+ code by toggling vms->highmem_{redists, ecam, mmio}.
24
+
25
+ (2) VIRT_HIGH_PCIE_ECAM region is disabled on machine, which is
26
+ 'virt-2.12' or ealier than it.
27
+
28
+ (3) VIRT_HIGH_PCIE_ECAM region is disabled when firmware is loaded
29
+ on 32-bits system.
30
+
31
+ (4) One specific high memory region is disabled when it breaks the
32
+ PA space limit.
33
+
34
+ The current implementation of virt_set_{memmap, high_memmap}() isn't
35
+ optimized because the high memory region's PA space is always reserved,
36
+ regardless of whatever the actual state in the corresponding
37
+ vms->highmem_{redists, ecam, mmio} flag. In the code, 'base' and
38
+ 'vms->highest_gpa' are always increased for case (1), (2) and (3).
39
+ It's unnecessary since the assigned PA space for the disabled high
40
+ memory region won't be used afterwards.
41
+
42
+ Improve the address assignment for those three high memory region by
43
+ skipping the address assignment for one specific high memory region if
44
+ it has been disabled in case (1), (2) and (3). The memory layout may
45
+ be changed after the improvement is applied, which leads to potential
46
+ migration breakage. So 'vms->highmem_compact' is added to control if
47
+ the improvement should be applied. For now, 'vms->highmem_compact' is
48
+ set to false, meaning that we don't have memory layout change until it
49
+ becomes configurable through property 'compact-highmem' in next patch.
50
+
51
+ Signed-off-by: Gavin Shan <gshan@redhat.com>
52
+ Reviewed-by: Eric Auger <eric.auger@redhat.com>
53
+ Reviewed-by: Cornelia Huck <cohuck@redhat.com>
54
+ Reviewed-by: Marc Zyngier <maz@kernel.org>
55
+ Tested-by: Zhenyu Zhang <zhenyzha@redhat.com>
56
+ Message-id: 20221029224307.138822-6-gshan@redhat.com
57
+ Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
58
+ (cherry picked from commit 4a4ff9edc6a8fdc76082af5b41b059217138c09b)
59
+ Signed-off-by: Gavin Shan <gshan@redhat.com>
60
+ ---
61
+ hw/arm/virt.c | 15 ++++++++++-----
62
+ include/hw/arm/virt.h | 1 +
63
+ 2 files changed, 11 insertions(+), 5 deletions(-)
64
+
65
+ diff --git a/hw/arm/virt.c b/hw/arm/virt.c
66
+ index 6e3b9fc060..6896e0ca0f 100644
67
+ --- a/hw/arm/virt.c
68
+ +++ b/hw/arm/virt.c
69
+ @@ -1768,18 +1768,23 @@ static void virt_set_high_memmap(VirtMachineState *vms,
70
+ vms->memmap[i].size = region_size;
71
+
72
+ /*
73
+ - * Check each device to see if they fit in the PA space,
74
+ - * moving highest_gpa as we go.
75
+ + * Check each device to see if it fits in the PA space,
76
+ + * moving highest_gpa as we go. For compatibility, move
77
+ + * highest_gpa for disabled fitting devices as well, if
78
+ + * the compact layout has been disabled.
79
+ *
80
+ * For each device that doesn't fit, disable it.
81
+ */
82
+ fits = (region_base + region_size) <= BIT_ULL(pa_bits);
83
+ - if (fits) {
84
+ - vms->highest_gpa = region_base + region_size - 1;
85
+ + *region_enabled &= fits;
86
+ + if (vms->highmem_compact && !*region_enabled) {
87
+ + continue;
88
+ }
89
+
90
+ - *region_enabled &= fits;
91
+ base = region_base + region_size;
92
+ + if (fits) {
93
+ + vms->highest_gpa = base - 1;
94
+ + }
95
+ }
96
+ }
97
+
98
+ diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
99
+ index 22b54ec510..15bd291311 100644
100
+ --- a/include/hw/arm/virt.h
101
+ +++ b/include/hw/arm/virt.h
102
+ @@ -144,6 +144,7 @@ struct VirtMachineState {
103
+ PFlashCFI01 *flash[2];
104
+ bool secure;
105
+ bool highmem;
106
+ + bool highmem_compact;
107
+ bool highmem_ecam;
108
+ bool highmem_mmio;
109
+ bool highmem_redists;
110
+ --
111
+ 2.31.1
112
+
SOURCES/kvm-hw-arm-virt-Introduce-variable-region_base-in-virt_s.patch ADDED
@@ -0,0 +1,82 @@
1
+ From 305a369fd18f29914bf96cc181add532d435d8ed Mon Sep 17 00:00:00 2001
2
+ From: Gavin Shan <gshan@redhat.com>
3
+ Date: Wed, 21 Dec 2022 08:48:45 +0800
4
+ Subject: [PATCH 3/8] hw/arm/virt: Introduce variable region_base in
5
+ virt_set_high_memmap()
6
+
7
+ RH-Author: Gavin Shan <gshan@redhat.com>
8
+ RH-MergeRequest: 126: hw/arm/virt: Optimize high memory region address assignment
9
+ RH-Bugzilla: 2113840
10
+ RH-Acked-by: Eric Auger <eric.auger@redhat.com>
11
+ RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
12
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
13
+ RH-Commit: [3/8] 15de90df217d680ccc858b679898b3993e1c050a
14
+
15
+ Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2113840
16
+
17
+ This introduces variable 'region_base' for the base address of the
18
+ specific high memory region. It's the preparatory work to optimize
19
+ high memory region address assignment.
20
+
21
+ No functional change intended.
22
+
23
+ Signed-off-by: Gavin Shan <gshan@redhat.com>
24
+ Reviewed-by: Eric Auger <eric.auger@redhat.com>
25
+ Reviewed-by: Cornelia Huck <cohuck@redhat.com>
26
+ Reviewed-by: Marc Zyngier <maz@kernel.org>
27
+ Tested-by: Zhenyu Zhang <zhenyzha@redhat.com>
28
+ Message-id: 20221029224307.138822-4-gshan@redhat.com
29
+ Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
30
+ (cherry picked from commit fa245799b9407fc7b561da185b3d889df5e16a88)
31
+ Signed-off-by: Gavin Shan <gshan@redhat.com>
32
+ ---
33
+ hw/arm/virt.c | 12 ++++++------
34
+ 1 file changed, 6 insertions(+), 6 deletions(-)
35
+
36
+ diff --git a/hw/arm/virt.c b/hw/arm/virt.c
37
+ index ca098d40b8..ddcf7ee2f8 100644
38
+ --- a/hw/arm/virt.c
39
+ +++ b/hw/arm/virt.c
40
+ @@ -1739,15 +1739,15 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx)
41
+ static void virt_set_high_memmap(VirtMachineState *vms,
42
+ hwaddr base, int pa_bits)
43
+ {
44
+ - hwaddr region_size;
45
+ + hwaddr region_base, region_size;
46
+ bool fits;
47
+ int i;
48
+
49
+ for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) {
50
+ + region_base = ROUND_UP(base, extended_memmap[i].size);
51
+ region_size = extended_memmap[i].size;
52
+
53
+ - base = ROUND_UP(base, region_size);
54
+ - vms->memmap[i].base = base;
55
+ + vms->memmap[i].base = region_base;
56
+ vms->memmap[i].size = region_size;
57
+
58
+ /*
59
+ @@ -1756,9 +1756,9 @@ static void virt_set_high_memmap(VirtMachineState *vms,
60
+ *
61
+ * For each device that doesn't fit, disable it.
62
+ */
63
+ - fits = (base + region_size) <= BIT_ULL(pa_bits);
64
+ + fits = (region_base + region_size) <= BIT_ULL(pa_bits);
65
+ if (fits) {
66
+ - vms->highest_gpa = base + region_size - 1;
67
+ + vms->highest_gpa = region_base + region_size - 1;
68
+ }
69
+
70
+ switch (i) {
71
+ @@ -1773,7 +1773,7 @@ static void virt_set_high_memmap(VirtMachineState *vms,
72
+ break;
73
+ }
74
+
75
+ - base += region_size;
76
+ + base = region_base + region_size;
77
+ }
78
+ }
79
+
80
+ --
81
+ 2.31.1
82
+
SOURCES/kvm-hw-arm-virt-Introduce-virt_get_high_memmap_enabled-h.patch ADDED
@@ -0,0 +1,95 @@
1
+ From a2ddd68c8365ec602db6b2a9cf83bb441ca701cc Mon Sep 17 00:00:00 2001
2
+ From: Gavin Shan <gshan@redhat.com>
3
+ Date: Wed, 21 Dec 2022 08:48:45 +0800
4
+ Subject: [PATCH 4/8] hw/arm/virt: Introduce virt_get_high_memmap_enabled()
5
+ helper
6
+
7
+ RH-Author: Gavin Shan <gshan@redhat.com>
8
+ RH-MergeRequest: 126: hw/arm/virt: Optimize high memory region address assignment
9
+ RH-Bugzilla: 2113840
10
+ RH-Acked-by: Eric Auger <eric.auger@redhat.com>
11
+ RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
12
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
13
+ RH-Commit: [4/8] 65524de2fc106600bbaff641caa8c4f2f8027114
14
+
15
+ Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2113840
16
+
17
+ This introduces virt_get_high_memmap_enabled() helper, which returns
18
+ the pointer to vms->highmem_{redists, ecam, mmio}. The pointer will
19
+ be used in the subsequent patches.
20
+
21
+ No functional change intended.
22
+
23
+ Signed-off-by: Gavin Shan <gshan@redhat.com>
24
+ Reviewed-by: Eric Auger <eric.auger@redhat.com>
25
+ Reviewed-by: Cornelia Huck <cohuck@redhat.com>
26
+ Reviewed-by: Marc Zyngier <maz@kernel.org>
27
+ Tested-by: Zhenyu Zhang <zhenyzha@redhat.com>
28
+ Message-id: 20221029224307.138822-5-gshan@redhat.com
29
+ Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
30
+ (cherry picked from commit a5cb1350b19a5c2a58ab4edddf609ed429c13085)
31
+ Signed-off-by: Gavin Shan <gshan@redhat.com>
32
+ ---
33
+ hw/arm/virt.c | 32 +++++++++++++++++++-------------
34
+ 1 file changed, 19 insertions(+), 13 deletions(-)
35
+
36
+ diff --git a/hw/arm/virt.c b/hw/arm/virt.c
37
+ index ddcf7ee2f8..6e3b9fc060 100644
38
+ --- a/hw/arm/virt.c
39
+ +++ b/hw/arm/virt.c
40
+ @@ -1736,14 +1736,31 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx)
41
+ return arm_cpu_mp_affinity(idx, clustersz);
42
+ }
43
+
44
+ +static inline bool *virt_get_high_memmap_enabled(VirtMachineState *vms,
45
+ + int index)
46
+ +{
47
+ + bool *enabled_array[] = {
48
+ + &vms->highmem_redists,
49
+ + &vms->highmem_ecam,
50
+ + &vms->highmem_mmio,
51
+ + };
52
+ +
53
+ + assert(ARRAY_SIZE(extended_memmap) - VIRT_LOWMEMMAP_LAST ==
54
+ + ARRAY_SIZE(enabled_array));
55
+ + assert(index - VIRT_LOWMEMMAP_LAST < ARRAY_SIZE(enabled_array));
56
+ +
57
+ + return enabled_array[index - VIRT_LOWMEMMAP_LAST];
58
+ +}
59
+ +
60
+ static void virt_set_high_memmap(VirtMachineState *vms,
61
+ hwaddr base, int pa_bits)
62
+ {
63
+ hwaddr region_base, region_size;
64
+ - bool fits;
65
+ + bool *region_enabled, fits;
66
+ int i;
67
+
68
+ for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) {
69
+ + region_enabled = virt_get_high_memmap_enabled(vms, i);
70
+ region_base = ROUND_UP(base, extended_memmap[i].size);
71
+ region_size = extended_memmap[i].size;
72
+
73
+ @@ -1761,18 +1778,7 @@ static void virt_set_high_memmap(VirtMachineState *vms,
74
+ vms->highest_gpa = region_base + region_size - 1;
75
+ }
76
+
77
+ - switch (i) {
78
+ - case VIRT_HIGH_GIC_REDIST2:
79
+ - vms->highmem_redists &= fits;
80
+ - break;
81
+ - case VIRT_HIGH_PCIE_ECAM:
82
+ - vms->highmem_ecam &= fits;
83
+ - break;
84
+ - case VIRT_HIGH_PCIE_MMIO:
85
+ - vms->highmem_mmio &= fits;
86
+ - break;
87
+ - }
88
+ -
89
+ + *region_enabled &= fits;
90
+ base = region_base + region_size;
91
+ }
92
+ }
93
+ --
94
+ 2.31.1
95
+
SOURCES/kvm-hw-arm-virt-Introduce-virt_set_high_memmap-helper.patch ADDED
@@ -0,0 +1,130 @@
1
+ From 5dff87c5ea60054709021025c9513ec259433ce2 Mon Sep 17 00:00:00 2001
2
+ From: Gavin Shan <gshan@redhat.com>
3
+ Date: Wed, 21 Dec 2022 08:48:45 +0800
4
+ Subject: [PATCH 1/8] hw/arm/virt: Introduce virt_set_high_memmap() helper
5
+
6
+ RH-Author: Gavin Shan <gshan@redhat.com>
7
+ RH-MergeRequest: 126: hw/arm/virt: Optimize high memory region address assignment
8
+ RH-Bugzilla: 2113840
9
+ RH-Acked-by: Eric Auger <eric.auger@redhat.com>
10
+ RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
11
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
+ RH-Commit: [1/8] 5f6ba5af7a2c21d8473c58e088ee99b11336c673
13
+
14
+ Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2113840
15
+
16
+ This introduces virt_set_high_memmap() helper. The logic of high
17
+ memory region address assignment is moved to the helper. The intention
18
+ is to make the subsequent optimization for high memory region address
19
+ assignment easier.
20
+
21
+ No functional change intended.
22
+
23
+ Signed-off-by: Gavin Shan <gshan@redhat.com>
24
+ Reviewed-by: Eric Auger <eric.auger@redhat.com>
25
+ Reviewed-by: Cornelia Huck <cohuck@redhat.com>
26
+ Reviewed-by: Marc Zyngier <maz@kernel.org>
27
+ Tested-by: Zhenyu Zhang <zhenyzha@redhat.com>
28
+ Message-id: 20221029224307.138822-2-gshan@redhat.com
29
+ Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
30
+ (cherry picked from commit 4af6b6edece5ef273d29972d53547f823d2bc1c0)
31
+ Signed-off-by: Gavin Shan <gshan@redhat.com>
32
+ ---
33
+ hw/arm/virt.c | 74 ++++++++++++++++++++++++++++-----------------------
34
+ 1 file changed, 41 insertions(+), 33 deletions(-)
35
+
36
+ diff --git a/hw/arm/virt.c b/hw/arm/virt.c
37
+ index bf18838b87..bea5f54720 100644
38
+ --- a/hw/arm/virt.c
39
+ +++ b/hw/arm/virt.c
40
+ @@ -1736,6 +1736,46 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx)
41
+ return arm_cpu_mp_affinity(idx, clustersz);
42
+ }
43
+
44
+ +static void virt_set_high_memmap(VirtMachineState *vms,
45
+ + hwaddr base, int pa_bits)
46
+ +{
47
+ + int i;
48
+ +
49
+ + for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) {
50
+ + hwaddr size = extended_memmap[i].size;
51
+ + bool fits;
52
+ +
53
+ + base = ROUND_UP(base, size);
54
+ + vms->memmap[i].base = base;
55
+ + vms->memmap[i].size = size;
56
+ +
57
+ + /*
58
+ + * Check each device to see if they fit in the PA space,
59
+ + * moving highest_gpa as we go.
60
+ + *
61
+ + * For each device that doesn't fit, disable it.
62
+ + */
63
+ + fits = (base + size) <= BIT_ULL(pa_bits);
64
+ + if (fits) {
65
+ + vms->highest_gpa = base + size - 1;
66
+ + }
67
+ +
68
+ + switch (i) {
69
+ + case VIRT_HIGH_GIC_REDIST2:
70
+ + vms->highmem_redists &= fits;
71
+ + break;
72
+ + case VIRT_HIGH_PCIE_ECAM:
73
+ + vms->highmem_ecam &= fits;
74
+ + break;
75
+ + case VIRT_HIGH_PCIE_MMIO:
76
+ + vms->highmem_mmio &= fits;
77
+ + break;
78
+ + }
79
+ +
80
+ + base += size;
81
+ + }
82
+ +}
83
+ +
84
+ static void virt_set_memmap(VirtMachineState *vms, int pa_bits)
85
+ {
86
+ MachineState *ms = MACHINE(vms);
87
+ @@ -1791,39 +1831,7 @@ static void virt_set_memmap(VirtMachineState *vms, int pa_bits)
88
+ /* We know for sure that at least the memory fits in the PA space */
89
+ vms->highest_gpa = memtop - 1;
90
+
91
+ - for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) {
92
+ - hwaddr size = extended_memmap[i].size;
93
+ - bool fits;
94
+ -
95
+ - base = ROUND_UP(base, size);
96
+ - vms->memmap[i].base = base;
97
+ - vms->memmap[i].size = size;
98
+ -
99
+ - /*
100
+ - * Check each device to see if they fit in the PA space,
101
+ - * moving highest_gpa as we go.
102
+ - *
103
+ - * For each device that doesn't fit, disable it.
104
+ - */
105
+ - fits = (base + size) <= BIT_ULL(pa_bits);
106
+ - if (fits) {
107
+ - vms->highest_gpa = base + size - 1;
108
+ - }
109
+ -
110
+ - switch (i) {
111
+ - case VIRT_HIGH_GIC_REDIST2:
112
+ - vms->highmem_redists &= fits;
113
+ - break;
114
+ - case VIRT_HIGH_PCIE_ECAM:
115
+ - vms->highmem_ecam &= fits;
116
+ - break;
117
+ - case VIRT_HIGH_PCIE_MMIO:
118
+ - vms->highmem_mmio &= fits;
119
+ - break;
120
+ - }
121
+ -
122
+ - base += size;
123
+ - }
124
+ + virt_set_high_memmap(vms, base, pa_bits);
125
+
126
+ if (device_memory_size > 0) {
127
+ ms->device_memory = g_malloc0(sizeof(*ms->device_memory));
128
+ --
129
+ 2.31.1
130
+
SOURCES/kvm-hw-arm-virt-Remove-the-dtb-kaslr-seed-machine-option.patch DELETED
@@ -1,76 +0,0 @@
1
- From 69f771c3dc641431f3e98497cbd3832edb69284f Mon Sep 17 00:00:00 2001
2
- From: Eric Auger <eric.auger@redhat.com>
3
- Date: Tue, 3 May 2022 08:56:52 +0200
4
- Subject: [PATCH 1/5] hw/arm/virt: Remove the dtb-kaslr-seed machine option
5
-
6
- RH-Author: Eric Auger <eric.auger@redhat.com>
7
- RH-MergeRequest: 82: hw/arm/virt: Remove the dtb-kaslr-seed machine option
8
- RH-Commit: [1/2] a89dcd7f22e04ae39de99795d3f34cdd0b831bc0 (eauger1/centos-qemu-kvm)
9
- RH-Bugzilla: 2046029
10
- RH-Acked-by: Gavin Shan <gshan@redhat.com>
11
- RH-Acked-by: Andrew Jones <drjones@redhat.com>
12
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
13
-
14
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2046029
15
- Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=45133161
16
- Upstream Status: RHEL-only
17
- Tested: Boot RHEL guest and check the option is not available
18
-
19
- In RHEL we do not want to expose the dtb-kaslr-seed virt machine
20
- option. Indeed the default 'on' value matches our need as
21
- random data in the DTB does not cause any boot failure and we
22
- want to support KASLR for the guest.
23
-
24
- Signed-off-by: Eric Auger <eric.auger@redhat.com>
25
-
26
- ---
27
- ---
28
- hw/arm/virt.c | 11 +++--------
29
- 1 file changed, 3 insertions(+), 8 deletions(-)
30
-
31
- diff --git a/hw/arm/virt.c b/hw/arm/virt.c
32
- index e06862d22a..bde4f77994 100644
33
- --- a/hw/arm/virt.c
34
- +++ b/hw/arm/virt.c
35
- @@ -2350,6 +2350,7 @@ static void virt_set_its(Object *obj, bool value, Error **errp)
36
- vms->its = value;
37
- }
38
-
39
- +#if 0 /* Disabled for Red Hat Enterprise Linux */
40
- static bool virt_get_dtb_kaslr_seed(Object *obj, Error **errp)
41
- {
42
- VirtMachineState *vms = VIRT_MACHINE(obj);
43
- @@ -2363,6 +2364,7 @@ static void virt_set_dtb_kaslr_seed(Object *obj, bool value, Error **errp)
44
-
45
- vms->dtb_kaslr_seed = value;
46
- }
47
- +#endif /* disabled for RHEL */
48
-
49
- static char *virt_get_oem_id(Object *obj, Error **errp)
50
- {
51
- @@ -3346,13 +3348,6 @@ static void rhel_machine_class_init(ObjectClass *oc, void *data)
52
- "Override the default value of field OEM Table ID "
53
- "in ACPI table header."
54
- "The string may be up to 8 bytes in size");
55
- -
56
- - object_class_property_add_bool(oc, "dtb-kaslr-seed",
57
- - virt_get_dtb_kaslr_seed,
58
- - virt_set_dtb_kaslr_seed);
59
- - object_class_property_set_description(oc, "dtb-kaslr-seed",
60
- - "Set off to disable passing of kaslr-seed "
61
- - "dtb node to guest");
62
- }
63
-
64
- static void rhel_virt_instance_init(Object *obj)
65
- @@ -3397,7 +3392,7 @@ static void rhel_virt_instance_init(Object *obj)
66
- /* MTE is disabled by default and non-configurable for RHEL */
67
- vms->mte = false;
68
-
69
- - /* Supply a kaslr-seed by default */
70
- + /* Supply a kaslr-seed by default and non-configurable for RHEL */
71
- vms->dtb_kaslr_seed = true;
72
-
73
- vms->irqmap = a15irqmap;
74
- --
75
- 2.31.1
76
-
SOURCES/kvm-hw-arm-virt-Rename-variable-size-to-region_size-in-v.patch ADDED
@@ -0,0 +1,83 @@
1
+ From bd5b7edbf8f4425f4b4e0d49a00cbdd48d9c6f48 Mon Sep 17 00:00:00 2001
2
+ From: Gavin Shan <gshan@redhat.com>
3
+ Date: Wed, 21 Dec 2022 08:48:45 +0800
4
+ Subject: [PATCH 2/8] hw/arm/virt: Rename variable size to region_size in
5
+ virt_set_high_memmap()
6
+
7
+ RH-Author: Gavin Shan <gshan@redhat.com>
8
+ RH-MergeRequest: 126: hw/arm/virt: Optimize high memory region address assignment
9
+ RH-Bugzilla: 2113840
10
+ RH-Acked-by: Eric Auger <eric.auger@redhat.com>
11
+ RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
12
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
13
+ RH-Commit: [2/8] 1cadf1b00686cceb45821a58fdcb509bc5da335d
14
+
15
+ Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2113840
16
+
17
+ This renames variable 'size' to 'region_size' in virt_set_high_memmap().
18
+ Its counterpart ('region_base') will be introduced in next patch.
19
+
20
+ No functional change intended.
21
+
22
+ Signed-off-by: Gavin Shan <gshan@redhat.com>
23
+ Reviewed-by: Eric Auger <eric.auger@redhat.com>
24
+ Reviewed-by: Cornelia Huck <cohuck@redhat.com>
25
+ Reviewed-by: Marc Zyngier <maz@kernel.org>
26
+ Tested-by: Zhenyu Zhang <zhenyzha@redhat.com>
27
+ Message-id: 20221029224307.138822-3-gshan@redhat.com
28
+ Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
29
+ (cherry picked from commit 370bea9d1c78796eec235ed6cb4310f489931a62)
30
+ Signed-off-by: Gavin Shan <gshan@redhat.com>
31
+ ---
32
+ hw/arm/virt.c | 15 ++++++++-------
33
+ 1 file changed, 8 insertions(+), 7 deletions(-)
34
+
35
+ diff --git a/hw/arm/virt.c b/hw/arm/virt.c
36
+ index bea5f54720..ca098d40b8 100644
37
+ --- a/hw/arm/virt.c
38
+ +++ b/hw/arm/virt.c
39
+ @@ -1739,15 +1739,16 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx)
40
+ static void virt_set_high_memmap(VirtMachineState *vms,
41
+ hwaddr base, int pa_bits)
42
+ {
43
+ + hwaddr region_size;
44
+ + bool fits;
45
+ int i;
46
+
47
+ for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) {
48
+ - hwaddr size = extended_memmap[i].size;
49
+ - bool fits;
50
+ + region_size = extended_memmap[i].size;
51
+
52
+ - base = ROUND_UP(base, size);
53
+ + base = ROUND_UP(base, region_size);
54
+ vms->memmap[i].base = base;
55
+ - vms->memmap[i].size = size;
56
+ + vms->memmap[i].size = region_size;
57
+
58
+ /*
59
+ * Check each device to see if they fit in the PA space,
60
+ @@ -1755,9 +1756,9 @@ static void virt_set_high_memmap(VirtMachineState *vms,
61
+ *
62
+ * For each device that doesn't fit, disable it.
63
+ */
64
+ - fits = (base + size) <= BIT_ULL(pa_bits);
65
+ + fits = (base + region_size) <= BIT_ULL(pa_bits);
66
+ if (fits) {
67
+ - vms->highest_gpa = base + size - 1;
68
+ + vms->highest_gpa = base + region_size - 1;
69
+ }
70
+
71
+ switch (i) {
72
+ @@ -1772,7 +1773,7 @@ static void virt_set_high_memmap(VirtMachineState *vms,
73
+ break;
74
+ }
75
+
76
+ - base += size;
77
+ + base += region_size;
78
+ }
79
+ }
80
+
81
+ --
82
+ 2.31.1
83
+
SOURCES/kvm-hw-block-fdc-Prevent-end-of-track-overrun-CVE-2021-3.patch DELETED
@@ -1,96 +0,0 @@
1
- From 6ee4a8718dcce2d6da43ee200534b75baf1d7bbe Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@redhat.com>
3
- Date: Thu, 18 Nov 2021 12:57:32 +0100
4
- Subject: [PATCH 16/17] hw/block/fdc: Prevent end-of-track overrun
5
- (CVE-2021-3507)
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Jon Maloy <jmaloy@redhat.com>
11
- RH-MergeRequest: 107: hw/block/fdc: Prevent end-of-track overrun (CVE-2021-3507)
12
- RH-Commit: [1/2] 9ffc5290348884d20b894fa79f4d0c8089247f8b (mrezanin/centos-src-qemu-kvm)
13
- RH-Bugzilla: 1951522
14
- RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
15
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
16
-
17
- Per the 82078 datasheet, if the end-of-track (EOT byte in
18
- the FIFO) is more than the number of sectors per side, the
19
- command is terminated unsuccessfully:
20
-
21
- * 5.2.5 DATA TRANSFER TERMINATION
22
-
23
- The 82078 supports terminal count explicitly through
24
- the TC pin and implicitly through the underrun/over-
25
- run and end-of-track (EOT) functions. For full sector
26
- transfers, the EOT parameter can define the last
27
- sector to be transferred in a single or multisector
28
- transfer. If the last sector to be transferred is a par-
29
- tial sector, the host can stop transferring the data in
30
- mid-sector, and the 82078 will continue to complete
31
- the sector as if a hardware TC was received. The
32
- only difference between these implicit functions and
33
- TC is that they return "abnormal termination" result
34
- status. Such status indications can be ignored if they
35
- were expected.
36
-
37
- * 6.1.3 READ TRACK
38
-
39
- This command terminates when the EOT specified
40
- number of sectors have been read. If the 82078
41
- does not find an I D Address Mark on the diskette
42
- after the second· occurrence of a pulse on the
43
- INDX# pin, then it sets the IC code in Status Regis-
44
- ter 0 to "01" (Abnormal termination), sets the MA bit
45
- in Status Register 1 to "1", and terminates the com-
46
- mand.
47
-
48
- * 6.1.6 VERIFY
49
-
50
- Refer to Table 6-6 and Table 6-7 for information
51
- concerning the values of MT and EC versus SC and
52
- EOT value.
53
-
54
- * Table 6·6. Result Phase Table
55
-
56
- * Table 6-7. Verify Command Result Phase Table
57
-
58
- Fix by aborting the transfer when EOT > # Sectors Per Side.
59
-
60
- Cc: qemu-stable@nongnu.org
61
- Cc: Hervé Poussineau <hpoussin@reactos.org>
62
- Fixes: baca51faff0 ("floppy driver: disk geometry auto detect")
63
- Reported-by: Alexander Bulekov <alxndr@bu.edu>
64
- Resolves: https://gitlab.com/qemu-project/qemu/-/issues/339
65
- Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
66
- Message-Id: <20211118115733.4038610-2-philmd@redhat.com>
67
- Reviewed-by: Hanna Reitz <hreitz@redhat.com>
68
- Signed-off-by: Kevin Wolf <kwolf@redhat.com>
69
- (cherry picked from commit defac5e2fbddf8423a354ff0454283a2115e1367)
70
- Signed-off-by: Jon Maloy <jmaloy@redhat.com>
71
- ---
72
- hw/block/fdc.c | 8 ++++++++
73
- 1 file changed, 8 insertions(+)
74
-
75
- diff --git a/hw/block/fdc.c b/hw/block/fdc.c
76
- index ca1776121f..6481ec0cfb 100644
77
- --- a/hw/block/fdc.c
78
- +++ b/hw/block/fdc.c
79
- @@ -1532,6 +1532,14 @@ static void fdctrl_start_transfer(FDCtrl *fdctrl, int direction)
80
- int tmp;
81
- fdctrl->data_len = 128 << (fdctrl->fifo[5] > 7 ? 7 : fdctrl->fifo[5]);
82
- tmp = (fdctrl->fifo[6] - ks + 1);
83
- + if (tmp < 0) {
84
- + FLOPPY_DPRINTF("invalid EOT: %d\n", tmp);
85
- + fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM, FD_SR1_MA, 0x00);
86
- + fdctrl->fifo[3] = kt;
87
- + fdctrl->fifo[4] = kh;
88
- + fdctrl->fifo[5] = ks;
89
- + return;
90
- + }
91
- if (fdctrl->fifo[0] & 0x80)
92
- tmp += fdctrl->fifo[6];
93
- fdctrl->data_len *= tmp;
94
- --
95
- 2.31.1
96
-
SOURCES/kvm-hw-virtio-Replace-g_memdup-by-g_memdup2.patch DELETED
@@ -1,95 +0,0 @@
1
- From 4dad0e9abbc843fba4e5fee6e7aa1b0db13f5898 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:27:35 +0200
4
- Subject: [PATCH 03/32] hw/virtio: Replace g_memdup() by g_memdup2()
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [3/27] ae196903eb1a7aebbf999100e997cf82e5024cb6 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit d792199de55ca5cb5334016884039c740290b5c7
22
- Author: Philippe Mathieu-Daudé <f4bug@amsat.org>
23
- Date: Thu May 12 19:57:46 2022 +0200
24
-
25
- hw/virtio: Replace g_memdup() by g_memdup2()
26
-
27
- Per https://discourse.gnome.org/t/port-your-module-from-g-memdup-to-g-memdup2-now/5538
28
-
29
- The old API took the size of the memory to duplicate as a guint,
30
- whereas most memory functions take memory sizes as a gsize. This
31
- made it easy to accidentally pass a gsize to g_memdup(). For large
32
- values, that would lead to a silent truncation of the size from 64
33
- to 32 bits, and result in a heap area being returned which is
34
- significantly smaller than what the caller expects. This can likely
35
- be exploited in various modules to cause a heap buffer overflow.
36
-
37
- Replace g_memdup() by the safer g_memdup2() wrapper.
38
-
39
- Acked-by: Jason Wang <jasowang@redhat.com>
40
- Acked-by: Eugenio Pérez <eperezma@redhat.com>
41
- Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
42
- Message-Id: <20220512175747.142058-6-eperezma@redhat.com>
43
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
44
- Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
45
-
46
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
47
- ---
48
- hw/net/virtio-net.c | 3 ++-
49
- hw/virtio/virtio-crypto.c | 6 +++---
50
- 2 files changed, 5 insertions(+), 4 deletions(-)
51
-
52
- diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
53
- index 099e65036d..633de61513 100644
54
- --- a/hw/net/virtio-net.c
55
- +++ b/hw/net/virtio-net.c
56
- @@ -1458,7 +1458,8 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
57
- }
58
-
59
- iov_cnt = elem->out_num;
60
- - iov2 = iov = g_memdup(elem->out_sg, sizeof(struct iovec) * elem->out_num);
61
- + iov2 = iov = g_memdup2(elem->out_sg,
62
- + sizeof(struct iovec) * elem->out_num);
63
- s = iov_to_buf(iov, iov_cnt, 0, &ctrl, sizeof(ctrl));
64
- iov_discard_front(&iov, &iov_cnt, sizeof(ctrl));
65
- if (s != sizeof(ctrl)) {
66
- diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
67
- index dcd80b904d..0e31e3cc04 100644
68
- --- a/hw/virtio/virtio-crypto.c
69
- +++ b/hw/virtio/virtio-crypto.c
70
- @@ -242,7 +242,7 @@ static void virtio_crypto_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
71
- }
72
-
73
- out_num = elem->out_num;
74
- - out_iov_copy = g_memdup(elem->out_sg, sizeof(out_iov[0]) * out_num);
75
- + out_iov_copy = g_memdup2(elem->out_sg, sizeof(out_iov[0]) * out_num);
76
- out_iov = out_iov_copy;
77
-
78
- in_num = elem->in_num;
79
- @@ -605,11 +605,11 @@ virtio_crypto_handle_request(VirtIOCryptoReq *request)
80
- }
81
-
82
- out_num = elem->out_num;
83
- - out_iov_copy = g_memdup(elem->out_sg, sizeof(out_iov[0]) * out_num);
84
- + out_iov_copy = g_memdup2(elem->out_sg, sizeof(out_iov[0]) * out_num);
85
- out_iov = out_iov_copy;
86
-
87
- in_num = elem->in_num;
88
- - in_iov_copy = g_memdup(elem->in_sg, sizeof(in_iov[0]) * in_num);
89
- + in_iov_copy = g_memdup2(elem->in_sg, sizeof(in_iov[0]) * in_num);
90
- in_iov = in_iov_copy;
91
-
92
- if (unlikely(iov_to_buf(out_iov, out_num, 0, &req, sizeof(req))
93
- --
94
- 2.31.1
95
-
SOURCES/kvm-io-Add-support-for-MSG_PEEK-for-socket-channel.patch ADDED
@@ -0,0 +1,386 @@
1
+ From 3a29b50036b972caae5bca0e5dfc34d910b1d5e9 Mon Sep 17 00:00:00 2001
2
+ From: "manish.mishra" <manish.mishra@nutanix.com>
3
+ Date: Tue, 20 Dec 2022 18:44:17 +0000
4
+ Subject: [PATCH 6/8] io: Add support for MSG_PEEK for socket channel
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Peter Xu <peterx@redhat.com>
10
+ RH-MergeRequest: 150: migration: Fix multifd crash on channel disorders
11
+ RH-Bugzilla: 2169732
12
+ RH-Acked-by: quintela1 <quintela@redhat.com>
13
+ RH-Acked-by: Leonardo Brás <leobras@redhat.com>
14
+ RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
15
+ RH-Commit: [1/2] 266563f3e387e97ec710d9bc179e5de26dfd09f1 (peterx/qemu-kvm)
16
+
17
+ MSG_PEEK peeks at the channel, The data is treated as unread and
18
+ the next read shall still return this data. This support is
19
+ currently added only for socket class. Extra parameter 'flags'
20
+ is added to io_readv calls to pass extra read flags like MSG_PEEK.
21
+
22
+ Reviewed-by: Peter Xu <peterx@redhat.com>
23
+ Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
24
+ Reviewed-by: Juan Quintela <quintela@redhat.com>
25
+ Suggested-by: Daniel P. Berrange <berrange@redhat.com>
26
+ Signed-off-by: manish.mishra <manish.mishra@nutanix.com>
27
+ Signed-off-by: Juan Quintela <quintela@redhat.com>
28
+ (cherry picked from commit 84615a19ddf2bfb38d7b3a0d487d2397ee55e4f3)
29
+ Signed-off-by: Peter Xu <peterx@redhat.com>
30
+ ---
31
+ chardev/char-socket.c | 4 ++--
32
+ include/io/channel.h | 6 ++++++
33
+ io/channel-buffer.c | 1 +
34
+ io/channel-command.c | 1 +
35
+ io/channel-file.c | 1 +
36
+ io/channel-null.c | 1 +
37
+ io/channel-socket.c | 19 ++++++++++++++++++-
38
+ io/channel-tls.c | 1 +
39
+ io/channel-websock.c | 1 +
40
+ io/channel.c | 16 ++++++++++++----
41
+ migration/channel-block.c | 1 +
42
+ migration/rdma.c | 1 +
43
+ scsi/qemu-pr-helper.c | 2 +-
44
+ tests/qtest/tpm-emu.c | 2 +-
45
+ tests/unit/test-io-channel-socket.c | 1 +
46
+ util/vhost-user-server.c | 2 +-
47
+ 16 files changed, 50 insertions(+), 10 deletions(-)
48
+
49
+ diff --git a/chardev/char-socket.c b/chardev/char-socket.c
50
+ index 879564aa8a..5afce9a464 100644
51
+ --- a/chardev/char-socket.c
52
+ +++ b/chardev/char-socket.c
53
+ @@ -283,11 +283,11 @@ static ssize_t tcp_chr_recv(Chardev *chr, char *buf, size_t len)
54
+ if (qio_channel_has_feature(s->ioc, QIO_CHANNEL_FEATURE_FD_PASS)) {
55
+ ret = qio_channel_readv_full(s->ioc, &iov, 1,
56
+ &msgfds, &msgfds_num,
57
+ - NULL);
58
+ + 0, NULL);
59
+ } else {
60
+ ret = qio_channel_readv_full(s->ioc, &iov, 1,
61
+ NULL, NULL,
62
+ - NULL);
63
+ + 0, NULL);
64
+ }
65
+
66
+ if (msgfds_num) {
67
+ diff --git a/include/io/channel.h b/include/io/channel.h
68
+ index c680ee7480..716235d496 100644
69
+ --- a/include/io/channel.h
70
+ +++ b/include/io/channel.h
71
+ @@ -34,6 +34,8 @@ OBJECT_DECLARE_TYPE(QIOChannel, QIOChannelClass,
72
+
73
+ #define QIO_CHANNEL_WRITE_FLAG_ZERO_COPY 0x1
74
+
75
+ +#define QIO_CHANNEL_READ_FLAG_MSG_PEEK 0x1
76
+ +
77
+ typedef enum QIOChannelFeature QIOChannelFeature;
78
+
79
+ enum QIOChannelFeature {
80
+ @@ -41,6 +43,7 @@ enum QIOChannelFeature {
81
+ QIO_CHANNEL_FEATURE_SHUTDOWN,
82
+ QIO_CHANNEL_FEATURE_LISTEN,
83
+ QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY,
84
+ + QIO_CHANNEL_FEATURE_READ_MSG_PEEK,
85
+ };
86
+
87
+
88
+ @@ -114,6 +117,7 @@ struct QIOChannelClass {
89
+ size_t niov,
90
+ int **fds,
91
+ size_t *nfds,
92
+ + int flags,
93
+ Error **errp);
94
+ int (*io_close)(QIOChannel *ioc,
95
+ Error **errp);
96
+ @@ -188,6 +192,7 @@ void qio_channel_set_name(QIOChannel *ioc,
97
+ * @niov: the length of the @iov array
98
+ * @fds: pointer to an array that will received file handles
99
+ * @nfds: pointer filled with number of elements in @fds on return
100
+ + * @flags: read flags (QIO_CHANNEL_READ_FLAG_*)
101
+ * @errp: pointer to a NULL-initialized error object
102
+ *
103
+ * Read data from the IO channel, storing it in the
104
+ @@ -224,6 +229,7 @@ ssize_t qio_channel_readv_full(QIOChannel *ioc,
105
+ size_t niov,
106
+ int **fds,
107
+ size_t *nfds,
108
+ + int flags,
109
+ Error **errp);
110
+
111
+
112
+ diff --git a/io/channel-buffer.c b/io/channel-buffer.c
113
+ index bf52011be2..8096180f85 100644
114
+ --- a/io/channel-buffer.c
115
+ +++ b/io/channel-buffer.c
116
+ @@ -54,6 +54,7 @@ static ssize_t qio_channel_buffer_readv(QIOChannel *ioc,
117
+ size_t niov,
118
+ int **fds,
119
+ size_t *nfds,
120
+ + int flags,
121
+ Error **errp)
122
+ {
123
+ QIOChannelBuffer *bioc = QIO_CHANNEL_BUFFER(ioc);
124
+ diff --git a/io/channel-command.c b/io/channel-command.c
125
+ index 74516252ba..e7edd091af 100644
126
+ --- a/io/channel-command.c
127
+ +++ b/io/channel-command.c
128
+ @@ -203,6 +203,7 @@ static ssize_t qio_channel_command_readv(QIOChannel *ioc,
129
+ size_t niov,
130
+ int **fds,
131
+ size_t *nfds,
132
+ + int flags,
133
+ Error **errp)
134
+ {
135
+ QIOChannelCommand *cioc = QIO_CHANNEL_COMMAND(ioc);
136
+ diff --git a/io/channel-file.c b/io/channel-file.c
137
+ index b67687c2aa..d76663e6ae 100644
138
+ --- a/io/channel-file.c
139
+ +++ b/io/channel-file.c
140
+ @@ -86,6 +86,7 @@ static ssize_t qio_channel_file_readv(QIOChannel *ioc,
141
+ size_t niov,
142
+ int **fds,
143
+ size_t *nfds,
144
+ + int flags,
145
+ Error **errp)
146
+ {
147
+ QIOChannelFile *fioc = QIO_CHANNEL_FILE(ioc);
148
+ diff --git a/io/channel-null.c b/io/channel-null.c
149
+ index 75e3781507..4fafdb770d 100644
150
+ --- a/io/channel-null.c
151
+ +++ b/io/channel-null.c
152
+ @@ -60,6 +60,7 @@ qio_channel_null_readv(QIOChannel *ioc,
153
+ size_t niov,
154
+ int **fds G_GNUC_UNUSED,
155
+ size_t *nfds G_GNUC_UNUSED,
156
+ + int flags,
157
+ Error **errp)
158
+ {
159
+ QIOChannelNull *nioc = QIO_CHANNEL_NULL(ioc);
160
+ diff --git a/io/channel-socket.c b/io/channel-socket.c
161
+ index b76dca9cc1..7aca84f61a 100644
162
+ --- a/io/channel-socket.c
163
+ +++ b/io/channel-socket.c
164
+ @@ -173,6 +173,9 @@ int qio_channel_socket_connect_sync(QIOChannelSocket *ioc,
165
+ }
166
+ #endif
167
+
168
+ + qio_channel_set_feature(QIO_CHANNEL(ioc),
169
+ + QIO_CHANNEL_FEATURE_READ_MSG_PEEK);
170
+ +
171
+ return 0;
172
+ }
173
+
174
+ @@ -406,6 +409,9 @@ qio_channel_socket_accept(QIOChannelSocket *ioc,
175
+ }
176
+ #endif /* WIN32 */
177
+
178
+ + qio_channel_set_feature(QIO_CHANNEL(cioc),
179
+ + QIO_CHANNEL_FEATURE_READ_MSG_PEEK);
180
+ +
181
+ trace_qio_channel_socket_accept_complete(ioc, cioc, cioc->fd);
182
+ return cioc;
183
+
184
+ @@ -496,6 +502,7 @@ static ssize_t qio_channel_socket_readv(QIOChannel *ioc,
185
+ size_t niov,
186
+ int **fds,
187
+ size_t *nfds,
188
+ + int flags,
189
+ Error **errp)
190
+ {
191
+ QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc);
192
+ @@ -517,6 +524,10 @@ static ssize_t qio_channel_socket_readv(QIOChannel *ioc,
193
+
194
+ }
195
+
196
+ + if (flags & QIO_CHANNEL_READ_FLAG_MSG_PEEK) {
197
+ + sflags |= MSG_PEEK;
198
+ + }
199
+ +
200
+ retry:
201
+ ret = recvmsg(sioc->fd, &msg, sflags);
202
+ if (ret < 0) {
203
+ @@ -624,11 +635,17 @@ static ssize_t qio_channel_socket_readv(QIOChannel *ioc,
204
+ size_t niov,
205
+ int **fds,
206
+ size_t *nfds,
207
+ + int flags,
208
+ Error **errp)
209
+ {
210
+ QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc);
211
+ ssize_t done = 0;
212
+ ssize_t i;
213
+ + int sflags = 0;
214
+ +
215
+ + if (flags & QIO_CHANNEL_READ_FLAG_MSG_PEEK) {
216
+ + sflags |= MSG_PEEK;
217
+ + }
218
+
219
+ for (i = 0; i < niov; i++) {
220
+ ssize_t ret;
221
+ @@ -636,7 +653,7 @@ static ssize_t qio_channel_socket_readv(QIOChannel *ioc,
222
+ ret = recv(sioc->fd,
223
+ iov[i].iov_base,
224
+ iov[i].iov_len,
225
+ - 0);
226
+ + sflags);
227
+ if (ret < 0) {
228
+ if (errno == EAGAIN) {
229
+ if (done) {
230
+ diff --git a/io/channel-tls.c b/io/channel-tls.c
231
+ index 4ce890a538..c730cb8ec5 100644
232
+ --- a/io/channel-tls.c
233
+ +++ b/io/channel-tls.c
234
+ @@ -260,6 +260,7 @@ static ssize_t qio_channel_tls_readv(QIOChannel *ioc,
235
+ size_t niov,
236
+ int **fds,
237
+ size_t *nfds,
238
+ + int flags,
239
+ Error **errp)
240
+ {
241
+ QIOChannelTLS *tioc = QIO_CHANNEL_TLS(ioc);
242
+ diff --git a/io/channel-websock.c b/io/channel-websock.c
243
+ index fb4932ade7..a12acc27cf 100644
244
+ --- a/io/channel-websock.c
245
+ +++ b/io/channel-websock.c
246
+ @@ -1081,6 +1081,7 @@ static ssize_t qio_channel_websock_readv(QIOChannel *ioc,
247
+ size_t niov,
248
+ int **fds,
249
+ size_t *nfds,
250
+ + int flags,
251
+ Error **errp)
252
+ {
253
+ QIOChannelWebsock *wioc = QIO_CHANNEL_WEBSOCK(ioc);
254
+ diff --git a/io/channel.c b/io/channel.c
255
+ index 0640941ac5..a8c7f11649 100644
256
+ --- a/io/channel.c
257
+ +++ b/io/channel.c
258
+ @@ -52,6 +52,7 @@ ssize_t qio_channel_readv_full(QIOChannel *ioc,
259
+ size_t niov,
260
+ int **fds,
261
+ size_t *nfds,
262
+ + int flags,
263
+ Error **errp)
264
+ {
265
+ QIOChannelClass *klass = QIO_CHANNEL_GET_CLASS(ioc);
266
+ @@ -63,7 +64,14 @@ ssize_t qio_channel_readv_full(QIOChannel *ioc,
267
+ return -1;
268
+ }
269
+
270
+ - return klass->io_readv(ioc, iov, niov, fds, nfds, errp);
271
+ + if ((flags & QIO_CHANNEL_READ_FLAG_MSG_PEEK) &&
272
+ + !qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_READ_MSG_PEEK)) {
273
+ + error_setg_errno(errp, EINVAL,
274
+ + "Channel does not support peek read");
275
+ + return -1;
276
+ + }
277
+ +
278
+ + return klass->io_readv(ioc, iov, niov, fds, nfds, flags, errp);
279
+ }
280
+
281
+
282
+ @@ -146,7 +154,7 @@ int qio_channel_readv_full_all_eof(QIOChannel *ioc,
283
+ while ((nlocal_iov > 0) || local_fds) {
284
+ ssize_t len;
285
+ len = qio_channel_readv_full(ioc, local_iov, nlocal_iov, local_fds,
286
+ - local_nfds, errp);
287
+ + local_nfds, 0, errp);
288
+ if (len == QIO_CHANNEL_ERR_BLOCK) {
289
+ if (qemu_in_coroutine()) {
290
+ qio_channel_yield(ioc, G_IO_IN);
291
+ @@ -284,7 +292,7 @@ ssize_t qio_channel_readv(QIOChannel *ioc,
292
+ size_t niov,
293
+ Error **errp)
294
+ {
295
+ - return qio_channel_readv_full(ioc, iov, niov, NULL, NULL, errp);
296
+ + return qio_channel_readv_full(ioc, iov, niov, NULL, NULL, 0, errp);
297
+ }
298
+
299
+
300
+ @@ -303,7 +311,7 @@ ssize_t qio_channel_read(QIOChannel *ioc,
301
+ Error **errp)
302
+ {
303
+ struct iovec iov = { .iov_base = buf, .iov_len = buflen };
304
+ - return qio_channel_readv_full(ioc, &iov, 1, NULL, NULL, errp);
305
+ + return qio_channel_readv_full(ioc, &iov, 1, NULL, NULL, 0, errp);
306
+ }
307
+
308
+
309
+ diff --git a/migration/channel-block.c b/migration/channel-block.c
310
+ index f4ab53acdb..b7374363c3 100644
311
+ --- a/migration/channel-block.c
312
+ +++ b/migration/channel-block.c
313
+ @@ -53,6 +53,7 @@ qio_channel_block_readv(QIOChannel *ioc,
314
+ size_t niov,
315
+ int **fds,
316
+ size_t *nfds,
317
+ + int flags,
318
+ Error **errp)
319
+ {
320
+ QIOChannelBlock *bioc = QIO_CHANNEL_BLOCK(ioc);
321
+ diff --git a/migration/rdma.c b/migration/rdma.c
322
+ index 94a55dd95b..d8b4632094 100644
323
+ --- a/migration/rdma.c
324
+ +++ b/migration/rdma.c
325
+ @@ -2854,6 +2854,7 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *ioc,
326
+ size_t niov,
327
+ int **fds,
328
+ size_t *nfds,
329
+ + int flags,
330
+ Error **errp)
331
+ {
332
+ QIOChannelRDMA *rioc = QIO_CHANNEL_RDMA(ioc);
333
+ diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
334
+ index 196b78c00d..199227a556 100644
335
+ --- a/scsi/qemu-pr-helper.c
336
+ +++ b/scsi/qemu-pr-helper.c
337
+ @@ -614,7 +614,7 @@ static int coroutine_fn prh_read(PRHelperClient *client, void *buf, int sz,
338
+ iov.iov_base = buf;
339
+ iov.iov_len = sz;
340
+ n_read = qio_channel_readv_full(QIO_CHANNEL(client->ioc), &iov, 1,
341
+ - &fds, &nfds, errp);
342
+ + &fds, &nfds, 0, errp);
343
+
344
+ if (n_read == QIO_CHANNEL_ERR_BLOCK) {
345
+ qio_channel_yield(QIO_CHANNEL(client->ioc), G_IO_IN);
346
+ diff --git a/tests/qtest/tpm-emu.c b/tests/qtest/tpm-emu.c
347
+ index 2994d1cf42..3cf1acaf7d 100644
348
+ --- a/tests/qtest/tpm-emu.c
349
+ +++ b/tests/qtest/tpm-emu.c
350
+ @@ -106,7 +106,7 @@ void *tpm_emu_ctrl_thread(void *data)
351
+ int *pfd = NULL;
352
+ size_t nfd = 0;
353
+
354
+ - qio_channel_readv_full(ioc, &iov, 1, &pfd, &nfd, &error_abort);
355
+ + qio_channel_readv_full(ioc, &iov, 1, &pfd, &nfd, 0, &error_abort);
356
+ cmd = be32_to_cpu(cmd);
357
+ g_assert_cmpint(cmd, ==, CMD_SET_DATAFD);
358
+ g_assert_cmpint(nfd, ==, 1);
359
+ diff --git a/tests/unit/test-io-channel-socket.c b/tests/unit/test-io-channel-socket.c
360
+ index b36a5d972a..b964bb202d 100644
361
+ --- a/tests/unit/test-io-channel-socket.c
362
+ +++ b/tests/unit/test-io-channel-socket.c
363
+ @@ -460,6 +460,7 @@ static void test_io_channel_unix_fd_pass(void)
364
+ G_N_ELEMENTS(iorecv),
365
+ &fdrecv,
366
+ &nfdrecv,
367
+ + 0,
368
+ &error_abort);
369
+
370
+ g_assert(nfdrecv == G_N_ELEMENTS(fdsend));
371
+ diff --git a/util/vhost-user-server.c b/util/vhost-user-server.c
372
+ index 232984ace6..145eb17c08 100644
373
+ --- a/util/vhost-user-server.c
374
+ +++ b/util/vhost-user-server.c
375
+ @@ -116,7 +116,7 @@ vu_message_read(VuDev *vu_dev, int conn_fd, VhostUserMsg *vmsg)
376
+ * qio_channel_readv_full may have short reads, keeping calling it
377
+ * until getting VHOST_USER_HDR_SIZE or 0 bytes in total
378
+ */
379
+ - rc = qio_channel_readv_full(ioc, &iov, 1, &fds, &nfds, &local_err);
380
+ + rc = qio_channel_readv_full(ioc, &iov, 1, &fds, &nfds, 0, &local_err);
381
+ if (rc < 0) {
382
+ if (rc == QIO_CHANNEL_ERR_BLOCK) {
383
+ assert(local_err == NULL);
384
+ --
385
+ 2.31.1
386
+
SOURCES/kvm-iotests-106-214-308-Read-only-one-size-line.patch ADDED
@@ -0,0 +1,99 @@
1
+ From 6727e92a97f8ee9f367a41111bef3f5cad4a479a Mon Sep 17 00:00:00 2001
2
+ From: Hanna Reitz <hreitz@redhat.com>
3
+ Date: Mon, 20 Jun 2022 18:27:02 +0200
4
+ Subject: [PATCH 15/20] iotests/106, 214, 308: Read only one size line
5
+
6
+ RH-Author: Hanna Czenczek <hreitz@redhat.com>
7
+ RH-MergeRequest: 145: Show protocol-level information in qemu-img info
8
+ RH-Bugzilla: 1860292
9
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
10
+ RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
11
+ RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
12
+ RH-Commit: [10/12] 1554e0a92b92ed101a251478ccae43f45f6e071e (hreitz/qemu-kvm-c-9-s)
13
+
14
+ These tests read size information (sometimes disk size, sometimes
15
+ virtual size) from qemu-img info's output. Once qemu-img starts
16
+ printing info about child nodes, we are going to see multiple instances
17
+ of that per image, but these tests are only interested in the first one,
18
+ so use "head -n 1" to get it.
19
+
20
+ Signed-off-by: Hanna Reitz <hreitz@redhat.com>
21
+ Message-Id: <20220620162704.80987-11-hreitz@redhat.com>
22
+ Reviewed-by: Kevin Wolf <kwolf@redhat.com>
23
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
24
+ (cherry picked from commit 74163adda3101b127943f7cbbf8fcccd2d472426)
25
+ Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
26
+ ---
27
+ tests/qemu-iotests/106 | 4 ++--
28
+ tests/qemu-iotests/214 | 6 ++++--
29
+ tests/qemu-iotests/308 | 4 ++--
30
+ 3 files changed, 8 insertions(+), 6 deletions(-)
31
+
32
+ diff --git a/tests/qemu-iotests/106 b/tests/qemu-iotests/106
33
+ index 9d6adb542d..ae0fc46691 100755
34
+ --- a/tests/qemu-iotests/106
35
+ +++ b/tests/qemu-iotests/106
36
+ @@ -66,7 +66,7 @@ for create_mode in off falloc full; do
37
+ expected_size=$((expected_size + $GROWTH_SIZE))
38
+ fi
39
+
40
+ - actual_size=$($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep 'disk size')
41
+ + actual_size=$($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep 'disk size' | head -n 1)
42
+ actual_size=$(echo "$actual_size" | sed -e 's/^[^0-9]*\([0-9]\+\).*$/\1/')
43
+
44
+ # The actual size may exceed the expected size, depending on the file
45
+ @@ -105,7 +105,7 @@ for growth_mode in falloc full; do
46
+ _make_test_img -o "extent_size_hint=0" 2G
47
+ $QEMU_IMG resize -f "$IMGFMT" --preallocation=$growth_mode "$TEST_IMG" +${GROWTH_SIZE}K
48
+
49
+ - actual_size=$($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep 'disk size')
50
+ + actual_size=$($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep 'disk size' | head -n 1)
51
+ actual_size=$(echo "$actual_size" | sed -e 's/^[^0-9]*\([0-9]\+\).*$/\1/')
52
+
53
+ if [ $actual_size -lt $GROWTH_SIZE ]; then
54
+ diff --git a/tests/qemu-iotests/214 b/tests/qemu-iotests/214
55
+ index c66e246ba2..55ffcd7f44 100755
56
+ --- a/tests/qemu-iotests/214
57
+ +++ b/tests/qemu-iotests/214
58
+ @@ -102,7 +102,8 @@ let data_size="8 * $cluster_size"
59
+ $QEMU_IO -c "write -P 0xaa 0 $data_size" "$TEST_IMG" \
60
+ 2>&1 | _filter_qemu_io | _filter_testdir
61
+ sizeA=$($QEMU_IMG info --output=json "$TEST_IMG" |
62
+ - sed -n '/"actual-size":/ s/[^0-9]//gp')
63
+ + sed -n '/"actual-size":/ s/[^0-9]//gp' |
64
+ + head -n 1)
65
+
66
+ _make_test_img 2M -o cluster_size=$cluster_size
67
+ echo "Write compressed data:"
68
+ @@ -124,7 +125,8 @@ $QEMU_IO -c "write -P 0xcc $offset $data_size" "json:{\
69
+ _filter_qemu_io | _filter_testdir
70
+
71
+ sizeB=$($QEMU_IMG info --output=json "$TEST_IMG" |
72
+ - sed -n '/"actual-size":/ s/[^0-9]//gp')
73
+ + sed -n '/"actual-size":/ s/[^0-9]//gp' |
74
+ + head -n 1)
75
+
76
+ if [ $sizeA -lt $sizeB ]
77
+ then
78
+ diff --git a/tests/qemu-iotests/308 b/tests/qemu-iotests/308
79
+ index bde4aac2fa..09275e9a10 100755
80
+ --- a/tests/qemu-iotests/308
81
+ +++ b/tests/qemu-iotests/308
82
+ @@ -217,12 +217,12 @@ echo
83
+ echo '=== Remove export ==='
84
+
85
+ # Double-check that $EXT_MP appears as a non-empty file (the raw image)
86
+ -$QEMU_IMG info -f raw "$EXT_MP" | grep 'virtual size'
87
+ +$QEMU_IMG info -f raw "$EXT_MP" | grep 'virtual size' | head -n 1
88
+
89
+ fuse_export_del 'export-mp'
90
+
91
+ # See that the file appears empty again
92
+ -$QEMU_IMG info -f raw "$EXT_MP" | grep 'virtual size'
93
+ +$QEMU_IMG info -f raw "$EXT_MP" | grep 'virtual size' | head -n 1
94
+
95
+ echo
96
+ echo '=== Writable export ==='
97
+ --
98
+ 2.31.1
99
+
SOURCES/kvm-iotests-108-Fix-when-missing-user_allow_other.patch DELETED
@@ -1,52 +0,0 @@
1
- From 447bca651c9156d7aba6b7495c75f19b5e4ed53f Mon Sep 17 00:00:00 2001
2
- From: Hanna Reitz <hreitz@redhat.com>
3
- Date: Thu, 21 Apr 2022 16:24:35 +0200
4
- Subject: [PATCH 07/16] iotests/108: Fix when missing user_allow_other
5
-
6
- RH-Author: Hanna Reitz <hreitz@redhat.com>
7
- RH-MergeRequest: 96: qcow2: Improve refcount structure rebuilding
8
- RH-Commit: [4/4] a51ab8606fc9d8dea2b6539f4e795d5813892a5c (hreitz/qemu-kvm-c-9-s)
9
- RH-Bugzilla: 2072379
10
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
- RH-Acked-by: Eric Blake <eblake@redhat.com>
12
- RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
13
-
14
- FUSE exports' allow-other option defaults to "auto", which means that it
15
- will try passing allow_other as a mount option, and fall back to not
16
- using it when an error occurs. We make no effort to hide fusermount's
17
- error message (because it would be difficult, and because users might
18
- want to know about the fallback occurring), and so when allow_other does
19
- not work (primarily when /etc/fuse.conf does not contain
20
- user_allow_other), this error message will appear and break the
21
- reference output.
22
-
23
- We do not need allow_other here, though, so we can just pass
24
- allow-other=off to fix that.
25
-
26
- Reported-by: Markus Armbruster <armbru@redhat.com>
27
- Signed-off-by: Hanna Reitz <hreitz@redhat.com>
28
- Message-Id: <20220421142435.569600-1-hreitz@redhat.com>
29
- Tested-by: Markus Armbruster <armbru@redhat.com>
30
- Tested-by: Eric Blake <eblake@redhat.com>
31
- (cherry picked from commit 348a0740afc5b313599533eb69bbb2b95d2f1bba)
32
- Signed-off-by: Hanna Reitz <hreitz@redhat.com>
33
- ---
34
- tests/qemu-iotests/108 | 2 +-
35
- 1 file changed, 1 insertion(+), 1 deletion(-)
36
-
37
- diff --git a/tests/qemu-iotests/108 b/tests/qemu-iotests/108
38
- index a3090e2875..4681c7c769 100755
39
- --- a/tests/qemu-iotests/108
40
- +++ b/tests/qemu-iotests/108
41
- @@ -326,7 +326,7 @@ else
42
-
43
- $QSD \
44
- --blockdev file,node-name=export-node,filename="$TEST_IMG" \
45
- - --export fuse,id=fuse-export,node-name=export-node,mountpoint="$export_mp",writable=on,growable=off \
46
- + --export fuse,id=fuse-export,node-name=export-node,mountpoint="$export_mp",writable=on,growable=off,allow-other=off \
47
- --pidfile "$TEST_DIR/qsd.pid" \
48
- &
49
-
50
- --
51
- 2.31.1
52
-
SOURCES/kvm-iotests-108-Test-new-refcount-rebuild-algorithm.patch DELETED
@@ -1,445 +0,0 @@
1
- From ed69e01352b5e9a06173daab53bfa373c8535732 Mon Sep 17 00:00:00 2001
2
- From: Hanna Reitz <hreitz@redhat.com>
3
- Date: Tue, 5 Apr 2022 15:46:51 +0200
4
- Subject: [PATCH 05/16] iotests/108: Test new refcount rebuild algorithm
5
-
6
- RH-Author: Hanna Reitz <hreitz@redhat.com>
7
- RH-MergeRequest: 96: qcow2: Improve refcount structure rebuilding
8
- RH-Commit: [2/4] b68310a9fee8465dd3f568c8e867e1b7ae52bdaf (hreitz/qemu-kvm-c-9-s)
9
- RH-Bugzilla: 2072379
10
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
- RH-Acked-by: Eric Blake <eblake@redhat.com>
12
- RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
13
-
14
- One clear problem with how qcow2's refcount structure rebuild algorithm
15
- used to be before "qcow2: Improve refcount structure rebuilding" was
16
- that it is prone to failure for qcow2 images on block devices: There is
17
- generally unused space after the actual image, and if that exceeds what
18
- one refblock covers, the old algorithm would invariably write the
19
- reftable past the block device's end, which cannot work. The new
20
- algorithm does not have this problem.
21
-
22
- Test it with three tests:
23
- (1) Create an image with more empty space at the end than what one
24
- refblock covers, see whether rebuilding the refcount structures
25
- results in a change in the image file length. (It should not.)
26
-
27
- (2) Leave precisely enough space somewhere at the beginning of the image
28
- for the new reftable (and the refblock for that place), see whether
29
- the new algorithm puts the reftable there. (It should.)
30
-
31
- (3) Test the original problem: Create (something like) a block device
32
- with a fixed size, then create a qcow2 image in there, write some
33
- data, and then have qemu-img check rebuild the refcount structures.
34
- Before HEAD^, the reftable would have been written past the image
35
- file end, i.e. outside of what the block device provides, which
36
- cannot work. HEAD^ should have fixed that.
37
- ("Something like a block device" means a loop device if we can use
38
- one ("sudo -n losetup" works), or a FUSE block export with
39
- growable=false otherwise.)
40
-
41
- Reviewed-by: Eric Blake <eblake@redhat.com>
42
- Signed-off-by: Hanna Reitz <hreitz@redhat.com>
43
- Message-Id: <20220405134652.19278-3-hreitz@redhat.com>
44
- (cherry picked from commit 9ffd6d646d1d5ee9087a8cbf0b7d2f96c5656162)
45
-
46
- Conflicts:
47
- - 108: The downstream qemu-storage-daemon does not support --daemonize,
48
- so this switch has been replaced by a loop waiting for the PID file to
49
- appear
50
-
51
- Signed-off-by: Hanna Reitz <hreitz@redhat.com>
52
- ---
53
- tests/qemu-iotests/108 | 263 ++++++++++++++++++++++++++++++++++++-
54
- tests/qemu-iotests/108.out | 81 ++++++++++++
55
- 2 files changed, 343 insertions(+), 1 deletion(-)
56
-
57
- diff --git a/tests/qemu-iotests/108 b/tests/qemu-iotests/108
58
- index 56339ab2c5..a3090e2875 100755
59
- --- a/tests/qemu-iotests/108
60
- +++ b/tests/qemu-iotests/108
61
- @@ -30,13 +30,20 @@ status=1 # failure is the default!
62
-
63
- _cleanup()
64
- {
65
- - _cleanup_test_img
66
- + _cleanup_test_img
67
- + if [ -f "$TEST_DIR/qsd.pid" ]; then
68
- + qsd_pid=$(cat "$TEST_DIR/qsd.pid")
69
- + kill -KILL "$qsd_pid"
70
- + fusermount -u "$TEST_DIR/fuse-export" &>/dev/null
71
- + fi
72
- + rm -f "$TEST_DIR/fuse-export"
73
- }
74
- trap "_cleanup; exit \$status" 0 1 2 3 15
75
-
76
- # get standard environment, filters and checks
77
- . ./common.rc
78
- . ./common.filter
79
- +. ./common.qemu
80
-
81
- # This tests qcow2-specific low-level functionality
82
- _supported_fmt qcow2
83
- @@ -47,6 +54,22 @@ _supported_os Linux
84
- # files
85
- _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file
86
-
87
- +# This test either needs sudo -n losetup or FUSE exports to work
88
- +if sudo -n losetup &>/dev/null; then
89
- + loopdev=true
90
- +else
91
- + loopdev=false
92
- +
93
- + # QSD --export fuse will either yield "Parameter 'id' is missing"
94
- + # or "Invalid parameter 'fuse'", depending on whether there is
95
- + # FUSE support or not.
96
- + error=$($QSD --export fuse 2>&1)
97
- + if [[ $error = *"'fuse'"* ]]; then
98
- + _notrun 'Passwordless sudo for losetup or FUSE support required, but' \
99
- + 'neither is available'
100
- + fi
101
- +fi
102
- +
103
- echo
104
- echo '=== Repairing an image without any refcount table ==='
105
- echo
106
- @@ -138,6 +161,244 @@ _make_test_img 64M
107
- poke_file "$TEST_IMG" $((0x10008)) "\xff\xff\xff\xff\xff\xff\x00\x00"
108
- _check_test_img -r all
109
-
110
- +echo
111
- +echo '=== Check rebuilt reftable location ==='
112
- +
113
- +# In an earlier version of the refcount rebuild algorithm, the
114
- +# reftable was generally placed at the image end (unless something was
115
- +# allocated in the area covered by the refblock right before the image
116
- +# file end, then we would try to place the reftable in that refblock).
117
- +# This was later changed so the reftable would be placed in the
118
- +# earliest possible location. Test this.
119
- +
120
- +echo
121
- +echo '--- Does the image size increase? ---'
122
- +echo
123
- +
124
- +# First test: Just create some image, write some data to it, and
125
- +# resize it so there is free space at the end of the image (enough
126
- +# that it spans at least one full refblock, which for cluster_size=512
127
- +# images, spans 128k). With the old algorithm, the reftable would
128
- +# have then been placed at the end of the image file, but with the new
129
- +# one, it will be put in that free space.
130
- +# We want to check whether the size of the image file increases due to
131
- +# rebuilding the refcount structures (it should not).
132
- +
133
- +_make_test_img -o 'cluster_size=512' 1M
134
- +# Write something
135
- +$QEMU_IO -c 'write 0 64k' "$TEST_IMG" | _filter_qemu_io
136
- +
137
- +# Add free space
138
- +file_len=$(stat -c '%s' "$TEST_IMG")
139
- +truncate -s $((file_len + 256 * 1024)) "$TEST_IMG"
140
- +
141
- +# Corrupt the image by saying the image header was not allocated
142
- +rt_offset=$(peek_file_be "$TEST_IMG" 48 8)
143
- +rb_offset=$(peek_file_be "$TEST_IMG" $rt_offset 8)
144
- +poke_file "$TEST_IMG" $rb_offset "\x00\x00"
145
- +
146
- +# Check whether rebuilding the refcount structures increases the image
147
- +# file size
148
- +file_len=$(stat -c '%s' "$TEST_IMG")
149
- +echo
150
- +# The only leaks there can be are the old refcount structures that are
151
- +# leaked during rebuilding, no need to clutter the output with them
152
- +_check_test_img -r all | grep -v '^Repairing cluster.*refcount=1 reference=0'
153
- +echo
154
- +post_repair_file_len=$(stat -c '%s' "$TEST_IMG")
155
- +
156
- +if [[ $file_len -eq $post_repair_file_len ]]; then
157
- + echo 'OK: Image size did not change'
158
- +else
159
- + echo 'ERROR: Image size differs' \
160
- + "($file_len before, $post_repair_file_len after)"
161
- +fi
162
- +
163
- +echo
164
- +echo '--- Will the reftable occupy a hole specifically left for it? ---'
165
- +echo
166
- +
167
- +# Note: With cluster_size=512, every refblock covers 128k.
168
- +# The reftable covers 8M per reftable cluster.
169
- +
170
- +# Create an image that requires two reftable clusters (just because
171
- +# this is more interesting than a single-clustered reftable).
172
- +_make_test_img -o 'cluster_size=512' 9M
173
- +$QEMU_IO -c 'write 0 8M' "$TEST_IMG" | _filter_qemu_io
174
- +
175
- +# Writing 8M will have resized the reftable. Unfortunately, doing so
176
- +# will leave holes in the file, so we need to fill them up so we can
177
- +# be sure the whole file is allocated. Do that by writing
178
- +# consecutively smaller chunks starting from 8 MB, until the file
179
- +# length increases even with a chunk size of 512. Then we must have
180
- +# filled all holes.
181
- +ofs=$((8 * 1024 * 1024))
182
- +block_len=$((16 * 1024))
183
- +while [[ $block_len -ge 512 ]]; do
184
- + file_len=$(stat -c '%s' "$TEST_IMG")
185
- + while [[ $(stat -c '%s' "$TEST_IMG") -eq $file_len ]]; do
186
- + # Do not include this in the reference output, it does not
187
- + # really matter which qemu-io calls we do here exactly
188
- + $QEMU_IO -c "write $ofs $block_len" "$TEST_IMG" >/dev/null
189
- + ofs=$((ofs + block_len))
190
- + done
191
- + block_len=$((block_len / 2))
192
- +done
193
- +
194
- +# Fill up to 9M (do not include this in the reference output either,
195
- +# $ofs is random for all we know)
196
- +$QEMU_IO -c "write $ofs $((9 * 1024 * 1024 - ofs))" "$TEST_IMG" >/dev/null
197
- +
198
- +# Make space as follows:
199
- +# - For the first refblock: Right at the beginning of the image (this
200
- +# refblock is placed in the first place possible),
201
- +# - For the reftable somewhere soon afterwards, still near the
202
- +# beginning of the image (i.e. covered by the first refblock); the
203
- +# reftable too is placed in the first place possible, but only after
204
- +# all refblocks have been placed)
205
- +# No space is needed for the other refblocks, because no refblock is
206
- +# put before the space it covers. In this test case, we do not mind
207
- +# if they are placed at the image file's end.
208
- +
209
- +# Before we make that space, we have to find out the host offset of
210
- +# the area that belonged to the two data clusters at guest offset 4k,
211
- +# because we expect the reftable to be placed there, and we will have
212
- +# to verify that it is.
213
- +
214
- +l1_offset=$(peek_file_be "$TEST_IMG" 40 8)
215
- +l2_offset=$(peek_file_be "$TEST_IMG" $l1_offset 8)
216
- +l2_offset=$((l2_offset & 0x00fffffffffffe00))
217
- +data_4k_offset=$(peek_file_be "$TEST_IMG" \
218
- + $((l2_offset + 4096 / 512 * 8)) 8)
219
- +data_4k_offset=$((data_4k_offset & 0x00fffffffffffe00))
220
- +
221
- +$QEMU_IO -c "discard 0 512" -c "discard 4k 1k" "$TEST_IMG" | _filter_qemu_io
222
- +
223
- +# Corrupt the image by saying the image header was not allocated
224
- +rt_offset=$(peek_file_be "$TEST_IMG" 48 8)
225
- +rb_offset=$(peek_file_be "$TEST_IMG" $rt_offset 8)
226
- +poke_file "$TEST_IMG" $rb_offset "\x00\x00"
227
- +
228
- +echo
229
- +# The only leaks there can be are the old refcount structures that are
230
- +# leaked during rebuilding, no need to clutter the output with them
231
- +_check_test_img -r all | grep -v '^Repairing cluster.*refcount=1 reference=0'
232
- +echo
233
- +
234
- +# Check whether the reftable was put where we expected
235
- +rt_offset=$(peek_file_be "$TEST_IMG" 48 8)
236
- +if [[ $rt_offset -eq $data_4k_offset ]]; then
237
- + echo 'OK: Reftable is where we expect it'
238
- +else
239
- + echo "ERROR: Reftable is at $rt_offset, but was expected at $data_4k_offset"
240
- +fi
241
- +
242
- +echo
243
- +echo '--- Rebuilding refcount structures on block devices ---'
244
- +echo
245
- +
246
- +# A block device cannot really grow, at least not during qemu-img
247
- +# check. As mentioned in the above cases, rebuilding the refcount
248
- +# structure may lead to new refcount structures being written after
249
- +# the end of the image, and in the past that happened even if there
250
- +# was more than sufficient space in the image. Such post-EOF writes
251
- +# will not work on block devices, so test that the new algorithm
252
- +# avoids it.
253
- +
254
- +# If we have passwordless sudo and losetup, we can use those to create
255
- +# a block device. Otherwise, we can resort to qemu's FUSE export to
256
- +# create a file that isn't growable, which effectively tests the same
257
- +# thing.
258
- +
259
- +_cleanup_test_img
260
- +truncate -s $((64 * 1024 * 1024)) "$TEST_IMG"
261
- +
262
- +if $loopdev; then
263
- + export_mp=$(sudo -n losetup --show -f "$TEST_IMG")
264
- + export_mp_driver=host_device
265
- + sudo -n chmod go+rw "$export_mp"
266
- +else
267
- + # Create non-growable FUSE export that is a bit like an empty
268
- + # block device
269
- + export_mp="$TEST_DIR/fuse-export"
270
- + export_mp_driver=file
271
- + touch "$export_mp"
272
- +
273
- + $QSD \
274
- + --blockdev file,node-name=export-node,filename="$TEST_IMG" \
275
- + --export fuse,id=fuse-export,node-name=export-node,mountpoint="$export_mp",writable=on,growable=off \
276
- + --pidfile "$TEST_DIR/qsd.pid" \
277
- + &
278
- +
279
- + while [ ! -f "$TEST_DIR/qsd.pid" ]; do
280
- + sleep 0.1
281
- + done
282
- +fi
283
- +
284
- +# Now create a qcow2 image on the device -- unfortunately, qemu-img
285
- +# create force-creates the file, so we have to resort to the
286
- +# blockdev-create job.
287
- +_launch_qemu \
288
- + --blockdev $export_mp_driver,node-name=file,filename="$export_mp"
289
- +
290
- +_send_qemu_cmd \
291
- + $QEMU_HANDLE \
292
- + '{ "execute": "qmp_capabilities" }' \
293
- + 'return'
294
- +
295
- +# Small cluster size again, so the image needs multiple refblocks
296
- +_send_qemu_cmd \
297
- + $QEMU_HANDLE \
298
- + '{ "execute": "blockdev-create",
299
- + "arguments": {
300
- + "job-id": "create",
301
- + "options": {
302
- + "driver": "qcow2",
303
- + "file": "file",
304
- + "size": '$((64 * 1024 * 1024))',
305
- + "cluster-size": 512
306
- + } } }' \
307
- + '"concluded"'
308
- +
309
- +_send_qemu_cmd \
310
- + $QEMU_HANDLE \
311
- + '{ "execute": "job-dismiss", "arguments": { "id": "create" } }' \
312
- + 'return'
313
- +
314
- +_send_qemu_cmd \
315
- + $QEMU_HANDLE \
316
- + '{ "execute": "quit" }' \
317
- + 'return'
318
- +
319
- +wait=y _cleanup_qemu
320
- +echo
321
- +
322
- +# Write some data
323
- +$QEMU_IO -c 'write 0 64k' "$export_mp" | _filter_qemu_io
324
- +
325
- +# Corrupt the image by saying the image header was not allocated
326
- +rt_offset=$(peek_file_be "$export_mp" 48 8)
327
- +rb_offset=$(peek_file_be "$export_mp" $rt_offset 8)
328
- +poke_file "$export_mp" $rb_offset "\x00\x00"
329
- +
330
- +# Repairing such a simple case should just work
331
- +# (We used to put the reftable at the end of the image file, which can
332
- +# never work for non-growable devices.)
333
- +echo
334
- +TEST_IMG="$export_mp" _check_test_img -r all \
335
- + | grep -v '^Repairing cluster.*refcount=1 reference=0'
336
- +
337
- +if $loopdev; then
338
- + sudo -n losetup -d "$export_mp"
339
- +else
340
- + qsd_pid=$(cat "$TEST_DIR/qsd.pid")
341
- + kill -TERM "$qsd_pid"
342
- + # Wait for process to exit (cannot `wait` because the QSD is daemonized)
343
- + while [ -f "$TEST_DIR/qsd.pid" ]; do
344
- + true
345
- + done
346
- +fi
347
- +
348
- # success, all done
349
- echo '*** done'
350
- rm -f $seq.full
351
- diff --git a/tests/qemu-iotests/108.out b/tests/qemu-iotests/108.out
352
- index 75bab8dc84..b5401d788d 100644
353
- --- a/tests/qemu-iotests/108.out
354
- +++ b/tests/qemu-iotests/108.out
355
- @@ -105,6 +105,87 @@ The following inconsistencies were found and repaired:
356
- 0 leaked clusters
357
- 1 corruptions
358
-
359
- +Double checking the fixed image now...
360
- +No errors were found on the image.
361
- +
362
- +=== Check rebuilt reftable location ===
363
- +
364
- +--- Does the image size increase? ---
365
- +
366
- +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
367
- +wrote 65536/65536 bytes at offset 0
368
- +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
369
- +
370
- +ERROR cluster 0 refcount=0 reference=1
371
- +Rebuilding refcount structure
372
- +The following inconsistencies were found and repaired:
373
- +
374
- + 0 leaked clusters
375
- + 1 corruptions
376
- +
377
- +Double checking the fixed image now...
378
- +No errors were found on the image.
379
- +
380
- +OK: Image size did not change
381
- +
382
- +--- Will the reftable occupy a hole specifically left for it? ---
383
- +
384
- +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=9437184
385
- +wrote 8388608/8388608 bytes at offset 0
386
- +8 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
387
- +discard 512/512 bytes at offset 0
388
- +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
389
- +discard 1024/1024 bytes at offset 4096
390
- +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
391
- +
392
- +ERROR cluster 0 refcount=0 reference=1
393
- +Rebuilding refcount structure
394
- +The following inconsistencies were found and repaired:
395
- +
396
- + 0 leaked clusters
397
- + 1 corruptions
398
- +
399
- +Double checking the fixed image now...
400
- +No errors were found on the image.
401
- +
402
- +OK: Reftable is where we expect it
403
- +
404
- +--- Rebuilding refcount structures on block devices ---
405
- +
406
- +{ "execute": "qmp_capabilities" }
407
- +{"return": {}}
408
- +{ "execute": "blockdev-create",
409
- + "arguments": {
410
- + "job-id": "create",
411
- + "options": {
412
- + "driver": "IMGFMT",
413
- + "file": "file",
414
- + "size": 67108864,
415
- + "cluster-size": 512
416
- + } } }
417
- +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "create"}}
418
- +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "create"}}
419
- +{"return": {}}
420
- +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "create"}}
421
- +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "create"}}
422
- +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "create"}}
423
- +{ "execute": "job-dismiss", "arguments": { "id": "create" } }
424
- +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "create"}}
425
- +{"return": {}}
426
- +{ "execute": "quit" }
427
- +{"return": {}}
428
- +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
429
- +
430
- +wrote 65536/65536 bytes at offset 0
431
- +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
432
- +
433
- +ERROR cluster 0 refcount=0 reference=1
434
- +Rebuilding refcount structure
435
- +The following inconsistencies were found and repaired:
436
- +
437
- + 0 leaked clusters
438
- + 1 corruptions
439
- +
440
- Double checking the fixed image now...
441
- No errors were found on the image.
442
- *** done
443
- --
444
- 2.31.1
445
-
SOURCES/kvm-iotests-Filter-child-node-information.patch ADDED
@@ -0,0 +1,171 @@
1
+ From 3102e62f80757729c97e58e2b3d62a6a9de952a7 Mon Sep 17 00:00:00 2001
2
+ From: Hanna Reitz <hreitz@redhat.com>
3
+ Date: Mon, 20 Jun 2022 18:27:01 +0200
4
+ Subject: [PATCH 14/20] iotests: Filter child node information
5
+
6
+ RH-Author: Hanna Czenczek <hreitz@redhat.com>
7
+ RH-MergeRequest: 145: Show protocol-level information in qemu-img info
8
+ RH-Bugzilla: 1860292
9
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
10
+ RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
11
+ RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
12
+ RH-Commit: [9/12] 0b0a42d54397791f7f149e53c9175b7863707e70 (hreitz/qemu-kvm-c-9-s)
13
+
14
+ Before we let qemu-img info print child node information, have
15
+ common.filter, common.rc, and iotests.py filter it from the test output
16
+ so we get as few reference output changes as possible.
17
+
18
+ Signed-off-by: Hanna Reitz <hreitz@redhat.com>
19
+ Message-Id: <20220620162704.80987-10-hreitz@redhat.com>
20
+ Tested-by: Kevin Wolf <kwolf@redhat.com>
21
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
22
+ (cherry picked from commit bcc6777ad6facede73c0cf8b1700045bf4365f7d)
23
+ Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
24
+ ---
25
+ tests/qemu-iotests/common.filter | 22 ++++++++++++++--------
26
+ tests/qemu-iotests/common.rc | 22 ++++++++++++++--------
27
+ tests/qemu-iotests/iotests.py | 18 +++++++++++++++---
28
+ 3 files changed, 43 insertions(+), 19 deletions(-)
29
+
30
+ diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
31
+ index 6a13757177..6ddda2ee64 100644
32
+ --- a/tests/qemu-iotests/common.filter
33
+ +++ b/tests/qemu-iotests/common.filter
34
+ @@ -224,6 +224,7 @@ _filter_img_info()
35
+
36
+ discard=0
37
+ regex_json_spec_start='^ *"format-specific": \{'
38
+ + regex_json_child_start='^ *"children": \['
39
+ gsed -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
40
+ -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
41
+ -e "s#$TEST_DIR#TEST_DIR#g" \
42
+ @@ -252,20 +253,25 @@ _filter_img_info()
43
+ -e 's/\(compression type: \)\(zlib\|zstd\)/\1COMPRESSION_TYPE/' \
44
+ -e "s/uuid: [-a-f0-9]\\+/uuid: 00000000-0000-0000-0000-000000000000/" | \
45
+ while IFS='' read -r line; do
46
+ - if [[ $format_specific == 1 ]]; then
47
+ - discard=0
48
+ - elif [[ $line == "Format specific information:" ]]; then
49
+ - discard=1
50
+ - elif [[ $line =~ $regex_json_spec_start ]]; then
51
+ - discard=2
52
+ - regex_json_spec_end="^${line%%[^ ]*}\\},? *$"
53
+ + if [[ $discard == 0 ]]; then
54
+ + if [[ $format_specific == 0 && $line == "Format specific information:" ]]; then
55
+ + discard=1
56
+ + elif [[ $line =~ "Child node '/" ]]; then
57
+ + discard=1
58
+ + elif [[ $line =~ $regex_json_spec_start ]]; then
59
+ + discard=2
60
+ + regex_json_end="^${line%%[^ ]*}\\},? *$"
61
+ + elif [[ $line =~ $regex_json_child_start ]]; then
62
+ + discard=2
63
+ + regex_json_end="^${line%%[^ ]*}\\],? *$"
64
+ + fi
65
+ fi
66
+ if [[ $discard == 0 ]]; then
67
+ echo "$line"
68
+ elif [[ $discard == 1 && ! $line ]]; then
69
+ echo
70
+ discard=0
71
+ - elif [[ $discard == 2 && $line =~ $regex_json_spec_end ]]; then
72
+ + elif [[ $discard == 2 && $line =~ $regex_json_end ]]; then
73
+ discard=0
74
+ fi
75
+ done
76
+ diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
77
+ index db757025cb..f4476b62f7 100644
78
+ --- a/tests/qemu-iotests/common.rc
79
+ +++ b/tests/qemu-iotests/common.rc
80
+ @@ -711,6 +711,7 @@ _img_info()
81
+
82
+ discard=0
83
+ regex_json_spec_start='^ *"format-specific": \{'
84
+ + regex_json_child_start='^ *"children": \['
85
+ $QEMU_IMG info $QEMU_IMG_EXTRA_ARGS "$@" "$TEST_IMG" 2>&1 | \
86
+ sed -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
87
+ -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
88
+ @@ -721,20 +722,25 @@ _img_info()
89
+ -e "/^disk size:/ D" \
90
+ -e "/actual-size/ D" | \
91
+ while IFS='' read -r line; do
92
+ - if [[ $format_specific == 1 ]]; then
93
+ - discard=0
94
+ - elif [[ $line == "Format specific information:" ]]; then
95
+ - discard=1
96
+ - elif [[ $line =~ $regex_json_spec_start ]]; then
97
+ - discard=2
98
+ - regex_json_spec_end="^${line%%[^ ]*}\\},? *$"
99
+ + if [[ $discard == 0 ]]; then
100
+ + if [[ $format_specific == 0 && $line == "Format specific information:" ]]; then
101
+ + discard=1
102
+ + elif [[ $line =~ "Child node '/" ]]; then
103
+ + discard=1
104
+ + elif [[ $format_specific == 0 && $line =~ $regex_json_spec_start ]]; then
105
+ + discard=2
106
+ + regex_json_end="^${line%%[^ ]*}\\},? *$"
107
+ + elif [[ $line =~ $regex_json_child_start ]]; then
108
+ + discard=2
109
+ + regex_json_end="^${line%%[^ ]*}\\],? *$"
110
+ + fi
111
+ fi
112
+ if [[ $discard == 0 ]]; then
113
+ echo "$line"
114
+ elif [[ $discard == 1 && ! $line ]]; then
115
+ echo
116
+ discard=0
117
+ - elif [[ $discard == 2 && $line =~ $regex_json_spec_end ]]; then
118
+ + elif [[ $discard == 2 && $line =~ $regex_json_end ]]; then
119
+ discard=0
120
+ fi
121
+ done
122
+ diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
123
+ index da7d6637e1..94aeb3f3b2 100644
124
+ --- a/tests/qemu-iotests/iotests.py
125
+ +++ b/tests/qemu-iotests/iotests.py
126
+ @@ -329,7 +329,7 @@ def qemu_img_log(*args: str, check: bool = True
127
+
128
+ def img_info_log(filename: str, filter_path: Optional[str] = None,
129
+ use_image_opts: bool = False, extra_args: Sequence[str] = (),
130
+ - check: bool = True,
131
+ + check: bool = True, drop_child_info: bool = True,
132
+ ) -> None:
133
+ args = ['info']
134
+ if use_image_opts:
135
+ @@ -342,7 +342,7 @@ def img_info_log(filename: str, filter_path: Optional[str] = None,
136
+ output = qemu_img(*args, check=check).stdout
137
+ if not filter_path:
138
+ filter_path = filename
139
+ - log(filter_img_info(output, filter_path))
140
+ + log(filter_img_info(output, filter_path, drop_child_info))
141
+
142
+ def qemu_io_wrap_args(args: Sequence[str]) -> List[str]:
143
+ if '-f' in args or '--image-opts' in args:
144
+ @@ -642,11 +642,23 @@ def _filter(_key, value):
145
+ def filter_generated_node_ids(msg):
146
+ return re.sub("#block[0-9]+", "NODE_NAME", msg)
147
+
148
+ -def filter_img_info(output, filename):
149
+ +def filter_img_info(output: str, filename: str,
150
+ + drop_child_info: bool = True) -> str:
151
+ lines = []
152
+ + drop_indented = False
153
+ for line in output.split('\n'):
154
+ if 'disk size' in line or 'actual-size' in line:
155
+ continue
156
+ +
157
+ + # Drop child node info
158
+ + if drop_indented:
159
+ + if line.startswith(' '):
160
+ + continue
161
+ + drop_indented = False
162
+ + if drop_child_info and "Child node '/" in line:
163
+ + drop_indented = True
164
+ + continue
165
+ +
166
+ line = line.replace(filename, 'TEST_IMG')
167
+ line = filter_testfiles(line)
168
+ line = line.replace(imgfmt, 'IMGFMT')
169
+ --
170
+ 2.31.1
171
+
SOURCES/kvm-kvm-Atomic-memslot-updates.patch ADDED
@@ -0,0 +1,286 @@
1
+ From e13fdc97ff05cdee46c112c2dee70b6ef33e7fa7 Mon Sep 17 00:00:00 2001
2
+ From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
3
+ Date: Mon, 16 Jan 2023 07:17:31 -0500
4
+ Subject: [PATCH 31/31] kvm: Atomic memslot updates
5
+
6
+ RH-Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
7
+ RH-MergeRequest: 138: accel: introduce accelerator blocker API
8
+ RH-Bugzilla: 1979276
9
+ RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
10
+ RH-Acked-by: David Hildenbrand <david@redhat.com>
11
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
+ RH-Commit: [3/3] 9f03181ebcad2474fbe859acbce7b9891caa216b (eesposit/qemu-kvm)
13
+
14
+ Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1979276
15
+
16
+ commit f39b7d2b96e3e73c01bb678cd096f7baf0b9ab39
17
+ Author: David Hildenbrand <david@redhat.com>
18
+ Date: Fri Nov 11 10:47:58 2022 -0500
19
+
20
+ kvm: Atomic memslot updates
21
+
22
+ If we update an existing memslot (e.g., resize, split), we temporarily
23
+ remove the memslot to re-add it immediately afterwards. These updates
24
+ are not atomic, especially not for KVM VCPU threads, such that we can
25
+ get spurious faults.
26
+
27
+ Let's inhibit most KVM ioctls while performing relevant updates, such
28
+ that we can perform the update just as if it would happen atomically
29
+ without additional kernel support.
30
+
31
+ We capture the add/del changes and apply them in the notifier commit
32
+ stage instead. There, we can check for overlaps and perform the ioctl
33
+ inhibiting only if really required (-> overlap).
34
+
35
+ To keep things simple we don't perform additional checks that wouldn't
36
+ actually result in an overlap -- such as !RAM memory regions in some
37
+ cases (see kvm_set_phys_mem()).
38
+
39
+ To minimize cache-line bouncing, use a separate indicator
40
+ (in_ioctl_lock) per CPU. Also, make sure to hold the kvm_slots_lock
41
+ while performing both actions (removing+re-adding).
42
+
43
+ We have to wait until all IOCTLs were exited and block new ones from
44
+ getting executed.
45
+
46
+ This approach cannot result in a deadlock as long as the inhibitor does
47
+ not hold any locks that might hinder an IOCTL from getting finished and
48
+ exited - something fairly unusual. The inhibitor will always hold the BQL.
49
+
50
+ AFAIKs, one possible candidate would be userfaultfd. If a page cannot be
51
+ placed (e.g., during postcopy), because we're waiting for a lock, or if the
52
+ userfaultfd thread cannot process a fault, because it is waiting for a
53
+ lock, there could be a deadlock. However, the BQL is not applicable here,
54
+ because any other guest memory access while holding the BQL would already
55
+ result in a deadlock.
56
+
57
+ Nothing else in the kernel should block forever and wait for userspace
58
+ intervention.
59
+
60
+ Note: pause_all_vcpus()/resume_all_vcpus() or
61
+ start_exclusive()/end_exclusive() cannot be used, as they either drop
62
+ the BQL or require to be called without the BQL - something inhibitors
63
+ cannot handle. We need a low-level locking mechanism that is
64
+ deadlock-free even when not releasing the BQL.
65
+
66
+ Signed-off-by: David Hildenbrand <david@redhat.com>
67
+ Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
68
+ Tested-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
69
+ Message-Id: <20221111154758.1372674-4-eesposit@redhat.com>
70
+ Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
71
+
72
+ Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
73
+ ---
74
+ accel/kvm/kvm-all.c | 101 ++++++++++++++++++++++++++++++++++-----
75
+ include/sysemu/kvm_int.h | 8 ++++
76
+ 2 files changed, 98 insertions(+), 11 deletions(-)
77
+
78
+ diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
79
+ index ff660fd469..39ed30ab59 100644
80
+ --- a/accel/kvm/kvm-all.c
81
+ +++ b/accel/kvm/kvm-all.c
82
+ @@ -31,6 +31,7 @@
83
+ #include "sysemu/kvm_int.h"
84
+ #include "sysemu/runstate.h"
85
+ #include "sysemu/cpus.h"
86
+ +#include "sysemu/accel-blocker.h"
87
+ #include "qemu/bswap.h"
88
+ #include "exec/memory.h"
89
+ #include "exec/ram_addr.h"
90
+ @@ -46,6 +47,7 @@
91
+ #include "sysemu/hw_accel.h"
92
+ #include "kvm-cpus.h"
93
+ #include "sysemu/dirtylimit.h"
94
+ +#include "qemu/range.h"
95
+
96
+ #include "hw/boards.h"
97
+ #include "monitor/stats.h"
98
+ @@ -1292,6 +1294,7 @@ void kvm_set_max_memslot_size(hwaddr max_slot_size)
99
+ kvm_max_slot_size = max_slot_size;
100
+ }
101
+
102
+ +/* Called with KVMMemoryListener.slots_lock held */
103
+ static void kvm_set_phys_mem(KVMMemoryListener *kml,
104
+ MemoryRegionSection *section, bool add)
105
+ {
106
+ @@ -1326,14 +1329,12 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml,
107
+ ram = memory_region_get_ram_ptr(mr) + mr_offset;
108
+ ram_start_offset = memory_region_get_ram_addr(mr) + mr_offset;
109
+
110
+ - kvm_slots_lock();
111
+ -
112
+ if (!add) {
113
+ do {
114
+ slot_size = MIN(kvm_max_slot_size, size);
115
+ mem = kvm_lookup_matching_slot(kml, start_addr, slot_size);
116
+ if (!mem) {
117
+ - goto out;
118
+ + return;
119
+ }
120
+ if (mem->flags & KVM_MEM_LOG_DIRTY_PAGES) {
121
+ /*
122
+ @@ -1371,7 +1372,7 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml,
123
+ start_addr += slot_size;
124
+ size -= slot_size;
125
+ } while (size);
126
+ - goto out;
127
+ + return;
128
+ }
129
+
130
+ /* register the new slot */
131
+ @@ -1396,9 +1397,6 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml,
132
+ ram += slot_size;
133
+ size -= slot_size;
134
+ } while (size);
135
+ -
136
+ -out:
137
+ - kvm_slots_unlock();
138
+ }
139
+
140
+ static void *kvm_dirty_ring_reaper_thread(void *data)
141
+ @@ -1455,18 +1453,95 @@ static void kvm_region_add(MemoryListener *listener,
142
+ MemoryRegionSection *section)
143
+ {
144
+ KVMMemoryListener *kml = container_of(listener, KVMMemoryListener, listener);
145
+ + KVMMemoryUpdate *update;
146
+ +
147
+ + update = g_new0(KVMMemoryUpdate, 1);
148
+ + update->section = *section;
149
+
150
+ - memory_region_ref(section->mr);
151
+ - kvm_set_phys_mem(kml, section, true);
152
+ + QSIMPLEQ_INSERT_TAIL(&kml->transaction_add, update, next);
153
+ }
154
+
155
+ static void kvm_region_del(MemoryListener *listener,
156
+ MemoryRegionSection *section)
157
+ {
158
+ KVMMemoryListener *kml = container_of(listener, KVMMemoryListener, listener);
159
+ + KVMMemoryUpdate *update;
160
+ +
161
+ + update = g_new0(KVMMemoryUpdate, 1);
162
+ + update->section = *section;
163
+ +
164
+ + QSIMPLEQ_INSERT_TAIL(&kml->transaction_del, update, next);
165
+ +}
166
+ +
167
+ +static void kvm_region_commit(MemoryListener *listener)
168
+ +{
169
+ + KVMMemoryListener *kml = container_of(listener, KVMMemoryListener,
170
+ + listener);
171
+ + KVMMemoryUpdate *u1, *u2;
172
+ + bool need_inhibit = false;
173
+ +
174
+ + if (QSIMPLEQ_EMPTY(&kml->transaction_add) &&
175
+ + QSIMPLEQ_EMPTY(&kml->transaction_del)) {
176
+ + return;
177
+ + }
178
+ +
179
+ + /*
180
+ + * We have to be careful when regions to add overlap with ranges to remove.
181
+ + * We have to simulate atomic KVM memslot updates by making sure no ioctl()
182
+ + * is currently active.
183
+ + *
184
+ + * The lists are order by addresses, so it's easy to find overlaps.
185
+ + */
186
+ + u1 = QSIMPLEQ_FIRST(&kml->transaction_del);
187
+ + u2 = QSIMPLEQ_FIRST(&kml->transaction_add);
188
+ + while (u1 && u2) {
189
+ + Range r1, r2;
190
+ +
191
+ + range_init_nofail(&r1, u1->section.offset_within_address_space,
192
+ + int128_get64(u1->section.size));
193
+ + range_init_nofail(&r2, u2->section.offset_within_address_space,
194
+ + int128_get64(u2->section.size));
195
+ +
196
+ + if (range_overlaps_range(&r1, &r2)) {
197
+ + need_inhibit = true;
198
+ + break;
199
+ + }
200
+ + if (range_lob(&r1) < range_lob(&r2)) {
201
+ + u1 = QSIMPLEQ_NEXT(u1, next);
202
+ + } else {
203
+ + u2 = QSIMPLEQ_NEXT(u2, next);
204
+ + }
205
+ + }
206
+ +
207
+ + kvm_slots_lock();
208
+ + if (need_inhibit) {
209
+ + accel_ioctl_inhibit_begin();
210
+ + }
211
+ +
212
+ + /* Remove all memslots before adding the new ones. */
213
+ + while (!QSIMPLEQ_EMPTY(&kml->transaction_del)) {
214
+ + u1 = QSIMPLEQ_FIRST(&kml->transaction_del);
215
+ + QSIMPLEQ_REMOVE_HEAD(&kml->transaction_del, next);
216
+
217
+ - kvm_set_phys_mem(kml, section, false);
218
+ - memory_region_unref(section->mr);
219
+ + kvm_set_phys_mem(kml, &u1->section, false);
220
+ + memory_region_unref(u1->section.mr);
221
+ +
222
+ + g_free(u1);
223
+ + }
224
+ + while (!QSIMPLEQ_EMPTY(&kml->transaction_add)) {
225
+ + u1 = QSIMPLEQ_FIRST(&kml->transaction_add);
226
+ + QSIMPLEQ_REMOVE_HEAD(&kml->transaction_add, next);
227
+ +
228
+ + memory_region_ref(u1->section.mr);
229
+ + kvm_set_phys_mem(kml, &u1->section, true);
230
+ +
231
+ + g_free(u1);
232
+ + }
233
+ +
234
+ + if (need_inhibit) {
235
+ + accel_ioctl_inhibit_end();
236
+ + }
237
+ + kvm_slots_unlock();
238
+ }
239
+
240
+ static void kvm_log_sync(MemoryListener *listener,
241
+ @@ -1610,8 +1685,12 @@ void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml,
242
+ kml->slots[i].slot = i;
243
+ }
244
+
245
+ + QSIMPLEQ_INIT(&kml->transaction_add);
246
+ + QSIMPLEQ_INIT(&kml->transaction_del);
247
+ +
248
+ kml->listener.region_add = kvm_region_add;
249
+ kml->listener.region_del = kvm_region_del;
250
+ + kml->listener.commit = kvm_region_commit;
251
+ kml->listener.log_start = kvm_log_start;
252
+ kml->listener.log_stop = kvm_log_stop;
253
+ kml->listener.priority = 10;
254
+ diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h
255
+ index 3b4adcdc10..60b520a13e 100644
256
+ --- a/include/sysemu/kvm_int.h
257
+ +++ b/include/sysemu/kvm_int.h
258
+ @@ -12,6 +12,7 @@
259
+ #include "exec/memory.h"
260
+ #include "qapi/qapi-types-common.h"
261
+ #include "qemu/accel.h"
262
+ +#include "qemu/queue.h"
263
+ #include "sysemu/kvm.h"
264
+
265
+ typedef struct KVMSlot
266
+ @@ -31,10 +32,17 @@ typedef struct KVMSlot
267
+ ram_addr_t ram_start_offset;
268
+ } KVMSlot;
269
+
270
+ +typedef struct KVMMemoryUpdate {
271
+ + QSIMPLEQ_ENTRY(KVMMemoryUpdate) next;
272
+ + MemoryRegionSection section;
273
+ +} KVMMemoryUpdate;
274
+ +
275
+ typedef struct KVMMemoryListener {
276
+ MemoryListener listener;
277
+ KVMSlot *slots;
278
+ int as_id;
279
+ + QSIMPLEQ_HEAD(, KVMMemoryUpdate) transaction_add;
280
+ + QSIMPLEQ_HEAD(, KVMMemoryUpdate) transaction_del;
281
+ } KVMMemoryListener;
282
+
283
+ #define KVM_MSI_HASHTAB_SIZE 256
284
+ --
285
+ 2.31.1
286
+
SOURCES/kvm-kvm-don-t-use-perror-without-useful-errno.patch DELETED
@@ -1,62 +0,0 @@
1
- From 9ddefaedf423ec03eadaf17496c14e0d7b2381c8 Mon Sep 17 00:00:00 2001
2
- From: Cornelia Huck <cohuck@redhat.com>
3
- Date: Thu, 28 Jul 2022 16:24:46 +0200
4
- Subject: [PATCH 30/32] kvm: don't use perror() without useful errno
5
-
6
- RH-Author: Cornelia Huck <cohuck@redhat.com>
7
- RH-MergeRequest: 110: kvm: don't use perror() without useful errno
8
- RH-Commit: [1/1] 20e51aac6767c1f89f74c7d692d1fb7689eff5f0 (cohuck/qemu-kvm-c9s)
9
- RH-Bugzilla: 2095608
10
- RH-Acked-by: Eric Auger <eric.auger@redhat.com>
11
- RH-Acked-by: Thomas Huth <thuth@redhat.com>
12
- RH-Acked-by: Gavin Shan <gshan@redhat.com>
13
-
14
- perror() is designed to append the decoded errno value to a
15
- string. This, however, only makes sense if we called something that
16
- actually sets errno prior to that.
17
-
18
- For the callers that check for split irqchip support that is not the
19
- case, and we end up with confusing error messages that end in
20
- "success". Use error_report() instead.
21
-
22
- Signed-off-by: Cornelia Huck <cohuck@redhat.com>
23
- Message-Id: <20220728142446.438177-1-cohuck@redhat.com>
24
- Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
25
-
26
- https://bugzilla.redhat.com/show_bug.cgi?id=2095608
27
- (cherry picked from commit 47c182fe8b03c0c40059fb95840923e65c9bdb4f)
28
- Signed-off-by: Cornelia Huck <cohuck@redhat.com>
29
- ---
30
- accel/kvm/kvm-all.c | 2 +-
31
- target/arm/kvm.c | 2 +-
32
- 2 files changed, 2 insertions(+), 2 deletions(-)
33
-
34
- diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
35
- index 5f1377ca04..e9c7947640 100644
36
- --- a/accel/kvm/kvm-all.c
37
- +++ b/accel/kvm/kvm-all.c
38
- @@ -2254,7 +2254,7 @@ static void kvm_irqchip_create(KVMState *s)
39
- ret = kvm_arch_irqchip_create(s);
40
- if (ret == 0) {
41
- if (s->kernel_irqchip_split == ON_OFF_AUTO_ON) {
42
- - perror("Split IRQ chip mode not supported.");
43
- + error_report("Split IRQ chip mode not supported.");
44
- exit(1);
45
- } else {
46
- ret = kvm_vm_ioctl(s, KVM_CREATE_IRQCHIP);
47
- diff --git a/target/arm/kvm.c b/target/arm/kvm.c
48
- index bbf1ce7ba3..0a2ba1f8e3 100644
49
- --- a/target/arm/kvm.c
50
- +++ b/target/arm/kvm.c
51
- @@ -960,7 +960,7 @@ void kvm_arch_init_irq_routing(KVMState *s)
52
- int kvm_arch_irqchip_create(KVMState *s)
53
- {
54
- if (kvm_kernel_irqchip_split()) {
55
- - perror("-machine kernel_irqchip=split is not supported on ARM.");
56
- + error_report("-machine kernel_irqchip=split is not supported on ARM.");
57
- exit(1);
58
- }
59
-
60
- --
61
- 2.31.1
62
-
SOURCES/kvm-linux-aio-explain-why-max-batch-is-checked-in-laio_i.patch DELETED
@@ -1,49 +0,0 @@
1
- From 49d9c9dced7278517105e9cfec34ea4af716432d Mon Sep 17 00:00:00 2001
2
- From: Stefan Hajnoczi <stefanha@redhat.com>
3
- Date: Thu, 9 Jun 2022 17:47:12 +0100
4
- Subject: [PATCH 6/6] linux-aio: explain why max batch is checked in
5
- laio_io_unplug()
6
-
7
- RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
8
- RH-MergeRequest: 102: linux-aio: fix unbalanced plugged counter in laio_io_unplug()
9
- RH-Commit: [2/2] b3d6421086bde50d4baad2343b2df89c5f66950e (stefanha/centos-stream-qemu-kvm)
10
- RH-Bugzilla: 2092788
11
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
- RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
-
15
- It may not be obvious why laio_io_unplug() checks max batch. I discussed
16
- this with Stefano and have added a comment summarizing the reason.
17
-
18
- Cc: Stefano Garzarella <sgarzare@redhat.com>
19
- Cc: Kevin Wolf <kwolf@redhat.com>
20
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
21
- Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
22
- Message-id: 20220609164712.1539045-3-stefanha@redhat.com
23
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
24
- (cherry picked from commit 99b969fbe105117f5af6060d3afef40ca39cc9c1)
25
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
26
- ---
27
- block/linux-aio.c | 6 ++++++
28
- 1 file changed, 6 insertions(+)
29
-
30
- diff --git a/block/linux-aio.c b/block/linux-aio.c
31
- index 6078da7e42..9c2393a2f7 100644
32
- --- a/block/linux-aio.c
33
- +++ b/block/linux-aio.c
34
- @@ -365,6 +365,12 @@ void laio_io_unplug(BlockDriverState *bs, LinuxAioState *s,
35
- assert(s->io_q.plugged);
36
- s->io_q.plugged--;
37
-
38
- + /*
39
- + * Why max batch checking is performed here:
40
- + * Another BDS may have queued requests with a higher dev_max_batch and
41
- + * therefore in_queue could now exceed our dev_max_batch. Re-check the max
42
- + * batch so we can honor our device's dev_max_batch.
43
- + */
44
- if (s->io_q.in_queue >= laio_max_batch(s, dev_max_batch) ||
45
- (!s->io_q.plugged &&
46
- !s->io_q.blocked && !QSIMPLEQ_EMPTY(&s->io_q.pending))) {
47
- --
48
- 2.31.1
49
-
SOURCES/kvm-linux-aio-fix-unbalanced-plugged-counter-in-laio_io_.patch DELETED
@@ -1,56 +0,0 @@
1
- From e7326c3a7e0fc022aa5c0ae07bc1e19ad1b6f2ed Mon Sep 17 00:00:00 2001
2
- From: Stefan Hajnoczi <stefanha@redhat.com>
3
- Date: Thu, 9 Jun 2022 17:47:11 +0100
4
- Subject: [PATCH 5/6] linux-aio: fix unbalanced plugged counter in
5
- laio_io_unplug()
6
-
7
- RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
8
- RH-MergeRequest: 102: linux-aio: fix unbalanced plugged counter in laio_io_unplug()
9
- RH-Commit: [1/2] 8a71da371c72521f1d70b8767ee564575e0d522b (stefanha/centos-stream-qemu-kvm)
10
- RH-Bugzilla: 2092788
11
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
- RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
-
15
- Every laio_io_plug() call has a matching laio_io_unplug() call. There is
16
- a plugged counter that tracks the number of levels of plugging and
17
- allows for nesting.
18
-
19
- The plugged counter must reflect the balance between laio_io_plug() and
20
- laio_io_unplug() calls accurately. Otherwise I/O stalls occur since
21
- io_submit(2) calls are skipped while plugged.
22
-
23
- Reported-by: Nikolay Tenev <nt@storpool.com>
24
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
25
- Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
26
- Message-id: 20220609164712.1539045-2-stefanha@redhat.com
27
- Cc: Stefano Garzarella <sgarzare@redhat.com>
28
- Fixes: 68d7946648 ("linux-aio: add `dev_max_batch` parameter to laio_io_unplug()")
29
- [Stefano Garzarella suggested adding a Fixes tag.
30
- --Stefan]
31
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
32
- (cherry picked from commit f387cac5af030a58ac5a0dacf64cab5e5a4fe5c7)
33
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
34
- ---
35
- block/linux-aio.c | 4 +++-
36
- 1 file changed, 3 insertions(+), 1 deletion(-)
37
-
38
- diff --git a/block/linux-aio.c b/block/linux-aio.c
39
- index 4c423fcccf..6078da7e42 100644
40
- --- a/block/linux-aio.c
41
- +++ b/block/linux-aio.c
42
- @@ -363,8 +363,10 @@ void laio_io_unplug(BlockDriverState *bs, LinuxAioState *s,
43
- uint64_t dev_max_batch)
44
- {
45
- assert(s->io_q.plugged);
46
- + s->io_q.plugged--;
47
- +
48
- if (s->io_q.in_queue >= laio_max_batch(s, dev_max_batch) ||
49
- - (--s->io_q.plugged == 0 &&
50
- + (!s->io_q.plugged &&
51
- !s->io_q.blocked && !QSIMPLEQ_EMPTY(&s->io_q.pending))) {
52
- ioq_submit(s);
53
- }
54
- --
55
- 2.31.1
56
-
SOURCES/kvm-linux-headers-Update-to-v6.1.patch ADDED
@@ -0,0 +1,577 @@
1
+ From cbe35c6a4794107ea1ddecf0b381ba4b1c8799f5 Mon Sep 17 00:00:00 2001
2
+ From: Peter Xu <peterx@redhat.com>
3
+ Date: Tue, 7 Feb 2023 15:57:10 -0500
4
+ Subject: [PATCH 3/8] linux-headers: Update to v6.1
5
+
6
+ RH-Author: Peter Xu <peterx@redhat.com>
7
+ RH-MergeRequest: 149: Support /dev/userfaultfd
8
+ RH-Bugzilla: 2158704
9
+ RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
10
+ RH-Acked-by: quintela1 <quintela@redhat.com>
11
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
+ RH-Commit: [1/3] 15d97026e802a0f01b5f80f81fb4414dc69b2b2d (peterx/qemu-kvm)
13
+
14
+ Signed-off-by: Peter Xu <peterx@redhat.com>
15
+ Reviewed-by: Juan Quintela <quintela@redhat.com>
16
+ Acked-by: Cornelia Huck <cohuck@redhat.com>
17
+ Signed-off-by: Juan Quintela <quintela@redhat.com>
18
+ (cherry picked from commit 93e0932b7be2498024cd6ba8446a0fa2cb1769bc)
19
+ Signed-off-by: Peter Xu <peterx@redhat.com>
20
+ ---
21
+ include/standard-headers/drm/drm_fourcc.h | 34 ++++-
22
+ include/standard-headers/linux/ethtool.h | 63 +++++++-
23
+ include/standard-headers/linux/fuse.h | 6 +-
24
+ .../linux/input-event-codes.h | 1 +
25
+ include/standard-headers/linux/virtio_blk.h | 19 +++
26
+ linux-headers/asm-generic/hugetlb_encode.h | 26 ++--
27
+ linux-headers/asm-generic/mman-common.h | 2 +
28
+ linux-headers/asm-mips/mman.h | 2 +
29
+ linux-headers/asm-riscv/kvm.h | 4 +
30
+ linux-headers/linux/kvm.h | 1 +
31
+ linux-headers/linux/psci.h | 14 ++
32
+ linux-headers/linux/userfaultfd.h | 4 +
33
+ linux-headers/linux/vfio.h | 142 ++++++++++++++++++
34
+ 13 files changed, 298 insertions(+), 20 deletions(-)
35
+
36
+ diff --git a/include/standard-headers/drm/drm_fourcc.h b/include/standard-headers/drm/drm_fourcc.h
37
+ index 48b620cbef..b868488f93 100644
38
+ --- a/include/standard-headers/drm/drm_fourcc.h
39
+ +++ b/include/standard-headers/drm/drm_fourcc.h
40
+ @@ -98,18 +98,42 @@ extern "C" {
41
+ #define DRM_FORMAT_INVALID 0
42
+
43
+ /* color index */
44
+ +#define DRM_FORMAT_C1 fourcc_code('C', '1', ' ', ' ') /* [7:0] C0:C1:C2:C3:C4:C5:C6:C7 1:1:1:1:1:1:1:1 eight pixels/byte */
45
+ +#define DRM_FORMAT_C2 fourcc_code('C', '2', ' ', ' ') /* [7:0] C0:C1:C2:C3 2:2:2:2 four pixels/byte */
46
+ +#define DRM_FORMAT_C4 fourcc_code('C', '4', ' ', ' ') /* [7:0] C0:C1 4:4 two pixels/byte */
47
+ #define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */
48
+
49
+ -/* 8 bpp Red */
50
+ +/* 1 bpp Darkness (inverse relationship between channel value and brightness) */
51
+ +#define DRM_FORMAT_D1 fourcc_code('D', '1', ' ', ' ') /* [7:0] D0:D1:D2:D3:D4:D5:D6:D7 1:1:1:1:1:1:1:1 eight pixels/byte */
52
+ +
53
+ +/* 2 bpp Darkness (inverse relationship between channel value and brightness) */
54
+ +#define DRM_FORMAT_D2 fourcc_code('D', '2', ' ', ' ') /* [7:0] D0:D1:D2:D3 2:2:2:2 four pixels/byte */
55
+ +
56
+ +/* 4 bpp Darkness (inverse relationship between channel value and brightness) */
57
+ +#define DRM_FORMAT_D4 fourcc_code('D', '4', ' ', ' ') /* [7:0] D0:D1 4:4 two pixels/byte */
58
+ +
59
+ +/* 8 bpp Darkness (inverse relationship between channel value and brightness) */
60
+ +#define DRM_FORMAT_D8 fourcc_code('D', '8', ' ', ' ') /* [7:0] D */
61
+ +
62
+ +/* 1 bpp Red (direct relationship between channel value and brightness) */
63
+ +#define DRM_FORMAT_R1 fourcc_code('R', '1', ' ', ' ') /* [7:0] R0:R1:R2:R3:R4:R5:R6:R7 1:1:1:1:1:1:1:1 eight pixels/byte */
64
+ +
65
+ +/* 2 bpp Red (direct relationship between channel value and brightness) */
66
+ +#define DRM_FORMAT_R2 fourcc_code('R', '2', ' ', ' ') /* [7:0] R0:R1:R2:R3 2:2:2:2 four pixels/byte */
67
+ +
68
+ +/* 4 bpp Red (direct relationship between channel value and brightness) */
69
+ +#define DRM_FORMAT_R4 fourcc_code('R', '4', ' ', ' ') /* [7:0] R0:R1 4:4 two pixels/byte */
70
+ +
71
+ +/* 8 bpp Red (direct relationship between channel value and brightness) */
72
+ #define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */
73
+
74
+ -/* 10 bpp Red */
75
+ +/* 10 bpp Red (direct relationship between channel value and brightness) */
76
+ #define DRM_FORMAT_R10 fourcc_code('R', '1', '0', ' ') /* [15:0] x:R 6:10 little endian */
77
+
78
+ -/* 12 bpp Red */
79
+ +/* 12 bpp Red (direct relationship between channel value and brightness) */
80
+ #define DRM_FORMAT_R12 fourcc_code('R', '1', '2', ' ') /* [15:0] x:R 4:12 little endian */
81
+
82
+ -/* 16 bpp Red */
83
+ +/* 16 bpp Red (direct relationship between channel value and brightness) */
84
+ #define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ') /* [15:0] R little endian */
85
+
86
+ /* 16 bpp RG */
87
+ @@ -204,7 +228,9 @@ extern "C" {
88
+ #define DRM_FORMAT_VYUY fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */
89
+
90
+ #define DRM_FORMAT_AYUV fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */
91
+ +#define DRM_FORMAT_AVUY8888 fourcc_code('A', 'V', 'U', 'Y') /* [31:0] A:Cr:Cb:Y 8:8:8:8 little endian */
92
+ #define DRM_FORMAT_XYUV8888 fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */
93
+ +#define DRM_FORMAT_XVUY8888 fourcc_code('X', 'V', 'U', 'Y') /* [31:0] X:Cr:Cb:Y 8:8:8:8 little endian */
94
+ #define DRM_FORMAT_VUY888 fourcc_code('V', 'U', '2', '4') /* [23:0] Cr:Cb:Y 8:8:8 little endian */
95
+ #define DRM_FORMAT_VUY101010 fourcc_code('V', 'U', '3', '0') /* Y followed by U then V, 10:10:10. Non-linear modifier only */
96
+
97
+ diff --git a/include/standard-headers/linux/ethtool.h b/include/standard-headers/linux/ethtool.h
98
+ index 4537da20cc..1dc56cdc0a 100644
99
+ --- a/include/standard-headers/linux/ethtool.h
100
+ +++ b/include/standard-headers/linux/ethtool.h
101
+ @@ -736,6 +736,51 @@ enum ethtool_module_power_mode {
102
+ ETHTOOL_MODULE_POWER_MODE_HIGH,
103
+ };
104
+
105
+ +/**
106
+ + * enum ethtool_podl_pse_admin_state - operational state of the PoDL PSE
107
+ + * functions. IEEE 802.3-2018 30.15.1.1.2 aPoDLPSEAdminState
108
+ + * @ETHTOOL_PODL_PSE_ADMIN_STATE_UNKNOWN: state of PoDL PSE functions are
109
+ + * unknown
110
+ + * @ETHTOOL_PODL_PSE_ADMIN_STATE_DISABLED: PoDL PSE functions are disabled
111
+ + * @ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED: PoDL PSE functions are enabled
112
+ + */
113
+ +enum ethtool_podl_pse_admin_state {
114
+ + ETHTOOL_PODL_PSE_ADMIN_STATE_UNKNOWN = 1,
115
+ + ETHTOOL_PODL_PSE_ADMIN_STATE_DISABLED,
116
+ + ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED,
117
+ +};
118
+ +
119
+ +/**
120
+ + * enum ethtool_podl_pse_pw_d_status - power detection status of the PoDL PSE.
121
+ + * IEEE 802.3-2018 30.15.1.1.3 aPoDLPSEPowerDetectionStatus:
122
+ + * @ETHTOOL_PODL_PSE_PW_D_STATUS_UNKNOWN: PoDL PSE
123
+ + * @ETHTOOL_PODL_PSE_PW_D_STATUS_DISABLED: "The enumeration “disabled” is
124
+ + * asserted true when the PoDL PSE state diagram variable mr_pse_enable is
125
+ + * false"
126
+ + * @ETHTOOL_PODL_PSE_PW_D_STATUS_SEARCHING: "The enumeration “searching” is
127
+ + * asserted true when either of the PSE state diagram variables
128
+ + * pi_detecting or pi_classifying is true."
129
+ + * @ETHTOOL_PODL_PSE_PW_D_STATUS_DELIVERING: "The enumeration “deliveringPower”
130
+ + * is asserted true when the PoDL PSE state diagram variable pi_powered is
131
+ + * true."
132
+ + * @ETHTOOL_PODL_PSE_PW_D_STATUS_SLEEP: "The enumeration “sleep” is asserted
133
+ + * true when the PoDL PSE state diagram variable pi_sleeping is true."
134
+ + * @ETHTOOL_PODL_PSE_PW_D_STATUS_IDLE: "The enumeration “idle” is asserted true
135
+ + * when the logical combination of the PoDL PSE state diagram variables
136
+ + * pi_prebiased*!pi_sleeping is true."
137
+ + * @ETHTOOL_PODL_PSE_PW_D_STATUS_ERROR: "The enumeration “error” is asserted
138
+ + * true when the PoDL PSE state diagram variable overload_held is true."
139
+ + */
140
+ +enum ethtool_podl_pse_pw_d_status {
141
+ + ETHTOOL_PODL_PSE_PW_D_STATUS_UNKNOWN = 1,
142
+ + ETHTOOL_PODL_PSE_PW_D_STATUS_DISABLED,
143
+ + ETHTOOL_PODL_PSE_PW_D_STATUS_SEARCHING,
144
+ + ETHTOOL_PODL_PSE_PW_D_STATUS_DELIVERING,
145
+ + ETHTOOL_PODL_PSE_PW_D_STATUS_SLEEP,
146
+ + ETHTOOL_PODL_PSE_PW_D_STATUS_IDLE,
147
+ + ETHTOOL_PODL_PSE_PW_D_STATUS_ERROR,
148
+ +};
149
+ +
150
+ /**
151
+ * struct ethtool_gstrings - string set for data tagging
152
+ * @cmd: Command number = %ETHTOOL_GSTRINGS
153
+ @@ -1840,6 +1885,20 @@ static inline int ethtool_validate_duplex(uint8_t duplex)
154
+ #define MASTER_SLAVE_STATE_SLAVE 3
155
+ #define MASTER_SLAVE_STATE_ERR 4
156
+
157
+ +/* These are used to throttle the rate of data on the phy interface when the
158
+ + * native speed of the interface is higher than the link speed. These should
159
+ + * not be used for phy interfaces which natively support multiple speeds (e.g.
160
+ + * MII or SGMII).
161
+ + */
162
+ +/* No rate matching performed. */
163
+ +#define RATE_MATCH_NONE 0
164
+ +/* The phy sends pause frames to throttle the MAC. */
165
+ +#define RATE_MATCH_PAUSE 1
166
+ +/* The phy asserts CRS to prevent the MAC from transmitting. */
167
+ +#define RATE_MATCH_CRS 2
168
+ +/* The MAC is programmed with a sufficiently-large IPG. */
169
+ +#define RATE_MATCH_OPEN_LOOP 3
170
+ +
171
+ /* Which connector port. */
172
+ #define PORT_TP 0x00
173
+ #define PORT_AUI 0x01
174
+ @@ -2033,8 +2092,8 @@ enum ethtool_reset_flags {
175
+ * reported consistently by PHYLIB. Read-only.
176
+ * @master_slave_cfg: Master/slave port mode.
177
+ * @master_slave_state: Master/slave port state.
178
+ + * @rate_matching: Rate adaptation performed by the PHY
179
+ * @reserved: Reserved for future use; see the note on reserved space.
180
+ - * @reserved1: Reserved for future use; see the note on reserved space.
181
+ * @link_mode_masks: Variable length bitmaps.
182
+ *
183
+ * If autonegotiation is disabled, the speed and @duplex represent the
184
+ @@ -2085,7 +2144,7 @@ struct ethtool_link_settings {
185
+ uint8_t transceiver;
186
+ uint8_t master_slave_cfg;
187
+ uint8_t master_slave_state;
188
+ - uint8_t reserved1[1];
189
+ + uint8_t rate_matching;
190
+ uint32_t reserved[7];
191
+ uint32_t link_mode_masks[];
192
+ /* layout of link_mode_masks fields:
193
+ diff --git a/include/standard-headers/linux/fuse.h b/include/standard-headers/linux/fuse.h
194
+ index bda06258be..713d259768 100644
195
+ --- a/include/standard-headers/linux/fuse.h
196
+ +++ b/include/standard-headers/linux/fuse.h
197
+ @@ -194,6 +194,9 @@
198
+ * - add FUSE_SECURITY_CTX init flag
199
+ * - add security context to create, mkdir, symlink, and mknod requests
200
+ * - add FUSE_HAS_INODE_DAX, FUSE_ATTR_DAX
201
+ + *
202
+ + * 7.37
203
+ + * - add FUSE_TMPFILE
204
+ */
205
+
206
+ #ifndef _LINUX_FUSE_H
207
+ @@ -225,7 +228,7 @@
208
+ #define FUSE_KERNEL_VERSION 7
209
+
210
+ /** Minor version number of this interface */
211
+ -#define FUSE_KERNEL_MINOR_VERSION 36
212
+ +#define FUSE_KERNEL_MINOR_VERSION 37
213
+
214
+ /** The node ID of the root inode */
215
+ #define FUSE_ROOT_ID 1
216
+ @@ -533,6 +536,7 @@ enum fuse_opcode {
217
+ FUSE_SETUPMAPPING = 48,
218
+ FUSE_REMOVEMAPPING = 49,
219
+ FUSE_SYNCFS = 50,
220
+ + FUSE_TMPFILE = 51,
221
+
222
+ /* CUSE specific operations */
223
+ CUSE_INIT = 4096,
224
+ diff --git a/include/standard-headers/linux/input-event-codes.h b/include/standard-headers/linux/input-event-codes.h
225
+ index 50790aee5a..815f7a1dff 100644
226
+ --- a/include/standard-headers/linux/input-event-codes.h
227
+ +++ b/include/standard-headers/linux/input-event-codes.h
228
+ @@ -862,6 +862,7 @@
229
+ #define ABS_TOOL_WIDTH 0x1c
230
+
231
+ #define ABS_VOLUME 0x20
232
+ +#define ABS_PROFILE 0x21
233
+
234
+ #define ABS_MISC 0x28
235
+
236
+ diff --git a/include/standard-headers/linux/virtio_blk.h b/include/standard-headers/linux/virtio_blk.h
237
+ index 2dcc90826a..e81715cd70 100644
238
+ --- a/include/standard-headers/linux/virtio_blk.h
239
+ +++ b/include/standard-headers/linux/virtio_blk.h
240
+ @@ -40,6 +40,7 @@
241
+ #define VIRTIO_BLK_F_MQ 12 /* support more than one vq */
242
+ #define VIRTIO_BLK_F_DISCARD 13 /* DISCARD is supported */
243
+ #define VIRTIO_BLK_F_WRITE_ZEROES 14 /* WRITE ZEROES is supported */
244
+ +#define VIRTIO_BLK_F_SECURE_ERASE 16 /* Secure Erase is supported */
245
+
246
+ /* Legacy feature bits */
247
+ #ifndef VIRTIO_BLK_NO_LEGACY
248
+ @@ -119,6 +120,21 @@ struct virtio_blk_config {
249
+ uint8_t write_zeroes_may_unmap;
250
+
251
+ uint8_t unused1[3];
252
+ +
253
+ + /* the next 3 entries are guarded by VIRTIO_BLK_F_SECURE_ERASE */
254
+ + /*
255
+ + * The maximum secure erase sectors (in 512-byte sectors) for
256
+ + * one segment.
257
+ + */
258
+ + __virtio32 max_secure_erase_sectors;
259
+ + /*
260
+ + * The maximum number of secure erase segments in a
261
+ + * secure erase command.
262
+ + */
263
+ + __virtio32 max_secure_erase_seg;
264
+ + /* Secure erase commands must be aligned to this number of sectors. */
265
+ + __virtio32 secure_erase_sector_alignment;
266
+ +
267
+ } QEMU_PACKED;
268
+
269
+ /*
270
+ @@ -153,6 +169,9 @@ struct virtio_blk_config {
271
+ /* Write zeroes command */
272
+ #define VIRTIO_BLK_T_WRITE_ZEROES 13
273
+
274
+ +/* Secure erase command */
275
+ +#define VIRTIO_BLK_T_SECURE_ERASE 14
276
+ +
277
+ #ifndef VIRTIO_BLK_NO_LEGACY
278
+ /* Barrier before this op. */
279
+ #define VIRTIO_BLK_T_BARRIER 0x80000000
280
+ diff --git a/linux-headers/asm-generic/hugetlb_encode.h b/linux-headers/asm-generic/hugetlb_encode.h
281
+ index 4f3d5aaa11..de687009bf 100644
282
+ --- a/linux-headers/asm-generic/hugetlb_encode.h
283
+ +++ b/linux-headers/asm-generic/hugetlb_encode.h
284
+ @@ -20,18 +20,18 @@
285
+ #define HUGETLB_FLAG_ENCODE_SHIFT 26
286
+ #define HUGETLB_FLAG_ENCODE_MASK 0x3f
287
+
288
+ -#define HUGETLB_FLAG_ENCODE_16KB (14 << HUGETLB_FLAG_ENCODE_SHIFT)
289
+ -#define HUGETLB_FLAG_ENCODE_64KB (16 << HUGETLB_FLAG_ENCODE_SHIFT)
290
+ -#define HUGETLB_FLAG_ENCODE_512KB (19 << HUGETLB_FLAG_ENCODE_SHIFT)
291
+ -#define HUGETLB_FLAG_ENCODE_1MB (20 << HUGETLB_FLAG_ENCODE_SHIFT)
292
+ -#define HUGETLB_FLAG_ENCODE_2MB (21 << HUGETLB_FLAG_ENCODE_SHIFT)
293
+ -#define HUGETLB_FLAG_ENCODE_8MB (23 << HUGETLB_FLAG_ENCODE_SHIFT)
294
+ -#define HUGETLB_FLAG_ENCODE_16MB (24 << HUGETLB_FLAG_ENCODE_SHIFT)
295
+ -#define HUGETLB_FLAG_ENCODE_32MB (25 << HUGETLB_FLAG_ENCODE_SHIFT)
296
+ -#define HUGETLB_FLAG_ENCODE_256MB (28 << HUGETLB_FLAG_ENCODE_SHIFT)
297
+ -#define HUGETLB_FLAG_ENCODE_512MB (29 << HUGETLB_FLAG_ENCODE_SHIFT)
298
+ -#define HUGETLB_FLAG_ENCODE_1GB (30 << HUGETLB_FLAG_ENCODE_SHIFT)
299
+ -#define HUGETLB_FLAG_ENCODE_2GB (31 << HUGETLB_FLAG_ENCODE_SHIFT)
300
+ -#define HUGETLB_FLAG_ENCODE_16GB (34 << HUGETLB_FLAG_ENCODE_SHIFT)
301
+ +#define HUGETLB_FLAG_ENCODE_16KB (14U << HUGETLB_FLAG_ENCODE_SHIFT)
302
+ +#define HUGETLB_FLAG_ENCODE_64KB (16U << HUGETLB_FLAG_ENCODE_SHIFT)
303
+ +#define HUGETLB_FLAG_ENCODE_512KB (19U << HUGETLB_FLAG_ENCODE_SHIFT)
304
+ +#define HUGETLB_FLAG_ENCODE_1MB (20U << HUGETLB_FLAG_ENCODE_SHIFT)
305
+ +#define HUGETLB_FLAG_ENCODE_2MB (21U << HUGETLB_FLAG_ENCODE_SHIFT)
306
+ +#define HUGETLB_FLAG_ENCODE_8MB (23U << HUGETLB_FLAG_ENCODE_SHIFT)
307
+ +#define HUGETLB_FLAG_ENCODE_16MB (24U << HUGETLB_FLAG_ENCODE_SHIFT)
308
+ +#define HUGETLB_FLAG_ENCODE_32MB (25U << HUGETLB_FLAG_ENCODE_SHIFT)
309
+ +#define HUGETLB_FLAG_ENCODE_256MB (28U << HUGETLB_FLAG_ENCODE_SHIFT)
310
+ +#define HUGETLB_FLAG_ENCODE_512MB (29U << HUGETLB_FLAG_ENCODE_SHIFT)
311
+ +#define HUGETLB_FLAG_ENCODE_1GB (30U << HUGETLB_FLAG_ENCODE_SHIFT)
312
+ +#define HUGETLB_FLAG_ENCODE_2GB (31U << HUGETLB_FLAG_ENCODE_SHIFT)
313
+ +#define HUGETLB_FLAG_ENCODE_16GB (34U << HUGETLB_FLAG_ENCODE_SHIFT)
314
+
315
+ #endif /* _ASM_GENERIC_HUGETLB_ENCODE_H_ */
316
+ diff --git a/linux-headers/asm-generic/mman-common.h b/linux-headers/asm-generic/mman-common.h
317
+ index 6c1aa92a92..6ce1f1ceb4 100644
318
+ --- a/linux-headers/asm-generic/mman-common.h
319
+ +++ b/linux-headers/asm-generic/mman-common.h
320
+ @@ -77,6 +77,8 @@
321
+
322
+ #define MADV_DONTNEED_LOCKED 24 /* like DONTNEED, but drop locked pages too */
323
+
324
+ +#define MADV_COLLAPSE 25 /* Synchronous hugepage collapse */
325
+ +
326
+ /* compatibility flags */
327
+ #define MAP_FILE 0
328
+
329
+ diff --git a/linux-headers/asm-mips/mman.h b/linux-headers/asm-mips/mman.h
330
+ index 1be428663c..c6e1fc77c9 100644
331
+ --- a/linux-headers/asm-mips/mman.h
332
+ +++ b/linux-headers/asm-mips/mman.h
333
+ @@ -103,6 +103,8 @@
334
+
335
+ #define MADV_DONTNEED_LOCKED 24 /* like DONTNEED, but drop locked pages too */
336
+
337
+ +#define MADV_COLLAPSE 25 /* Synchronous hugepage collapse */
338
+ +
339
+ /* compatibility flags */
340
+ #define MAP_FILE 0
341
+
342
+ diff --git a/linux-headers/asm-riscv/kvm.h b/linux-headers/asm-riscv/kvm.h
343
+ index 7351417afd..8985ff234c 100644
344
+ --- a/linux-headers/asm-riscv/kvm.h
345
+ +++ b/linux-headers/asm-riscv/kvm.h
346
+ @@ -48,6 +48,7 @@ struct kvm_sregs {
347
+ /* CONFIG registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
348
+ struct kvm_riscv_config {
349
+ unsigned long isa;
350
+ + unsigned long zicbom_block_size;
351
+ };
352
+
353
+ /* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
354
+ @@ -98,6 +99,9 @@ enum KVM_RISCV_ISA_EXT_ID {
355
+ KVM_RISCV_ISA_EXT_M,
356
+ KVM_RISCV_ISA_EXT_SVPBMT,
357
+ KVM_RISCV_ISA_EXT_SSTC,
358
+ + KVM_RISCV_ISA_EXT_SVINVAL,
359
+ + KVM_RISCV_ISA_EXT_ZIHINTPAUSE,
360
+ + KVM_RISCV_ISA_EXT_ZICBOM,
361
+ KVM_RISCV_ISA_EXT_MAX,
362
+ };
363
+
364
+ diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
365
+ index ebdafa576d..b2783c5202 100644
366
+ --- a/linux-headers/linux/kvm.h
367
+ +++ b/linux-headers/linux/kvm.h
368
+ @@ -1175,6 +1175,7 @@ struct kvm_ppc_resize_hpt {
369
+ #define KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 220
370
+ #define KVM_CAP_S390_ZPCI_OP 221
371
+ #define KVM_CAP_S390_CPU_TOPOLOGY 222
372
+ +#define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223
373
+
374
+ #ifdef KVM_CAP_IRQ_ROUTING
375
+
376
+ diff --git a/linux-headers/linux/psci.h b/linux-headers/linux/psci.h
377
+ index 213b2a0f70..e60dfd8907 100644
378
+ --- a/linux-headers/linux/psci.h
379
+ +++ b/linux-headers/linux/psci.h
380
+ @@ -48,12 +48,26 @@
381
+ #define PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU PSCI_0_2_FN64(7)
382
+
383
+ #define PSCI_1_0_FN_PSCI_FEATURES PSCI_0_2_FN(10)
384
+ +#define PSCI_1_0_FN_CPU_FREEZE PSCI_0_2_FN(11)
385
+ +#define PSCI_1_0_FN_CPU_DEFAULT_SUSPEND PSCI_0_2_FN(12)
386
+ +#define PSCI_1_0_FN_NODE_HW_STATE PSCI_0_2_FN(13)
387
+ #define PSCI_1_0_FN_SYSTEM_SUSPEND PSCI_0_2_FN(14)
388
+ #define PSCI_1_0_FN_SET_SUSPEND_MODE PSCI_0_2_FN(15)
389
+ +#define PSCI_1_0_FN_STAT_RESIDENCY PSCI_0_2_FN(16)
390
+ +#define PSCI_1_0_FN_STAT_COUNT PSCI_0_2_FN(17)
391
+ +
392
+ #define PSCI_1_1_FN_SYSTEM_RESET2 PSCI_0_2_FN(18)
393
+ +#define PSCI_1_1_FN_MEM_PROTECT PSCI_0_2_FN(19)
394
+ +#define PSCI_1_1_FN_MEM_PROTECT_CHECK_RANGE PSCI_0_2_FN(19)
395
+
396
+ +#define PSCI_1_0_FN64_CPU_DEFAULT_SUSPEND PSCI_0_2_FN64(12)
397
+ +#define PSCI_1_0_FN64_NODE_HW_STATE PSCI_0_2_FN64(13)
398
+ #define PSCI_1_0_FN64_SYSTEM_SUSPEND PSCI_0_2_FN64(14)
399
+ +#define PSCI_1_0_FN64_STAT_RESIDENCY PSCI_0_2_FN64(16)
400
+ +#define PSCI_1_0_FN64_STAT_COUNT PSCI_0_2_FN64(17)
401
+ +
402
+ #define PSCI_1_1_FN64_SYSTEM_RESET2 PSCI_0_2_FN64(18)
403
+ +#define PSCI_1_1_FN64_MEM_PROTECT_CHECK_RANGE PSCI_0_2_FN64(19)
404
+
405
+ /* PSCI v0.2 power state encoding for CPU_SUSPEND function */
406
+ #define PSCI_0_2_POWER_STATE_ID_MASK 0xffff
407
+ diff --git a/linux-headers/linux/userfaultfd.h b/linux-headers/linux/userfaultfd.h
408
+ index a3a377cd44..ba5d0df52f 100644
409
+ --- a/linux-headers/linux/userfaultfd.h
410
+ +++ b/linux-headers/linux/userfaultfd.h
411
+ @@ -12,6 +12,10 @@
412
+
413
+ #include <linux/types.h>
414
+
415
+ +/* ioctls for /dev/userfaultfd */
416
+ +#define USERFAULTFD_IOC 0xAA
417
+ +#define USERFAULTFD_IOC_NEW _IO(USERFAULTFD_IOC, 0x00)
418
+ +
419
+ /*
420
+ * If the UFFDIO_API is upgraded someday, the UFFDIO_UNREGISTER and
421
+ * UFFDIO_WAKE ioctls should be defined as _IOW and not as _IOR. In
422
+ diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h
423
+ index ede44b5572..bee7e42198 100644
424
+ --- a/linux-headers/linux/vfio.h
425
+ +++ b/linux-headers/linux/vfio.h
426
+ @@ -986,6 +986,148 @@ enum vfio_device_mig_state {
427
+ VFIO_DEVICE_STATE_RUNNING_P2P = 5,
428
+ };
429
+
430
+ +/*
431
+ + * Upon VFIO_DEVICE_FEATURE_SET, allow the device to be moved into a low power
432
+ + * state with the platform-based power management. Device use of lower power
433
+ + * states depends on factors managed by the runtime power management core,
434
+ + * including system level support and coordinating support among dependent
435
+ + * devices. Enabling device low power entry does not guarantee lower power
436
+ + * usage by the device, nor is a mechanism provided through this feature to
437
+ + * know the current power state of the device. If any device access happens
438
+ + * (either from the host or through the vfio uAPI) when the device is in the
439
+ + * low power state, then the host will move the device out of the low power
440
+ + * state as necessary prior to the access. Once the access is completed, the
441
+ + * device may re-enter the low power state. For single shot low power support
442
+ + * with wake-up notification, see
443
+ + * VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP below. Access to mmap'd
444
+ + * device regions is disabled on LOW_POWER_ENTRY and may only be resumed after
445
+ + * calling LOW_POWER_EXIT.
446
+ + */
447
+ +#define VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY 3
448
+ +
449
+ +/*
450
+ + * This device feature has the same behavior as
451
+ + * VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY with the exception that the user
452
+ + * provides an eventfd for wake-up notification. When the device moves out of
453
+ + * the low power state for the wake-up, the host will not allow the device to
454
+ + * re-enter a low power state without a subsequent user call to one of the low
455
+ + * power entry device feature IOCTLs. Access to mmap'd device regions is
456
+ + * disabled on LOW_POWER_ENTRY_WITH_WAKEUP and may only be resumed after the
457
+ + * low power exit. The low power exit can happen either through LOW_POWER_EXIT
458
+ + * or through any other access (where the wake-up notification has been
459
+ + * generated). The access to mmap'd device regions will not trigger low power
460
+ + * exit.
461
+ + *
462
+ + * The notification through the provided eventfd will be generated only when
463
+ + * the device has entered and is resumed from a low power state after
464
+ + * calling this device feature IOCTL. A device that has not entered low power
465
+ + * state, as managed through the runtime power management core, will not
466
+ + * generate a notification through the provided eventfd on access. Calling the
467
+ + * LOW_POWER_EXIT feature is optional in the case where notification has been
468
+ + * signaled on the provided eventfd that a resume from low power has occurred.
469
+ + */
470
+ +struct vfio_device_low_power_entry_with_wakeup {
471
+ + __s32 wakeup_eventfd;
472
+ + __u32 reserved;
473
+ +};
474
+ +
475
+ +#define VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP 4
476
+ +
477
+ +/*
478
+ + * Upon VFIO_DEVICE_FEATURE_SET, disallow use of device low power states as
479
+ + * previously enabled via VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY or
480
+ + * VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP device features.
481
+ + * This device feature IOCTL may itself generate a wakeup eventfd notification
482
+ + * in the latter case if the device had previously entered a low power state.
483
+ + */
484
+ +#define VFIO_DEVICE_FEATURE_LOW_POWER_EXIT 5
485
+ +
486
+ +/*
487
+ + * Upon VFIO_DEVICE_FEATURE_SET start/stop device DMA logging.
488
+ + * VFIO_DEVICE_FEATURE_PROBE can be used to detect if the device supports
489
+ + * DMA logging.
490
+ + *
491
+ + * DMA logging allows a device to internally record what DMAs the device is
492
+ + * initiating and report them back to userspace. It is part of the VFIO
493
+ + * migration infrastructure that allows implementing dirty page tracking
494
+ + * during the pre copy phase of live migration. Only DMA WRITEs are logged,
495
+ + * and this API is not connected to VFIO_DEVICE_FEATURE_MIG_DEVICE_STATE.
496
+ + *
497
+ + * When DMA logging is started a range of IOVAs to monitor is provided and the
498
+ + * device can optimize its logging to cover only the IOVA range given. Each
499
+ + * DMA that the device initiates inside the range will be logged by the device
500
+ + * for later retrieval.
501
+ + *
502
+ + * page_size is an input that hints what tracking granularity the device
503
+ + * should try to achieve. If the device cannot do the hinted page size then
504
+ + * it's the driver choice which page size to pick based on its support.
505
+ + * On output the device will return the page size it selected.
506
+ + *
507
+ + * ranges is a pointer to an array of
508
+ + * struct vfio_device_feature_dma_logging_range.
509
+ + *
510
+ + * The core kernel code guarantees to support by minimum num_ranges that fit
511
+ + * into a single kernel page. User space can try higher values but should give
512
+ + * up if the above can't be achieved as of some driver limitations.
513
+ + *
514
+ + * A single call to start device DMA logging can be issued and a matching stop
515
+ + * should follow at the end. Another start is not allowed in the meantime.
516
+ + */
517
+ +struct vfio_device_feature_dma_logging_control {
518
+ + __aligned_u64 page_size;
519
+ + __u32 num_ranges;
520
+ + __u32 __reserved;
521
+ + __aligned_u64 ranges;
522
+ +};
523
+ +
524
+ +struct vfio_device_feature_dma_logging_range {
525
+ + __aligned_u64 iova;
526
+ + __aligned_u64 length;
527
+ +};
528
+ +
529
+ +#define VFIO_DEVICE_FEATURE_DMA_LOGGING_START 6
530
+ +
531
+ +/*
532
+ + * Upon VFIO_DEVICE_FEATURE_SET stop device DMA logging that was started
533
+ + * by VFIO_DEVICE_FEATURE_DMA_LOGGING_START
534
+ + */
535
+ +#define VFIO_DEVICE_FEATURE_DMA_LOGGING_STOP 7
536
+ +
537
+ +/*
538
+ + * Upon VFIO_DEVICE_FEATURE_GET read back and clear the device DMA log
539
+ + *
540
+ + * Query the device's DMA log for written pages within the given IOVA range.
541
+ + * During querying the log is cleared for the IOVA range.
542
+ + *
543
+ + * bitmap is a pointer to an array of u64s that will hold the output bitmap
544
+ + * with 1 bit reporting a page_size unit of IOVA. The mapping of IOVA to bits
545
+ + * is given by:
546
+ + * bitmap[(addr - iova)/page_size] & (1ULL << (addr % 64))
547
+ + *
548
+ + * The input page_size can be any power of two value and does not have to
549
+ + * match the value given to VFIO_DEVICE_FEATURE_DMA_LOGGING_START. The driver
550
+ + * will format its internal logging to match the reporting page size, possibly
551
+ + * by replicating bits if the internal page size is lower than requested.
552
+ + *
553
+ + * The LOGGING_REPORT will only set bits in the bitmap and never clear or
554
+ + * perform any initialization of the user provided bitmap.
555
+ + *
556
+ + * If any error is returned userspace should assume that the dirty log is
557
+ + * corrupted. Error recovery is to consider all memory dirty and try to
558
+ + * restart the dirty tracking, or to abort/restart the whole migration.
559
+ + *
560
+ + * If DMA logging is not enabled, an error will be returned.
561
+ + *
562
+ + */
563
+ +struct vfio_device_feature_dma_logging_report {
564
+ + __aligned_u64 iova;
565
+ + __aligned_u64 length;
566
+ + __aligned_u64 page_size;
567
+ + __aligned_u64 bitmap;
568
+ +};
569
+ +
570
+ +#define VFIO_DEVICE_FEATURE_DMA_LOGGING_REPORT 8
571
+ +
572
+ /* -------- API for Type1 VFIO IOMMU -------- */
573
+
574
+ /**
575
+ --
576
+ 2.31.1
577
+
SOURCES/kvm-meson-create-have_vhost_-variables.patch DELETED
@@ -1,154 +0,0 @@
1
- From 51c310097832724bafac26aed81399da40128400 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:50:43 +0200
4
- Subject: [PATCH 05/32] meson: create have_vhost_* variables
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [5/27] 3b30f89e6d639923dc9d9a92a4261bb4509e5c83 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit 2a3129a37652e5e81d12f6e16dd3c447f09831f9
22
- Author: Paolo Bonzini <pbonzini@redhat.com>
23
- Date: Wed Apr 20 17:34:05 2022 +0200
24
-
25
- meson: create have_vhost_* variables
26
-
27
- When using Meson options rather than config-host.h, the "when" clauses
28
- have to be changed to if statements (which is not necessarily great,
29
- though at least it highlights which parts of the build are per-target
30
- and which are not).
31
-
32
- Do that before moving vhost logic to meson.build, though for now
33
- the variables are just based on config-host.mak data.
34
-
35
- Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
36
- Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
37
-
38
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
39
- ---
40
- meson.build | 30 ++++++++++++++++++++----------
41
- tests/meson.build | 2 +-
42
- tools/meson.build | 2 +-
43
- 3 files changed, 22 insertions(+), 12 deletions(-)
44
-
45
- diff --git a/meson.build b/meson.build
46
- index 13e3323380..735f538497 100644
47
- --- a/meson.build
48
- +++ b/meson.build
49
- @@ -298,6 +298,15 @@ have_tpm = get_option('tpm') \
50
- .require(targetos != 'windows', error_message: 'TPM emulation only available on POSIX systems') \
51
- .allowed()
52
-
53
- +# vhost
54
- +have_vhost_user = 'CONFIG_VHOST_USER' in config_host
55
- +have_vhost_vdpa = 'CONFIG_VHOST_VDPA' in config_host
56
- +have_vhost_kernel = 'CONFIG_VHOST_KERNEL' in config_host
57
- +have_vhost_net_user = 'CONFIG_VHOST_NET_USER' in config_host
58
- +have_vhost_net_vdpa = 'CONFIG_VHOST_NET_VDPA' in config_host
59
- +have_vhost_net = 'CONFIG_VHOST_NET' in config_host
60
- +have_vhost_user_crypto = 'CONFIG_VHOST_CRYPTO' in config_host
61
- +
62
- # Target-specific libraries and flags
63
- libm = cc.find_library('m', required: false)
64
- threads = dependency('threads')
65
- @@ -1335,7 +1344,7 @@ has_statx_mnt_id = cc.links(statx_mnt_id_test)
66
- have_vhost_user_blk_server = get_option('vhost_user_blk_server') \
67
- .require(targetos == 'linux',
68
- error_message: 'vhost_user_blk_server requires linux') \
69
- - .require('CONFIG_VHOST_USER' in config_host,
70
- + .require(have_vhost_user,
71
- error_message: 'vhost_user_blk_server requires vhost-user support') \
72
- .disable_auto_if(not have_system) \
73
- .allowed()
74
- @@ -2116,9 +2125,9 @@ host_kconfig = \
75
- (have_ivshmem ? ['CONFIG_IVSHMEM=y'] : []) + \
76
- ('CONFIG_OPENGL' in config_host ? ['CONFIG_OPENGL=y'] : []) + \
77
- (x11.found() ? ['CONFIG_X11=y'] : []) + \
78
- - ('CONFIG_VHOST_USER' in config_host ? ['CONFIG_VHOST_USER=y'] : []) + \
79
- - ('CONFIG_VHOST_VDPA' in config_host ? ['CONFIG_VHOST_VDPA=y'] : []) + \
80
- - ('CONFIG_VHOST_KERNEL' in config_host ? ['CONFIG_VHOST_KERNEL=y'] : []) + \
81
- + (have_vhost_user ? ['CONFIG_VHOST_USER=y'] : []) + \
82
- + (have_vhost_vdpa ? ['CONFIG_VHOST_VDPA=y'] : []) + \
83
- + (have_vhost_kernel ? ['CONFIG_VHOST_KERNEL=y'] : []) + \
84
- (have_virtfs ? ['CONFIG_VIRTFS=y'] : []) + \
85
- ('CONFIG_LINUX' in config_host ? ['CONFIG_LINUX=y'] : []) + \
86
- ('CONFIG_PVRDMA' in config_host ? ['CONFIG_PVRDMA=y'] : []) + \
87
- @@ -2799,7 +2808,7 @@ if have_system or have_user
88
- endif
89
-
90
- vhost_user = not_found
91
- -if targetos == 'linux' and 'CONFIG_VHOST_USER' in config_host
92
- +if targetos == 'linux' and have_vhost_user
93
- libvhost_user = subproject('libvhost-user')
94
- vhost_user = libvhost_user.get_variable('vhost_user_dep')
95
- endif
96
- @@ -3386,7 +3395,7 @@ if have_tools
97
- dependencies: qemuutil,
98
- install: true)
99
-
100
- - if 'CONFIG_VHOST_USER' in config_host
101
- + if have_vhost_user
102
- subdir('contrib/vhost-user-blk')
103
- subdir('contrib/vhost-user-gpu')
104
- subdir('contrib/vhost-user-input')
105
- @@ -3516,15 +3525,16 @@ if 'simple' in get_option('trace_backends')
106
- endif
107
- summary_info += {'D-Bus display': dbus_display}
108
- summary_info += {'QOM debugging': get_option('qom_cast_debug')}
109
- -summary_info += {'vhost-kernel support': config_host.has_key('CONFIG_VHOST_KERNEL')}
110
- -summary_info += {'vhost-net support': config_host.has_key('CONFIG_VHOST_NET')}
111
- -summary_info += {'vhost-crypto support': config_host.has_key('CONFIG_VHOST_CRYPTO')}
112
- +summary_info += {'vhost-kernel support': have_vhost_kernel}
113
- +summary_info += {'vhost-net support': have_vhost_net}
114
- +summary_info += {'vhost-user support': have_vhost_user}
115
- +summary_info += {'vhost-user-crypto support': have_vhost_user_crypto}
116
- summary_info += {'vhost-scsi support': config_host.has_key('CONFIG_VHOST_SCSI')}
117
- summary_info += {'vhost-vsock support': config_host.has_key('CONFIG_VHOST_VSOCK')}
118
- -summary_info += {'vhost-user support': config_host.has_key('CONFIG_VHOST_USER')}
119
- summary_info += {'vhost-user-blk server support': have_vhost_user_blk_server}
120
- summary_info += {'vhost-user-fs support': config_host.has_key('CONFIG_VHOST_USER_FS')}
121
- summary_info += {'vhost-vdpa support': config_host.has_key('CONFIG_VHOST_VDPA')}
122
- +summary_info += {'vhost-vdpa support': have_vhost_vdpa}
123
- summary_info += {'build guest agent': have_ga}
124
- summary(summary_info, bool_yn: true, section: 'Configurable features')
125
-
126
- diff --git a/tests/meson.build b/tests/meson.build
127
- index 1d05109eb4..bbe41c8559 100644
128
- --- a/tests/meson.build
129
- +++ b/tests/meson.build
130
- @@ -70,7 +70,7 @@ test_deps = {
131
- 'test-qht-par': qht_bench,
132
- }
133
-
134
- -if have_tools and 'CONFIG_VHOST_USER' in config_host and 'CONFIG_LINUX' in config_host
135
- +if have_tools and have_vhost_user and 'CONFIG_LINUX' in config_host
136
- executable('vhost-user-bridge',
137
- sources: files('vhost-user-bridge.c'),
138
- dependencies: [qemuutil, vhost_user])
139
- diff --git a/tools/meson.build b/tools/meson.build
140
- index 46977af84f..10eb3a043f 100644
141
- --- a/tools/meson.build
142
- +++ b/tools/meson.build
143
- @@ -3,7 +3,7 @@ have_virtiofsd = get_option('virtiofsd') \
144
- error_message: 'virtiofsd requires Linux') \
145
- .require(seccomp.found() and libcap_ng.found(),
146
- error_message: 'virtiofsd requires libcap-ng-devel and seccomp-devel') \
147
- - .require('CONFIG_VHOST_USER' in config_host,
148
- + .require(have_vhost_user,
149
- error_message: 'virtiofsd needs vhost-user-support') \
150
- .disable_auto_if(not have_tools and not have_system) \
151
- .allowed()
152
- --
153
- 2.31.1
154
-
SOURCES/kvm-meson-use-have_vhost_-variables-to-pick-sources.patch DELETED
@@ -1,213 +0,0 @@
1
- From a7d57a09e33275d5e6649273b5c9da1bc3c92491 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:51:53 +0200
4
- Subject: [PATCH 06/32] meson: use have_vhost_* variables to pick sources
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [6/27] bc3db1efb759c0bc97fde2f4fbb3d6dc404c8d3d (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit 43b6d7ee1fbc5b5fb7c85d8131fdac1863214ad6
22
- Author: Paolo Bonzini <pbonzini@redhat.com>
23
- Date: Wed Apr 20 17:34:06 2022 +0200
24
-
25
- meson: use have_vhost_* variables to pick sources
26
-
27
- Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
28
- Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
29
-
30
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
31
- ---
32
- Kconfig.host | 3 ---
33
- backends/meson.build | 8 ++++++--
34
- hw/net/meson.build | 8 ++++++--
35
- hw/virtio/Kconfig | 3 ---
36
- hw/virtio/meson.build | 25 ++++++++++++++++---------
37
- meson.build | 1 +
38
- net/meson.build | 12 +++++++-----
39
- tests/qtest/meson.build | 4 +++-
40
- 8 files changed, 39 insertions(+), 25 deletions(-)
41
-
42
- diff --git a/Kconfig.host b/Kconfig.host
43
- index 60b9c07b5e..1165c4eacd 100644
44
- --- a/Kconfig.host
45
- +++ b/Kconfig.host
46
- @@ -22,15 +22,12 @@ config TPM
47
-
48
- config VHOST_USER
49
- bool
50
- - select VHOST
51
-
52
- config VHOST_VDPA
53
- bool
54
- - select VHOST
55
-
56
- config VHOST_KERNEL
57
- bool
58
- - select VHOST
59
-
60
- config VIRTFS
61
- bool
62
- diff --git a/backends/meson.build b/backends/meson.build
63
- index 6e68945528..cb92f639ca 100644
64
- --- a/backends/meson.build
65
- +++ b/backends/meson.build
66
- @@ -12,9 +12,13 @@ softmmu_ss.add([files(
67
- softmmu_ss.add(when: 'CONFIG_POSIX', if_true: files('rng-random.c'))
68
- softmmu_ss.add(when: 'CONFIG_POSIX', if_true: files('hostmem-file.c'))
69
- softmmu_ss.add(when: 'CONFIG_LINUX', if_true: files('hostmem-memfd.c'))
70
- -softmmu_ss.add(when: ['CONFIG_VHOST_USER', 'CONFIG_VIRTIO'], if_true: files('vhost-user.c'))
71
- +if have_vhost_user
72
- + softmmu_ss.add(when: 'CONFIG_VIRTIO', if_true: files('vhost-user.c'))
73
- +endif
74
- softmmu_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('cryptodev-vhost.c'))
75
- -softmmu_ss.add(when: ['CONFIG_VIRTIO_CRYPTO', 'CONFIG_VHOST_CRYPTO'], if_true: files('cryptodev-vhost-user.c'))
76
- +if have_vhost_user_crypto
77
- + softmmu_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('cryptodev-vhost-user.c'))
78
- +endif
79
- softmmu_ss.add(when: 'CONFIG_GIO', if_true: [files('dbus-vmstate.c'), gio])
80
- softmmu_ss.add(when: 'CONFIG_SGX', if_true: files('hostmem-epc.c'))
81
-
82
- diff --git a/hw/net/meson.build b/hw/net/meson.build
83
- index 685b75badb..ebac261542 100644
84
- --- a/hw/net/meson.build
85
- +++ b/hw/net/meson.build
86
- @@ -46,8 +46,12 @@ specific_ss.add(when: 'CONFIG_XILINX_ETHLITE', if_true: files('xilinx_ethlite.c'
87
- softmmu_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('net_rx_pkt.c'))
88
- specific_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('virtio-net.c'))
89
-
90
- -softmmu_ss.add(when: ['CONFIG_VIRTIO_NET', 'CONFIG_VHOST_NET'], if_true: files('vhost_net.c'), if_false: files('vhost_net-stub.c'))
91
- -softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost_net-stub.c'))
92
- +if have_vhost_net
93
- + softmmu_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('vhost_net.c'), if_false: files('vhost_net-stub.c'))
94
- + softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost_net-stub.c'))
95
- +else
96
- + softmmu_ss.add(files('vhost_net-stub.c'))
97
- +endif
98
-
99
- softmmu_ss.add(when: 'CONFIG_ETSEC', if_true: files(
100
- 'fsl_etsec/etsec.c',
101
- diff --git a/hw/virtio/Kconfig b/hw/virtio/Kconfig
102
- index c144d42f9b..8ca7b3d9d6 100644
103
- --- a/hw/virtio/Kconfig
104
- +++ b/hw/virtio/Kconfig
105
- @@ -1,6 +1,3 @@
106
- -config VHOST
107
- - bool
108
- -
109
- config VIRTIO
110
- bool
111
-
112
- diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build
113
- index 67dc77e00f..30a832eb4a 100644
114
- --- a/hw/virtio/meson.build
115
- +++ b/hw/virtio/meson.build
116
- @@ -2,18 +2,22 @@ softmmu_virtio_ss = ss.source_set()
117
- softmmu_virtio_ss.add(files('virtio-bus.c'))
118
- softmmu_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('virtio-pci.c'))
119
- softmmu_virtio_ss.add(when: 'CONFIG_VIRTIO_MMIO', if_true: files('virtio-mmio.c'))
120
- -softmmu_virtio_ss.add(when: 'CONFIG_VHOST', if_false: files('vhost-stub.c'))
121
- -
122
- -softmmu_ss.add_all(when: 'CONFIG_VIRTIO', if_true: softmmu_virtio_ss)
123
- -softmmu_ss.add(when: 'CONFIG_VIRTIO', if_false: files('vhost-stub.c'))
124
- -
125
- -softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-stub.c'))
126
-
127
- virtio_ss = ss.source_set()
128
- virtio_ss.add(files('virtio.c'))
129
- -virtio_ss.add(when: 'CONFIG_VHOST', if_true: files('vhost.c', 'vhost-backend.c', 'vhost-iova-tree.c'))
130
- -virtio_ss.add(when: 'CONFIG_VHOST_USER', if_true: files('vhost-user.c'))
131
- -virtio_ss.add(when: 'CONFIG_VHOST_VDPA', if_true: files('vhost-shadow-virtqueue.c', 'vhost-vdpa.c'))
132
- +
133
- +if have_vhost
134
- + virtio_ss.add(files('vhost.c', 'vhost-backend.c', 'vhost-iova-tree.c'))
135
- + if have_vhost_user
136
- + virtio_ss.add(files('vhost-user.c'))
137
- + endif
138
- + if have_vhost_vdpa
139
- + virtio_ss.add(files('vhost-vdpa.c', 'vhost-shadow-virtqueue.c'))
140
- + endif
141
- +else
142
- + softmmu_virtio_ss.add(files('vhost-stub.c'))
143
- +endif
144
- +
145
- virtio_ss.add(when: 'CONFIG_VIRTIO_BALLOON', if_true: files('virtio-balloon.c'))
146
- virtio_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('virtio-crypto.c'))
147
- virtio_ss.add(when: ['CONFIG_VIRTIO_CRYPTO', 'CONFIG_VIRTIO_PCI'], if_true: files('virtio-crypto-pci.c'))
148
- @@ -53,3 +57,6 @@ virtio_pci_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem-pci.c'))
149
- virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss)
150
-
151
- specific_ss.add_all(when: 'CONFIG_VIRTIO', if_true: virtio_ss)
152
- +softmmu_ss.add_all(when: 'CONFIG_VIRTIO', if_true: softmmu_virtio_ss)
153
- +softmmu_ss.add(when: 'CONFIG_VIRTIO', if_false: files('vhost-stub.c'))
154
- +softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-stub.c'))
155
- diff --git a/meson.build b/meson.build
156
- index 735f538497..9ba675f098 100644
157
- --- a/meson.build
158
- +++ b/meson.build
159
- @@ -305,6 +305,7 @@ have_vhost_kernel = 'CONFIG_VHOST_KERNEL' in config_host
160
- have_vhost_net_user = 'CONFIG_VHOST_NET_USER' in config_host
161
- have_vhost_net_vdpa = 'CONFIG_VHOST_NET_VDPA' in config_host
162
- have_vhost_net = 'CONFIG_VHOST_NET' in config_host
163
- +have_vhost = have_vhost_user or have_vhost_vdpa or have_vhost_kernel
164
- have_vhost_user_crypto = 'CONFIG_VHOST_CRYPTO' in config_host
165
-
166
- # Target-specific libraries and flags
167
- diff --git a/net/meson.build b/net/meson.build
168
- index 847bc2ac85..c965e83b26 100644
169
- --- a/net/meson.build
170
- +++ b/net/meson.build
171
- @@ -26,10 +26,10 @@ softmmu_ss.add(when: vde, if_true: files('vde.c'))
172
- if have_netmap
173
- softmmu_ss.add(files('netmap.c'))
174
- endif
175
- -vhost_user_ss = ss.source_set()
176
- -vhost_user_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('vhost-user.c'), if_false: files('vhost-user-stub.c'))
177
- -softmmu_ss.add_all(when: 'CONFIG_VHOST_NET_USER', if_true: vhost_user_ss)
178
- -softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-user-stub.c'))
179
- +if have_vhost_net_user
180
- + softmmu_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('vhost-user.c'), if_false: files('vhost-user-stub.c'))
181
- + softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-user-stub.c'))
182
- +endif
183
-
184
- softmmu_ss.add(when: 'CONFIG_LINUX', if_true: files('tap-linux.c'))
185
- softmmu_ss.add(when: 'CONFIG_BSD', if_true: files('tap-bsd.c'))
186
- @@ -40,6 +40,8 @@ if not config_host.has_key('CONFIG_LINUX') and not config_host.has_key('CONFIG_B
187
- endif
188
- softmmu_ss.add(when: 'CONFIG_POSIX', if_true: files(tap_posix))
189
- softmmu_ss.add(when: 'CONFIG_WIN32', if_true: files('tap-win32.c'))
190
- -softmmu_ss.add(when: 'CONFIG_VHOST_NET_VDPA', if_true: files('vhost-vdpa.c'))
191
- +if have_vhost_net_vdpa
192
- + softmmu_ss.add(files('vhost-vdpa.c'))
193
- +endif
194
-
195
- subdir('can')
196
- diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
197
- index 67cd32def1..9f550df900 100644
198
- --- a/tests/qtest/meson.build
199
- +++ b/tests/qtest/meson.build
200
- @@ -269,7 +269,9 @@ qos_test_ss.add(
201
- if have_virtfs
202
- qos_test_ss.add(files('virtio-9p-test.c'))
203
- endif
204
- -qos_test_ss.add(when: 'CONFIG_VHOST_USER', if_true: files('vhost-user-test.c'))
205
- +if have_vhost_user
206
- + qos_test_ss.add(files('vhost-user-test.c'))
207
- +endif
208
- if have_tools and have_vhost_user_blk_server
209
- qos_test_ss.add(files('vhost-user-blk-test.c'))
210
- endif
211
- --
212
- 2.31.1
213
-
SOURCES/kvm-meson.build-Fix-docker-test-build-alpine-when-includ.patch DELETED
@@ -1,87 +0,0 @@
1
- From 7c489b54b0bb33445113fbf16e88feb23be68013 Mon Sep 17 00:00:00 2001
2
- From: Leonardo Bras <leobras@redhat.com>
3
- Date: Fri, 13 May 2022 03:28:30 -0300
4
- Subject: [PATCH 07/18] meson.build: Fix docker-test-build@alpine when
5
- including linux/errqueue.h
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Leonardo Brás <leobras@redhat.com>
11
- RH-MergeRequest: 95: MSG_ZEROCOPY + Multifd
12
- RH-Commit: [1/11] f058eb846fcf611d527a1dd3b0cc399cdc17e3ee (LeoBras/centos-qemu-kvm)
13
- RH-Bugzilla: 1968509
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
16
- RH-Acked-by: Peter Xu <peterx@redhat.com>
17
-
18
- A build error happens in alpine CI when linux/errqueue.h is included
19
- in io/channel-socket.c, due to redefining of 'struct __kernel_timespec':
20
-
21
- ===
22
- ninja: job failed: [...]
23
- In file included from /usr/include/linux/errqueue.h:6,
24
- from ../io/channel-socket.c:29:
25
- /usr/include/linux/time_types.h:7:8: error: redefinition of 'struct __kernel_timespec'
26
- 7 | struct __kernel_timespec {
27
- | ^~~~~~~~~~~~~~~~~
28
- In file included from /usr/include/liburing.h:19,
29
- from /builds/user/qemu/include/block/aio.h:18,
30
- from /builds/user/qemu/include/io/channel.h:26,
31
- from /builds/user/qemu/include/io/channel-socket.h:24,
32
- from ../io/channel-socket.c:24:
33
- /usr/include/liburing/compat.h:9:8: note: originally defined here
34
- 9 | struct __kernel_timespec {
35
- | ^~~~~~~~~~~~~~~~~
36
- ninja: subcommand failed
37
- ===
38
-
39
- As above error message suggests, 'struct __kernel_timespec' was already
40
- defined by liburing/compat.h.
41
-
42
- Fix alpine CI by adding test to disable liburing in configure step if a
43
- redefinition happens between linux/errqueue.h and liburing/compat.h.
44
-
45
- [dgilbert: This has been fixed in Alpine issue 13813 and liburing]
46
-
47
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
48
- Message-Id: <20220513062836.965425-2-leobras@redhat.com>
49
- Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
50
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
51
- (cherry picked from commit 354081d43de44ebd3497fe08f7f0121a5517d528)
52
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
53
- ---
54
- meson.build | 11 +++++++++++
55
- 1 file changed, 11 insertions(+)
56
-
57
- diff --git a/meson.build b/meson.build
58
- index 5a7c10e639..13e3323380 100644
59
- --- a/meson.build
60
- +++ b/meson.build
61
- @@ -471,12 +471,23 @@ if not get_option('linux_aio').auto() or have_block
62
- required: get_option('linux_aio'),
63
- kwargs: static_kwargs)
64
- endif
65
- +
66
- +linux_io_uring_test = '''
67
- + #include <liburing.h>
68
- + #include <linux/errqueue.h>
69
- +
70
- + int main(void) { return 0; }'''
71
- +
72
- linux_io_uring = not_found
73
- if not get_option('linux_io_uring').auto() or have_block
74
- linux_io_uring = dependency('liburing', version: '>=0.3',
75
- required: get_option('linux_io_uring'),
76
- method: 'pkg-config', kwargs: static_kwargs)
77
- + if not cc.links(linux_io_uring_test)
78
- + linux_io_uring = not_found
79
- + endif
80
- endif
81
- +
82
- libnfs = not_found
83
- if not get_option('libnfs').auto() or have_block
84
- libnfs = dependency('libnfs', version: '>=1.9.3',
85
- --
86
- 2.35.3
87
-
SOURCES/kvm-migration-Add-migrate_use_tls-helper.patch DELETED
@@ -1,106 +0,0 @@
1
- From 828f6c106eedcb7a48e551ffda15af56ff92a899 Mon Sep 17 00:00:00 2001
2
- From: Leonardo Bras <leobras@redhat.com>
3
- Date: Fri, 13 May 2022 03:28:34 -0300
4
- Subject: [PATCH 11/18] migration: Add migrate_use_tls() helper
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Leonardo Brás <leobras@redhat.com>
10
- RH-MergeRequest: 95: MSG_ZEROCOPY + Multifd
11
- RH-Commit: [5/11] 06e945297c3b9c0ce5864885aafcdba1e5746bc2 (LeoBras/centos-qemu-kvm)
12
- RH-Bugzilla: 1968509
13
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
14
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
15
- RH-Acked-by: Peter Xu <peterx@redhat.com>
16
-
17
- A lot of places check parameters.tls_creds in order to evaluate if TLS is
18
- in use, and sometimes call migrate_get_current() just for that test.
19
-
20
- Add new helper function migrate_use_tls() in order to simplify testing
21
- for TLS usage.
22
-
23
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
24
- Reviewed-by: Juan Quintela <quintela@redhat.com>
25
- Reviewed-by: Peter Xu <peterx@redhat.com>
26
- Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
27
- Message-Id: <20220513062836.965425-6-leobras@redhat.com>
28
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
29
- (cherry picked from commit d2fafb6a6814a8998607d0baf691265032996a0f)
30
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
31
- ---
32
- migration/channel.c | 3 +--
33
- migration/migration.c | 9 +++++++++
34
- migration/migration.h | 1 +
35
- migration/multifd.c | 5 +----
36
- 4 files changed, 12 insertions(+), 6 deletions(-)
37
-
38
- diff --git a/migration/channel.c b/migration/channel.c
39
- index c4fc000a1a..086b5c0d8b 100644
40
- --- a/migration/channel.c
41
- +++ b/migration/channel.c
42
- @@ -38,8 +38,7 @@ void migration_channel_process_incoming(QIOChannel *ioc)
43
- trace_migration_set_incoming_channel(
44
- ioc, object_get_typename(OBJECT(ioc)));
45
-
46
- - if (s->parameters.tls_creds &&
47
- - *s->parameters.tls_creds &&
48
- + if (migrate_use_tls() &&
49
- !object_dynamic_cast(OBJECT(ioc),
50
- TYPE_QIO_CHANNEL_TLS)) {
51
- migration_tls_channel_process_incoming(s, ioc, &local_err);
52
- diff --git a/migration/migration.c b/migration/migration.c
53
- index 0a6b3b9f4d..d91efb66fe 100644
54
- --- a/migration/migration.c
55
- +++ b/migration/migration.c
56
- @@ -2582,6 +2582,15 @@ bool migrate_use_zero_copy_send(void)
57
- }
58
- #endif
59
-
60
- +int migrate_use_tls(void)
61
- +{
62
- + MigrationState *s;
63
- +
64
- + s = migrate_get_current();
65
- +
66
- + return s->parameters.tls_creds && *s->parameters.tls_creds;
67
- +}
68
- +
69
- int migrate_use_xbzrle(void)
70
- {
71
- MigrationState *s;
72
- diff --git a/migration/migration.h b/migration/migration.h
73
- index 5bcb7628ef..c2cabb8a14 100644
74
- --- a/migration/migration.h
75
- +++ b/migration/migration.h
76
- @@ -381,6 +381,7 @@ bool migrate_use_zero_copy_send(void);
77
- #else
78
- #define migrate_use_zero_copy_send() (false)
79
- #endif
80
- +int migrate_use_tls(void);
81
- int migrate_use_xbzrle(void);
82
- uint64_t migrate_xbzrle_cache_size(void);
83
- bool migrate_colo_enabled(void);
84
- diff --git a/migration/multifd.c b/migration/multifd.c
85
- index 76b57a7177..43998ad117 100644
86
- --- a/migration/multifd.c
87
- +++ b/migration/multifd.c
88
- @@ -784,14 +784,11 @@ static bool multifd_channel_connect(MultiFDSendParams *p,
89
- QIOChannel *ioc,
90
- Error *error)
91
- {
92
- - MigrationState *s = migrate_get_current();
93
- -
94
- trace_multifd_set_outgoing_channel(
95
- ioc, object_get_typename(OBJECT(ioc)), p->tls_hostname, error);
96
-
97
- if (!error) {
98
- - if (s->parameters.tls_creds &&
99
- - *s->parameters.tls_creds &&
100
- + if (migrate_use_tls() &&
101
- !object_dynamic_cast(OBJECT(ioc),
102
- TYPE_QIO_CHANNEL_TLS)) {
103
- multifd_tls_channel_connect(p, ioc, &error);
104
- --
105
- 2.35.3
106
-
SOURCES/kvm-migration-Add-zero-copy-send-parameter-for-QMP-HMP-f.patch DELETED
@@ -1,250 +0,0 @@
1
- From d6500340dc3c1152b5efe04ef3daa50c17a55e30 Mon Sep 17 00:00:00 2001
2
- From: Leonardo Bras <leobras@redhat.com>
3
- Date: Fri, 13 May 2022 03:28:33 -0300
4
- Subject: [PATCH 10/18] migration: Add zero-copy-send parameter for QMP/HMP for
5
- Linux
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Leonardo Brás <leobras@redhat.com>
11
- RH-MergeRequest: 95: MSG_ZEROCOPY + Multifd
12
- RH-Commit: [4/11] 514d98d595992c53ff98de750035e080ded8972e (LeoBras/centos-qemu-kvm)
13
- RH-Bugzilla: 1968509
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
16
- RH-Acked-by: Peter Xu <peterx@redhat.com>
17
-
18
- Add property that allows zero-copy migration of memory pages
19
- on the sending side, and also includes a helper function
20
- migrate_use_zero_copy_send() to check if it's enabled.
21
-
22
- No code is introduced to actually do the migration, but it allow
23
- future implementations to enable/disable this feature.
24
-
25
- On non-Linux builds this parameter is compiled-out.
26
-
27
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
28
- Reviewed-by: Peter Xu <peterx@redhat.com>
29
- Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
30
- Reviewed-by: Juan Quintela <quintela@redhat.com>
31
- Acked-by: Markus Armbruster <armbru@redhat.com>
32
- Message-Id: <20220513062836.965425-5-leobras@redhat.com>
33
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
34
- (cherry picked from commit abb6295b3ace5d17c3a65936913fc346616dbf14)
35
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
36
- ---
37
- migration/migration.c | 32 ++++++++++++++++++++++++++++++++
38
- migration/migration.h | 5 +++++
39
- migration/socket.c | 11 +++++++++--
40
- monitor/hmp-cmds.c | 6 ++++++
41
- qapi/migration.json | 24 ++++++++++++++++++++++++
42
- 5 files changed, 76 insertions(+), 2 deletions(-)
43
-
44
- diff --git a/migration/migration.c b/migration/migration.c
45
- index 695f0f2900..0a6b3b9f4d 100644
46
- --- a/migration/migration.c
47
- +++ b/migration/migration.c
48
- @@ -899,6 +899,10 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
49
- params->multifd_zlib_level = s->parameters.multifd_zlib_level;
50
- params->has_multifd_zstd_level = true;
51
- params->multifd_zstd_level = s->parameters.multifd_zstd_level;
52
- +#ifdef CONFIG_LINUX
53
- + params->has_zero_copy_send = true;
54
- + params->zero_copy_send = s->parameters.zero_copy_send;
55
- +#endif
56
- params->has_xbzrle_cache_size = true;
57
- params->xbzrle_cache_size = s->parameters.xbzrle_cache_size;
58
- params->has_max_postcopy_bandwidth = true;
59
- @@ -1555,6 +1559,11 @@ static void migrate_params_test_apply(MigrateSetParameters *params,
60
- if (params->has_multifd_compression) {
61
- dest->multifd_compression = params->multifd_compression;
62
- }
63
- +#ifdef CONFIG_LINUX
64
- + if (params->has_zero_copy_send) {
65
- + dest->zero_copy_send = params->zero_copy_send;
66
- + }
67
- +#endif
68
- if (params->has_xbzrle_cache_size) {
69
- dest->xbzrle_cache_size = params->xbzrle_cache_size;
70
- }
71
- @@ -1667,6 +1676,11 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
72
- if (params->has_multifd_compression) {
73
- s->parameters.multifd_compression = params->multifd_compression;
74
- }
75
- +#ifdef CONFIG_LINUX
76
- + if (params->has_zero_copy_send) {
77
- + s->parameters.zero_copy_send = params->zero_copy_send;
78
- + }
79
- +#endif
80
- if (params->has_xbzrle_cache_size) {
81
- s->parameters.xbzrle_cache_size = params->xbzrle_cache_size;
82
- xbzrle_cache_resize(params->xbzrle_cache_size, errp);
83
- @@ -2557,6 +2571,17 @@ int migrate_multifd_zstd_level(void)
84
- return s->parameters.multifd_zstd_level;
85
- }
86
-
87
- +#ifdef CONFIG_LINUX
88
- +bool migrate_use_zero_copy_send(void)
89
- +{
90
- + MigrationState *s;
91
- +
92
- + s = migrate_get_current();
93
- +
94
- + return s->parameters.zero_copy_send;
95
- +}
96
- +#endif
97
- +
98
- int migrate_use_xbzrle(void)
99
- {
100
- MigrationState *s;
101
- @@ -4200,6 +4225,10 @@ static Property migration_properties[] = {
102
- DEFINE_PROP_UINT8("multifd-zstd-level", MigrationState,
103
- parameters.multifd_zstd_level,
104
- DEFAULT_MIGRATE_MULTIFD_ZSTD_LEVEL),
105
- +#ifdef CONFIG_LINUX
106
- + DEFINE_PROP_BOOL("zero_copy_send", MigrationState,
107
- + parameters.zero_copy_send, false),
108
- +#endif
109
- DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState,
110
- parameters.xbzrle_cache_size,
111
- DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE),
112
- @@ -4297,6 +4326,9 @@ static void migration_instance_init(Object *obj)
113
- params->has_multifd_compression = true;
114
- params->has_multifd_zlib_level = true;
115
- params->has_multifd_zstd_level = true;
116
- +#ifdef CONFIG_LINUX
117
- + params->has_zero_copy_send = true;
118
- +#endif
119
- params->has_xbzrle_cache_size = true;
120
- params->has_max_postcopy_bandwidth = true;
121
- params->has_max_cpu_throttle = true;
122
- diff --git a/migration/migration.h b/migration/migration.h
123
- index 2de861df01..5bcb7628ef 100644
124
- --- a/migration/migration.h
125
- +++ b/migration/migration.h
126
- @@ -376,6 +376,11 @@ MultiFDCompression migrate_multifd_compression(void);
127
- int migrate_multifd_zlib_level(void);
128
- int migrate_multifd_zstd_level(void);
129
-
130
- +#ifdef CONFIG_LINUX
131
- +bool migrate_use_zero_copy_send(void);
132
- +#else
133
- +#define migrate_use_zero_copy_send() (false)
134
- +#endif
135
- int migrate_use_xbzrle(void);
136
- uint64_t migrate_xbzrle_cache_size(void);
137
- bool migrate_colo_enabled(void);
138
- diff --git a/migration/socket.c b/migration/socket.c
139
- index 05705a32d8..3754d8f72c 100644
140
- --- a/migration/socket.c
141
- +++ b/migration/socket.c
142
- @@ -74,9 +74,16 @@ static void socket_outgoing_migration(QIOTask *task,
143
-
144
- if (qio_task_propagate_error(task, &err)) {
145
- trace_migration_socket_outgoing_error(error_get_pretty(err));
146
- - } else {
147
- - trace_migration_socket_outgoing_connected(data->hostname);
148
- + goto out;
149
- }
150
- +
151
- + trace_migration_socket_outgoing_connected(data->hostname);
152
- +
153
- + if (migrate_use_zero_copy_send()) {
154
- + error_setg(&err, "Zero copy send not available in migration");
155
- + }
156
- +
157
- +out:
158
- migration_channel_connect(data->s, sioc, data->hostname, err);
159
- object_unref(OBJECT(sioc));
160
- }
161
- diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
162
- index 634968498b..55b48d3733 100644
163
- --- a/monitor/hmp-cmds.c
164
- +++ b/monitor/hmp-cmds.c
165
- @@ -1309,6 +1309,12 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
166
- p->has_multifd_zstd_level = true;
167
- visit_type_uint8(v, param, &p->multifd_zstd_level, &err);
168
- break;
169
- +#ifdef CONFIG_LINUX
170
- + case MIGRATION_PARAMETER_ZERO_COPY_SEND:
171
- + p->has_zero_copy_send = true;
172
- + visit_type_bool(v, param, &p->zero_copy_send, &err);
173
- + break;
174
- +#endif
175
- case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE:
176
- p->has_xbzrle_cache_size = true;
177
- if (!visit_type_size(v, param, &cache_size, &err)) {
178
- diff --git a/qapi/migration.json b/qapi/migration.json
179
- index 27d7b28158..4d833ecdd6 100644
180
- --- a/qapi/migration.json
181
- +++ b/qapi/migration.json
182
- @@ -741,6 +741,13 @@
183
- # will consume more CPU.
184
- # Defaults to 1. (Since 5.0)
185
- #
186
- +# @zero-copy-send: Controls behavior on sending memory pages on migration.
187
- +# When true, enables a zero-copy mechanism for sending
188
- +# memory pages, if host supports it.
189
- +# Requires that QEMU be permitted to use locked memory
190
- +# for guest RAM pages.
191
- +# Defaults to false. (Since 7.1)
192
- +#
193
- # @block-bitmap-mapping: Maps block nodes and bitmaps on them to
194
- # aliases for the purpose of dirty bitmap migration. Such
195
- # aliases may for example be the corresponding names on the
196
- @@ -780,6 +787,7 @@
197
- 'xbzrle-cache-size', 'max-postcopy-bandwidth',
198
- 'max-cpu-throttle', 'multifd-compression',
199
- 'multifd-zlib-level' ,'multifd-zstd-level',
200
- + { 'name': 'zero-copy-send', 'if' : 'CONFIG_LINUX'},
201
- 'block-bitmap-mapping' ] }
202
-
203
- ##
204
- @@ -906,6 +914,13 @@
205
- # will consume more CPU.
206
- # Defaults to 1. (Since 5.0)
207
- #
208
- +# @zero-copy-send: Controls behavior on sending memory pages on migration.
209
- +# When true, enables a zero-copy mechanism for sending
210
- +# memory pages, if host supports it.
211
- +# Requires that QEMU be permitted to use locked memory
212
- +# for guest RAM pages.
213
- +# Defaults to false. (Since 7.1)
214
- +#
215
- # @block-bitmap-mapping: Maps block nodes and bitmaps on them to
216
- # aliases for the purpose of dirty bitmap migration. Such
217
- # aliases may for example be the corresponding names on the
218
- @@ -960,6 +975,7 @@
219
- '*multifd-compression': 'MultiFDCompression',
220
- '*multifd-zlib-level': 'uint8',
221
- '*multifd-zstd-level': 'uint8',
222
- + '*zero-copy-send': { 'type': 'bool', 'if': 'CONFIG_LINUX' },
223
- '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ] } }
224
-
225
- ##
226
- @@ -1106,6 +1122,13 @@
227
- # will consume more CPU.
228
- # Defaults to 1. (Since 5.0)
229
- #
230
- +# @zero-copy-send: Controls behavior on sending memory pages on migration.
231
- +# When true, enables a zero-copy mechanism for sending
232
- +# memory pages, if host supports it.
233
- +# Requires that QEMU be permitted to use locked memory
234
- +# for guest RAM pages.
235
- +# Defaults to false. (Since 7.1)
236
- +#
237
- # @block-bitmap-mapping: Maps block nodes and bitmaps on them to
238
- # aliases for the purpose of dirty bitmap migration. Such
239
- # aliases may for example be the corresponding names on the
240
- @@ -1158,6 +1181,7 @@
241
- '*multifd-compression': 'MultiFDCompression',
242
- '*multifd-zlib-level': 'uint8',
243
- '*multifd-zstd-level': 'uint8',
244
- + '*zero-copy-send': { 'type': 'bool', 'if': 'CONFIG_LINUX' },
245
- '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ] } }
246
-
247
- ##
248
- --
249
- 2.35.3
250
-
SOURCES/kvm-migration-Allow-migrate-recover-to-run-multiple-time.patch DELETED
@@ -1,98 +0,0 @@
1
- From fd6f516a94e635bc42e58448f314db575814a834 Mon Sep 17 00:00:00 2001
2
- From: Peter Xu <peterx@redhat.com>
3
- Date: Thu, 31 Mar 2022 11:08:45 -0400
4
- Subject: [PATCH 18/18] migration: Allow migrate-recover to run multiple times
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Peter Xu <peterx@redhat.com>
10
- RH-MergeRequest: 104: migration: Allow migrate-recover to run multiple times
11
- RH-Commit: [1/1] afd726e54c069ae800e2d01f34e768d6bac7dcb9 (peterx/qemu-kvm)
12
- RH-Bugzilla: 2096143
13
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
14
- RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
15
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
16
-
17
- Previously migration didn't have an easy way to cleanup the listening
18
- transport, migrate recovery only allows to execute once. That's done with a
19
- trick flag in postcopy_recover_triggered.
20
-
21
- Now the facility is already there.
22
-
23
- Drop postcopy_recover_triggered and instead allows a new migrate-recover to
24
- release the previous listener transport.
25
-
26
- Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
27
- Signed-off-by: Peter Xu <peterx@redhat.com>
28
- Message-Id: <20220331150857.74406-8-peterx@redhat.com>
29
- Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
30
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
31
- (cherry picked from commit 08401c0426bc1a5ce4609afd1cda5dd39abbf9fa)
32
- Signed-off-by: Peter Xu <peterx@redhat.com>
33
- ---
34
- migration/migration.c | 13 ++-----------
35
- migration/migration.h | 1 -
36
- migration/savevm.c | 3 ---
37
- 3 files changed, 2 insertions(+), 15 deletions(-)
38
-
39
- diff --git a/migration/migration.c b/migration/migration.c
40
- index 2a141bfaf3..8fb3eae910 100644
41
- --- a/migration/migration.c
42
- +++ b/migration/migration.c
43
- @@ -2166,11 +2166,8 @@ void qmp_migrate_recover(const char *uri, Error **errp)
44
- return;
45
- }
46
-
47
- - if (qatomic_cmpxchg(&mis->postcopy_recover_triggered,
48
- - false, true) == true) {
49
- - error_setg(errp, "Migrate recovery is triggered already");
50
- - return;
51
- - }
52
- + /* If there's an existing transport, release it */
53
- + migration_incoming_transport_cleanup(mis);
54
-
55
- /*
56
- * Note that this call will never start a real migration; it will
57
- @@ -2178,12 +2175,6 @@ void qmp_migrate_recover(const char *uri, Error **errp)
58
- * to continue using that newly established channel.
59
- */
60
- qemu_start_incoming_migration(uri, errp);
61
- -
62
- - /* Safe to dereference with the assert above */
63
- - if (*errp) {
64
- - /* Reset the flag so user could still retry */
65
- - qatomic_set(&mis->postcopy_recover_triggered, false);
66
- - }
67
- }
68
-
69
- void qmp_migrate_pause(Error **errp)
70
- diff --git a/migration/migration.h b/migration/migration.h
71
- index c2cabb8a14..fbc8690ec8 100644
72
- --- a/migration/migration.h
73
- +++ b/migration/migration.h
74
- @@ -139,7 +139,6 @@ struct MigrationIncomingState {
75
- struct PostcopyBlocktimeContext *blocktime_ctx;
76
-
77
- /* notify PAUSED postcopy incoming migrations to try to continue */
78
- - bool postcopy_recover_triggered;
79
- QemuSemaphore postcopy_pause_sem_dst;
80
- QemuSemaphore postcopy_pause_sem_fault;
81
-
82
- diff --git a/migration/savevm.c b/migration/savevm.c
83
- index 02ed94c180..d9076897b8 100644
84
- --- a/migration/savevm.c
85
- +++ b/migration/savevm.c
86
- @@ -2589,9 +2589,6 @@ static bool postcopy_pause_incoming(MigrationIncomingState *mis)
87
-
88
- assert(migrate_postcopy_ram());
89
-
90
- - /* Clear the triggered bit to allow one recovery */
91
- - mis->postcopy_recover_triggered = false;
92
- -
93
- /*
94
- * Unregister yank with either from/to src would work, since ioc behind it
95
- * is the same
96
- --
97
- 2.35.3
98
-
SOURCES/kvm-migration-Avoid-false-positive-on-non-supported-scen.patch DELETED
@@ -1,93 +0,0 @@
1
- From 0753565af588dfa78b3529e359b1590e15fcbdb3 Mon Sep 17 00:00:00 2001
2
- From: Leonardo Bras <leobras@redhat.com>
3
- Date: Tue, 19 Jul 2022 09:23:45 -0300
4
- Subject: [PATCH 04/11] migration: Avoid false-positive on non-supported
5
- scenarios for zero-copy-send
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Leonardo Brás <leobras@redhat.com>
11
- RH-MergeRequest: 111: zero-copy-send fixes & improvements
12
- RH-Commit: [4/6] f5c7ed6710d92668acb81d0118a71fab0b4e3d43 (LeoBras/centos-qemu-kvm)
13
- RH-Bugzilla: 2107466
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Thomas Huth <thuth@redhat.com>
16
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
17
-
18
- Migration with zero-copy-send currently has it's limitations, as it can't
19
- be used with TLS nor any kind of compression. In such scenarios, it should
20
- output errors during parameter / capability setting.
21
-
22
- But currently there are some ways of setting this not-supported scenarios
23
- without printing the error message:
24
-
25
- !) For 'compression' capability, it works by enabling it together with
26
- zero-copy-send. This happens because the validity test for zero-copy uses
27
- the helper unction migrate_use_compression(), which check for compression
28
- presence in s->enabled_capabilities[MIGRATION_CAPABILITY_COMPRESS].
29
-
30
- The point here is: the validity test happens before the capability gets
31
- enabled. If all of them get enabled together, this test will not return
32
- error.
33
-
34
- In order to fix that, replace migrate_use_compression() by directly testing
35
- the cap_list parameter migrate_caps_check().
36
-
37
- 2) For features enabled by parameters such as TLS & 'multifd_compression',
38
- there was also a possibility of setting non-supported scenarios: setting
39
- zero-copy-send first, then setting the unsupported parameter.
40
-
41
- In order to fix that, also add a check for parameters conflicting with
42
- zero-copy-send on migrate_params_check().
43
-
44
- 3) XBZRLE is also a compression capability, so it makes sense to also add
45
- it to the list of capabilities which are not supported with zero-copy-send.
46
-
47
- Fixes: 1abaec9a1b2c ("migration: Change zero_copy_send from migration parameter to migration capability")
48
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
49
- Message-Id: <20220719122345.253713-1-leobras@redhat.com>
50
- Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
51
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
52
- (cherry picked from commit 90eb69e4f1a16b388d0483543bf6bfc69a9966e4)
53
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
54
- ---
55
- migration/migration.c | 15 ++++++++++++++-
56
- 1 file changed, 14 insertions(+), 1 deletion(-)
57
-
58
- diff --git a/migration/migration.c b/migration/migration.c
59
- index 3a3a7a4a50..343629d59c 100644
60
- --- a/migration/migration.c
61
- +++ b/migration/migration.c
62
- @@ -1265,7 +1265,9 @@ static bool migrate_caps_check(bool *cap_list,
63
- #ifdef CONFIG_LINUX
64
- if (cap_list[MIGRATION_CAPABILITY_ZERO_COPY_SEND] &&
65
- (!cap_list[MIGRATION_CAPABILITY_MULTIFD] ||
66
- - migrate_use_compression() ||
67
- + cap_list[MIGRATION_CAPABILITY_COMPRESS] ||
68
- + cap_list[MIGRATION_CAPABILITY_XBZRLE] ||
69
- + migrate_multifd_compression() ||
70
- migrate_use_tls())) {
71
- error_setg(errp,
72
- "Zero copy only available for non-compressed non-TLS multifd migration");
73
- @@ -1502,6 +1504,17 @@ static bool migrate_params_check(MigrationParameters *params, Error **errp)
74
- error_prepend(errp, "Invalid mapping given for block-bitmap-mapping: ");
75
- return false;
76
- }
77
- +
78
- +#ifdef CONFIG_LINUX
79
- + if (migrate_use_zero_copy_send() &&
80
- + ((params->has_multifd_compression && params->multifd_compression) ||
81
- + (params->has_tls_creds && params->tls_creds && *params->tls_creds))) {
82
- + error_setg(errp,
83
- + "Zero copy only available for non-compressed non-TLS multifd migration");
84
- + return false;
85
- + }
86
- +#endif
87
- +
88
- return true;
89
- }
90
-
91
- --
92
- 2.31.1
93
-
SOURCES/kvm-migration-Change-zero_copy_send-from-migration-param.patch DELETED
@@ -1,289 +0,0 @@
1
- From 7e2a037f3f349c21201152cecce32d8c8ff0bea0 Mon Sep 17 00:00:00 2001
2
- From: Leonardo Bras <leobras@redhat.com>
3
- Date: Mon, 20 Jun 2022 02:39:45 -0300
4
- Subject: [PATCH 17/18] migration: Change zero_copy_send from migration
5
- parameter to migration capability
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Leonardo Brás <leobras@redhat.com>
11
- RH-MergeRequest: 95: MSG_ZEROCOPY + Multifd
12
- RH-Commit: [11/11] e4a955607947896a49398ac8400241a0adac51a1 (LeoBras/centos-qemu-kvm)
13
- RH-Bugzilla: 1968509
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
16
- RH-Acked-by: Peter Xu <peterx@redhat.com>
17
-
18
- When originally implemented, zero_copy_send was designed as a Migration
19
- paramenter.
20
-
21
- But taking into account how is that supposed to work, and how
22
- the difference between a capability and a parameter, it only makes sense
23
- that zero-copy-send would work better as a capability.
24
-
25
- Taking into account how recently the change got merged, it was decided
26
- that it's still time to make it right, and convert zero_copy_send into
27
- a Migration capability.
28
-
29
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
30
- Reviewed-by: Juan Quintela <quintela@redhat.com>
31
- Acked-by: Markus Armbruster <armbru@redhat.com>
32
- Acked-by: Peter Xu <peterx@redhat.com>
33
- Signed-off-by: Juan Quintela <quintela@redhat.com>
34
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
35
- dgilbert: always define the capability, even on non-Linux but error if
36
- set; avoids build problems with the capability
37
- (cherry picked from commit 1abaec9a1b2c23f7aa94709a422128d9e42c3e0b)
38
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
39
- ---
40
- migration/migration.c | 58 +++++++++++++++++++------------------------
41
- monitor/hmp-cmds.c | 6 -----
42
- qapi/migration.json | 33 +++++++-----------------
43
- 3 files changed, 34 insertions(+), 63 deletions(-)
44
-
45
- diff --git a/migration/migration.c b/migration/migration.c
46
- index 102236fba0..2a141bfaf3 100644
47
- --- a/migration/migration.c
48
- +++ b/migration/migration.c
49
- @@ -163,7 +163,8 @@ INITIALIZE_MIGRATE_CAPS_SET(check_caps_background_snapshot,
50
- MIGRATION_CAPABILITY_COMPRESS,
51
- MIGRATION_CAPABILITY_XBZRLE,
52
- MIGRATION_CAPABILITY_X_COLO,
53
- - MIGRATION_CAPABILITY_VALIDATE_UUID);
54
- + MIGRATION_CAPABILITY_VALIDATE_UUID,
55
- + MIGRATION_CAPABILITY_ZERO_COPY_SEND);
56
-
57
- /* When we add fault tolerance, we could have several
58
- migrations at once. For now we don't need to add
59
- @@ -899,10 +900,6 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
60
- params->multifd_zlib_level = s->parameters.multifd_zlib_level;
61
- params->has_multifd_zstd_level = true;
62
- params->multifd_zstd_level = s->parameters.multifd_zstd_level;
63
- -#ifdef CONFIG_LINUX
64
- - params->has_zero_copy_send = true;
65
- - params->zero_copy_send = s->parameters.zero_copy_send;
66
- -#endif
67
- params->has_xbzrle_cache_size = true;
68
- params->xbzrle_cache_size = s->parameters.xbzrle_cache_size;
69
- params->has_max_postcopy_bandwidth = true;
70
- @@ -1263,6 +1260,24 @@ static bool migrate_caps_check(bool *cap_list,
71
- }
72
- }
73
-
74
- +#ifdef CONFIG_LINUX
75
- + if (cap_list[MIGRATION_CAPABILITY_ZERO_COPY_SEND] &&
76
- + (!cap_list[MIGRATION_CAPABILITY_MULTIFD] ||
77
- + migrate_use_compression() ||
78
- + migrate_use_tls())) {
79
- + error_setg(errp,
80
- + "Zero copy only available for non-compressed non-TLS multifd migration");
81
- + return false;
82
- + }
83
- +#else
84
- + if (cap_list[MIGRATION_CAPABILITY_ZERO_COPY_SEND]) {
85
- + error_setg(errp,
86
- + "Zero copy currently only available on Linux");
87
- + return false;
88
- + }
89
- +#endif
90
- +
91
- +
92
- /* incoming side only */
93
- if (runstate_check(RUN_STATE_INMIGRATE) &&
94
- !migrate_multifd_is_allowed() &&
95
- @@ -1485,16 +1500,6 @@ static bool migrate_params_check(MigrationParameters *params, Error **errp)
96
- error_prepend(errp, "Invalid mapping given for block-bitmap-mapping: ");
97
- return false;
98
- }
99
- -#ifdef CONFIG_LINUX
100
- - if (params->zero_copy_send &&
101
- - (!migrate_use_multifd() ||
102
- - params->multifd_compression != MULTIFD_COMPRESSION_NONE ||
103
- - (params->tls_creds && *params->tls_creds))) {
104
- - error_setg(errp,
105
- - "Zero copy only available for non-compressed non-TLS multifd migration");
106
- - return false;
107
- - }
108
- -#endif
109
- return true;
110
- }
111
-
112
- @@ -1568,11 +1573,6 @@ static void migrate_params_test_apply(MigrateSetParameters *params,
113
- if (params->has_multifd_compression) {
114
- dest->multifd_compression = params->multifd_compression;
115
- }
116
- -#ifdef CONFIG_LINUX
117
- - if (params->has_zero_copy_send) {
118
- - dest->zero_copy_send = params->zero_copy_send;
119
- - }
120
- -#endif
121
- if (params->has_xbzrle_cache_size) {
122
- dest->xbzrle_cache_size = params->xbzrle_cache_size;
123
- }
124
- @@ -1685,11 +1685,6 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
125
- if (params->has_multifd_compression) {
126
- s->parameters.multifd_compression = params->multifd_compression;
127
- }
128
- -#ifdef CONFIG_LINUX
129
- - if (params->has_zero_copy_send) {
130
- - s->parameters.zero_copy_send = params->zero_copy_send;
131
- - }
132
- -#endif
133
- if (params->has_xbzrle_cache_size) {
134
- s->parameters.xbzrle_cache_size = params->xbzrle_cache_size;
135
- xbzrle_cache_resize(params->xbzrle_cache_size, errp);
136
- @@ -2587,7 +2582,7 @@ bool migrate_use_zero_copy_send(void)
137
-
138
- s = migrate_get_current();
139
-
140
- - return s->parameters.zero_copy_send;
141
- + return s->enabled_capabilities[MIGRATION_CAPABILITY_ZERO_COPY_SEND];
142
- }
143
- #endif
144
-
145
- @@ -4243,10 +4238,6 @@ static Property migration_properties[] = {
146
- DEFINE_PROP_UINT8("multifd-zstd-level", MigrationState,
147
- parameters.multifd_zstd_level,
148
- DEFAULT_MIGRATE_MULTIFD_ZSTD_LEVEL),
149
- -#ifdef CONFIG_LINUX
150
- - DEFINE_PROP_BOOL("zero_copy_send", MigrationState,
151
- - parameters.zero_copy_send, false),
152
- -#endif
153
- DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState,
154
- parameters.xbzrle_cache_size,
155
- DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE),
156
- @@ -4284,6 +4275,10 @@ static Property migration_properties[] = {
157
- DEFINE_PROP_MIG_CAP("x-multifd", MIGRATION_CAPABILITY_MULTIFD),
158
- DEFINE_PROP_MIG_CAP("x-background-snapshot",
159
- MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT),
160
- +#ifdef CONFIG_LINUX
161
- + DEFINE_PROP_MIG_CAP("x-zero-copy-send",
162
- + MIGRATION_CAPABILITY_ZERO_COPY_SEND),
163
- +#endif
164
-
165
- DEFINE_PROP_END_OF_LIST(),
166
- };
167
- @@ -4344,9 +4339,6 @@ static void migration_instance_init(Object *obj)
168
- params->has_multifd_compression = true;
169
- params->has_multifd_zlib_level = true;
170
- params->has_multifd_zstd_level = true;
171
- -#ifdef CONFIG_LINUX
172
- - params->has_zero_copy_send = true;
173
- -#endif
174
- params->has_xbzrle_cache_size = true;
175
- params->has_max_postcopy_bandwidth = true;
176
- params->has_max_cpu_throttle = true;
177
- diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
178
- index 55b48d3733..634968498b 100644
179
- --- a/monitor/hmp-cmds.c
180
- +++ b/monitor/hmp-cmds.c
181
- @@ -1309,12 +1309,6 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
182
- p->has_multifd_zstd_level = true;
183
- visit_type_uint8(v, param, &p->multifd_zstd_level, &err);
184
- break;
185
- -#ifdef CONFIG_LINUX
186
- - case MIGRATION_PARAMETER_ZERO_COPY_SEND:
187
- - p->has_zero_copy_send = true;
188
- - visit_type_bool(v, param, &p->zero_copy_send, &err);
189
- - break;
190
- -#endif
191
- case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE:
192
- p->has_xbzrle_cache_size = true;
193
- if (!visit_type_size(v, param, &cache_size, &err)) {
194
- diff --git a/qapi/migration.json b/qapi/migration.json
195
- index 4d833ecdd6..5105790cd0 100644
196
- --- a/qapi/migration.json
197
- +++ b/qapi/migration.json
198
- @@ -463,6 +463,13 @@
199
- # procedure starts. The VM RAM is saved with running VM.
200
- # (since 6.0)
201
- #
202
- +# @zero-copy-send: Controls behavior on sending memory pages on migration.
203
- +# When true, enables a zero-copy mechanism for sending
204
- +# memory pages, if host supports it.
205
- +# Requires that QEMU be permitted to use locked memory
206
- +# for guest RAM pages.
207
- +# (since 7.1)
208
- +#
209
- # Features:
210
- # @unstable: Members @x-colo and @x-ignore-shared are experimental.
211
- #
212
- @@ -476,7 +483,8 @@
213
- 'block', 'return-path', 'pause-before-switchover', 'multifd',
214
- 'dirty-bitmaps', 'postcopy-blocktime', 'late-block-activate',
215
- { 'name': 'x-ignore-shared', 'features': [ 'unstable' ] },
216
- - 'validate-uuid', 'background-snapshot'] }
217
- + 'validate-uuid', 'background-snapshot',
218
- + 'zero-copy-send'] }
219
-
220
- ##
221
- # @MigrationCapabilityStatus:
222
- @@ -741,12 +749,6 @@
223
- # will consume more CPU.
224
- # Defaults to 1. (Since 5.0)
225
- #
226
- -# @zero-copy-send: Controls behavior on sending memory pages on migration.
227
- -# When true, enables a zero-copy mechanism for sending
228
- -# memory pages, if host supports it.
229
- -# Requires that QEMU be permitted to use locked memory
230
- -# for guest RAM pages.
231
- -# Defaults to false. (Since 7.1)
232
- #
233
- # @block-bitmap-mapping: Maps block nodes and bitmaps on them to
234
- # aliases for the purpose of dirty bitmap migration. Such
235
- @@ -787,7 +789,6 @@
236
- 'xbzrle-cache-size', 'max-postcopy-bandwidth',
237
- 'max-cpu-throttle', 'multifd-compression',
238
- 'multifd-zlib-level' ,'multifd-zstd-level',
239
- - { 'name': 'zero-copy-send', 'if' : 'CONFIG_LINUX'},
240
- 'block-bitmap-mapping' ] }
241
-
242
- ##
243
- @@ -914,13 +915,6 @@
244
- # will consume more CPU.
245
- # Defaults to 1. (Since 5.0)
246
- #
247
- -# @zero-copy-send: Controls behavior on sending memory pages on migration.
248
- -# When true, enables a zero-copy mechanism for sending
249
- -# memory pages, if host supports it.
250
- -# Requires that QEMU be permitted to use locked memory
251
- -# for guest RAM pages.
252
- -# Defaults to false. (Since 7.1)
253
- -#
254
- # @block-bitmap-mapping: Maps block nodes and bitmaps on them to
255
- # aliases for the purpose of dirty bitmap migration. Such
256
- # aliases may for example be the corresponding names on the
257
- @@ -975,7 +969,6 @@
258
- '*multifd-compression': 'MultiFDCompression',
259
- '*multifd-zlib-level': 'uint8',
260
- '*multifd-zstd-level': 'uint8',
261
- - '*zero-copy-send': { 'type': 'bool', 'if': 'CONFIG_LINUX' },
262
- '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ] } }
263
-
264
- ##
265
- @@ -1122,13 +1115,6 @@
266
- # will consume more CPU.
267
- # Defaults to 1. (Since 5.0)
268
- #
269
- -# @zero-copy-send: Controls behavior on sending memory pages on migration.
270
- -# When true, enables a zero-copy mechanism for sending
271
- -# memory pages, if host supports it.
272
- -# Requires that QEMU be permitted to use locked memory
273
- -# for guest RAM pages.
274
- -# Defaults to false. (Since 7.1)
275
- -#
276
- # @block-bitmap-mapping: Maps block nodes and bitmaps on them to
277
- # aliases for the purpose of dirty bitmap migration. Such
278
- # aliases may for example be the corresponding names on the
279
- @@ -1181,7 +1167,6 @@
280
- '*multifd-compression': 'MultiFDCompression',
281
- '*multifd-zlib-level': 'uint8',
282
- '*multifd-zstd-level': 'uint8',
283
- - '*zero-copy-send': { 'type': 'bool', 'if': 'CONFIG_LINUX' },
284
- '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ] } }
285
-
286
- ##
287
- --
288
- 2.35.3
289
-
SOURCES/kvm-migration-Fix-operator-type.patch DELETED
@@ -1,47 +0,0 @@
1
- From 4bd48e784ae0c38c89f1a944b06c997fd28c4d37 Mon Sep 17 00:00:00 2001
2
- From: Miroslav Rezanina <mrezanin@redhat.com>
3
- Date: Thu, 19 May 2022 04:15:33 -0400
4
- Subject: [PATCH 16/16] migration: Fix operator type
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
10
- RH-MergeRequest: 92: Fix build using clang 14
11
- RH-Commit: [1/1] ad9980e64cf2e39085d68f1ff601444bf2afe228 (mrezanin/centos-src-qemu-kvm)
12
- RH-Bugzilla: 2064530
13
- RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
14
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
15
-
16
- Clang spotted an & that should have been an &&; fix it.
17
-
18
- Reported by: David Binderman / https://gitlab.com/dcb
19
- Fixes: 65dacaa04fa ("migration: introduce save_normal_page()")
20
- Resolves: https://gitlab.com/qemu-project/qemu/-/issues/963
21
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
22
- Message-Id: <20220406102515.96320-1-dgilbert@redhat.com>
23
- Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
24
- Reviewed-by: Peter Xu <peterx@redhat.com>
25
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
26
- (cherry picked from commit f912ec5b2d65644116ff496b58d7c9145c19e4c0)
27
- Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
28
- ---
29
- migration/ram.c | 2 +-
30
- 1 file changed, 1 insertion(+), 1 deletion(-)
31
-
32
- diff --git a/migration/ram.c b/migration/ram.c
33
- index 3532f64ecb..0ef4bd63eb 100644
34
- --- a/migration/ram.c
35
- +++ b/migration/ram.c
36
- @@ -1289,7 +1289,7 @@ static int save_normal_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,
37
- offset | RAM_SAVE_FLAG_PAGE));
38
- if (async) {
39
- qemu_put_buffer_async(rs->f, buf, TARGET_PAGE_SIZE,
40
- - migrate_release_ram() &
41
- + migrate_release_ram() &&
42
- migration_in_postcopy());
43
- } else {
44
- qemu_put_buffer(rs->f, buf, TARGET_PAGE_SIZE);
45
- --
46
- 2.31.1
47
-
SOURCES/kvm-migration-add-remaining-params-has_-true-in-migratio.patch DELETED
@@ -1,62 +0,0 @@
1
- From 9698c0e8dd9b4f5dbc237a3f98ac46297dac85fb Mon Sep 17 00:00:00 2001
2
- From: Leonardo Bras <leobras@redhat.com>
3
- Date: Mon, 25 Jul 2022 22:02:35 -0300
4
- Subject: [PATCH 05/11] migration: add remaining params->has_* = true in
5
- migration_instance_init()
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Leonardo Brás <leobras@redhat.com>
11
- RH-MergeRequest: 111: zero-copy-send fixes & improvements
12
- RH-Commit: [5/6] 50bbad254e2356b3ae16f6e00a3db8fd0b22dde9 (LeoBras/centos-qemu-kvm)
13
- RH-Bugzilla: 2107466
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Thomas Huth <thuth@redhat.com>
16
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
17
-
18
- Some of params->has_* = true are missing in migration_instance_init, this
19
- causes migrate_params_check() to skip some tests, allowing some
20
- unsupported scenarios.
21
-
22
- Fix this by adding all missing params->has_* = true in
23
- migration_instance_init().
24
-
25
- Fixes: 69ef1f36b0 ("migration: define 'tls-creds' and 'tls-hostname' migration parameters")
26
- Fixes: 1d58872a91 ("migration: do not wait for free thread")
27
- Fixes: d2f1d29b95 ("migration: add support for a "tls-authz" migration parameter")
28
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
29
- Message-Id: <20220726010235.342927-1-leobras@redhat.com>
30
- Reviewed-by: Peter Xu <peterx@redhat.com>
31
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
32
- (cherry picked from commit df67aa3e61e2c83459da7d815962d9706f1528fc)
33
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
34
- ---
35
- migration/migration.c | 4 ++++
36
- 1 file changed, 4 insertions(+)
37
-
38
- diff --git a/migration/migration.c b/migration/migration.c
39
- index 343629d59c..5e78028df4 100644
40
- --- a/migration/migration.c
41
- +++ b/migration/migration.c
42
- @@ -4332,6 +4332,7 @@ static void migration_instance_init(Object *obj)
43
- /* Set has_* up only for parameter checks */
44
- params->has_compress_level = true;
45
- params->has_compress_threads = true;
46
- + params->has_compress_wait_thread = true;
47
- params->has_decompress_threads = true;
48
- params->has_throttle_trigger_threshold = true;
49
- params->has_cpu_throttle_initial = true;
50
- @@ -4352,6 +4353,9 @@ static void migration_instance_init(Object *obj)
51
- params->has_announce_max = true;
52
- params->has_announce_rounds = true;
53
- params->has_announce_step = true;
54
- + params->has_tls_creds = true;
55
- + params->has_tls_hostname = true;
56
- + params->has_tls_authz = true;
57
-
58
- qemu_sem_init(&ms->postcopy_pause_sem, 0);
59
- qemu_sem_init(&ms->postcopy_pause_rp_sem, 0);
60
- --
61
- 2.31.1
62
-
SOURCES/kvm-migration-check-magic-value-for-deciding-the-mapping.patch ADDED
@@ -0,0 +1,330 @@
1
+ From 29eee1fbb84c0e2f0ece9e6d996afa7238ed2912 Mon Sep 17 00:00:00 2001
2
+ From: "manish.mishra" <manish.mishra@nutanix.com>
3
+ Date: Tue, 20 Dec 2022 18:44:18 +0000
4
+ Subject: [PATCH 7/8] migration: check magic value for deciding the mapping of
5
+ channels
6
+ MIME-Version: 1.0
7
+ Content-Type: text/plain; charset=UTF-8
8
+ Content-Transfer-Encoding: 8bit
9
+
10
+ RH-Author: Peter Xu <peterx@redhat.com>
11
+ RH-MergeRequest: 150: migration: Fix multifd crash on channel disorders
12
+ RH-Bugzilla: 2169732
13
+ RH-Acked-by: quintela1 <quintela@redhat.com>
14
+ RH-Acked-by: Leonardo Brás <leobras@redhat.com>
15
+ RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
16
+ RH-Commit: [2/2] 4fb9408478923415a91fe0527bf4b1a0f022f329 (peterx/qemu-kvm)
17
+
18
+ Current logic assumes that channel connections on the destination side are
19
+ always established in the same order as the source and the first one will
20
+ always be the main channel followed by the multifid or post-copy
21
+ preemption channel. This may not be always true, as even if a channel has a
22
+ connection established on the source side it can be in the pending state on
23
+ the destination side and a newer connection can be established first.
24
+ Basically causing out of order mapping of channels on the destination side.
25
+ Currently, all channels except post-copy preempt send a magic number, this
26
+ patch uses that magic number to decide the type of channel. This logic is
27
+ applicable only for precopy(multifd) live migration, as mentioned, the
28
+ post-copy preempt channel does not send any magic number. Also, tls live
29
+ migrations already does tls handshake before creating other channels, so
30
+ this issue is not possible with tls, hence this logic is avoided for tls
31
+ live migrations. This patch uses read peek to check the magic number of
32
+ channels so that current data/control stream management remains
33
+ un-effected.
34
+
35
+ Reviewed-by: Peter Xu <peterx@redhat.com>
36
+ Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
37
+ Reviewed-by: Juan Quintela <quintela@redhat.com>
38
+ Suggested-by: Daniel P. Berrange <berrange@redhat.com>
39
+ Signed-off-by: manish.mishra <manish.mishra@nutanix.com>
40
+ Signed-off-by: Juan Quintela <quintela@redhat.com>
41
+ (cherry picked from commit 6720c2b32725e6ac404f22851a0ecd0a71d0cbe2)
42
+ Signed-off-by: Peter Xu <peterx@redhat.com>
43
+ ---
44
+ migration/channel.c | 45 +++++++++++++++++++++++++++++++++
45
+ migration/channel.h | 5 ++++
46
+ migration/migration.c | 54 ++++++++++++++++++++++++++++------------
47
+ migration/multifd.c | 19 +++++++-------
48
+ migration/multifd.h | 2 +-
49
+ migration/postcopy-ram.c | 5 +---
50
+ migration/postcopy-ram.h | 2 +-
51
+ 7 files changed, 101 insertions(+), 31 deletions(-)
52
+
53
+ diff --git a/migration/channel.c b/migration/channel.c
54
+ index 1b0815039f..ca3319a309 100644
55
+ --- a/migration/channel.c
56
+ +++ b/migration/channel.c
57
+ @@ -92,3 +92,48 @@ void migration_channel_connect(MigrationState *s,
58
+ migrate_fd_connect(s, error);
59
+ error_free(error);
60
+ }
61
+ +
62
+ +
63
+ +/**
64
+ + * @migration_channel_read_peek - Peek at migration channel, without
65
+ + * actually removing it from channel buffer.
66
+ + *
67
+ + * @ioc: the channel object
68
+ + * @buf: the memory region to read data into
69
+ + * @buflen: the number of bytes to read in @buf
70
+ + * @errp: pointer to a NULL-initialized error object
71
+ + *
72
+ + * Returns 0 if successful, returns -1 and sets @errp if fails.
73
+ + */
74
+ +int migration_channel_read_peek(QIOChannel *ioc,
75
+ + const char *buf,
76
+ + const size_t buflen,
77
+ + Error **errp)
78
+ +{
79
+ + ssize_t len = 0;
80
+ + struct iovec iov = { .iov_base = (char *)buf, .iov_len = buflen };
81
+ +
82
+ + while (true) {
83
+ + len = qio_channel_readv_full(ioc, &iov, 1, NULL, NULL,
84
+ + QIO_CHANNEL_READ_FLAG_MSG_PEEK, errp);
85
+ +
86
+ + if (len <= 0 && len != QIO_CHANNEL_ERR_BLOCK) {
87
+ + error_setg(errp,
88
+ + "Failed to peek at channel");
89
+ + return -1;
90
+ + }
91
+ +
92
+ + if (len == buflen) {
93
+ + break;
94
+ + }
95
+ +
96
+ + /* 1ms sleep. */
97
+ + if (qemu_in_coroutine()) {
98
+ + qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, 1000000);
99
+ + } else {
100
+ + g_usleep(1000);
101
+ + }
102
+ + }
103
+ +
104
+ + return 0;
105
+ +}
106
+ diff --git a/migration/channel.h b/migration/channel.h
107
+ index 67a461c28a..5bdb8208a7 100644
108
+ --- a/migration/channel.h
109
+ +++ b/migration/channel.h
110
+ @@ -24,4 +24,9 @@ void migration_channel_connect(MigrationState *s,
111
+ QIOChannel *ioc,
112
+ const char *hostname,
113
+ Error *error_in);
114
+ +
115
+ +int migration_channel_read_peek(QIOChannel *ioc,
116
+ + const char *buf,
117
+ + const size_t buflen,
118
+ + Error **errp);
119
+ #endif
120
+ diff --git a/migration/migration.c b/migration/migration.c
121
+ index f485eea5fb..593dbd25de 100644
122
+ --- a/migration/migration.c
123
+ +++ b/migration/migration.c
124
+ @@ -31,6 +31,7 @@
125
+ #include "migration.h"
126
+ #include "savevm.h"
127
+ #include "qemu-file.h"
128
+ +#include "channel.h"
129
+ #include "migration/vmstate.h"
130
+ #include "block/block.h"
131
+ #include "qapi/error.h"
132
+ @@ -663,10 +664,6 @@ static bool migration_incoming_setup(QEMUFile *f, Error **errp)
133
+ {
134
+ MigrationIncomingState *mis = migration_incoming_get_current();
135
+
136
+ - if (multifd_load_setup(errp) != 0) {
137
+ - return false;
138
+ - }
139
+ -
140
+ if (!mis->from_src_file) {
141
+ mis->from_src_file = f;
142
+ }
143
+ @@ -733,31 +730,56 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
144
+ {
145
+ MigrationIncomingState *mis = migration_incoming_get_current();
146
+ Error *local_err = NULL;
147
+ - bool start_migration;
148
+ QEMUFile *f;
149
+ + bool default_channel = true;
150
+ + uint32_t channel_magic = 0;
151
+ + int ret = 0;
152
+
153
+ - if (!mis->from_src_file) {
154
+ - /* The first connection (multifd may have multiple) */
155
+ + if (migrate_use_multifd() && !migrate_postcopy_ram() &&
156
+ + qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_READ_MSG_PEEK)) {
157
+ + /*
158
+ + * With multiple channels, it is possible that we receive channels
159
+ + * out of order on destination side, causing incorrect mapping of
160
+ + * source channels on destination side. Check channel MAGIC to
161
+ + * decide type of channel. Please note this is best effort, postcopy
162
+ + * preempt channel does not send any magic number so avoid it for
163
+ + * postcopy live migration. Also tls live migration already does
164
+ + * tls handshake while initializing main channel so with tls this
165
+ + * issue is not possible.
166
+ + */
167
+ + ret = migration_channel_read_peek(ioc, (void *)&channel_magic,
168
+ + sizeof(channel_magic), &local_err);
169
+ +
170
+ + if (ret != 0) {
171
+ + error_propagate(errp, local_err);
172
+ + return;
173
+ + }
174
+ +
175
+ + default_channel = (channel_magic == cpu_to_be32(QEMU_VM_FILE_MAGIC));
176
+ + } else {
177
+ + default_channel = !mis->from_src_file;
178
+ + }
179
+ +
180
+ + if (multifd_load_setup(errp) != 0) {
181
+ + error_setg(errp, "Failed to setup multifd channels");
182
+ + return;
183
+ + }
184
+ +
185
+ + if (default_channel) {
186
+ f = qemu_file_new_input(ioc);
187
+
188
+ if (!migration_incoming_setup(f, errp)) {
189
+ return;
190
+ }
191
+ -
192
+ - /*
193
+ - * Common migration only needs one channel, so we can start
194
+ - * right now. Some features need more than one channel, we wait.
195
+ - */
196
+ - start_migration = !migration_needs_multiple_sockets();
197
+ } else {
198
+ /* Multiple connections */
199
+ assert(migration_needs_multiple_sockets());
200
+ if (migrate_use_multifd()) {
201
+ - start_migration = multifd_recv_new_channel(ioc, &local_err);
202
+ + multifd_recv_new_channel(ioc, &local_err);
203
+ } else {
204
+ assert(migrate_postcopy_preempt());
205
+ f = qemu_file_new_input(ioc);
206
+ - start_migration = postcopy_preempt_new_channel(mis, f);
207
+ + postcopy_preempt_new_channel(mis, f);
208
+ }
209
+ if (local_err) {
210
+ error_propagate(errp, local_err);
211
+ @@ -765,7 +787,7 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
212
+ }
213
+ }
214
+
215
+ - if (start_migration) {
216
+ + if (migration_has_all_channels()) {
217
+ /* If it's a recovery, we're done */
218
+ if (postcopy_try_recover()) {
219
+ return;
220
+ diff --git a/migration/multifd.c b/migration/multifd.c
221
+ index 509bbbe3bf..c3385529cf 100644
222
+ --- a/migration/multifd.c
223
+ +++ b/migration/multifd.c
224
+ @@ -1167,9 +1167,14 @@ int multifd_load_setup(Error **errp)
225
+ uint32_t page_count = MULTIFD_PACKET_SIZE / qemu_target_page_size();
226
+ uint8_t i;
227
+
228
+ - if (!migrate_use_multifd()) {
229
+ + /*
230
+ + * Return successfully if multiFD recv state is already initialised
231
+ + * or multiFD is not enabled.
232
+ + */
233
+ + if (multifd_recv_state || !migrate_use_multifd()) {
234
+ return 0;
235
+ }
236
+ +
237
+ if (!migrate_multi_channels_is_allowed()) {
238
+ error_setg(errp, "multifd is not supported by current protocol");
239
+ return -1;
240
+ @@ -1228,11 +1233,9 @@ bool multifd_recv_all_channels_created(void)
241
+
242
+ /*
243
+ * Try to receive all multifd channels to get ready for the migration.
244
+ - * - Return true and do not set @errp when correctly receiving all channels;
245
+ - * - Return false and do not set @errp when correctly receiving the current one;
246
+ - * - Return false and set @errp when failing to receive the current channel.
247
+ + * Sets @errp when failing to receive the current channel.
248
+ */
249
+ -bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp)
250
+ +void multifd_recv_new_channel(QIOChannel *ioc, Error **errp)
251
+ {
252
+ MultiFDRecvParams *p;
253
+ Error *local_err = NULL;
254
+ @@ -1245,7 +1248,7 @@ bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp)
255
+ "failed to receive packet"
256
+ " via multifd channel %d: ",
257
+ qatomic_read(&multifd_recv_state->count));
258
+ - return false;
259
+ + return;
260
+ }
261
+ trace_multifd_recv_new_channel(id);
262
+
263
+ @@ -1255,7 +1258,7 @@ bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp)
264
+ id);
265
+ multifd_recv_terminate_threads(local_err);
266
+ error_propagate(errp, local_err);
267
+ - return false;
268
+ + return;
269
+ }
270
+ p->c = ioc;
271
+ object_ref(OBJECT(ioc));
272
+ @@ -1266,6 +1269,4 @@ bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp)
273
+ qemu_thread_create(&p->thread, p->name, multifd_recv_thread, p,
274
+ QEMU_THREAD_JOINABLE);
275
+ qatomic_inc(&multifd_recv_state->count);
276
+ - return qatomic_read(&multifd_recv_state->count) ==
277
+ - migrate_multifd_channels();
278
+ }
279
+ diff --git a/migration/multifd.h b/migration/multifd.h
280
+ index 519f498643..913e4ba274 100644
281
+ --- a/migration/multifd.h
282
+ +++ b/migration/multifd.h
283
+ @@ -18,7 +18,7 @@ void multifd_save_cleanup(void);
284
+ int multifd_load_setup(Error **errp);
285
+ int multifd_load_cleanup(Error **errp);
286
+ bool multifd_recv_all_channels_created(void);
287
+ -bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp);
288
+ +void multifd_recv_new_channel(QIOChannel *ioc, Error **errp);
289
+ void multifd_recv_sync_main(void);
290
+ int multifd_send_sync_main(QEMUFile *f);
291
+ int multifd_queue_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset);
292
+ diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
293
+ index 0c55df0e52..b98e95dab0 100644
294
+ --- a/migration/postcopy-ram.c
295
+ +++ b/migration/postcopy-ram.c
296
+ @@ -1538,7 +1538,7 @@ void postcopy_unregister_shared_ufd(struct PostCopyFD *pcfd)
297
+ }
298
+ }
299
+
300
+ -bool postcopy_preempt_new_channel(MigrationIncomingState *mis, QEMUFile *file)
301
+ +void postcopy_preempt_new_channel(MigrationIncomingState *mis, QEMUFile *file)
302
+ {
303
+ /*
304
+ * The new loading channel has its own threads, so it needs to be
305
+ @@ -1547,9 +1547,6 @@ bool postcopy_preempt_new_channel(MigrationIncomingState *mis, QEMUFile *file)
306
+ qemu_file_set_blocking(file, true);
307
+ mis->postcopy_qemufile_dst = file;
308
+ trace_postcopy_preempt_new_channel();
309
+ -
310
+ - /* Start the migration immediately */
311
+ - return true;
312
+ }
313
+
314
+ /*
315
+ diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h
316
+ index 6147bf7d1d..25881c4127 100644
317
+ --- a/migration/postcopy-ram.h
318
+ +++ b/migration/postcopy-ram.h
319
+ @@ -190,7 +190,7 @@ enum PostcopyChannels {
320
+ RAM_CHANNEL_MAX,
321
+ };
322
+
323
+ -bool postcopy_preempt_new_channel(MigrationIncomingState *mis, QEMUFile *file);
324
+ +void postcopy_preempt_new_channel(MigrationIncomingState *mis, QEMUFile *file);
325
+ int postcopy_preempt_setup(MigrationState *s, Error **errp);
326
+ int postcopy_preempt_wait_channel(MigrationState *s);
327
+
328
+ --
329
+ 2.31.1
330
+
SOURCES/kvm-migration-multifd-Report-to-user-when-zerocopy-not-w.patch DELETED
@@ -1,83 +0,0 @@
1
- From 78bbe28d5f5691330239041448cccfb339eed779 Mon Sep 17 00:00:00 2001
2
- From: Leonardo Bras <leobras@redhat.com>
3
- Date: Mon, 11 Jul 2022 18:11:13 -0300
4
- Subject: [PATCH 03/11] migration/multifd: Report to user when zerocopy not
5
- working
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Leonardo Brás <leobras@redhat.com>
11
- RH-MergeRequest: 111: zero-copy-send fixes & improvements
12
- RH-Commit: [3/6] 4f9165325b3cb8ff16d8b3b7649ff780fae0e2ad (LeoBras/centos-qemu-kvm)
13
- RH-Bugzilla: 2107466
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Thomas Huth <thuth@redhat.com>
16
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
17
-
18
- Some errors, like the lack of Scatter-Gather support by the network
19
- interface(NETIF_F_SG) may cause sendmsg(...,MSG_ZEROCOPY) to fail on using
20
- zero-copy, which causes it to fall back to the default copying mechanism.
21
-
22
- After each full dirty-bitmap scan there should be a zero-copy flush
23
- happening, which checks for errors each of the previous calls to
24
- sendmsg(...,MSG_ZEROCOPY). If all of them failed to use zero-copy, then
25
- increment dirty_sync_missed_zero_copy migration stat to let the user know
26
- about it.
27
-
28
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
29
- Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
30
- Acked-by: Peter Xu <peterx@redhat.com>
31
- Message-Id: <20220711211112.18951-4-leobras@redhat.com>
32
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
33
- (cherry picked from commit d59c40cc483729f2e67c80e58df769ad19976fe9)
34
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
35
- ---
36
- migration/multifd.c | 2 ++
37
- migration/ram.c | 5 +++++
38
- migration/ram.h | 2 ++
39
- 3 files changed, 9 insertions(+)
40
-
41
- diff --git a/migration/multifd.c b/migration/multifd.c
42
- index 0b5b41c53f..96e5f0a058 100644
43
- --- a/migration/multifd.c
44
- +++ b/migration/multifd.c
45
- @@ -626,6 +626,8 @@ int multifd_send_sync_main(QEMUFile *f)
46
- if (ret < 0) {
47
- error_report_err(err);
48
- return -1;
49
- + } else if (ret == 1) {
50
- + dirty_sync_missed_zero_copy();
51
- }
52
- }
53
- }
54
- diff --git a/migration/ram.c b/migration/ram.c
55
- index ee40e4a718..c437ff1b1f 100644
56
- --- a/migration/ram.c
57
- +++ b/migration/ram.c
58
- @@ -406,6 +406,11 @@ static void ram_transferred_add(uint64_t bytes)
59
- ram_counters.transferred += bytes;
60
- }
61
-
62
- +void dirty_sync_missed_zero_copy(void)
63
- +{
64
- + ram_counters.dirty_sync_missed_zero_copy++;
65
- +}
66
- +
67
- /* used by the search for pages to send */
68
- struct PageSearchStatus {
69
- /* Current block being searched */
70
- diff --git a/migration/ram.h b/migration/ram.h
71
- index 2c6dc3675d..34adf5cb92 100644
72
- --- a/migration/ram.h
73
- +++ b/migration/ram.h
74
- @@ -86,4 +86,6 @@ void ram_write_tracking_prepare(void);
75
- int ram_write_tracking_start(void);
76
- void ram_write_tracking_stop(void);
77
-
78
- +void dirty_sync_missed_zero_copy(void);
79
- +
80
- #endif
81
- --
82
- 2.31.1
83
-
SOURCES/kvm-multifd-Copy-pages-before-compressing-them-with-zlib.patch DELETED
@@ -1,142 +0,0 @@
1
- From 1d280070748b604c60a7be4d4c3c3a28e3964f37 Mon Sep 17 00:00:00 2001
2
- From: Thomas Huth <thuth@redhat.com>
3
- Date: Tue, 2 Aug 2022 10:11:21 +0200
4
- Subject: [PATCH 31/32] multifd: Copy pages before compressing them with zlib
5
-
6
- RH-Author: Thomas Huth <thuth@redhat.com>
7
- RH-MergeRequest: 112: Fix postcopy migration on s390x
8
- RH-Commit: [1/2] fd5a0221e22b4563bd1cb7f8a8b95f0bfe8f5fc9 (thuth/qemu-kvm-cs9)
9
- RH-Bugzilla: 2099934
10
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
11
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
12
- RH-Acked-by: David Hildenbrand <david@redhat.com>
13
- RH-Acked-by: Peter Xu <peterx@redhat.com>
14
-
15
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2099934
16
-
17
- zlib_send_prepare() compresses pages of a running VM. zlib does not
18
- make any thread-safety guarantees with respect to changing deflate()
19
- input concurrently with deflate() [1].
20
-
21
- One can observe problems due to this with the IBM zEnterprise Data
22
- Compression accelerator capable zlib [2]. When the hardware
23
- acceleration is enabled, migration/multifd/tcp/plain/zlib test fails
24
- intermittently [3] due to sliding window corruption. The accelerator's
25
- architecture explicitly discourages concurrent accesses [4]:
26
-
27
- Page 26-57, "Other Conditions":
28
-
29
- As observed by this CPU, other CPUs, and channel
30
- programs, references to the parameter block, first,
31
- second, and third operands may be multiple-access
32
- references, accesses to these storage locations are
33
- not necessarily block-concurrent, and the sequence
34
- of these accesses or references is undefined.
35
-
36
- Mark Adler pointed out that vanilla zlib performs double fetches under
37
- certain circumstances as well [5], therefore we need to copy data
38
- before passing it to deflate().
39
-
40
- [1] https://zlib.net/manual.html
41
- [2] https://github.com/madler/zlib/pull/410
42
- [3] https://lists.nongnu.org/archive/html/qemu-devel/2022-03/msg03988.html
43
- [4] http://publibfp.dhe.ibm.com/epubs/pdf/a227832c.pdf
44
- [5] https://lists.gnu.org/archive/html/qemu-devel/2022-07/msg00889.html
45
-
46
- Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
47
- Message-Id: <20220705203559.2960949-1-iii@linux.ibm.com>
48
- Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
49
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
50
- (cherry picked from commit 007e179ef0e97eafda4c9ff2a9d665a1947c7c6d)
51
- Signed-off-by: Thomas Huth <thuth@redhat.com>
52
- ---
53
- migration/multifd-zlib.c | 38 ++++++++++++++++++++++++++++++--------
54
- 1 file changed, 30 insertions(+), 8 deletions(-)
55
-
56
- diff --git a/migration/multifd-zlib.c b/migration/multifd-zlib.c
57
- index 3a7ae44485..18213a9513 100644
58
- --- a/migration/multifd-zlib.c
59
- +++ b/migration/multifd-zlib.c
60
- @@ -27,6 +27,8 @@ struct zlib_data {
61
- uint8_t *zbuff;
62
- /* size of compressed buffer */
63
- uint32_t zbuff_len;
64
- + /* uncompressed buffer of size qemu_target_page_size() */
65
- + uint8_t *buf;
66
- };
67
-
68
- /* Multifd zlib compression */
69
- @@ -45,26 +47,38 @@ static int zlib_send_setup(MultiFDSendParams *p, Error **errp)
70
- {
71
- struct zlib_data *z = g_new0(struct zlib_data, 1);
72
- z_stream *zs = &z->zs;
73
- + const char *err_msg;
74
-
75
- zs->zalloc = Z_NULL;
76
- zs->zfree = Z_NULL;
77
- zs->opaque = Z_NULL;
78
- if (deflateInit(zs, migrate_multifd_zlib_level()) != Z_OK) {
79
- - g_free(z);
80
- - error_setg(errp, "multifd %u: deflate init failed", p->id);
81
- - return -1;
82
- + err_msg = "deflate init failed";
83
- + goto err_free_z;
84
- }
85
- /* This is the maxium size of the compressed buffer */
86
- z->zbuff_len = compressBound(MULTIFD_PACKET_SIZE);
87
- z->zbuff = g_try_malloc(z->zbuff_len);
88
- if (!z->zbuff) {
89
- - deflateEnd(&z->zs);
90
- - g_free(z);
91
- - error_setg(errp, "multifd %u: out of memory for zbuff", p->id);
92
- - return -1;
93
- + err_msg = "out of memory for zbuff";
94
- + goto err_deflate_end;
95
- + }
96
- + z->buf = g_try_malloc(qemu_target_page_size());
97
- + if (!z->buf) {
98
- + err_msg = "out of memory for buf";
99
- + goto err_free_zbuff;
100
- }
101
- p->data = z;
102
- return 0;
103
- +
104
- +err_free_zbuff:
105
- + g_free(z->zbuff);
106
- +err_deflate_end:
107
- + deflateEnd(&z->zs);
108
- +err_free_z:
109
- + g_free(z);
110
- + error_setg(errp, "multifd %u: %s", p->id, err_msg);
111
- + return -1;
112
- }
113
-
114
- /**
115
- @@ -82,6 +96,8 @@ static void zlib_send_cleanup(MultiFDSendParams *p, Error **errp)
116
- deflateEnd(&z->zs);
117
- g_free(z->zbuff);
118
- z->zbuff = NULL;
119
- + g_free(z->buf);
120
- + z->buf = NULL;
121
- g_free(p->data);
122
- p->data = NULL;
123
- }
124
- @@ -114,8 +130,14 @@ static int zlib_send_prepare(MultiFDSendParams *p, Error **errp)
125
- flush = Z_SYNC_FLUSH;
126
- }
127
-
128
- + /*
129
- + * Since the VM might be running, the page may be changing concurrently
130
- + * with compression. zlib does not guarantee that this is safe,
131
- + * therefore copy the page before calling deflate().
132
- + */
133
- + memcpy(z->buf, p->pages->block->host + p->normal[i], page_size);
134
- zs->avail_in = page_size;
135
- - zs->next_in = p->pages->block->host + p->normal[i];
136
- + zs->next_in = z->buf;
137
-
138
- zs->avail_out = available;
139
- zs->next_out = z->zbuff + out_size;
140
- --
141
- 2.31.1
142
-
SOURCES/kvm-multifd-Implement-zero-copy-write-in-multifd-migrati.patch DELETED
@@ -1,182 +0,0 @@
1
- From c1a2866d158ac67179fa0d17f1710302eb9a3866 Mon Sep 17 00:00:00 2001
2
- From: Leonardo Bras <leobras@redhat.com>
3
- Date: Fri, 13 May 2022 03:28:37 -0300
4
- Subject: [PATCH 14/18] multifd: Implement zero copy write in multifd migration
5
- (multifd-zero-copy)
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Leonardo Brás <leobras@redhat.com>
11
- RH-MergeRequest: 95: MSG_ZEROCOPY + Multifd
12
- RH-Commit: [8/11] b93009cc94b2cc4b464b4f68ebfb37b870dd6f7d (LeoBras/centos-qemu-kvm)
13
- RH-Bugzilla: 1968509
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
16
- RH-Acked-by: Peter Xu <peterx@redhat.com>
17
-
18
- Implement zero copy send on nocomp_send_write(), by making use of QIOChannel
19
- writev + flags & flush interface.
20
-
21
- Change multifd_send_sync_main() so flush_zero_copy() can be called
22
- after each iteration in order to make sure all dirty pages are sent before
23
- a new iteration is started. It will also flush at the beginning and at the
24
- end of migration.
25
-
26
- Also make it return -1 if flush_zero_copy() fails, in order to cancel
27
- the migration process, and avoid resuming the guest in the target host
28
- without receiving all current RAM.
29
-
30
- This will work fine on RAM migration because the RAM pages are not usually freed,
31
- and there is no problem on changing the pages content between writev_zero_copy() and
32
- the actual sending of the buffer, because this change will dirty the page and
33
- cause it to be re-sent on a next iteration anyway.
34
-
35
- A lot of locked memory may be needed in order to use multifd migration
36
- with zero-copy enabled, so disabling the feature should be necessary for
37
- low-privileged users trying to perform multifd migrations.
38
-
39
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
40
- Reviewed-by: Peter Xu <peterx@redhat.com>
41
- Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
42
- Message-Id: <20220513062836.965425-9-leobras@redhat.com>
43
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
44
- (cherry picked from commit 5b1d9bab2da4fca3a3caee97c430e5709cb32b7b)
45
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
46
- ---
47
- migration/migration.c | 11 ++++++++++-
48
- migration/multifd.c | 37 +++++++++++++++++++++++++++++++++++--
49
- migration/multifd.h | 2 ++
50
- migration/socket.c | 5 +++--
51
- 4 files changed, 50 insertions(+), 5 deletions(-)
52
-
53
- diff --git a/migration/migration.c b/migration/migration.c
54
- index d91efb66fe..102236fba0 100644
55
- --- a/migration/migration.c
56
- +++ b/migration/migration.c
57
- @@ -1485,7 +1485,16 @@ static bool migrate_params_check(MigrationParameters *params, Error **errp)
58
- error_prepend(errp, "Invalid mapping given for block-bitmap-mapping: ");
59
- return false;
60
- }
61
- -
62
- +#ifdef CONFIG_LINUX
63
- + if (params->zero_copy_send &&
64
- + (!migrate_use_multifd() ||
65
- + params->multifd_compression != MULTIFD_COMPRESSION_NONE ||
66
- + (params->tls_creds && *params->tls_creds))) {
67
- + error_setg(errp,
68
- + "Zero copy only available for non-compressed non-TLS multifd migration");
69
- + return false;
70
- + }
71
- +#endif
72
- return true;
73
- }
74
-
75
- diff --git a/migration/multifd.c b/migration/multifd.c
76
- index 8fca6c970e..0b5b41c53f 100644
77
- --- a/migration/multifd.c
78
- +++ b/migration/multifd.c
79
- @@ -571,6 +571,7 @@ void multifd_save_cleanup(void)
80
- int multifd_send_sync_main(QEMUFile *f)
81
- {
82
- int i;
83
- + bool flush_zero_copy;
84
-
85
- if (!migrate_use_multifd()) {
86
- return 0;
87
- @@ -581,6 +582,20 @@ int multifd_send_sync_main(QEMUFile *f)
88
- return -1;
89
- }
90
- }
91
- +
92
- + /*
93
- + * When using zero-copy, it's necessary to flush the pages before any of
94
- + * the pages can be sent again, so we'll make sure the new version of the
95
- + * pages will always arrive _later_ than the old pages.
96
- + *
97
- + * Currently we achieve this by flushing the zero-page requested writes
98
- + * per ram iteration, but in the future we could potentially optimize it
99
- + * to be less frequent, e.g. only after we finished one whole scanning of
100
- + * all the dirty bitmaps.
101
- + */
102
- +
103
- + flush_zero_copy = migrate_use_zero_copy_send();
104
- +
105
- for (i = 0; i < migrate_multifd_channels(); i++) {
106
- MultiFDSendParams *p = &multifd_send_state->params[i];
107
-
108
- @@ -602,6 +617,17 @@ int multifd_send_sync_main(QEMUFile *f)
109
- ram_counters.transferred += p->packet_len;
110
- qemu_mutex_unlock(&p->mutex);
111
- qemu_sem_post(&p->sem);
112
- +
113
- + if (flush_zero_copy && p->c) {
114
- + int ret;
115
- + Error *err = NULL;
116
- +
117
- + ret = qio_channel_flush(p->c, &err);
118
- + if (ret < 0) {
119
- + error_report_err(err);
120
- + return -1;
121
- + }
122
- + }
123
- }
124
- for (i = 0; i < migrate_multifd_channels(); i++) {
125
- MultiFDSendParams *p = &multifd_send_state->params[i];
126
- @@ -686,8 +712,8 @@ static void *multifd_send_thread(void *opaque)
127
- p->iov[0].iov_base = p->packet;
128
- }
129
-
130
- - ret = qio_channel_writev_all(p->c, p->iov, p->iovs_num,
131
- - &local_err);
132
- + ret = qio_channel_writev_full_all(p->c, p->iov, p->iovs_num, NULL,
133
- + 0, p->write_flags, &local_err);
134
- if (ret != 0) {
135
- break;
136
- }
137
- @@ -928,6 +954,13 @@ int multifd_save_setup(Error **errp)
138
- /* We need one extra place for the packet header */
139
- p->iov = g_new0(struct iovec, page_count + 1);
140
- p->normal = g_new0(ram_addr_t, page_count);
141
- +
142
- + if (migrate_use_zero_copy_send()) {
143
- + p->write_flags = QIO_CHANNEL_WRITE_FLAG_ZERO_COPY;
144
- + } else {
145
- + p->write_flags = 0;
146
- + }
147
- +
148
- socket_send_channel_create(multifd_new_send_channel_async, p);
149
- }
150
-
151
- diff --git a/migration/multifd.h b/migration/multifd.h
152
- index cd495195ce..7ec688fb4f 100644
153
- --- a/migration/multifd.h
154
- +++ b/migration/multifd.h
155
- @@ -96,6 +96,8 @@ typedef struct {
156
- uint32_t packet_len;
157
- /* pointer to the packet */
158
- MultiFDPacket_t *packet;
159
- + /* multifd flags for sending ram */
160
- + int write_flags;
161
- /* multifd flags for each packet */
162
- uint32_t flags;
163
- /* size of the next packet that contains pages */
164
- diff --git a/migration/socket.c b/migration/socket.c
165
- index 3754d8f72c..4fd5e85f50 100644
166
- --- a/migration/socket.c
167
- +++ b/migration/socket.c
168
- @@ -79,8 +79,9 @@ static void socket_outgoing_migration(QIOTask *task,
169
-
170
- trace_migration_socket_outgoing_connected(data->hostname);
171
-
172
- - if (migrate_use_zero_copy_send()) {
173
- - error_setg(&err, "Zero copy send not available in migration");
174
- + if (migrate_use_zero_copy_send() &&
175
- + !qio_channel_has_feature(sioc, QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY)) {
176
- + error_setg(&err, "Zero copy send feature not detected in host kernel");
177
- }
178
-
179
- out:
180
- --
181
- 2.35.3
182
-
SOURCES/kvm-multifd-Send-header-packet-without-flags-if-zero-cop.patch DELETED
@@ -1,102 +0,0 @@
1
- From 63255c13492f42a3236d96e706e5f8e70bb4e219 Mon Sep 17 00:00:00 2001
2
- From: Leonardo Bras <leobras@redhat.com>
3
- Date: Fri, 13 May 2022 03:28:36 -0300
4
- Subject: [PATCH 13/18] multifd: Send header packet without flags if
5
- zero-copy-send is enabled
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Leonardo Brás <leobras@redhat.com>
11
- RH-MergeRequest: 95: MSG_ZEROCOPY + Multifd
12
- RH-Commit: [7/11] 137eea685e387d3d6aff187ec3fcac05bc16b6e3 (LeoBras/centos-qemu-kvm)
13
- RH-Bugzilla: 1968509
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
16
- RH-Acked-by: Peter Xu <peterx@redhat.com>
17
-
18
- Since d48c3a0445 ("multifd: Use a single writev on the send side"),
19
- sending the header packet and the memory pages happens in the same
20
- writev, which can potentially make the migration faster.
21
-
22
- Using channel-socket as example, this works well with the default copying
23
- mechanism of sendmsg(), but with zero-copy-send=true, it will cause
24
- the migration to often break.
25
-
26
- This happens because the header packet buffer gets reused quite often,
27
- and there is a high chance that by the time the MSG_ZEROCOPY mechanism get
28
- to send the buffer, it has already changed, sending the wrong data and
29
- causing the migration to abort.
30
-
31
- It means that, as it is, the buffer for the header packet is not suitable
32
- for sending with MSG_ZEROCOPY.
33
-
34
- In order to enable zero copy for multifd, send the header packet on an
35
- individual write(), without any flags, and the remanining pages with a
36
- writev(), as it was happening before. This only changes how a migration
37
- with zero-copy-send=true works, not changing any current behavior for
38
- migrations with zero-copy-send=false.
39
-
40
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
41
- Reviewed-by: Peter Xu <peterx@redhat.com>
42
- Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
43
- Message-Id: <20220513062836.965425-8-leobras@redhat.com>
44
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
45
- (cherry picked from commit b7dbdd8e76cd03453c234dbb9578d20969859d74)
46
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
47
- ---
48
- migration/multifd.c | 22 +++++++++++++++++++---
49
- 1 file changed, 19 insertions(+), 3 deletions(-)
50
-
51
- diff --git a/migration/multifd.c b/migration/multifd.c
52
- index cdb57439a7..8fca6c970e 100644
53
- --- a/migration/multifd.c
54
- +++ b/migration/multifd.c
55
- @@ -619,6 +619,7 @@ static void *multifd_send_thread(void *opaque)
56
- MultiFDSendParams *p = opaque;
57
- Error *local_err = NULL;
58
- int ret = 0;
59
- + bool use_zero_copy_send = migrate_use_zero_copy_send();
60
-
61
- trace_multifd_send_thread_start(p->id);
62
- rcu_register_thread();
63
- @@ -641,9 +642,14 @@ static void *multifd_send_thread(void *opaque)
64
- if (p->pending_job) {
65
- uint64_t packet_num = p->packet_num;
66
- uint32_t flags = p->flags;
67
- - p->iovs_num = 1;
68
- p->normal_num = 0;
69
-
70
- + if (use_zero_copy_send) {
71
- + p->iovs_num = 0;
72
- + } else {
73
- + p->iovs_num = 1;
74
- + }
75
- +
76
- for (int i = 0; i < p->pages->num; i++) {
77
- p->normal[p->normal_num] = p->pages->offset[i];
78
- p->normal_num++;
79
- @@ -667,8 +673,18 @@ static void *multifd_send_thread(void *opaque)
80
- trace_multifd_send(p->id, packet_num, p->normal_num, flags,
81
- p->next_packet_size);
82
-
83
- - p->iov[0].iov_len = p->packet_len;
84
- - p->iov[0].iov_base = p->packet;
85
- + if (use_zero_copy_send) {
86
- + /* Send header first, without zerocopy */
87
- + ret = qio_channel_write_all(p->c, (void *)p->packet,
88
- + p->packet_len, &local_err);
89
- + if (ret != 0) {
90
- + break;
91
- + }
92
- + } else {
93
- + /* Send header using the same writev call */
94
- + p->iov[0].iov_len = p->packet_len;
95
- + p->iov[0].iov_base = p->packet;
96
- + }
97
-
98
- ret = qio_channel_writev_all(p->c, p->iov, p->iovs_num,
99
- &local_err);
100
- --
101
- 2.35.3
102
-
SOURCES/kvm-multifd-multifd_send_sync_main-now-returns-negative-.patch DELETED
@@ -1,163 +0,0 @@
1
- From 4ca5375a936bc87829c6e2b4620f56c73a5efc70 Mon Sep 17 00:00:00 2001
2
- From: Leonardo Bras <leobras@redhat.com>
3
- Date: Fri, 13 May 2022 03:28:35 -0300
4
- Subject: [PATCH 12/18] multifd: multifd_send_sync_main now returns negative on
5
- error
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Leonardo Brás <leobras@redhat.com>
11
- RH-MergeRequest: 95: MSG_ZEROCOPY + Multifd
12
- RH-Commit: [6/11] c8ebdee4327d463c74f4b2eeb42d3c964f314c94 (LeoBras/centos-qemu-kvm)
13
- RH-Bugzilla: 1968509
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
16
- RH-Acked-by: Peter Xu <peterx@redhat.com>
17
-
18
- Even though multifd_send_sync_main() currently emits error_reports, it's
19
- callers don't really check it before continuing.
20
-
21
- Change multifd_send_sync_main() to return -1 on error and 0 on success.
22
- Also change all it's callers to make use of this change and possibly fail
23
- earlier.
24
-
25
- (This change is important to next patch on multifd zero copy
26
- implementation, to make it sure an error in zero-copy flush does not go
27
- unnoticed.
28
-
29
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
30
- Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
31
- Reviewed-by: Peter Xu <peterx@redhat.com>
32
- Message-Id: <20220513062836.965425-7-leobras@redhat.com>
33
- Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
34
- (cherry picked from commit 33d70973a3a6e8c6b62bcbc64d9e488961981007)
35
- Signed-off-by: Leonardo Bras <leobras@redhat.com>
36
- ---
37
- migration/multifd.c | 10 ++++++----
38
- migration/multifd.h | 2 +-
39
- migration/ram.c | 29 ++++++++++++++++++++++-------
40
- 3 files changed, 29 insertions(+), 12 deletions(-)
41
-
42
- diff --git a/migration/multifd.c b/migration/multifd.c
43
- index 43998ad117..cdb57439a7 100644
44
- --- a/migration/multifd.c
45
- +++ b/migration/multifd.c
46
- @@ -568,17 +568,17 @@ void multifd_save_cleanup(void)
47
- multifd_send_state = NULL;
48
- }
49
-
50
- -void multifd_send_sync_main(QEMUFile *f)
51
- +int multifd_send_sync_main(QEMUFile *f)
52
- {
53
- int i;
54
-
55
- if (!migrate_use_multifd()) {
56
- - return;
57
- + return 0;
58
- }
59
- if (multifd_send_state->pages->num) {
60
- if (multifd_send_pages(f) < 0) {
61
- error_report("%s: multifd_send_pages fail", __func__);
62
- - return;
63
- + return -1;
64
- }
65
- }
66
- for (i = 0; i < migrate_multifd_channels(); i++) {
67
- @@ -591,7 +591,7 @@ void multifd_send_sync_main(QEMUFile *f)
68
- if (p->quit) {
69
- error_report("%s: channel %d has already quit", __func__, i);
70
- qemu_mutex_unlock(&p->mutex);
71
- - return;
72
- + return -1;
73
- }
74
-
75
- p->packet_num = multifd_send_state->packet_num++;
76
- @@ -610,6 +610,8 @@ void multifd_send_sync_main(QEMUFile *f)
77
- qemu_sem_wait(&p->sem_sync);
78
- }
79
- trace_multifd_send_sync_main(multifd_send_state->packet_num);
80
- +
81
- + return 0;
82
- }
83
-
84
- static void *multifd_send_thread(void *opaque)
85
- diff --git a/migration/multifd.h b/migration/multifd.h
86
- index 4dda900a0b..cd495195ce 100644
87
- --- a/migration/multifd.h
88
- +++ b/migration/multifd.h
89
- @@ -22,7 +22,7 @@ int multifd_load_cleanup(Error **errp);
90
- bool multifd_recv_all_channels_created(void);
91
- bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp);
92
- void multifd_recv_sync_main(void);
93
- -void multifd_send_sync_main(QEMUFile *f);
94
- +int multifd_send_sync_main(QEMUFile *f);
95
- int multifd_queue_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset);
96
-
97
- /* Multifd Compression flags */
98
- diff --git a/migration/ram.c b/migration/ram.c
99
- index 0ef4bd63eb..fb6db54642 100644
100
- --- a/migration/ram.c
101
- +++ b/migration/ram.c
102
- @@ -2903,6 +2903,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
103
- {
104
- RAMState **rsp = opaque;
105
- RAMBlock *block;
106
- + int ret;
107
-
108
- if (compress_threads_save_setup()) {
109
- return -1;
110
- @@ -2937,7 +2938,11 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
111
- ram_control_before_iterate(f, RAM_CONTROL_SETUP);
112
- ram_control_after_iterate(f, RAM_CONTROL_SETUP);
113
-
114
- - multifd_send_sync_main(f);
115
- + ret = multifd_send_sync_main(f);
116
- + if (ret < 0) {
117
- + return ret;
118
- + }
119
- +
120
- qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
121
- qemu_fflush(f);
122
-
123
- @@ -3046,7 +3051,11 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
124
- out:
125
- if (ret >= 0
126
- && migration_is_setup_or_active(migrate_get_current()->state)) {
127
- - multifd_send_sync_main(rs->f);
128
- + ret = multifd_send_sync_main(rs->f);
129
- + if (ret < 0) {
130
- + return ret;
131
- + }
132
- +
133
- qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
134
- qemu_fflush(f);
135
- ram_transferred_add(8);
136
- @@ -3106,13 +3115,19 @@ static int ram_save_complete(QEMUFile *f, void *opaque)
137
- ram_control_after_iterate(f, RAM_CONTROL_FINISH);
138
- }
139
-
140
- - if (ret >= 0) {
141
- - multifd_send_sync_main(rs->f);
142
- - qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
143
- - qemu_fflush(f);
144
- + if (ret < 0) {
145
- + return ret;
146
- }
147
-
148
- - return ret;
149
- + ret = multifd_send_sync_main(rs->f);
150
- + if (ret < 0) {
151
- + return ret;
152
- + }
153
- +
154
- + qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
155
- + qemu_fflush(f);
156
- +
157
- + return 0;
158
- }
159
-
160
- static void ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_size,
161
- --
162
- 2.35.3
163
-
SOURCES/kvm-nbd-server-Allow-MULTI_CONN-for-shared-writable-expo.patch DELETED
@@ -1,381 +0,0 @@
1
- From 4a9ddf42788d3f924bdad7746f7aca615f03d7c1 Mon Sep 17 00:00:00 2001
2
- From: Eric Blake <eblake@redhat.com>
3
- Date: Wed, 11 May 2022 19:49:24 -0500
4
- Subject: [PATCH 2/2] nbd/server: Allow MULTI_CONN for shared writable exports
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eric Blake <eblake@redhat.com>
10
- RH-MergeRequest: 90: Advertise MULTI_CONN on writeable NBD servers
11
- RH-Commit: [2/2] 53f0e885a5ed7f6e4bb14e74fe8e7957e6afe90f (ebblake/centos-qemu-kvm)
12
- RH-Bugzilla: 1708300
13
- RH-Acked-by: Nir Soffer <nsoffer@redhat.com>
14
- RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
15
- RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
16
-
17
- According to the NBD spec, a server that advertises
18
- NBD_FLAG_CAN_MULTI_CONN promises that multiple client connections will
19
- not see any cache inconsistencies: when properly separated by a single
20
- flush, actions performed by one client will be visible to another
21
- client, regardless of which client did the flush.
22
-
23
- We always satisfy these conditions in qemu - even when we support
24
- multiple clients, ALL clients go through a single point of reference
25
- into the block layer, with no local caching. The effect of one client
26
- is instantly visible to the next client. Even if our backend were a
27
- network device, we argue that any multi-path caching effects that
28
- would cause inconsistencies in back-to-back actions not seeing the
29
- effect of previous actions would be a bug in that backend, and not the
30
- fault of caching in qemu. As such, it is safe to unconditionally
31
- advertise CAN_MULTI_CONN for any qemu NBD server situation that
32
- supports parallel clients.
33
-
34
- Note, however, that we don't want to advertise CAN_MULTI_CONN when we
35
- know that a second client cannot connect (for historical reasons,
36
- qemu-nbd defaults to a single connection while nbd-server-add and QMP
37
- commands default to unlimited connections; but we already have
38
- existing means to let either style of NBD server creation alter those
39
- defaults). This is visible by no longer advertising MULTI_CONN for
40
- 'qemu-nbd -r' without -e, as in the iotest nbd-qemu-allocation.
41
-
42
- The harder part of this patch is setting up an iotest to demonstrate
43
- behavior of multiple NBD clients to a single server. It might be
44
- possible with parallel qemu-io processes, but I found it easier to do
45
- in python with the help of libnbd, and help from Nir and Vladimir in
46
- writing the test.
47
-
48
- Signed-off-by: Eric Blake <eblake@redhat.com>
49
- Suggested-by: Nir Soffer <nsoffer@redhat.com>
50
- Suggested-by: Vladimir Sementsov-Ogievskiy <v.sementsov-og@mail.ru>
51
- Message-Id: <20220512004924.417153-3-eblake@redhat.com>
52
- Signed-off-by: Kevin Wolf <kwolf@redhat.com>
53
-
54
- (cherry picked from commit 58a6fdcc9efb2a7c1ef4893dca4aa5e8020ca3dc)
55
- Conflicts:
56
- nbd/server.c - context, e5fb29d5 not backported
57
- Signed-off-by: Eric Blake <eblake@redhat.com>
58
- ---
59
- MAINTAINERS | 1 +
60
- blockdev-nbd.c | 5 +
61
- docs/interop/nbd.txt | 1 +
62
- docs/tools/qemu-nbd.rst | 3 +-
63
- include/block/nbd.h | 3 +-
64
- nbd/server.c | 10 +-
65
- qapi/block-export.json | 8 +-
66
- tests/qemu-iotests/tests/nbd-multiconn | 145 ++++++++++++++++++
67
- tests/qemu-iotests/tests/nbd-multiconn.out | 5 +
68
- .../tests/nbd-qemu-allocation.out | 2 +-
69
- 10 files changed, 172 insertions(+), 11 deletions(-)
70
- create mode 100755 tests/qemu-iotests/tests/nbd-multiconn
71
- create mode 100644 tests/qemu-iotests/tests/nbd-multiconn.out
72
-
73
- diff --git a/MAINTAINERS b/MAINTAINERS
74
- index 4ad2451e03..2fe20a49ab 100644
75
- --- a/MAINTAINERS
76
- +++ b/MAINTAINERS
77
- @@ -3370,6 +3370,7 @@ F: qemu-nbd.*
78
- F: blockdev-nbd.c
79
- F: docs/interop/nbd.txt
80
- F: docs/tools/qemu-nbd.rst
81
- +F: tests/qemu-iotests/tests/*nbd*
82
- T: git https://repo.or.cz/qemu/ericb.git nbd
83
- T: git https://src.openvz.org/scm/~vsementsov/qemu.git nbd
84
-
85
- diff --git a/blockdev-nbd.c b/blockdev-nbd.c
86
- index add41a23af..c6d9b0324c 100644
87
- --- a/blockdev-nbd.c
88
- +++ b/blockdev-nbd.c
89
- @@ -44,6 +44,11 @@ bool nbd_server_is_running(void)
90
- return nbd_server || qemu_nbd_connections >= 0;
91
- }
92
-
93
- +int nbd_server_max_connections(void)
94
- +{
95
- + return nbd_server ? nbd_server->max_connections : qemu_nbd_connections;
96
- +}
97
- +
98
- static void nbd_blockdev_client_closed(NBDClient *client, bool ignored)
99
- {
100
- nbd_client_put(client);
101
- diff --git a/docs/interop/nbd.txt b/docs/interop/nbd.txt
102
- index bdb0f2a41a..f5ca25174a 100644
103
- --- a/docs/interop/nbd.txt
104
- +++ b/docs/interop/nbd.txt
105
- @@ -68,3 +68,4 @@ NBD_CMD_BLOCK_STATUS for "qemu:dirty-bitmap:", NBD_CMD_CACHE
106
- * 4.2: NBD_FLAG_CAN_MULTI_CONN for shareable read-only exports,
107
- NBD_CMD_FLAG_FAST_ZERO
108
- * 5.2: NBD_CMD_BLOCK_STATUS for "qemu:allocation-depth"
109
- +* 7.1: NBD_FLAG_CAN_MULTI_CONN for shareable writable exports
110
- diff --git a/docs/tools/qemu-nbd.rst b/docs/tools/qemu-nbd.rst
111
- index 4c950f6199..8e08a29e89 100644
112
- --- a/docs/tools/qemu-nbd.rst
113
- +++ b/docs/tools/qemu-nbd.rst
114
- @@ -139,8 +139,7 @@ driver options if :option:`--image-opts` is specified.
115
- .. option:: -e, --shared=NUM
116
-
117
- Allow up to *NUM* clients to share the device (default
118
- - ``1``), 0 for unlimited. Safe for readers, but for now,
119
- - consistency is not guaranteed between multiple writers.
120
- + ``1``), 0 for unlimited.
121
-
122
- .. option:: -t, --persistent
123
-
124
- diff --git a/include/block/nbd.h b/include/block/nbd.h
125
- index c5a29ce1c6..c74b7a9d2e 100644
126
- --- a/include/block/nbd.h
127
- +++ b/include/block/nbd.h
128
- @@ -1,5 +1,5 @@
129
- /*
130
- - * Copyright (C) 2016-2020 Red Hat, Inc.
131
- + * Copyright (C) 2016-2022 Red Hat, Inc.
132
- * Copyright (C) 2005 Anthony Liguori <anthony@codemonkey.ws>
133
- *
134
- * Network Block Device
135
- @@ -346,6 +346,7 @@ void nbd_client_put(NBDClient *client);
136
-
137
- void nbd_server_is_qemu_nbd(int max_connections);
138
- bool nbd_server_is_running(void);
139
- +int nbd_server_max_connections(void);
140
- void nbd_server_start(SocketAddress *addr, const char *tls_creds,
141
- const char *tls_authz, uint32_t max_connections,
142
- Error **errp);
143
- diff --git a/nbd/server.c b/nbd/server.c
144
- index c5644fd3f6..6e2157acfa 100644
145
- --- a/nbd/server.c
146
- +++ b/nbd/server.c
147
- @@ -1,5 +1,5 @@
148
- /*
149
- - * Copyright (C) 2016-2021 Red Hat, Inc.
150
- + * Copyright (C) 2016-2022 Red Hat, Inc.
151
- * Copyright (C) 2005 Anthony Liguori <anthony@codemonkey.ws>
152
- *
153
- * Network Block Device Server Side
154
- @@ -1642,7 +1642,6 @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args,
155
- int64_t size;
156
- uint64_t perm, shared_perm;
157
- bool readonly = !exp_args->writable;
158
- - bool shared = !exp_args->writable;
159
- strList *bitmaps;
160
- size_t i;
161
- int ret;
162
- @@ -1693,11 +1692,12 @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args,
163
- exp->description = g_strdup(arg->description);
164
- exp->nbdflags = (NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_FLUSH |
165
- NBD_FLAG_SEND_FUA | NBD_FLAG_SEND_CACHE);
166
- +
167
- + if (nbd_server_max_connections() != 1) {
168
- + exp->nbdflags |= NBD_FLAG_CAN_MULTI_CONN;
169
- + }
170
- if (readonly) {
171
- exp->nbdflags |= NBD_FLAG_READ_ONLY;
172
- - if (shared) {
173
- - exp->nbdflags |= NBD_FLAG_CAN_MULTI_CONN;
174
- - }
175
- } else {
176
- exp->nbdflags |= (NBD_FLAG_SEND_TRIM | NBD_FLAG_SEND_WRITE_ZEROES |
177
- NBD_FLAG_SEND_FAST_ZERO);
178
- diff --git a/qapi/block-export.json b/qapi/block-export.json
179
- index 1e34927f85..755ccc89b1 100644
180
- --- a/qapi/block-export.json
181
- +++ b/qapi/block-export.json
182
- @@ -21,7 +21,9 @@
183
- # recreated on the fly while the NBD server is active.
184
- # If missing, it will default to denying access (since 4.0).
185
- # @max-connections: The maximum number of connections to allow at the same
186
- -# time, 0 for unlimited. (since 5.2; default: 0)
187
- +# time, 0 for unlimited. Setting this to 1 also stops
188
- +# the server from advertising multiple client support
189
- +# (since 5.2; default: 0)
190
- #
191
- # Since: 4.2
192
- ##
193
- @@ -50,7 +52,9 @@
194
- # recreated on the fly while the NBD server is active.
195
- # If missing, it will default to denying access (since 4.0).
196
- # @max-connections: The maximum number of connections to allow at the same
197
- -# time, 0 for unlimited. (since 5.2; default: 0)
198
- +# time, 0 for unlimited. Setting this to 1 also stops
199
- +# the server from advertising multiple client support
200
- +# (since 5.2; default: 0).
201
- #
202
- # Returns: error if the server is already running.
203
- #
204
- diff --git a/tests/qemu-iotests/tests/nbd-multiconn b/tests/qemu-iotests/tests/nbd-multiconn
205
- new file mode 100755
206
- index 0000000000..b121f2e363
207
- --- /dev/null
208
- +++ b/tests/qemu-iotests/tests/nbd-multiconn
209
- @@ -0,0 +1,145 @@
210
- +#!/usr/bin/env python3
211
- +# group: rw auto quick
212
- +#
213
- +# Test cases for NBD multi-conn advertisement
214
- +#
215
- +# Copyright (C) 2022 Red Hat, Inc.
216
- +#
217
- +# This program is free software; you can redistribute it and/or modify
218
- +# it under the terms of the GNU General Public License as published by
219
- +# the Free Software Foundation; either version 2 of the License, or
220
- +# (at your option) any later version.
221
- +#
222
- +# This program is distributed in the hope that it will be useful,
223
- +# but WITHOUT ANY WARRANTY; without even the implied warranty of
224
- +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
225
- +# GNU General Public License for more details.
226
- +#
227
- +# You should have received a copy of the GNU General Public License
228
- +# along with this program. If not, see <http://www.gnu.org/licenses/>.
229
- +
230
- +import os
231
- +from contextlib import contextmanager
232
- +import iotests
233
- +from iotests import qemu_img_create, qemu_io
234
- +
235
- +
236
- +disk = os.path.join(iotests.test_dir, 'disk')
237
- +size = '4M'
238
- +nbd_sock = os.path.join(iotests.sock_dir, 'nbd_sock')
239
- +nbd_uri = 'nbd+unix:///{}?socket=' + nbd_sock
240
- +
241
- +
242
- +@contextmanager
243
- +def open_nbd(export_name):
244
- + h = nbd.NBD()
245
- + try:
246
- + h.connect_uri(nbd_uri.format(export_name))
247
- + yield h
248
- + finally:
249
- + h.shutdown()
250
- +
251
- +class TestNbdMulticonn(iotests.QMPTestCase):
252
- + def setUp(self):
253
- + qemu_img_create('-f', iotests.imgfmt, disk, size)
254
- + qemu_io('-c', 'w -P 1 0 2M', '-c', 'w -P 2 2M 2M', disk)
255
- +
256
- + self.vm = iotests.VM()
257
- + self.vm.launch()
258
- + result = self.vm.qmp('blockdev-add', {
259
- + 'driver': 'qcow2',
260
- + 'node-name': 'n',
261
- + 'file': {'driver': 'file', 'filename': disk}
262
- + })
263
- + self.assert_qmp(result, 'return', {})
264
- +
265
- + def tearDown(self):
266
- + self.vm.shutdown()
267
- + os.remove(disk)
268
- + try:
269
- + os.remove(nbd_sock)
270
- + except OSError:
271
- + pass
272
- +
273
- + @contextmanager
274
- + def run_server(self, max_connections=None):
275
- + args = {
276
- + 'addr': {
277
- + 'type': 'unix',
278
- + 'data': {'path': nbd_sock}
279
- + }
280
- + }
281
- + if max_connections is not None:
282
- + args['max-connections'] = max_connections
283
- +
284
- + result = self.vm.qmp('nbd-server-start', args)
285
- + self.assert_qmp(result, 'return', {})
286
- + yield
287
- +
288
- + result = self.vm.qmp('nbd-server-stop')
289
- + self.assert_qmp(result, 'return', {})
290
- +
291
- + def add_export(self, name, writable=None):
292
- + args = {
293
- + 'type': 'nbd',
294
- + 'id': name,
295
- + 'node-name': 'n',
296
- + 'name': name,
297
- + }
298
- + if writable is not None:
299
- + args['writable'] = writable
300
- +
301
- + result = self.vm.qmp('block-export-add', args)
302
- + self.assert_qmp(result, 'return', {})
303
- +
304
- + def test_default_settings(self):
305
- + with self.run_server():
306
- + self.add_export('r')
307
- + self.add_export('w', writable=True)
308
- + with open_nbd('r') as h:
309
- + self.assertTrue(h.can_multi_conn())
310
- + with open_nbd('w') as h:
311
- + self.assertTrue(h.can_multi_conn())
312
- +
313
- + def test_limited_connections(self):
314
- + with self.run_server(max_connections=1):
315
- + self.add_export('r')
316
- + self.add_export('w', writable=True)
317
- + with open_nbd('r') as h:
318
- + self.assertFalse(h.can_multi_conn())
319
- + with open_nbd('w') as h:
320
- + self.assertFalse(h.can_multi_conn())
321
- +
322
- + def test_parallel_writes(self):
323
- + with self.run_server():
324
- + self.add_export('w', writable=True)
325
- +
326
- + clients = [nbd.NBD() for _ in range(3)]
327
- + for c in clients:
328
- + c.connect_uri(nbd_uri.format('w'))
329
- + self.assertTrue(c.can_multi_conn())
330
- +
331
- + initial_data = clients[0].pread(1024 * 1024, 0)
332
- + self.assertEqual(initial_data, b'\x01' * 1024 * 1024)
333
- +
334
- + updated_data = b'\x03' * 1024 * 1024
335
- + clients[1].pwrite(updated_data, 0)
336
- + clients[2].flush()
337
- + current_data = clients[0].pread(1024 * 1024, 0)
338
- +
339
- + self.assertEqual(updated_data, current_data)
340
- +
341
- + for i in range(3):
342
- + clients[i].shutdown()
343
- +
344
- +
345
- +if __name__ == '__main__':
346
- + try:
347
- + # Easier to use libnbd than to try and set up parallel
348
- + # 'qemu-nbd --list' or 'qemu-io' processes, but not all systems
349
- + # have libnbd installed.
350
- + import nbd # type: ignore
351
- +
352
- + iotests.main(supported_fmts=['qcow2'])
353
- + except ImportError:
354
- + iotests.notrun('libnbd not installed')
355
- diff --git a/tests/qemu-iotests/tests/nbd-multiconn.out b/tests/qemu-iotests/tests/nbd-multiconn.out
356
- new file mode 100644
357
- index 0000000000..8d7e996700
358
- --- /dev/null
359
- +++ b/tests/qemu-iotests/tests/nbd-multiconn.out
360
- @@ -0,0 +1,5 @@
361
- +...
362
- +----------------------------------------------------------------------
363
- +Ran 3 tests
364
- +
365
- +OK
366
- diff --git a/tests/qemu-iotests/tests/nbd-qemu-allocation.out b/tests/qemu-iotests/tests/nbd-qemu-allocation.out
367
- index 0bf1abb063..9d938db24e 100644
368
- --- a/tests/qemu-iotests/tests/nbd-qemu-allocation.out
369
- +++ b/tests/qemu-iotests/tests/nbd-qemu-allocation.out
370
- @@ -17,7 +17,7 @@ wrote 2097152/2097152 bytes at offset 1048576
371
- exports available: 1
372
- export: ''
373
- size: 4194304
374
- - flags: 0x58f ( readonly flush fua df multi cache )
375
- + flags: 0x48f ( readonly flush fua df cache )
376
- min block: 1
377
- opt block: 4096
378
- max block: 33554432
379
- --
380
- 2.31.1
381
-
SOURCES/kvm-net-stream-add-a-new-option-to-automatically-reconne.patch ADDED
@@ -0,0 +1,325 @@
1
+ From e5834364958a3914d7b8b46b985a1b054728b466 Mon Sep 17 00:00:00 2001
2
+ From: Laurent Vivier <lvivier@redhat.com>
3
+ Date: Thu, 19 Jan 2023 11:16:45 +0100
4
+ Subject: [PATCH 2/8] net: stream: add a new option to automatically reconnect
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Laurent Vivier <lvivier@redhat.com>
10
+ RH-MergeRequest: 148: net: stream: add a new option to automatically reconnect
11
+ RH-Bugzilla: 2169232
12
+ RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
13
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
14
+ RH-Acked-by: MST <mst@redhat.com>
15
+ RH-Acked-by: David Gibson (Red Hat) <dgibson@redhat.com>
16
+ RH-Commit: [2/2] 9b87647a9ed2e7c1b91bdfa9d0a736e091c892a5 (lvivier/qemu-kvm-centos)
17
+
18
+ In stream mode, if the server shuts down there is currently
19
+ no way to reconnect the client to a new server without removing
20
+ the NIC device and the netdev backend (or to reboot).
21
+
22
+ This patch introduces a reconnect option that specifies a delay
23
+ to try to reconnect with the same parameters.
24
+
25
+ Add a new test in qtest to test the reconnect option and the
26
+ connect/disconnect events.
27
+
28
+ Signed-off-by: Laurent Vivier <lvivier@redhat.com>
29
+ Signed-off-by: Jason Wang <jasowang@redhat.com>
30
+ (cherry picked from commit b95c0d4440950fba6dbef0f781962911fa42abdb)
31
+ ---
32
+ net/stream.c | 53 ++++++++++++++++++-
33
+ qapi/net.json | 7 ++-
34
+ qemu-options.hx | 6 +--
35
+ tests/qtest/netdev-socket.c | 101 ++++++++++++++++++++++++++++++++++++
36
+ 4 files changed, 162 insertions(+), 5 deletions(-)
37
+
38
+ diff --git a/net/stream.c b/net/stream.c
39
+ index 37ff727e0c..9204b4c96e 100644
40
+ --- a/net/stream.c
41
+ +++ b/net/stream.c
42
+ @@ -39,6 +39,8 @@
43
+ #include "io/channel-socket.h"
44
+ #include "io/net-listener.h"
45
+ #include "qapi/qapi-events-net.h"
46
+ +#include "qapi/qapi-visit-sockets.h"
47
+ +#include "qapi/clone-visitor.h"
48
+
49
+ typedef struct NetStreamState {
50
+ NetClientState nc;
51
+ @@ -49,11 +51,15 @@ typedef struct NetStreamState {
52
+ guint ioc_write_tag;
53
+ SocketReadState rs;
54
+ unsigned int send_index; /* number of bytes sent*/
55
+ + uint32_t reconnect;
56
+ + guint timer_tag;
57
+ + SocketAddress *addr;
58
+ } NetStreamState;
59
+
60
+ static void net_stream_listen(QIONetListener *listener,
61
+ QIOChannelSocket *cioc,
62
+ void *opaque);
63
+ +static void net_stream_arm_reconnect(NetStreamState *s);
64
+
65
+ static gboolean net_stream_writable(QIOChannel *ioc,
66
+ GIOCondition condition,
67
+ @@ -170,6 +176,7 @@ static gboolean net_stream_send(QIOChannel *ioc,
68
+ qemu_set_info_str(&s->nc, "%s", "");
69
+
70
+ qapi_event_send_netdev_stream_disconnected(s->nc.name);
71
+ + net_stream_arm_reconnect(s);
72
+
73
+ return G_SOURCE_REMOVE;
74
+ }
75
+ @@ -187,6 +194,14 @@ static gboolean net_stream_send(QIOChannel *ioc,
76
+ static void net_stream_cleanup(NetClientState *nc)
77
+ {
78
+ NetStreamState *s = DO_UPCAST(NetStreamState, nc, nc);
79
+ + if (s->timer_tag) {
80
+ + g_source_remove(s->timer_tag);
81
+ + s->timer_tag = 0;
82
+ + }
83
+ + if (s->addr) {
84
+ + qapi_free_SocketAddress(s->addr);
85
+ + s->addr = NULL;
86
+ + }
87
+ if (s->ioc) {
88
+ if (QIO_CHANNEL_SOCKET(s->ioc)->fd != -1) {
89
+ if (s->ioc_read_tag) {
90
+ @@ -346,12 +361,37 @@ static void net_stream_client_connected(QIOTask *task, gpointer opaque)
91
+ error:
92
+ object_unref(OBJECT(s->ioc));
93
+ s->ioc = NULL;
94
+ + net_stream_arm_reconnect(s);
95
+ +}
96
+ +
97
+ +static gboolean net_stream_reconnect(gpointer data)
98
+ +{
99
+ + NetStreamState *s = data;
100
+ + QIOChannelSocket *sioc;
101
+ +
102
+ + s->timer_tag = 0;
103
+ +
104
+ + sioc = qio_channel_socket_new();
105
+ + s->ioc = QIO_CHANNEL(sioc);
106
+ + qio_channel_socket_connect_async(sioc, s->addr,
107
+ + net_stream_client_connected, s,
108
+ + NULL, NULL);
109
+ + return G_SOURCE_REMOVE;
110
+ +}
111
+ +
112
+ +static void net_stream_arm_reconnect(NetStreamState *s)
113
+ +{
114
+ + if (s->reconnect && s->timer_tag == 0) {
115
+ + s->timer_tag = g_timeout_add_seconds(s->reconnect,
116
+ + net_stream_reconnect, s);
117
+ + }
118
+ }
119
+
120
+ static int net_stream_client_init(NetClientState *peer,
121
+ const char *model,
122
+ const char *name,
123
+ SocketAddress *addr,
124
+ + uint32_t reconnect,
125
+ Error **errp)
126
+ {
127
+ NetStreamState *s;
128
+ @@ -364,6 +404,10 @@ static int net_stream_client_init(NetClientState *peer,
129
+ s->ioc = QIO_CHANNEL(sioc);
130
+ s->nc.link_down = true;
131
+
132
+ + s->reconnect = reconnect;
133
+ + if (reconnect) {
134
+ + s->addr = QAPI_CLONE(SocketAddress, addr);
135
+ + }
136
+ qio_channel_socket_connect_async(sioc, addr,
137
+ net_stream_client_connected, s,
138
+ NULL, NULL);
139
+ @@ -380,7 +424,14 @@ int net_init_stream(const Netdev *netdev, const char *name,
140
+ sock = &netdev->u.stream;
141
+
142
+ if (!sock->has_server || !sock->server) {
143
+ - return net_stream_client_init(peer, "stream", name, sock->addr, errp);
144
+ + return net_stream_client_init(peer, "stream", name, sock->addr,
145
+ + sock->has_reconnect ? sock->reconnect : 0,
146
+ + errp);
147
+ + }
148
+ + if (sock->has_reconnect) {
149
+ + error_setg(errp, "'reconnect' option is incompatible with "
150
+ + "socket in server mode");
151
+ + return -1;
152
+ }
153
+ return net_stream_server_init(peer, "stream", name, sock->addr, errp);
154
+ }
155
+ diff --git a/qapi/net.json b/qapi/net.json
156
+ index 522ac582ed..d6eb30008b 100644
157
+ --- a/qapi/net.json
158
+ +++ b/qapi/net.json
159
+ @@ -585,6 +585,10 @@
160
+ # @addr: socket address to listen on (server=true)
161
+ # or connect to (server=false)
162
+ # @server: create server socket (default: false)
163
+ +# @reconnect: For a client socket, if a socket is disconnected,
164
+ +# then attempt a reconnect after the given number of seconds.
165
+ +# Setting this to zero disables this function. (default: 0)
166
+ +# (since 8.0)
167
+ #
168
+ # Only SocketAddress types 'unix', 'inet' and 'fd' are supported.
169
+ #
170
+ @@ -593,7 +597,8 @@
171
+ { 'struct': 'NetdevStreamOptions',
172
+ 'data': {
173
+ 'addr': 'SocketAddress',
174
+ - '*server': 'bool' } }
175
+ + '*server': 'bool',
176
+ + '*reconnect': 'uint32' } }
177
+
178
+ ##
179
+ # @NetdevDgramOptions:
180
+ diff --git a/qemu-options.hx b/qemu-options.hx
181
+ index ea02ca3a45..48eef4aa2c 100644
182
+ --- a/qemu-options.hx
183
+ +++ b/qemu-options.hx
184
+ @@ -2766,9 +2766,9 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
185
+ "-netdev socket,id=str[,fd=h][,udp=host:port][,localaddr=host:port]\n"
186
+ " configure a network backend to connect to another network\n"
187
+ " using an UDP tunnel\n"
188
+ - "-netdev stream,id=str[,server=on|off],addr.type=inet,addr.host=host,addr.port=port[,to=maxport][,numeric=on|off][,keep-alive=on|off][,mptcp=on|off][,addr.ipv4=on|off][,addr.ipv6=on|off]\n"
189
+ - "-netdev stream,id=str[,server=on|off],addr.type=unix,addr.path=path[,abstract=on|off][,tight=on|off]\n"
190
+ - "-netdev stream,id=str[,server=on|off],addr.type=fd,addr.str=file-descriptor\n"
191
+ + "-netdev stream,id=str[,server=on|off],addr.type=inet,addr.host=host,addr.port=port[,to=maxport][,numeric=on|off][,keep-alive=on|off][,mptcp=on|off][,addr.ipv4=on|off][,addr.ipv6=on|off][,reconnect=seconds]\n"
192
+ + "-netdev stream,id=str[,server=on|off],addr.type=unix,addr.path=path[,abstract=on|off][,tight=on|off][,reconnect=seconds]\n"
193
+ + "-netdev stream,id=str[,server=on|off],addr.type=fd,addr.str=file-descriptor[,reconnect=seconds]\n"
194
+ " configure a network backend to connect to another network\n"
195
+ " using a socket connection in stream mode.\n"
196
+ "-netdev dgram,id=str,remote.type=inet,remote.host=maddr,remote.port=port[,local.type=inet,local.host=addr]\n"
197
+ diff --git a/tests/qtest/netdev-socket.c b/tests/qtest/netdev-socket.c
198
+ index 6ba256e173..acc32c378b 100644
199
+ --- a/tests/qtest/netdev-socket.c
200
+ +++ b/tests/qtest/netdev-socket.c
201
+ @@ -11,6 +11,10 @@
202
+ #include <glib/gstdio.h>
203
+ #include "../unit/socket-helpers.h"
204
+ #include "libqtest.h"
205
+ +#include "qapi/qmp/qstring.h"
206
+ +#include "qemu/sockets.h"
207
+ +#include "qapi/qobject-input-visitor.h"
208
+ +#include "qapi/qapi-visit-sockets.h"
209
+
210
+ #define CONNECTION_TIMEOUT 5
211
+
212
+ @@ -142,6 +146,101 @@ static void test_stream_inet_ipv4(void)
213
+ qtest_quit(qts0);
214
+ }
215
+
216
+ +static void wait_stream_connected(QTestState *qts, const char *id,
217
+ + SocketAddress **addr)
218
+ +{
219
+ + QDict *resp, *data;
220
+ + QString *qstr;
221
+ + QObject *obj;
222
+ + Visitor *v = NULL;
223
+ +
224
+ + resp = qtest_qmp_eventwait_ref(qts, "NETDEV_STREAM_CONNECTED");
225
+ + g_assert_nonnull(resp);
226
+ + data = qdict_get_qdict(resp, "data");
227
+ + g_assert_nonnull(data);
228
+ +
229
+ + qstr = qobject_to(QString, qdict_get(data, "netdev-id"));
230
+ + g_assert_nonnull(data);
231
+ +
232
+ + g_assert(!strcmp(qstring_get_str(qstr), id));
233
+ +
234
+ + obj = qdict_get(data, "addr");
235
+ +
236
+ + v = qobject_input_visitor_new(obj);
237
+ + visit_type_SocketAddress(v, NULL, addr, NULL);
238
+ + visit_free(v);
239
+ + qobject_unref(resp);
240
+ +}
241
+ +
242
+ +static void wait_stream_disconnected(QTestState *qts, const char *id)
243
+ +{
244
+ + QDict *resp, *data;
245
+ + QString *qstr;
246
+ +
247
+ + resp = qtest_qmp_eventwait_ref(qts, "NETDEV_STREAM_DISCONNECTED");
248
+ + g_assert_nonnull(resp);
249
+ + data = qdict_get_qdict(resp, "data");
250
+ + g_assert_nonnull(data);
251
+ +
252
+ + qstr = qobject_to(QString, qdict_get(data, "netdev-id"));
253
+ + g_assert_nonnull(data);
254
+ +
255
+ + g_assert(!strcmp(qstring_get_str(qstr), id));
256
+ + qobject_unref(resp);
257
+ +}
258
+ +
259
+ +static void test_stream_inet_reconnect(void)
260
+ +{
261
+ + QTestState *qts0, *qts1;
262
+ + int port;
263
+ + SocketAddress *addr;
264
+ +
265
+ + port = inet_get_free_port(false);
266
+ + qts0 = qtest_initf("-nodefaults -M none "
267
+ + "-netdev stream,id=st0,server=true,addr.type=inet,"
268
+ + "addr.ipv4=on,addr.ipv6=off,"
269
+ + "addr.host=127.0.0.1,addr.port=%d", port);
270
+ +
271
+ + EXPECT_STATE(qts0, "st0: index=0,type=stream,\r\n", 0);
272
+ +
273
+ + qts1 = qtest_initf("-nodefaults -M none "
274
+ + "-netdev stream,server=false,id=st0,addr.type=inet,"
275
+ + "addr.ipv4=on,addr.ipv6=off,reconnect=1,"
276
+ + "addr.host=127.0.0.1,addr.port=%d", port);
277
+ +
278
+ + wait_stream_connected(qts0, "st0", &addr);
279
+ + g_assert_cmpint(addr->type, ==, SOCKET_ADDRESS_TYPE_INET);
280
+ + g_assert_cmpstr(addr->u.inet.host, ==, "127.0.0.1");
281
+ + qapi_free_SocketAddress(addr);
282
+ +
283
+ + /* kill server */
284
+ + qtest_quit(qts0);
285
+ +
286
+ + /* check client has been disconnected */
287
+ + wait_stream_disconnected(qts1, "st0");
288
+ +
289
+ + /* restart server */
290
+ + qts0 = qtest_initf("-nodefaults -M none "
291
+ + "-netdev stream,id=st0,server=true,addr.type=inet,"
292
+ + "addr.ipv4=on,addr.ipv6=off,"
293
+ + "addr.host=127.0.0.1,addr.port=%d", port);
294
+ +
295
+ + /* wait connection events*/
296
+ + wait_stream_connected(qts0, "st0", &addr);
297
+ + g_assert_cmpint(addr->type, ==, SOCKET_ADDRESS_TYPE_INET);
298
+ + g_assert_cmpstr(addr->u.inet.host, ==, "127.0.0.1");
299
+ + qapi_free_SocketAddress(addr);
300
+ +
301
+ + wait_stream_connected(qts1, "st0", &addr);
302
+ + g_assert_cmpint(addr->type, ==, SOCKET_ADDRESS_TYPE_INET);
303
+ + g_assert_cmpstr(addr->u.inet.host, ==, "127.0.0.1");
304
+ + g_assert_cmpint(atoi(addr->u.inet.port), ==, port);
305
+ + qapi_free_SocketAddress(addr);
306
+ +
307
+ + qtest_quit(qts1);
308
+ + qtest_quit(qts0);
309
+ +}
310
+ +
311
+ static void test_stream_inet_ipv6(void)
312
+ {
313
+ QTestState *qts0, *qts1;
314
+ @@ -418,6 +517,8 @@ int main(int argc, char **argv)
315
+ #ifndef _WIN32
316
+ qtest_add_func("/netdev/dgram/mcast", test_dgram_mcast);
317
+ #endif
318
+ + qtest_add_func("/netdev/stream/inet/reconnect",
319
+ + test_stream_inet_reconnect);
320
+ }
321
+ if (has_ipv6) {
322
+ qtest_add_func("/netdev/stream/inet/ipv6", test_stream_inet_ipv6);
323
+ --
324
+ 2.31.1
325
+
SOURCES/kvm-pc-bios-s390-ccw-Fix-booting-with-logical-block-size.patch DELETED
@@ -1,63 +0,0 @@
1
- From 03996a8a826c9186e4a16e1b4757f1ef5947a503 Mon Sep 17 00:00:00 2001
2
- From: Thomas Huth <thuth@redhat.com>
3
- Date: Fri, 5 Aug 2022 11:42:14 +0200
4
- Subject: [PATCH 07/11] pc-bios/s390-ccw: Fix booting with logical block size <
5
- physical block size
6
-
7
- RH-Author: Thomas Huth <thuth@redhat.com>
8
- RH-MergeRequest: 113: pc-bios/s390-ccw: Fix booting with logical block size < physical block size
9
- RH-Commit: [1/1] a45ff477bc7d7011ea6c4d42a1aade213d1e4690 (thuth/qemu-kvm-cs9)
10
- RH-Bugzilla: 2112303
11
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
12
- RH-Acked-by: David Hildenbrand <david@redhat.com>
13
- RH-Acked-by: Claudio Imbrenda <None>
14
-
15
- For accessing single blocks during boot, it's the logical block size that
16
- matters. (Physical block sizes are rather interesting e.g. for creating
17
- file systems with the correct alignment for speed reasons etc.).
18
- So the s390-ccw bios has to use the logical block size for calculating
19
- sector numbers during the boot phase, the "physical_block_exp" shift
20
- value must not be taken into account. This change fixes the boot process
21
- when the guest hast been installed on a disk where the logical block size
22
- differs from the physical one, e.g. if the guest has been installed
23
- like this:
24
-
25
- qemu-system-s390x -nographic -accel kvm -m 2G \
26
- -drive if=none,id=d1,file=fedora.iso,format=raw,media=cdrom \
27
- -device virtio-scsi -device scsi-cd,drive=d1 \
28
- -drive if=none,id=d2,file=test.qcow2,format=qcow2
29
- -device virtio-blk,drive=d2,physical_block_size=4096,logical_block_size=512
30
-
31
- Linux correctly uses the logical block size of 512 for the installation,
32
- but the s390-ccw bios tries to boot from a disk with 4096 block size so
33
- far, as long as this patch has not been applied yet (well, it used to work
34
- by accident in the past due to the virtio_assume_scsi() hack that used to
35
- enforce 512 byte sectors on all virtio-block disks, but that hack has been
36
- well removed in commit 5447de2619050a0a4d to fix other scenarios).
37
-
38
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2112303
39
- Message-Id: <20220805094214.285223-1-thuth@redhat.com>
40
- Reviewed-by: Cornelia Huck <cohuck@redhat.com>
41
- Reviewed-by: Eric Farman <farman@linux.ibm.com>
42
- Signed-off-by: Thomas Huth <thuth@redhat.com>
43
- (cherry picked from commit 393296de19650e1400ca265914cfdeb313725363)
44
- ---
45
- pc-bios/s390-ccw/virtio-blkdev.c | 2 +-
46
- 1 file changed, 1 insertion(+), 1 deletion(-)
47
-
48
- diff --git a/pc-bios/s390-ccw/virtio-blkdev.c b/pc-bios/s390-ccw/virtio-blkdev.c
49
- index 8271c47296..794f99b42c 100644
50
- --- a/pc-bios/s390-ccw/virtio-blkdev.c
51
- +++ b/pc-bios/s390-ccw/virtio-blkdev.c
52
- @@ -173,7 +173,7 @@ int virtio_get_block_size(void)
53
-
54
- switch (vdev->senseid.cu_model) {
55
- case VIRTIO_ID_BLOCK:
56
- - return vdev->config.blk.blk_size << vdev->config.blk.physical_block_exp;
57
- + return vdev->config.blk.blk_size;
58
- case VIRTIO_ID_SCSI:
59
- return vdev->scsi_block_size;
60
- }
61
- --
62
- 2.31.1
63
-
SOURCES/kvm-pc-bios-s390-ccw-Split-virtio-scsi-code-from-virtio_.patch DELETED
@@ -1,180 +0,0 @@
1
- From 2e38b4ec5c53b2b98539a70105d3046e1c452ab8 Mon Sep 17 00:00:00 2001
2
- From: Thomas Huth <thuth@redhat.com>
3
- Date: Fri, 8 Jul 2022 20:49:01 +0200
4
- Subject: [PATCH 13/17] pc-bios/s390-ccw: Split virtio-scsi code from
5
- virtio_blk_setup_device()
6
-
7
- RH-Author: Thomas Huth <thuth@redhat.com>
8
- RH-MergeRequest: 106: pc-bios/s390-ccw: Fix boot from disks with 4k sectors that do not have the typical DASD geometry
9
- RH-Commit: [8/10] f49c5fb77e05c9dc09ed9f037e37f6a461e4bba6 (thuth/qemu-kvm-cs9)
10
- RH-Bugzilla: 2098077
11
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
- RH-Acked-by: David Hildenbrand <david@redhat.com>
13
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
14
-
15
- Bugzilla: http://bugzilla.redhat.com/2098077
16
-
17
- commit cf30b7c4a9b2c64518be8037c2e6670aacdb00b9
18
- Author: Thomas Huth <thuth@redhat.com>
19
- Date: Mon Jul 4 13:19:00 2022 +0200
20
-
21
- pc-bios/s390-ccw: Split virtio-scsi code from virtio_blk_setup_device()
22
-
23
- The next patch is going to add more virtio-block specific code to
24
- virtio_blk_setup_device(), and if the virtio-scsi code is also in
25
- there, this is more cumbersome. And the calling function virtio_setup()
26
- in main.c looks at the device type already anyway, so it's more
27
- logical to separate the virtio-scsi stuff into a new function in
28
- virtio-scsi.c instead.
29
-
30
- Message-Id: <20220704111903.62400-10-thuth@redhat.com>
31
- Reviewed-by: Eric Farman <farman@linux.ibm.com>
32
- Signed-off-by: Thomas Huth <thuth@redhat.com>
33
-
34
- Signed-off-by: Thomas Huth <thuth@redhat.com>
35
- ---
36
- pc-bios/s390-ccw/main.c | 24 +++++++++++++++++-------
37
- pc-bios/s390-ccw/virtio-blkdev.c | 20 ++------------------
38
- pc-bios/s390-ccw/virtio-scsi.c | 19 ++++++++++++++++++-
39
- pc-bios/s390-ccw/virtio-scsi.h | 2 +-
40
- 4 files changed, 38 insertions(+), 27 deletions(-)
41
-
42
- diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
43
- index 5d2b7ba94d..13e1d8fdf7 100644
44
- --- a/pc-bios/s390-ccw/main.c
45
- +++ b/pc-bios/s390-ccw/main.c
46
- @@ -14,6 +14,7 @@
47
- #include "s390-ccw.h"
48
- #include "cio.h"
49
- #include "virtio.h"
50
- +#include "virtio-scsi.h"
51
- #include "dasd-ipl.h"
52
-
53
- char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));
54
- @@ -218,6 +219,7 @@ static int virtio_setup(void)
55
- {
56
- VDev *vdev = virtio_get_device();
57
- QemuIplParameters *early_qipl = (QemuIplParameters *)QIPL_ADDRESS;
58
- + int ret;
59
-
60
- memcpy(&qipl, early_qipl, sizeof(QemuIplParameters));
61
-
62
- @@ -225,18 +227,26 @@ static int virtio_setup(void)
63
- menu_setup();
64
- }
65
-
66
- - if (virtio_get_device_type() == VIRTIO_ID_NET) {
67
- + switch (vdev->senseid.cu_model) {
68
- + case VIRTIO_ID_NET:
69
- sclp_print("Network boot device detected\n");
70
- vdev->netboot_start_addr = qipl.netboot_start_addr;
71
- - } else {
72
- - int ret = virtio_blk_setup_device(blk_schid);
73
- - if (ret) {
74
- - return ret;
75
- - }
76
- + return 0;
77
- + case VIRTIO_ID_BLOCK:
78
- + ret = virtio_blk_setup_device(blk_schid);
79
- + break;
80
- + case VIRTIO_ID_SCSI:
81
- + ret = virtio_scsi_setup_device(blk_schid);
82
- + break;
83
- + default:
84
- + panic("\n! No IPL device available !\n");
85
- + }
86
- +
87
- + if (!ret) {
88
- IPL_assert(virtio_ipl_disk_is_valid(), "No valid IPL device detected");
89
- }
90
-
91
- - return 0;
92
- + return ret;
93
- }
94
-
95
- static void ipl_boot_device(void)
96
- diff --git a/pc-bios/s390-ccw/virtio-blkdev.c b/pc-bios/s390-ccw/virtio-blkdev.c
97
- index db1f7f44aa..c175b66a47 100644
98
- --- a/pc-bios/s390-ccw/virtio-blkdev.c
99
- +++ b/pc-bios/s390-ccw/virtio-blkdev.c
100
- @@ -222,27 +222,11 @@ uint64_t virtio_get_blocks(void)
101
- int virtio_blk_setup_device(SubChannelId schid)
102
- {
103
- VDev *vdev = virtio_get_device();
104
- - int ret = 0;
105
-
106
- vdev->schid = schid;
107
- virtio_setup_ccw(vdev);
108
-
109
- - switch (vdev->senseid.cu_model) {
110
- - case VIRTIO_ID_BLOCK:
111
- - sclp_print("Using virtio-blk.\n");
112
- - break;
113
- - case VIRTIO_ID_SCSI:
114
- - IPL_assert(vdev->config.scsi.sense_size == VIRTIO_SCSI_SENSE_SIZE,
115
- - "Config: sense size mismatch");
116
- - IPL_assert(vdev->config.scsi.cdb_size == VIRTIO_SCSI_CDB_SIZE,
117
- - "Config: CDB size mismatch");
118
- + sclp_print("Using virtio-blk.\n");
119
-
120
- - sclp_print("Using virtio-scsi.\n");
121
- - ret = virtio_scsi_setup(vdev);
122
- - break;
123
- - default:
124
- - panic("\n! No IPL device available !\n");
125
- - }
126
- -
127
- - return ret;
128
- + return 0;
129
- }
130
- diff --git a/pc-bios/s390-ccw/virtio-scsi.c b/pc-bios/s390-ccw/virtio-scsi.c
131
- index 2c8d0f3097..3b7069270c 100644
132
- --- a/pc-bios/s390-ccw/virtio-scsi.c
133
- +++ b/pc-bios/s390-ccw/virtio-scsi.c
134
- @@ -329,7 +329,7 @@ static void scsi_parse_capacity_report(void *data,
135
- }
136
- }
137
-
138
- -int virtio_scsi_setup(VDev *vdev)
139
- +static int virtio_scsi_setup(VDev *vdev)
140
- {
141
- int retry_test_unit_ready = 3;
142
- uint8_t data[256];
143
- @@ -430,3 +430,20 @@ int virtio_scsi_setup(VDev *vdev)
144
-
145
- return 0;
146
- }
147
- +
148
- +int virtio_scsi_setup_device(SubChannelId schid)
149
- +{
150
- + VDev *vdev = virtio_get_device();
151
- +
152
- + vdev->schid = schid;
153
- + virtio_setup_ccw(vdev);
154
- +
155
- + IPL_assert(vdev->config.scsi.sense_size == VIRTIO_SCSI_SENSE_SIZE,
156
- + "Config: sense size mismatch");
157
- + IPL_assert(vdev->config.scsi.cdb_size == VIRTIO_SCSI_CDB_SIZE,
158
- + "Config: CDB size mismatch");
159
- +
160
- + sclp_print("Using virtio-scsi.\n");
161
- +
162
- + return virtio_scsi_setup(vdev);
163
- +}
164
- diff --git a/pc-bios/s390-ccw/virtio-scsi.h b/pc-bios/s390-ccw/virtio-scsi.h
165
- index 4b14c2c2f9..e6b6cd4815 100644
166
- --- a/pc-bios/s390-ccw/virtio-scsi.h
167
- +++ b/pc-bios/s390-ccw/virtio-scsi.h
168
- @@ -67,8 +67,8 @@ static inline bool virtio_scsi_response_ok(const VirtioScsiCmdResp *r)
169
- return r->response == VIRTIO_SCSI_S_OK && r->status == CDB_STATUS_GOOD;
170
- }
171
-
172
- -int virtio_scsi_setup(VDev *vdev);
173
- int virtio_scsi_read_many(VDev *vdev,
174
- ulong sector, void *load_addr, int sec_num);
175
- +int virtio_scsi_setup_device(SubChannelId schid);
176
-
177
- #endif /* VIRTIO_SCSI_H */
178
- --
179
- 2.31.1
180
-
SOURCES/kvm-pc-bios-s390-ccw-bootmap-Improve-the-guessing-logic-.patch DELETED
@@ -1,102 +0,0 @@
1
- From 64fa56e0520215e3909e442f09d8073c1870648a Mon Sep 17 00:00:00 2001
2
- From: Thomas Huth <thuth@redhat.com>
3
- Date: Fri, 8 Jul 2022 20:49:01 +0200
4
- Subject: [PATCH 07/17] pc-bios/s390-ccw/bootmap: Improve the guessing logic in
5
- zipl_load_vblk()
6
-
7
- RH-Author: Thomas Huth <thuth@redhat.com>
8
- RH-MergeRequest: 106: pc-bios/s390-ccw: Fix boot from disks with 4k sectors that do not have the typical DASD geometry
9
- RH-Commit: [2/10] ca8f5e847617cf4ac2fd6c38edb2982f32fa3eba (thuth/qemu-kvm-cs9)
10
- RH-Bugzilla: 2098077
11
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
- RH-Acked-by: David Hildenbrand <david@redhat.com>
13
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
14
-
15
- Bugzilla: http://bugzilla.redhat.com/2098077
16
-
17
- commit 422865f6672ee1482b98d18321b55c1ecfb06c82
18
- Author: Thomas Huth <thuth@redhat.com>
19
- Date: Mon Jul 4 13:18:54 2022 +0200
20
-
21
- pc-bios/s390-ccw/bootmap: Improve the guessing logic in zipl_load_vblk()
22
-
23
- The logic of trying an final ISO or ECKD boot on virtio-block devices is
24
- very weird: Since the geometry hardly ever matches in virtio_disk_is_scsi(),
25
- virtio_blk_setup_device() always sets a "guessed" disk geometry via
26
- virtio_assume_scsi() (which is certainly also wrong in a lot of cases).
27
-
28
- zipl_load_vblk() then sees that there's been a "virtio_guessed_disk_nature"
29
- and tries to fix up the geometry again via virtio_assume_iso9660() before
30
- always trying to do ipl_iso_el_torito(). That's a very brain-twisting
31
- way of attempting to boot from ISO images, which won't work anymore after
32
- the following patches that will clean up the virtio_assume_scsi() mess
33
- (and thus get rid of the "virtio_guessed_disk_nature" here).
34
-
35
- Let's try a better approach instead: ISO files always have a magic
36
- string "CD001" at offset 0x8001 (see e.g. the ECMA-119 specification)
37
- which we can use to decide whether we should try to boot in ISO 9660
38
- mode (which we should also try if we see a sector size of 2048).
39
-
40
- And if we were not able to boot in ISO mode here, the final boot attempt
41
- before panicking is to boot in ECKD mode. Since this is our last boot
42
- attempt anyway, simply always assume the ECKD geometry here (if the sector
43
- size was not 4096 yet), so that we also do not depend on the guessed disk
44
- geometry from virtio_blk_setup_device() here anymore.
45
-
46
- Message-Id: <20220704111903.62400-4-thuth@redhat.com>
47
- Signed-off-by: Thomas Huth <thuth@redhat.com>
48
-
49
- Signed-off-by: Thomas Huth <thuth@redhat.com>
50
- ---
51
- pc-bios/s390-ccw/bootmap.c | 27 +++++++++++++++++++++++----
52
- 1 file changed, 23 insertions(+), 4 deletions(-)
53
-
54
- diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c
55
- index 56411ab3b6..994e59c0b0 100644
56
- --- a/pc-bios/s390-ccw/bootmap.c
57
- +++ b/pc-bios/s390-ccw/bootmap.c
58
- @@ -780,18 +780,37 @@ static void ipl_iso_el_torito(void)
59
- }
60
- }
61
-
62
- +/**
63
- + * Detect whether we're trying to boot from an .ISO image.
64
- + * These always have a signature string "CD001" at offset 0x8001.
65
- + */
66
- +static bool has_iso_signature(void)
67
- +{
68
- + int blksize = virtio_get_block_size();
69
- +
70
- + if (!blksize || virtio_read(0x8000 / blksize, sec)) {
71
- + return false;
72
- + }
73
- +
74
- + return !memcmp("CD001", &sec[1], 5);
75
- +}
76
- +
77
- /***********************************************************************
78
- * Bus specific IPL sequences
79
- */
80
-
81
- static void zipl_load_vblk(void)
82
- {
83
- - if (virtio_guessed_disk_nature()) {
84
- - virtio_assume_iso9660();
85
- + int blksize = virtio_get_block_size();
86
- +
87
- + if (blksize == VIRTIO_ISO_BLOCK_SIZE || has_iso_signature()) {
88
- + if (blksize != VIRTIO_ISO_BLOCK_SIZE) {
89
- + virtio_assume_iso9660();
90
- + }
91
- + ipl_iso_el_torito();
92
- }
93
- - ipl_iso_el_torito();
94
-
95
- - if (virtio_guessed_disk_nature()) {
96
- + if (blksize != VIRTIO_DASD_DEFAULT_BLOCK_SIZE) {
97
- sclp_print("Using guessed DASD geometry.\n");
98
- virtio_assume_eckd();
99
- }
100
- --
101
- 2.31.1
102
-
SOURCES/kvm-pc-bios-s390-ccw-netboot.mak-Ignore-Clang-s-warnings.patch DELETED
@@ -1,78 +0,0 @@
1
- From 56674ee1f25f12978a6a8a1390e11b55b3e0fabe Mon Sep 17 00:00:00 2001
2
- From: Thomas Huth <thuth@redhat.com>
3
- Date: Fri, 8 Jul 2022 20:49:01 +0200
4
- Subject: [PATCH 15/17] pc-bios/s390-ccw/netboot.mak: Ignore Clang's warnings
5
- about GNU extensions
6
-
7
- RH-Author: Thomas Huth <thuth@redhat.com>
8
- RH-MergeRequest: 106: pc-bios/s390-ccw: Fix boot from disks with 4k sectors that do not have the typical DASD geometry
9
- RH-Commit: [10/10] 037dab4df23ebb2b42871bca8c842a53a7204b50 (thuth/qemu-kvm-cs9)
10
- RH-Bugzilla: 2098077
11
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
- RH-Acked-by: David Hildenbrand <david@redhat.com>
13
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
14
-
15
- Bugzilla: http://bugzilla.redhat.com/2098077
16
-
17
- commit e2269220acb03e6c6a460c3090d804835e202239
18
- Author: Thomas Huth <thuth@redhat.com>
19
- Date: Mon Jul 4 13:19:03 2022 +0200
20
-
21
- pc-bios/s390-ccw/netboot.mak: Ignore Clang's warnings about GNU extensions
22
-
23
- When compiling the s390-ccw bios with Clang (v14.0), there is currently
24
- an unuseful warning like this:
25
-
26
- CC pc-bios/s390-ccw/ipv6.o
27
- ../../roms/SLOF/lib/libnet/ipv6.c:447:18: warning: variable length array
28
- folded to constant array as an extension [-Wgnu-folding-constant]
29
- unsigned short raw[ip6size];
30
- ^
31
-
32
- SLOF is currently GCC-only and cannot be compiled with Clang yet, so
33
- it is expected that such extensions sneak in there - and as long as
34
- we don't want to compile the code with a compiler that is neither GCC
35
- or Clang, it is also not necessary to avoid such extensions.
36
-
37
- Thus these GNU-extension related warnings are completely useless in
38
- the s390-ccw bios, especially in the code that is coming from SLOF,
39
- so we should simply disable the related warnings here now.
40
-
41
- Message-Id: <20220704111903.62400-13-thuth@redhat.com>
42
- Signed-off-by: Thomas Huth <thuth@redhat.com>
43
-
44
- Signed-off-by: Thomas Huth <thuth@redhat.com>
45
- ---
46
- pc-bios/s390-ccw/netboot.mak | 7 +++++--
47
- 1 file changed, 5 insertions(+), 2 deletions(-)
48
-
49
- diff --git a/pc-bios/s390-ccw/netboot.mak b/pc-bios/s390-ccw/netboot.mak
50
- index 68b4d7edcb..ad41898cb6 100644
51
- --- a/pc-bios/s390-ccw/netboot.mak
52
- +++ b/pc-bios/s390-ccw/netboot.mak
53
- @@ -16,9 +16,12 @@ s390-netboot.elf: $(NETOBJS) libnet.a libc.a
54
- s390-netboot.img: s390-netboot.elf
55
- $(call quiet-command,$(STRIP) --strip-unneeded $< -o $@,"STRIP","$(TARGET_DIR)$@")
56
-
57
- +# SLOF is GCC-only, so ignore warnings about GNU extensions with Clang here
58
- +NO_GNU_WARN := $(call cc-option,-Werror $(QEMU_CFLAGS),-Wno-gnu)
59
- +
60
- # libc files:
61
-
62
- -LIBC_CFLAGS = $(QEMU_CFLAGS) $(CFLAGS) $(LIBC_INC) $(LIBNET_INC) \
63
- +LIBC_CFLAGS = $(QEMU_CFLAGS) $(CFLAGS) $(NO_GNU_WARN) $(LIBC_INC) $(LIBNET_INC) \
64
- -MMD -MP -MT $@ -MF $(@:%.o=%.d)
65
-
66
- CTYPE_OBJS = isdigit.o isxdigit.o toupper.o
67
- @@ -52,7 +55,7 @@ libc.a: $(LIBCOBJS)
68
-
69
- LIBNETOBJS := args.o dhcp.o dns.o icmpv6.o ipv6.o tcp.o udp.o bootp.o \
70
- dhcpv6.o ethernet.o ipv4.o ndp.o tftp.o pxelinux.o
71
- -LIBNETCFLAGS = $(QEMU_CFLAGS) $(CFLAGS) $(LIBC_INC) $(LIBNET_INC) \
72
- +LIBNETCFLAGS = $(QEMU_CFLAGS) $(CFLAGS) $(NO_GNU_WARN) $(LIBC_INC) $(LIBNET_INC) \
73
- -DDHCPARCH=0x1F -MMD -MP -MT $@ -MF $(@:%.o=%.d)
74
-
75
- %.o : $(SLOF_DIR)/lib/libnet/%.c
76
- --
77
- 2.31.1
78
-
SOURCES/kvm-pc-bios-s390-ccw-virtio-Beautify-the-code-for-readin.patch DELETED
@@ -1,56 +0,0 @@
1
- From 430e76fd964390db86c8486f76b916a1cf7f74c2 Mon Sep 17 00:00:00 2001
2
- From: Thomas Huth <thuth@redhat.com>
3
- Date: Fri, 8 Jul 2022 20:49:01 +0200
4
- Subject: [PATCH 12/17] pc-bios/s390-ccw/virtio: Beautify the code for reading
5
- virtqueue configuration
6
-
7
- RH-Author: Thomas Huth <thuth@redhat.com>
8
- RH-MergeRequest: 106: pc-bios/s390-ccw: Fix boot from disks with 4k sectors that do not have the typical DASD geometry
9
- RH-Commit: [7/10] b15c06b4c5431837672b6cb5d57d09da20718441 (thuth/qemu-kvm-cs9)
10
- RH-Bugzilla: 2098077
11
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
- RH-Acked-by: David Hildenbrand <david@redhat.com>
13
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
14
-
15
- Bugzilla: http://bugzilla.redhat.com/2098077
16
-
17
- commit 070824885741f5d2a66626d3c4ecb2773c8e0552
18
- Author: Thomas Huth <thuth@redhat.com>
19
- Date: Mon Jul 4 13:18:59 2022 +0200
20
-
21
- pc-bios/s390-ccw/virtio: Beautify the code for reading virtqueue configuration
22
-
23
- It looks nicer if we separate the run_ccw() from the IPL_assert()
24
- statement, and the error message should talk about "virtio device"
25
- instead of "block device", since this code is nowadays used for
26
- non-block (i.e. network) devices, too.
27
-
28
- Message-Id: <20220704111903.62400-9-thuth@redhat.com>
29
- Reviewed-by: Cornelia Huck <cohuck@redhat.com>
30
- Reviewed-by: Eric Farman <farman@linux.ibm.com>
31
- Signed-off-by: Thomas Huth <thuth@redhat.com>
32
-
33
- Signed-off-by: Thomas Huth <thuth@redhat.com>
34
- ---
35
- pc-bios/s390-ccw/virtio.c | 5 ++---
36
- 1 file changed, 2 insertions(+), 3 deletions(-)
37
-
38
- diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
39
- index d8c2b52710..f37510f312 100644
40
- --- a/pc-bios/s390-ccw/virtio.c
41
- +++ b/pc-bios/s390-ccw/virtio.c
42
- @@ -289,9 +289,8 @@ void virtio_setup_ccw(VDev *vdev)
43
- .num = 0,
44
- };
45
-
46
- - IPL_assert(
47
- - run_ccw(vdev, CCW_CMD_READ_VQ_CONF, &config, sizeof(config), false) == 0,
48
- - "Could not get block device VQ configuration");
49
- + rc = run_ccw(vdev, CCW_CMD_READ_VQ_CONF, &config, sizeof(config), false);
50
- + IPL_assert(rc == 0, "Could not get virtio device VQ configuration");
51
- info.num = config.num;
52
- vring_init(&vdev->vrings[i], &info);
53
- vdev->vrings[i].schid = vdev->schid;
54
- --
55
- 2.31.1
56
-
SOURCES/kvm-pc-bios-s390-ccw-virtio-Introduce-a-macro-for-the-DA.patch DELETED
@@ -1,63 +0,0 @@
1
- From 7d4f2454f95bfc087ad3f2fe3bc4625dcea3568e Mon Sep 17 00:00:00 2001
2
- From: Thomas Huth <thuth@redhat.com>
3
- Date: Fri, 8 Jul 2022 20:49:01 +0200
4
- Subject: [PATCH 06/17] pc-bios/s390-ccw/virtio: Introduce a macro for the DASD
5
- block size
6
-
7
- RH-Author: Thomas Huth <thuth@redhat.com>
8
- RH-MergeRequest: 106: pc-bios/s390-ccw: Fix boot from disks with 4k sectors that do not have the typical DASD geometry
9
- RH-Commit: [1/10] 71033934e1e9988bcf71362e02665ceb7449009d (thuth/qemu-kvm-cs9)
10
- RH-Bugzilla: 2098077
11
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
- RH-Acked-by: David Hildenbrand <david@redhat.com>
13
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
14
-
15
- Bugzilla: http://bugzilla.redhat.com/2098077
16
-
17
- commit 1f2c2ee48e87ea743f8e23cc7569dd26c4cf9623
18
- Author: Thomas Huth <thuth@redhat.com>
19
- Date: Mon Jul 4 13:18:53 2022 +0200
20
-
21
- pc-bios/s390-ccw/virtio: Introduce a macro for the DASD block size
22
-
23
- Use VIRTIO_DASD_DEFAULT_BLOCK_SIZE instead of the magic value 4096.
24
-
25
- Message-Id: <20220704111903.62400-3-thuth@redhat.com>
26
- Reviewed-by: Eric Farman <farman@linux.ibm.com>
27
- Reviewed-by: Cornelia Huck <cohuck@redhat.com>
28
- Signed-off-by: Thomas Huth <thuth@redhat.com>
29
-
30
- Signed-off-by: Thomas Huth <thuth@redhat.com>
31
- ---
32
- pc-bios/s390-ccw/virtio-blkdev.c | 2 +-
33
- pc-bios/s390-ccw/virtio.h | 1 +
34
- 2 files changed, 2 insertions(+), 1 deletion(-)
35
-
36
- diff --git a/pc-bios/s390-ccw/virtio-blkdev.c b/pc-bios/s390-ccw/virtio-blkdev.c
37
- index 7d35050292..6483307630 100644
38
- --- a/pc-bios/s390-ccw/virtio-blkdev.c
39
- +++ b/pc-bios/s390-ccw/virtio-blkdev.c
40
- @@ -155,7 +155,7 @@ void virtio_assume_eckd(void)
41
- vdev->config.blk.physical_block_exp = 0;
42
- switch (vdev->senseid.cu_model) {
43
- case VIRTIO_ID_BLOCK:
44
- - vdev->config.blk.blk_size = 4096;
45
- + vdev->config.blk.blk_size = VIRTIO_DASD_DEFAULT_BLOCK_SIZE;
46
- break;
47
- case VIRTIO_ID_SCSI:
48
- vdev->config.blk.blk_size = vdev->scsi_block_size;
49
- diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h
50
- index 19fceb6495..9e410bde6f 100644
51
- --- a/pc-bios/s390-ccw/virtio.h
52
- +++ b/pc-bios/s390-ccw/virtio.h
53
- @@ -198,6 +198,7 @@ extern int virtio_read_many(ulong sector, void *load_addr, int sec_num);
54
- #define VIRTIO_SECTOR_SIZE 512
55
- #define VIRTIO_ISO_BLOCK_SIZE 2048
56
- #define VIRTIO_SCSI_BLOCK_SIZE 512
57
- +#define VIRTIO_DASD_DEFAULT_BLOCK_SIZE 4096
58
-
59
- static inline ulong virtio_sector_adjust(ulong sector)
60
- {
61
- --
62
- 2.31.1
63
-
SOURCES/kvm-pc-bios-s390-ccw-virtio-Read-device-config-after-fea.patch DELETED
@@ -1,67 +0,0 @@
1
- From 20f8724d0837acbe642c8c7698a4b256f34c1209 Mon Sep 17 00:00:00 2001
2
- From: Thomas Huth <thuth@redhat.com>
3
- Date: Fri, 8 Jul 2022 20:49:01 +0200
4
- Subject: [PATCH 11/17] pc-bios/s390-ccw/virtio: Read device config after
5
- feature negotiation
6
-
7
- RH-Author: Thomas Huth <thuth@redhat.com>
8
- RH-MergeRequest: 106: pc-bios/s390-ccw: Fix boot from disks with 4k sectors that do not have the typical DASD geometry
9
- RH-Commit: [6/10] 54d21e430b2dfba9e0a0823d6bb8ec7e7f8ff2ff (thuth/qemu-kvm-cs9)
10
- RH-Bugzilla: 2098077
11
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
- RH-Acked-by: David Hildenbrand <david@redhat.com>
13
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
14
-
15
- Bugzilla: http://bugzilla.redhat.com/2098077
16
-
17
- commit aa5c69ce99411c4886bcd051f288afc02b6d968d
18
- Author: Thomas Huth <thuth@redhat.com>
19
- Date: Mon Jul 4 13:18:58 2022 +0200
20
-
21
- pc-bios/s390-ccw/virtio: Read device config after feature negotiation
22
-
23
- Feature negotiation should be done first, since some fields in the
24
- config area can depend on the negotiated features and thus should
25
- rather be read afterwards.
26
-
27
- While we're at it, also adjust the error message here a little bit
28
- (the code is nowadays used for non-block virtio devices, too).
29
-
30
- Message-Id: <20220704111903.62400-8-thuth@redhat.com>
31
- Reviewed-by: Eric Farman <farman@linux.ibm.com>
32
- Reviewed-by: Cornelia Huck <cohuck@redhat.com>
33
- Signed-off-by: Thomas Huth <thuth@redhat.com>
34
-
35
- Signed-off-by: Thomas Huth <thuth@redhat.com>
36
- ---
37
- pc-bios/s390-ccw/virtio.c | 7 +++----
38
- 1 file changed, 3 insertions(+), 4 deletions(-)
39
-
40
- diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
41
- index 4e85a2eb82..d8c2b52710 100644
42
- --- a/pc-bios/s390-ccw/virtio.c
43
- +++ b/pc-bios/s390-ccw/virtio.c
44
- @@ -262,10 +262,6 @@ void virtio_setup_ccw(VDev *vdev)
45
- rc = run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status), false);
46
- IPL_assert(rc == 0, "Could not write DRIVER status to host");
47
-
48
- - IPL_assert(
49
- - run_ccw(vdev, CCW_CMD_READ_CONF, &vdev->config, cfg_size, false) == 0,
50
- - "Could not get block device configuration");
51
- -
52
- /* Feature negotiation */
53
- for (i = 0; i < ARRAY_SIZE(vdev->guest_features); i++) {
54
- feats.features = 0;
55
- @@ -278,6 +274,9 @@ void virtio_setup_ccw(VDev *vdev)
56
- IPL_assert(rc == 0, "Could not set features bits");
57
- }
58
-
59
- + rc = run_ccw(vdev, CCW_CMD_READ_CONF, &vdev->config, cfg_size, false);
60
- + IPL_assert(rc == 0, "Could not get virtio device configuration");
61
- +
62
- for (i = 0; i < vdev->nr_vqs; i++) {
63
- VqInfo info = {
64
- .queue = (unsigned long long) ring_area + (i * VIRTIO_RING_SIZE),
65
- --
66
- 2.31.1
67
-
SOURCES/kvm-pc-bios-s390-ccw-virtio-Set-missing-status-bits-whil.patch DELETED
@@ -1,93 +0,0 @@
1
- From 303fb3ddcdbbd1373c5b1aa28e03f90507e217f3 Mon Sep 17 00:00:00 2001
2
- From: Thomas Huth <thuth@redhat.com>
3
- Date: Fri, 8 Jul 2022 20:49:01 +0200
4
- Subject: [PATCH 10/17] pc-bios/s390-ccw/virtio: Set missing status bits while
5
- initializing
6
-
7
- RH-Author: Thomas Huth <thuth@redhat.com>
8
- RH-MergeRequest: 106: pc-bios/s390-ccw: Fix boot from disks with 4k sectors that do not have the typical DASD geometry
9
- RH-Commit: [5/10] 4bc44d9adae055fb60b79d04a2f08535b4d38d2b (thuth/qemu-kvm-cs9)
10
- RH-Bugzilla: 2098077
11
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
- RH-Acked-by: David Hildenbrand <david@redhat.com>
13
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
14
-
15
- Bugzilla: http://bugzilla.redhat.com/2098077
16
-
17
- commit 175aa06a152ef6b58ba9b2e47a1296b024dea70c
18
- Author: Thomas Huth <thuth@redhat.com>
19
- Date: Mon Jul 4 13:18:57 2022 +0200
20
-
21
- pc-bios/s390-ccw/virtio: Set missing status bits while initializing
22
-
23
- According chapter "3.1.1 Driver Requirements: Device Initialization"
24
- of the Virtio specification (v1.1), a driver for a device has to set
25
- the ACKNOWLEDGE and DRIVER bits in the status field after resetting
26
- the device. The s390-ccw bios skipped these steps so far and seems
27
- like QEMU never cared. Anyway, it's better to follow the spec, so
28
- let's set these bits now in the right spots, too.
29
-
30
- Message-Id: <20220704111903.62400-7-thuth@redhat.com>
31
- Acked-by: Christian Borntraeger <borntraeger@linux.ibm.com>
32
- Reviewed-by: Cornelia Huck <cohuck@redhat.com>
33
- Reviewed-by: Eric Farman <farman@linux.ibm.com>
34
- Signed-off-by: Thomas Huth <thuth@redhat.com>
35
-
36
- Signed-off-by: Thomas Huth <thuth@redhat.com>
37
- ---
38
- pc-bios/s390-ccw/virtio.c | 18 ++++++++++++++----
39
- 1 file changed, 14 insertions(+), 4 deletions(-)
40
-
41
- diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
42
- index 5d2c6e3381..4e85a2eb82 100644
43
- --- a/pc-bios/s390-ccw/virtio.c
44
- +++ b/pc-bios/s390-ccw/virtio.c
45
- @@ -220,7 +220,7 @@ int virtio_run(VDev *vdev, int vqid, VirtioCmd *cmd)
46
- void virtio_setup_ccw(VDev *vdev)
47
- {
48
- int i, rc, cfg_size = 0;
49
- - unsigned char status = VIRTIO_CONFIG_S_DRIVER_OK;
50
- + uint8_t status;
51
- struct VirtioFeatureDesc {
52
- uint32_t features;
53
- uint8_t index;
54
- @@ -234,6 +234,10 @@ void virtio_setup_ccw(VDev *vdev)
55
-
56
- run_ccw(vdev, CCW_CMD_VDEV_RESET, NULL, 0, false);
57
-
58
- + status = VIRTIO_CONFIG_S_ACKNOWLEDGE;
59
- + rc = run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status), false);
60
- + IPL_assert(rc == 0, "Could not write ACKNOWLEDGE status to host");
61
- +
62
- switch (vdev->senseid.cu_model) {
63
- case VIRTIO_ID_NET:
64
- vdev->nr_vqs = 2;
65
- @@ -253,6 +257,11 @@ void virtio_setup_ccw(VDev *vdev)
66
- default:
67
- panic("Unsupported virtio device\n");
68
- }
69
- +
70
- + status |= VIRTIO_CONFIG_S_DRIVER;
71
- + rc = run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status), false);
72
- + IPL_assert(rc == 0, "Could not write DRIVER status to host");
73
- +
74
- IPL_assert(
75
- run_ccw(vdev, CCW_CMD_READ_CONF, &vdev->config, cfg_size, false) == 0,
76
- "Could not get block device configuration");
77
- @@ -291,9 +300,10 @@ void virtio_setup_ccw(VDev *vdev)
78
- run_ccw(vdev, CCW_CMD_SET_VQ, &info, sizeof(info), false) == 0,
79
- "Cannot set VQ info");
80
- }
81
- - IPL_assert(
82
- - run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status), false) == 0,
83
- - "Could not write status to host");
84
- +
85
- + status |= VIRTIO_CONFIG_S_DRIVER_OK;
86
- + rc = run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status), false);
87
- + IPL_assert(rc == 0, "Could not write DRIVER_OK status to host");
88
- }
89
-
90
- bool virtio_is_supported(SubChannelId schid)
91
- --
92
- 2.31.1
93
-
SOURCES/kvm-pc-bios-s390-ccw-virtio-blkdev-Remove-virtio_assume_.patch DELETED
@@ -1,101 +0,0 @@
1
- From d3335a98a7b6e084aadf4907968536a67cf8e64c Mon Sep 17 00:00:00 2001
2
- From: Thomas Huth <thuth@redhat.com>
3
- Date: Fri, 8 Jul 2022 20:49:01 +0200
4
- Subject: [PATCH 09/17] pc-bios/s390-ccw/virtio-blkdev: Remove
5
- virtio_assume_scsi()
6
-
7
- RH-Author: Thomas Huth <thuth@redhat.com>
8
- RH-MergeRequest: 106: pc-bios/s390-ccw: Fix boot from disks with 4k sectors that do not have the typical DASD geometry
9
- RH-Commit: [4/10] bf27f75344f220a03475a2918ed49ec9cd5ba317 (thuth/qemu-kvm-cs9)
10
- RH-Bugzilla: 2098077
11
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
- RH-Acked-by: David Hildenbrand <david@redhat.com>
13
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
14
-
15
- Bugzilla: http://bugzilla.redhat.com/2098077
16
-
17
- commit 5447de2619050a0a4dd480b97f88a9b58da360d1
18
- Author: Thomas Huth <thuth@redhat.com>
19
- Date: Mon Jul 4 13:18:56 2022 +0200
20
-
21
- pc-bios/s390-ccw/virtio-blkdev: Remove virtio_assume_scsi()
22
-
23
- The virtio_assume_scsi() function is very questionable: First, it
24
- is only called for virtio-blk, and not for virtio-scsi, so the naming
25
- is already quite confusing. Second, it is called if we detected a
26
- "invalid" IPL disk, trying to fix it by blindly setting a sector
27
- size of 512. This of course won't work in most cases since disks
28
- might have a different sector size for a reason.
29
-
30
- Thus let's remove this strange function now. The calling code can
31
- also be removed completely, since there is another spot in main.c
32
- that does "IPL_assert(virtio_ipl_disk_is_valid(), ...)" to make
33
- sure that we do not try to IPL from an invalid device.
34
-
35
- Message-Id: <20220704111903.62400-6-thuth@redhat.com>
36
- Reviewed-by: Eric Farman <farman@linux.ibm.com>
37
- Signed-off-by: Thomas Huth <thuth@redhat.com>
38
-
39
- Signed-off-by: Thomas Huth <thuth@redhat.com>
40
- ---
41
- pc-bios/s390-ccw/virtio-blkdev.c | 24 ------------------------
42
- pc-bios/s390-ccw/virtio.h | 1 -
43
- 2 files changed, 25 deletions(-)
44
-
45
- diff --git a/pc-bios/s390-ccw/virtio-blkdev.c b/pc-bios/s390-ccw/virtio-blkdev.c
46
- index 7e13155589..db1f7f44aa 100644
47
- --- a/pc-bios/s390-ccw/virtio-blkdev.c
48
- +++ b/pc-bios/s390-ccw/virtio-blkdev.c
49
- @@ -112,23 +112,6 @@ VirtioGDN virtio_guessed_disk_nature(void)
50
- return virtio_get_device()->guessed_disk_nature;
51
- }
52
-
53
- -void virtio_assume_scsi(void)
54
- -{
55
- - VDev *vdev = virtio_get_device();
56
- -
57
- - switch (vdev->senseid.cu_model) {
58
- - case VIRTIO_ID_BLOCK:
59
- - vdev->guessed_disk_nature = VIRTIO_GDN_SCSI;
60
- - vdev->config.blk.blk_size = VIRTIO_SCSI_BLOCK_SIZE;
61
- - vdev->config.blk.physical_block_exp = 0;
62
- - vdev->blk_factor = 1;
63
- - break;
64
- - case VIRTIO_ID_SCSI:
65
- - vdev->scsi_block_size = VIRTIO_SCSI_BLOCK_SIZE;
66
- - break;
67
- - }
68
- -}
69
- -
70
- void virtio_assume_iso9660(void)
71
- {
72
- VDev *vdev = virtio_get_device();
73
- @@ -247,13 +230,6 @@ int virtio_blk_setup_device(SubChannelId schid)
74
- switch (vdev->senseid.cu_model) {
75
- case VIRTIO_ID_BLOCK:
76
- sclp_print("Using virtio-blk.\n");
77
- - if (!virtio_ipl_disk_is_valid()) {
78
- - /* make sure all getters but blocksize return 0 for
79
- - * invalid IPL disk
80
- - */
81
- - memset(&vdev->config.blk, 0, sizeof(vdev->config.blk));
82
- - virtio_assume_scsi();
83
- - }
84
- break;
85
- case VIRTIO_ID_SCSI:
86
- IPL_assert(vdev->config.scsi.sense_size == VIRTIO_SCSI_SENSE_SIZE,
87
- diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h
88
- index 241730effe..600ba5052b 100644
89
- --- a/pc-bios/s390-ccw/virtio.h
90
- +++ b/pc-bios/s390-ccw/virtio.h
91
- @@ -182,7 +182,6 @@ enum guessed_disk_nature_type {
92
- typedef enum guessed_disk_nature_type VirtioGDN;
93
-
94
- VirtioGDN virtio_guessed_disk_nature(void);
95
- -void virtio_assume_scsi(void);
96
- void virtio_assume_eckd(void);
97
- void virtio_assume_iso9660(void);
98
-
99
- --
100
- 2.31.1
101
-
SOURCES/kvm-pc-bios-s390-ccw-virtio-blkdev-Request-the-right-fea.patch DELETED
@@ -1,63 +0,0 @@
1
- From db58915fcaf3d24b64fe2c34cc15b5596b9a81bb Mon Sep 17 00:00:00 2001
2
- From: Thomas Huth <thuth@redhat.com>
3
- Date: Fri, 8 Jul 2022 20:49:01 +0200
4
- Subject: [PATCH 14/17] pc-bios/s390-ccw/virtio-blkdev: Request the right
5
- feature bits
6
-
7
- RH-Author: Thomas Huth <thuth@redhat.com>
8
- RH-MergeRequest: 106: pc-bios/s390-ccw: Fix boot from disks with 4k sectors that do not have the typical DASD geometry
9
- RH-Commit: [9/10] 9dcd8c2f659f366f9487ab6473d1f0d7778b40a7 (thuth/qemu-kvm-cs9)
10
- RH-Bugzilla: 2098077
11
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
- RH-Acked-by: David Hildenbrand <david@redhat.com>
13
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
14
-
15
- Bugzilla: http://bugzilla.redhat.com/2098077
16
-
17
- commit 9125a314cca4a1838b09305a87d8efb98f80ab67
18
- Author: Thomas Huth <thuth@redhat.com>
19
- Date: Mon Jul 4 13:19:01 2022 +0200
20
-
21
- pc-bios/s390-ccw/virtio-blkdev: Request the right feature bits
22
-
23
- The virtio-blk code uses the block size and geometry fields in the
24
- config area. According to the virtio-spec, these have to be negotiated
25
- with the right feature bits during initialization, otherwise they
26
- might not be available. QEMU is so far very forgiving and always
27
- provides them, but we should not rely on this behavior, so let's
28
- better request them properly via the VIRTIO_BLK_F_GEOMETRY and
29
- VIRTIO_BLK_F_BLK_SIZE feature bits.
30
-
31
- Message-Id: <20220704111903.62400-11-thuth@redhat.com>
32
- Signed-off-by: Thomas Huth <thuth@redhat.com>
33
-
34
- Signed-off-by: Thomas Huth <thuth@redhat.com>
35
- ---
36
- pc-bios/s390-ccw/virtio-blkdev.c | 4 ++++
37
- 1 file changed, 4 insertions(+)
38
-
39
- diff --git a/pc-bios/s390-ccw/virtio-blkdev.c b/pc-bios/s390-ccw/virtio-blkdev.c
40
- index c175b66a47..8271c47296 100644
41
- --- a/pc-bios/s390-ccw/virtio-blkdev.c
42
- +++ b/pc-bios/s390-ccw/virtio-blkdev.c
43
- @@ -13,6 +13,9 @@
44
- #include "virtio.h"
45
- #include "virtio-scsi.h"
46
-
47
- +#define VIRTIO_BLK_F_GEOMETRY (1 << 4)
48
- +#define VIRTIO_BLK_F_BLK_SIZE (1 << 6)
49
- +
50
- static int virtio_blk_read_many(VDev *vdev, ulong sector, void *load_addr,
51
- int sec_num)
52
- {
53
- @@ -223,6 +226,7 @@ int virtio_blk_setup_device(SubChannelId schid)
54
- {
55
- VDev *vdev = virtio_get_device();
56
-
57
- + vdev->guest_features[0] = VIRTIO_BLK_F_GEOMETRY | VIRTIO_BLK_F_BLK_SIZE;
58
- vdev->schid = schid;
59
- virtio_setup_ccw(vdev);
60
-
61
- --
62
- 2.31.1
63
-
SOURCES/kvm-pc-bios-s390-ccw-virtio-blkdev-Simplify-fix-virtio_i.patch DELETED
@@ -1,124 +0,0 @@
1
- From f07e4629a7c58407f903810a038660c88c6a6315 Mon Sep 17 00:00:00 2001
2
- From: Thomas Huth <thuth@redhat.com>
3
- Date: Fri, 8 Jul 2022 20:49:01 +0200
4
- Subject: [PATCH 08/17] pc-bios/s390-ccw/virtio-blkdev: Simplify/fix
5
- virtio_ipl_disk_is_valid()
6
-
7
- RH-Author: Thomas Huth <thuth@redhat.com>
8
- RH-MergeRequest: 106: pc-bios/s390-ccw: Fix boot from disks with 4k sectors that do not have the typical DASD geometry
9
- RH-Commit: [3/10] fb06830a3e50d9da3d84913b50bb227865cc44b3 (thuth/qemu-kvm-cs9)
10
- RH-Bugzilla: 2098077
11
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
- RH-Acked-by: David Hildenbrand <david@redhat.com>
13
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
14
-
15
- Bugzilla: http://bugzilla.redhat.com/2098077
16
-
17
- commit bbf615f7b707f009ef8e757d170902ad33b90644
18
- Author: Thomas Huth <thuth@redhat.com>
19
- Date: Mon Jul 4 13:18:55 2022 +0200
20
-
21
- pc-bios/s390-ccw/virtio-blkdev: Simplify/fix virtio_ipl_disk_is_valid()
22
-
23
- The s390-ccw bios fails to boot if the boot disk is a virtio-blk
24
- disk with a sector size of 4096. For example:
25
-
26
- dasdfmt -b 4096 -d cdl -y -p -M quick /dev/dasdX
27
- fdasd -a /dev/dasdX
28
- install a guest onto /dev/dasdX1 using virtio-blk
29
- qemu-system-s390x -nographic -hda /dev/dasdX1
30
-
31
- The bios then bails out with:
32
-
33
- ! Cannot read block 0 !
34
-
35
- Looking at virtio_ipl_disk_is_valid() and especially the function
36
- virtio_disk_is_scsi(), it does not really make sense that we expect
37
- only such a limited disk geometry (like a block size of 512) for
38
- our boot disks. Let's relax the check and allow everything that
39
- remotely looks like a sane disk.
40
-
41
- Message-Id: <20220704111903.62400-5-thuth@redhat.com>
42
- Reviewed-by: Eric Farman <farman@linux.ibm.com>
43
- Signed-off-by: Thomas Huth <thuth@redhat.com>
44
-
45
- Signed-off-by: Thomas Huth <thuth@redhat.com>
46
- ---
47
- pc-bios/s390-ccw/virtio-blkdev.c | 41 ++++++--------------------------
48
- pc-bios/s390-ccw/virtio.h | 2 --
49
- 2 files changed, 7 insertions(+), 36 deletions(-)
50
-
51
- diff --git a/pc-bios/s390-ccw/virtio-blkdev.c b/pc-bios/s390-ccw/virtio-blkdev.c
52
- index 6483307630..7e13155589 100644
53
- --- a/pc-bios/s390-ccw/virtio-blkdev.c
54
- +++ b/pc-bios/s390-ccw/virtio-blkdev.c
55
- @@ -166,46 +166,19 @@ void virtio_assume_eckd(void)
56
- virtio_eckd_sectors_for_block_size(vdev->config.blk.blk_size);
57
- }
58
-
59
- -bool virtio_disk_is_scsi(void)
60
- -{
61
- - VDev *vdev = virtio_get_device();
62
- -
63
- - if (vdev->guessed_disk_nature == VIRTIO_GDN_SCSI) {
64
- - return true;
65
- - }
66
- - switch (vdev->senseid.cu_model) {
67
- - case VIRTIO_ID_BLOCK:
68
- - return (vdev->config.blk.geometry.heads == 255)
69
- - && (vdev->config.blk.geometry.sectors == 63)
70
- - && (virtio_get_block_size() == VIRTIO_SCSI_BLOCK_SIZE);
71
- - case VIRTIO_ID_SCSI:
72
- - return true;
73
- - }
74
- - return false;
75
- -}
76
- -
77
- -bool virtio_disk_is_eckd(void)
78
- +bool virtio_ipl_disk_is_valid(void)
79
- {
80
- + int blksize = virtio_get_block_size();
81
- VDev *vdev = virtio_get_device();
82
- - const int block_size = virtio_get_block_size();
83
-
84
- - if (vdev->guessed_disk_nature == VIRTIO_GDN_DASD) {
85
- + if (vdev->guessed_disk_nature == VIRTIO_GDN_SCSI ||
86
- + vdev->guessed_disk_nature == VIRTIO_GDN_DASD) {
87
- return true;
88
- }
89
- - switch (vdev->senseid.cu_model) {
90
- - case VIRTIO_ID_BLOCK:
91
- - return (vdev->config.blk.geometry.heads == 15)
92
- - && (vdev->config.blk.geometry.sectors ==
93
- - virtio_eckd_sectors_for_block_size(block_size));
94
- - case VIRTIO_ID_SCSI:
95
- - return false;
96
- - }
97
- - return false;
98
- -}
99
-
100
- -bool virtio_ipl_disk_is_valid(void)
101
- -{
102
- - return virtio_disk_is_scsi() || virtio_disk_is_eckd();
103
- + return (vdev->senseid.cu_model == VIRTIO_ID_BLOCK ||
104
- + vdev->senseid.cu_model == VIRTIO_ID_SCSI) &&
105
- + blksize >= 512 && blksize <= 4096;
106
- }
107
-
108
- int virtio_get_block_size(void)
109
- diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h
110
- index 9e410bde6f..241730effe 100644
111
- --- a/pc-bios/s390-ccw/virtio.h
112
- +++ b/pc-bios/s390-ccw/virtio.h
113
- @@ -186,8 +186,6 @@ void virtio_assume_scsi(void);
114
- void virtio_assume_eckd(void);
115
- void virtio_assume_iso9660(void);
116
-
117
- -extern bool virtio_disk_is_scsi(void);
118
- -extern bool virtio_disk_is_eckd(void);
119
- extern bool virtio_ipl_disk_is_valid(void);
120
- extern int virtio_get_block_size(void);
121
- extern uint8_t virtio_get_heads(void);
122
- --
123
- 2.31.1
124
-
SOURCES/kvm-qapi-machine.json-Add-cluster-id.patch DELETED
@@ -1,126 +0,0 @@
1
- From e97c563f7146098119839aa146a6f25070eb7148 Mon Sep 17 00:00:00 2001
2
- From: Gavin Shan <gshan@redhat.com>
3
- Date: Wed, 11 May 2022 18:01:02 +0800
4
- Subject: [PATCH 01/16] qapi/machine.json: Add cluster-id
5
-
6
- RH-Author: Gavin Shan <gshan@redhat.com>
7
- RH-MergeRequest: 86: hw/arm/virt: Fix the default CPU topology
8
- RH-Commit: [1/6] 44d7d83008c6d28485ae44f7cced792f4987b919 (gwshan/qemu-rhel-9)
9
- RH-Bugzilla: 2041823
10
- RH-Acked-by: Eric Auger <eric.auger@redhat.com>
11
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
12
- RH-Acked-by: Andrew Jones <drjones@redhat.com>
13
-
14
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2041823
15
-
16
- This adds cluster-id in CPU instance properties, which will be used
17
- by arm/virt machine. Besides, the cluster-id is also verified or
18
- dumped in various spots:
19
-
20
- * hw/core/machine.c::machine_set_cpu_numa_node() to associate
21
- CPU with its NUMA node.
22
-
23
- * hw/core/machine.c::machine_numa_finish_cpu_init() to record
24
- CPU slots with no NUMA mapping set.
25
-
26
- * hw/core/machine-hmp-cmds.c::hmp_hotpluggable_cpus() to dump
27
- cluster-id.
28
-
29
- Signed-off-by: Gavin Shan <gshan@redhat.com>
30
- Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
31
- Acked-by: Igor Mammedov <imammedo@redhat.com>
32
- Message-id: 20220503140304.855514-2-gshan@redhat.com
33
- Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
34
- (cherry picked from commit 1dcf7001d4bae651129d46d5628b29e93a411d0b)
35
- Signed-off-by: Gavin Shan <gshan@redhat.com>
36
- ---
37
- hw/core/machine-hmp-cmds.c | 4 ++++
38
- hw/core/machine.c | 16 ++++++++++++++++
39
- qapi/machine.json | 6 ++++--
40
- 3 files changed, 24 insertions(+), 2 deletions(-)
41
-
42
- diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
43
- index 4e2f319aeb..5cb5eecbfc 100644
44
- --- a/hw/core/machine-hmp-cmds.c
45
- +++ b/hw/core/machine-hmp-cmds.c
46
- @@ -77,6 +77,10 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)
47
- if (c->has_die_id) {
48
- monitor_printf(mon, " die-id: \"%" PRIu64 "\"\n", c->die_id);
49
- }
50
- + if (c->has_cluster_id) {
51
- + monitor_printf(mon, " cluster-id: \"%" PRIu64 "\"\n",
52
- + c->cluster_id);
53
- + }
54
- if (c->has_core_id) {
55
- monitor_printf(mon, " core-id: \"%" PRIu64 "\"\n", c->core_id);
56
- }
57
- diff --git a/hw/core/machine.c b/hw/core/machine.c
58
- index dffc3ef4ab..168f4de910 100644
59
- --- a/hw/core/machine.c
60
- +++ b/hw/core/machine.c
61
- @@ -890,6 +890,11 @@ void machine_set_cpu_numa_node(MachineState *machine,
62
- return;
63
- }
64
-
65
- + if (props->has_cluster_id && !slot->props.has_cluster_id) {
66
- + error_setg(errp, "cluster-id is not supported");
67
- + return;
68
- + }
69
- +
70
- if (props->has_socket_id && !slot->props.has_socket_id) {
71
- error_setg(errp, "socket-id is not supported");
72
- return;
73
- @@ -909,6 +914,11 @@ void machine_set_cpu_numa_node(MachineState *machine,
74
- continue;
75
- }
76
-
77
- + if (props->has_cluster_id &&
78
- + props->cluster_id != slot->props.cluster_id) {
79
- + continue;
80
- + }
81
- +
82
- if (props->has_die_id && props->die_id != slot->props.die_id) {
83
- continue;
84
- }
85
- @@ -1203,6 +1213,12 @@ static char *cpu_slot_to_string(const CPUArchId *cpu)
86
- }
87
- g_string_append_printf(s, "die-id: %"PRId64, cpu->props.die_id);
88
- }
89
- + if (cpu->props.has_cluster_id) {
90
- + if (s->len) {
91
- + g_string_append_printf(s, ", ");
92
- + }
93
- + g_string_append_printf(s, "cluster-id: %"PRId64, cpu->props.cluster_id);
94
- + }
95
- if (cpu->props.has_core_id) {
96
- if (s->len) {
97
- g_string_append_printf(s, ", ");
98
- diff --git a/qapi/machine.json b/qapi/machine.json
99
- index d25a481ce4..4c417e32a5 100644
100
- --- a/qapi/machine.json
101
- +++ b/qapi/machine.json
102
- @@ -868,10 +868,11 @@
103
- # @node-id: NUMA node ID the CPU belongs to
104
- # @socket-id: socket number within node/board the CPU belongs to
105
- # @die-id: die number within socket the CPU belongs to (since 4.1)
106
- -# @core-id: core number within die the CPU belongs to
107
- +# @cluster-id: cluster number within die the CPU belongs to (since 7.1)
108
- +# @core-id: core number within cluster the CPU belongs to
109
- # @thread-id: thread number within core the CPU belongs to
110
- #
111
- -# Note: currently there are 5 properties that could be present
112
- +# Note: currently there are 6 properties that could be present
113
- # but management should be prepared to pass through other
114
- # properties with device_add command to allow for future
115
- # interface extension. This also requires the filed names to be kept in
116
- @@ -883,6 +884,7 @@
117
- 'data': { '*node-id': 'int',
118
- '*socket-id': 'int',
119
- '*die-id': 'int',
120
- + '*cluster-id': 'int',
121
- '*core-id': 'int',
122
- '*thread-id': 'int'
123
- }
124
- --
125
- 2.31.1
126
-
SOURCES/kvm-qcow2-Add-errp-to-rebuild_refcount_structure.patch DELETED
@@ -1,162 +0,0 @@
1
- From 5e385a0e49a520550a83299632be175857b63f19 Mon Sep 17 00:00:00 2001
2
- From: Hanna Reitz <hreitz@redhat.com>
3
- Date: Tue, 5 Apr 2022 15:46:52 +0200
4
- Subject: [PATCH 06/16] qcow2: Add errp to rebuild_refcount_structure()
5
-
6
- RH-Author: Hanna Reitz <hreitz@redhat.com>
7
- RH-MergeRequest: 96: qcow2: Improve refcount structure rebuilding
8
- RH-Commit: [3/4] 937b89a7eab6ec6b18618d59bc1526976ad03290 (hreitz/qemu-kvm-c-9-s)
9
- RH-Bugzilla: 2072379
10
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
- RH-Acked-by: Eric Blake <eblake@redhat.com>
12
- RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
13
-
14
- Instead of fprint()-ing error messages in rebuild_refcount_structure()
15
- and its rebuild_refcounts_write_refblocks() helper, pass them through an
16
- Error object to qcow2_check_refcounts() (which will then print it).
17
-
18
- Suggested-by: Eric Blake <eblake@redhat.com>
19
- Signed-off-by: Hanna Reitz <hreitz@redhat.com>
20
- Message-Id: <20220405134652.19278-4-hreitz@redhat.com>
21
- Reviewed-by: Eric Blake <eblake@redhat.com>
22
- (cherry picked from commit 0423f75351ab83b844a31349218b0eadd830e07a)
23
- Signed-off-by: Hanna Reitz <hreitz@redhat.com>
24
- ---
25
- block/qcow2-refcount.c | 33 +++++++++++++++++++--------------
26
- 1 file changed, 19 insertions(+), 14 deletions(-)
27
-
28
- diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
29
- index c5669eaa51..ed0ecfaa89 100644
30
- --- a/block/qcow2-refcount.c
31
- +++ b/block/qcow2-refcount.c
32
- @@ -2465,7 +2465,8 @@ static int64_t alloc_clusters_imrt(BlockDriverState *bs,
33
- static int rebuild_refcounts_write_refblocks(
34
- BlockDriverState *bs, void **refcount_table, int64_t *nb_clusters,
35
- int64_t first_cluster, int64_t end_cluster,
36
- - uint64_t **on_disk_reftable_ptr, uint32_t *on_disk_reftable_entries_ptr
37
- + uint64_t **on_disk_reftable_ptr, uint32_t *on_disk_reftable_entries_ptr,
38
- + Error **errp
39
- )
40
- {
41
- BDRVQcow2State *s = bs->opaque;
42
- @@ -2516,8 +2517,8 @@ static int rebuild_refcounts_write_refblocks(
43
- nb_clusters,
44
- &first_free_cluster);
45
- if (refblock_offset < 0) {
46
- - fprintf(stderr, "ERROR allocating refblock: %s\n",
47
- - strerror(-refblock_offset));
48
- + error_setg_errno(errp, -refblock_offset,
49
- + "ERROR allocating refblock");
50
- return refblock_offset;
51
- }
52
-
53
- @@ -2539,6 +2540,7 @@ static int rebuild_refcounts_write_refblocks(
54
- on_disk_reftable_entries *
55
- REFTABLE_ENTRY_SIZE);
56
- if (!on_disk_reftable) {
57
- + error_setg(errp, "ERROR allocating reftable memory");
58
- return -ENOMEM;
59
- }
60
-
61
- @@ -2562,7 +2564,7 @@ static int rebuild_refcounts_write_refblocks(
62
- ret = qcow2_pre_write_overlap_check(bs, 0, refblock_offset,
63
- s->cluster_size, false);
64
- if (ret < 0) {
65
- - fprintf(stderr, "ERROR writing refblock: %s\n", strerror(-ret));
66
- + error_setg_errno(errp, -ret, "ERROR writing refblock");
67
- return ret;
68
- }
69
-
70
- @@ -2578,7 +2580,7 @@ static int rebuild_refcounts_write_refblocks(
71
- ret = bdrv_pwrite(bs->file, refblock_offset, on_disk_refblock,
72
- s->cluster_size);
73
- if (ret < 0) {
74
- - fprintf(stderr, "ERROR writing refblock: %s\n", strerror(-ret));
75
- + error_setg_errno(errp, -ret, "ERROR writing refblock");
76
- return ret;
77
- }
78
-
79
- @@ -2601,7 +2603,8 @@ static int rebuild_refcounts_write_refblocks(
80
- static int rebuild_refcount_structure(BlockDriverState *bs,
81
- BdrvCheckResult *res,
82
- void **refcount_table,
83
- - int64_t *nb_clusters)
84
- + int64_t *nb_clusters,
85
- + Error **errp)
86
- {
87
- BDRVQcow2State *s = bs->opaque;
88
- int64_t reftable_offset = -1;
89
- @@ -2652,7 +2655,7 @@ static int rebuild_refcount_structure(BlockDriverState *bs,
90
- rebuild_refcounts_write_refblocks(bs, refcount_table, nb_clusters,
91
- 0, *nb_clusters,
92
- &on_disk_reftable,
93
- - &on_disk_reftable_entries);
94
- + &on_disk_reftable_entries, errp);
95
- if (reftable_size_changed < 0) {
96
- res->check_errors++;
97
- ret = reftable_size_changed;
98
- @@ -2676,8 +2679,8 @@ static int rebuild_refcount_structure(BlockDriverState *bs,
99
- refcount_table, nb_clusters,
100
- &first_free_cluster);
101
- if (reftable_offset < 0) {
102
- - fprintf(stderr, "ERROR allocating reftable: %s\n",
103
- - strerror(-reftable_offset));
104
- + error_setg_errno(errp, -reftable_offset,
105
- + "ERROR allocating reftable");
106
- res->check_errors++;
107
- ret = reftable_offset;
108
- goto fail;
109
- @@ -2695,7 +2698,7 @@ static int rebuild_refcount_structure(BlockDriverState *bs,
110
- reftable_start_cluster,
111
- reftable_end_cluster,
112
- &on_disk_reftable,
113
- - &on_disk_reftable_entries);
114
- + &on_disk_reftable_entries, errp);
115
- if (reftable_size_changed < 0) {
116
- res->check_errors++;
117
- ret = reftable_size_changed;
118
- @@ -2725,7 +2728,7 @@ static int rebuild_refcount_structure(BlockDriverState *bs,
119
- ret = qcow2_pre_write_overlap_check(bs, 0, reftable_offset, reftable_length,
120
- false);
121
- if (ret < 0) {
122
- - fprintf(stderr, "ERROR writing reftable: %s\n", strerror(-ret));
123
- + error_setg_errno(errp, -ret, "ERROR writing reftable");
124
- goto fail;
125
- }
126
-
127
- @@ -2733,7 +2736,7 @@ static int rebuild_refcount_structure(BlockDriverState *bs,
128
- ret = bdrv_pwrite(bs->file, reftable_offset, on_disk_reftable,
129
- reftable_length);
130
- if (ret < 0) {
131
- - fprintf(stderr, "ERROR writing reftable: %s\n", strerror(-ret));
132
- + error_setg_errno(errp, -ret, "ERROR writing reftable");
133
- goto fail;
134
- }
135
-
136
- @@ -2746,7 +2749,7 @@ static int rebuild_refcount_structure(BlockDriverState *bs,
137
- &reftable_offset_and_clusters,
138
- sizeof(reftable_offset_and_clusters));
139
- if (ret < 0) {
140
- - fprintf(stderr, "ERROR setting reftable: %s\n", strerror(-ret));
141
- + error_setg_errno(errp, -ret, "ERROR setting reftable");
142
- goto fail;
143
- }
144
-
145
- @@ -2814,11 +2817,13 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
146
- if (rebuild && (fix & BDRV_FIX_ERRORS)) {
147
- BdrvCheckResult old_res = *res;
148
- int fresh_leaks = 0;
149
- + Error *local_err = NULL;
150
-
151
- fprintf(stderr, "Rebuilding refcount structure\n");
152
- ret = rebuild_refcount_structure(bs, res, &refcount_table,
153
- - &nb_clusters);
154
- + &nb_clusters, &local_err);
155
- if (ret < 0) {
156
- + error_report_err(local_err);
157
- goto fail;
158
- }
159
-
160
- --
161
- 2.31.1
162
-
SOURCES/kvm-qcow2-Fix-theoretical-corruption-in-store_bitmap-err.patch ADDED
@@ -0,0 +1,67 @@
1
+ From 46ead2c391924b68741d6da28f28f909b80f5914 Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Thu, 12 Jan 2023 20:14:51 +0100
4
+ Subject: [PATCH 01/20] qcow2: Fix theoretical corruption in store_bitmap()
5
+ error path
6
+ MIME-Version: 1.0
7
+ Content-Type: text/plain; charset=UTF-8
8
+ Content-Transfer-Encoding: 8bit
9
+
10
+ RH-Author: Kevin Wolf <kwolf@redhat.com>
11
+ RH-MergeRequest: 143: qemu-img: Fix exit code for errors closing the image
12
+ RH-Bugzilla: 2150180
13
+ RH-Acked-by: Thomas Huth <thuth@redhat.com>
14
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
15
+ RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
16
+ RH-Commit: [1/4] a6a497947179431567d330d0501247a3749fb9fd (kmwolf/centos-qemu-kvm)
17
+
18
+ In order to write the bitmap table to the image file, it is converted to
19
+ big endian. If the write fails, it is passed to clear_bitmap_table() to
20
+ free all of the clusters it had allocated before. However, if we don't
21
+ convert it back to native endianness first, we'll free things at a wrong
22
+ offset.
23
+
24
+ In practical terms, the offsets will be so high that we won't actually
25
+ free any allocated clusters, but just run into an error, but in theory
26
+ this can cause image corruption.
27
+
28
+ Cc: qemu-stable@nongnu.org
29
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
30
+ Message-Id: <20230112191454.169353-2-kwolf@redhat.com>
31
+ Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
32
+ Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
33
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
34
+ (cherry picked from commit b03dd9613bcf8fe948581b2b3585510cb525c382)
35
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
36
+ ---
37
+ block/qcow2-bitmap.c | 5 +++--
38
+ 1 file changed, 3 insertions(+), 2 deletions(-)
39
+
40
+ diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
41
+ index bcad567c0c..3dff99ba06 100644
42
+ --- a/block/qcow2-bitmap.c
43
+ +++ b/block/qcow2-bitmap.c
44
+ @@ -115,7 +115,7 @@ static int update_header_sync(BlockDriverState *bs)
45
+ return bdrv_flush(bs->file->bs);
46
+ }
47
+
48
+ -static inline void bitmap_table_to_be(uint64_t *bitmap_table, size_t size)
49
+ +static inline void bitmap_table_bswap_be(uint64_t *bitmap_table, size_t size)
50
+ {
51
+ size_t i;
52
+
53
+ @@ -1401,9 +1401,10 @@ static int store_bitmap(BlockDriverState *bs, Qcow2Bitmap *bm, Error **errp)
54
+ goto fail;
55
+ }
56
+
57
+ - bitmap_table_to_be(tb, tb_size);
58
+ + bitmap_table_bswap_be(tb, tb_size);
59
+ ret = bdrv_pwrite(bs->file, tb_offset, tb_size * sizeof(tb[0]), tb, 0);
60
+ if (ret < 0) {
61
+ + bitmap_table_bswap_be(tb, tb_size);
62
+ error_setg_errno(errp, -ret, "Failed to write bitmap '%s' to file",
63
+ bm_name);
64
+ goto fail;
65
+ --
66
+ 2.31.1
67
+
SOURCES/kvm-qcow2-Improve-refcount-structure-rebuilding.patch DELETED
@@ -1,465 +0,0 @@
1
- From b453cf6be8429f4438d51eb24fcf49e7d9f14db6 Mon Sep 17 00:00:00 2001
2
- From: Hanna Reitz <hreitz@redhat.com>
3
- Date: Tue, 5 Apr 2022 15:46:50 +0200
4
- Subject: [PATCH 04/16] qcow2: Improve refcount structure rebuilding
5
-
6
- RH-Author: Hanna Reitz <hreitz@redhat.com>
7
- RH-MergeRequest: 96: qcow2: Improve refcount structure rebuilding
8
- RH-Commit: [1/4] a3606b7abcaebb4930b566e95b1090aead62dfae (hreitz/qemu-kvm-c-9-s)
9
- RH-Bugzilla: 2072379
10
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
- RH-Acked-by: Eric Blake <eblake@redhat.com>
12
- RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
13
-
14
- When rebuilding the refcount structures (when qemu-img check -r found
15
- errors with refcount = 0, but reference count > 0), the new refcount
16
- table defaults to being put at the image file end[1]. There is no good
17
- reason for that except that it means we will not have to rewrite any
18
- refblocks we already wrote to disk.
19
-
20
- Changing the code to rewrite those refblocks is not too difficult,
21
- though, so let us do that. That is beneficial for images on block
22
- devices, where we cannot really write beyond the end of the image file.
23
-
24
- Use this opportunity to add extensive comments to the code, and refactor
25
- it a bit, getting rid of the backwards-jumping goto.
26
-
27
- [1] Unless there is something allocated in the area pointed to by the
28
- last refblock, so we have to write that refblock. In that case, we
29
- try to put the reftable in there.
30
-
31
- Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1519071
32
- Closes: https://gitlab.com/qemu-project/qemu/-/issues/941
33
- Reviewed-by: Eric Blake <eblake@redhat.com>
34
- Signed-off-by: Hanna Reitz <hreitz@redhat.com>
35
- Message-Id: <20220405134652.19278-2-hreitz@redhat.com>
36
- (cherry picked from commit a8c07ec287554dcefd33733f0e5888a281ddc95e)
37
- Signed-off-by: Hanna Reitz <hreitz@redhat.com>
38
- ---
39
- block/qcow2-refcount.c | 332 +++++++++++++++++++++++++++++------------
40
- 1 file changed, 235 insertions(+), 97 deletions(-)
41
-
42
- diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
43
- index b91499410c..c5669eaa51 100644
44
- --- a/block/qcow2-refcount.c
45
- +++ b/block/qcow2-refcount.c
46
- @@ -2438,111 +2438,140 @@ static int64_t alloc_clusters_imrt(BlockDriverState *bs,
47
- }
48
-
49
- /*
50
- - * Creates a new refcount structure based solely on the in-memory information
51
- - * given through *refcount_table. All necessary allocations will be reflected
52
- - * in that array.
53
- + * Helper function for rebuild_refcount_structure().
54
- *
55
- - * On success, the old refcount structure is leaked (it will be covered by the
56
- - * new refcount structure).
57
- + * Scan the range of clusters [first_cluster, end_cluster) for allocated
58
- + * clusters and write all corresponding refblocks to disk. The refblock
59
- + * and allocation data is taken from the in-memory refcount table
60
- + * *refcount_table[] (of size *nb_clusters), which is basically one big
61
- + * (unlimited size) refblock for the whole image.
62
- + *
63
- + * For these refblocks, clusters are allocated using said in-memory
64
- + * refcount table. Care is taken that these allocations are reflected
65
- + * in the refblocks written to disk.
66
- + *
67
- + * The refblocks' offsets are written into a reftable, which is
68
- + * *on_disk_reftable_ptr[] (of size *on_disk_reftable_entries_ptr). If
69
- + * that reftable is of insufficient size, it will be resized to fit.
70
- + * This reftable is not written to disk.
71
- + *
72
- + * (If *on_disk_reftable_ptr is not NULL, the entries within are assumed
73
- + * to point to existing valid refblocks that do not need to be allocated
74
- + * again.)
75
- + *
76
- + * Return whether the on-disk reftable array was resized (true/false),
77
- + * or -errno on error.
78
- */
79
- -static int rebuild_refcount_structure(BlockDriverState *bs,
80
- - BdrvCheckResult *res,
81
- - void **refcount_table,
82
- - int64_t *nb_clusters)
83
- +static int rebuild_refcounts_write_refblocks(
84
- + BlockDriverState *bs, void **refcount_table, int64_t *nb_clusters,
85
- + int64_t first_cluster, int64_t end_cluster,
86
- + uint64_t **on_disk_reftable_ptr, uint32_t *on_disk_reftable_entries_ptr
87
- + )
88
- {
89
- BDRVQcow2State *s = bs->opaque;
90
- - int64_t first_free_cluster = 0, reftable_offset = -1, cluster = 0;
91
- + int64_t cluster;
92
- int64_t refblock_offset, refblock_start, refblock_index;
93
- - uint32_t reftable_size = 0;
94
- - uint64_t *on_disk_reftable = NULL;
95
- + int64_t first_free_cluster = 0;
96
- + uint64_t *on_disk_reftable = *on_disk_reftable_ptr;
97
- + uint32_t on_disk_reftable_entries = *on_disk_reftable_entries_ptr;
98
- void *on_disk_refblock;
99
- - int ret = 0;
100
- - struct {
101
- - uint64_t reftable_offset;
102
- - uint32_t reftable_clusters;
103
- - } QEMU_PACKED reftable_offset_and_clusters;
104
- -
105
- - qcow2_cache_empty(bs, s->refcount_block_cache);
106
- + bool reftable_grown = false;
107
- + int ret;
108
-
109
- -write_refblocks:
110
- - for (; cluster < *nb_clusters; cluster++) {
111
- + for (cluster = first_cluster; cluster < end_cluster; cluster++) {
112
- + /* Check all clusters to find refblocks that contain non-zero entries */
113
- if (!s->get_refcount(*refcount_table, cluster)) {
114
- continue;
115
- }
116
-
117
- + /*
118
- + * This cluster is allocated, so we need to create a refblock
119
- + * for it. The data we will write to disk is just the
120
- + * respective slice from *refcount_table, so it will contain
121
- + * accurate refcounts for all clusters belonging to this
122
- + * refblock. After we have written it, we will therefore skip
123
- + * all remaining clusters in this refblock.
124
- + */
125
- +
126
- refblock_index = cluster >> s->refcount_block_bits;
127
- refblock_start = refblock_index << s->refcount_block_bits;
128
-
129
- - /* Don't allocate a cluster in a refblock already written to disk */
130
- - if (first_free_cluster < refblock_start) {
131
- - first_free_cluster = refblock_start;
132
- - }
133
- - refblock_offset = alloc_clusters_imrt(bs, 1, refcount_table,
134
- - nb_clusters, &first_free_cluster);
135
- - if (refblock_offset < 0) {
136
- - fprintf(stderr, "ERROR allocating refblock: %s\n",
137
- - strerror(-refblock_offset));
138
- - res->check_errors++;
139
- - ret = refblock_offset;
140
- - goto fail;
141
- - }
142
- + if (on_disk_reftable_entries > refblock_index &&
143
- + on_disk_reftable[refblock_index])
144
- + {
145
- + /*
146
- + * We can get here after a `goto write_refblocks`: We have a
147
- + * reftable from a previous run, and the refblock is already
148
- + * allocated. No need to allocate it again.
149
- + */
150
- + refblock_offset = on_disk_reftable[refblock_index];
151
- + } else {
152
- + int64_t refblock_cluster_index;
153
-
154
- - if (reftable_size <= refblock_index) {
155
- - uint32_t old_reftable_size = reftable_size;
156
- - uint64_t *new_on_disk_reftable;
157
- + /* Don't allocate a cluster in a refblock already written to disk */
158
- + if (first_free_cluster < refblock_start) {
159
- + first_free_cluster = refblock_start;
160
- + }
161
- + refblock_offset = alloc_clusters_imrt(bs, 1, refcount_table,
162
- + nb_clusters,
163
- + &first_free_cluster);
164
- + if (refblock_offset < 0) {
165
- + fprintf(stderr, "ERROR allocating refblock: %s\n",
166
- + strerror(-refblock_offset));
167
- + return refblock_offset;
168
- + }
169
-
170
- - reftable_size = ROUND_UP((refblock_index + 1) * REFTABLE_ENTRY_SIZE,
171
- - s->cluster_size) / REFTABLE_ENTRY_SIZE;
172
- - new_on_disk_reftable = g_try_realloc(on_disk_reftable,
173
- - reftable_size *
174
- - REFTABLE_ENTRY_SIZE);
175
- - if (!new_on_disk_reftable) {
176
- - res->check_errors++;
177
- - ret = -ENOMEM;
178
- - goto fail;
179
- + refblock_cluster_index = refblock_offset / s->cluster_size;
180
- + if (refblock_cluster_index >= end_cluster) {
181
- + /*
182
- + * We must write the refblock that holds this refblock's
183
- + * refcount
184
- + */
185
- + end_cluster = refblock_cluster_index + 1;
186
- }
187
- - on_disk_reftable = new_on_disk_reftable;
188
-
189
- - memset(on_disk_reftable + old_reftable_size, 0,
190
- - (reftable_size - old_reftable_size) * REFTABLE_ENTRY_SIZE);
191
- + if (on_disk_reftable_entries <= refblock_index) {
192
- + on_disk_reftable_entries =
193
- + ROUND_UP((refblock_index + 1) * REFTABLE_ENTRY_SIZE,
194
- + s->cluster_size) / REFTABLE_ENTRY_SIZE;
195
- + on_disk_reftable =
196
- + g_try_realloc(on_disk_reftable,
197
- + on_disk_reftable_entries *
198
- + REFTABLE_ENTRY_SIZE);
199
- + if (!on_disk_reftable) {
200
- + return -ENOMEM;
201
- + }
202
-
203
- - /* The offset we have for the reftable is now no longer valid;
204
- - * this will leak that range, but we can easily fix that by running
205
- - * a leak-fixing check after this rebuild operation */
206
- - reftable_offset = -1;
207
- - } else {
208
- - assert(on_disk_reftable);
209
- - }
210
- - on_disk_reftable[refblock_index] = refblock_offset;
211
- + memset(on_disk_reftable + *on_disk_reftable_entries_ptr, 0,
212
- + (on_disk_reftable_entries -
213
- + *on_disk_reftable_entries_ptr) *
214
- + REFTABLE_ENTRY_SIZE);
215
-
216
- - /* If this is apparently the last refblock (for now), try to squeeze the
217
- - * reftable in */
218
- - if (refblock_index == (*nb_clusters - 1) >> s->refcount_block_bits &&
219
- - reftable_offset < 0)
220
- - {
221
- - uint64_t reftable_clusters = size_to_clusters(s, reftable_size *
222
- - REFTABLE_ENTRY_SIZE);
223
- - reftable_offset = alloc_clusters_imrt(bs, reftable_clusters,
224
- - refcount_table, nb_clusters,
225
- - &first_free_cluster);
226
- - if (reftable_offset < 0) {
227
- - fprintf(stderr, "ERROR allocating reftable: %s\n",
228
- - strerror(-reftable_offset));
229
- - res->check_errors++;
230
- - ret = reftable_offset;
231
- - goto fail;
232
- + *on_disk_reftable_ptr = on_disk_reftable;
233
- + *on_disk_reftable_entries_ptr = on_disk_reftable_entries;
234
- +
235
- + reftable_grown = true;
236
- + } else {
237
- + assert(on_disk_reftable);
238
- }
239
- + on_disk_reftable[refblock_index] = refblock_offset;
240
- }
241
-
242
- + /* Refblock is allocated, write it to disk */
243
- +
244
- ret = qcow2_pre_write_overlap_check(bs, 0, refblock_offset,
245
- s->cluster_size, false);
246
- if (ret < 0) {
247
- fprintf(stderr, "ERROR writing refblock: %s\n", strerror(-ret));
248
- - goto fail;
249
- + return ret;
250
- }
251
-
252
- - /* The size of *refcount_table is always cluster-aligned, therefore the
253
- - * write operation will not overflow */
254
- + /*
255
- + * The refblock is simply a slice of *refcount_table.
256
- + * Note that the size of *refcount_table is always aligned to
257
- + * whole clusters, so the write operation will not result in
258
- + * out-of-bounds accesses.
259
- + */
260
- on_disk_refblock = (void *)((char *) *refcount_table +
261
- refblock_index * s->cluster_size);
262
-
263
- @@ -2550,23 +2579,99 @@ write_refblocks:
264
- s->cluster_size);
265
- if (ret < 0) {
266
- fprintf(stderr, "ERROR writing refblock: %s\n", strerror(-ret));
267
- - goto fail;
268
- + return ret;
269
- }
270
-
271
- - /* Go to the end of this refblock */
272
- + /* This refblock is done, skip to its end */
273
- cluster = refblock_start + s->refcount_block_size - 1;
274
- }
275
-
276
- - if (reftable_offset < 0) {
277
- - uint64_t post_refblock_start, reftable_clusters;
278
- + return reftable_grown;
279
- +}
280
- +
281
- +/*
282
- + * Creates a new refcount structure based solely on the in-memory information
283
- + * given through *refcount_table (this in-memory information is basically just
284
- + * the concatenation of all refblocks). All necessary allocations will be
285
- + * reflected in that array.
286
- + *
287
- + * On success, the old refcount structure is leaked (it will be covered by the
288
- + * new refcount structure).
289
- + */
290
- +static int rebuild_refcount_structure(BlockDriverState *bs,
291
- + BdrvCheckResult *res,
292
- + void **refcount_table,
293
- + int64_t *nb_clusters)
294
- +{
295
- + BDRVQcow2State *s = bs->opaque;
296
- + int64_t reftable_offset = -1;
297
- + int64_t reftable_length = 0;
298
- + int64_t reftable_clusters;
299
- + int64_t refblock_index;
300
- + uint32_t on_disk_reftable_entries = 0;
301
- + uint64_t *on_disk_reftable = NULL;
302
- + int ret = 0;
303
- + int reftable_size_changed = 0;
304
- + struct {
305
- + uint64_t reftable_offset;
306
- + uint32_t reftable_clusters;
307
- + } QEMU_PACKED reftable_offset_and_clusters;
308
- +
309
- + qcow2_cache_empty(bs, s->refcount_block_cache);
310
- +
311
- + /*
312
- + * For each refblock containing entries, we try to allocate a
313
- + * cluster (in the in-memory refcount table) and write its offset
314
- + * into on_disk_reftable[]. We then write the whole refblock to
315
- + * disk (as a slice of the in-memory refcount table).
316
- + * This is done by rebuild_refcounts_write_refblocks().
317
- + *
318
- + * Once we have scanned all clusters, we try to find space for the
319
- + * reftable. This will dirty the in-memory refcount table (i.e.
320
- + * make it differ from the refblocks we have already written), so we
321
- + * need to run rebuild_refcounts_write_refblocks() again for the
322
- + * range of clusters where the reftable has been allocated.
323
- + *
324
- + * This second run might make the reftable grow again, in which case
325
- + * we will need to allocate another space for it, which is why we
326
- + * repeat all this until the reftable stops growing.
327
- + *
328
- + * (This loop will terminate, because with every cluster the
329
- + * reftable grows, it can accomodate a multitude of more refcounts,
330
- + * so that at some point this must be able to cover the reftable
331
- + * and all refblocks describing it.)
332
- + *
333
- + * We then convert the reftable to big-endian and write it to disk.
334
- + *
335
- + * Note that we never free any reftable allocations. Doing so would
336
- + * needlessly complicate the algorithm: The eventual second check
337
- + * run we do will clean up all leaks we have caused.
338
- + */
339
- +
340
- + reftable_size_changed =
341
- + rebuild_refcounts_write_refblocks(bs, refcount_table, nb_clusters,
342
- + 0, *nb_clusters,
343
- + &on_disk_reftable,
344
- + &on_disk_reftable_entries);
345
- + if (reftable_size_changed < 0) {
346
- + res->check_errors++;
347
- + ret = reftable_size_changed;
348
- + goto fail;
349
- + }
350
- +
351
- + /*
352
- + * There was no reftable before, so rebuild_refcounts_write_refblocks()
353
- + * must have increased its size (from 0 to something).
354
- + */
355
- + assert(reftable_size_changed);
356
- +
357
- + do {
358
- + int64_t reftable_start_cluster, reftable_end_cluster;
359
- + int64_t first_free_cluster = 0;
360
- +
361
- + reftable_length = on_disk_reftable_entries * REFTABLE_ENTRY_SIZE;
362
- + reftable_clusters = size_to_clusters(s, reftable_length);
363
-
364
- - post_refblock_start = ROUND_UP(*nb_clusters, s->refcount_block_size);
365
- - reftable_clusters =
366
- - size_to_clusters(s, reftable_size * REFTABLE_ENTRY_SIZE);
367
- - /* Not pretty but simple */
368
- - if (first_free_cluster < post_refblock_start) {
369
- - first_free_cluster = post_refblock_start;
370
- - }
371
- reftable_offset = alloc_clusters_imrt(bs, reftable_clusters,
372
- refcount_table, nb_clusters,
373
- &first_free_cluster);
374
- @@ -2578,24 +2683,55 @@ write_refblocks:
375
- goto fail;
376
- }
377
-
378
- - goto write_refblocks;
379
- - }
380
- + /*
381
- + * We need to update the affected refblocks, so re-run the
382
- + * write_refblocks loop for the reftable's range of clusters.
383
- + */
384
- + assert(offset_into_cluster(s, reftable_offset) == 0);
385
- + reftable_start_cluster = reftable_offset / s->cluster_size;
386
- + reftable_end_cluster = reftable_start_cluster + reftable_clusters;
387
- + reftable_size_changed =
388
- + rebuild_refcounts_write_refblocks(bs, refcount_table, nb_clusters,
389
- + reftable_start_cluster,
390
- + reftable_end_cluster,
391
- + &on_disk_reftable,
392
- + &on_disk_reftable_entries);
393
- + if (reftable_size_changed < 0) {
394
- + res->check_errors++;
395
- + ret = reftable_size_changed;
396
- + goto fail;
397
- + }
398
- +
399
- + /*
400
- + * If the reftable size has changed, we will need to find a new
401
- + * allocation, repeating the loop.
402
- + */
403
- + } while (reftable_size_changed);
404
-
405
- - for (refblock_index = 0; refblock_index < reftable_size; refblock_index++) {
406
- + /* The above loop must have run at least once */
407
- + assert(reftable_offset >= 0);
408
- +
409
- + /*
410
- + * All allocations are done, all refblocks are written, convert the
411
- + * reftable to big-endian and write it to disk.
412
- + */
413
- +
414
- + for (refblock_index = 0; refblock_index < on_disk_reftable_entries;
415
- + refblock_index++)
416
- + {
417
- cpu_to_be64s(&on_disk_reftable[refblock_index]);
418
- }
419
-
420
- - ret = qcow2_pre_write_overlap_check(bs, 0, reftable_offset,
421
- - reftable_size * REFTABLE_ENTRY_SIZE,
422
- + ret = qcow2_pre_write_overlap_check(bs, 0, reftable_offset, reftable_length,
423
- false);
424
- if (ret < 0) {
425
- fprintf(stderr, "ERROR writing reftable: %s\n", strerror(-ret));
426
- goto fail;
427
- }
428
-
429
- - assert(reftable_size < INT_MAX / REFTABLE_ENTRY_SIZE);
430
- + assert(reftable_length < INT_MAX);
431
- ret = bdrv_pwrite(bs->file, reftable_offset, on_disk_reftable,
432
- - reftable_size * REFTABLE_ENTRY_SIZE);
433
- + reftable_length);
434
- if (ret < 0) {
435
- fprintf(stderr, "ERROR writing reftable: %s\n", strerror(-ret));
436
- goto fail;
437
- @@ -2604,7 +2740,7 @@ write_refblocks:
438
- /* Enter new reftable into the image header */
439
- reftable_offset_and_clusters.reftable_offset = cpu_to_be64(reftable_offset);
440
- reftable_offset_and_clusters.reftable_clusters =
441
- - cpu_to_be32(size_to_clusters(s, reftable_size * REFTABLE_ENTRY_SIZE));
442
- + cpu_to_be32(reftable_clusters);
443
- ret = bdrv_pwrite_sync(bs->file,
444
- offsetof(QCowHeader, refcount_table_offset),
445
- &reftable_offset_and_clusters,
446
- @@ -2614,12 +2750,14 @@ write_refblocks:
447
- goto fail;
448
- }
449
-
450
- - for (refblock_index = 0; refblock_index < reftable_size; refblock_index++) {
451
- + for (refblock_index = 0; refblock_index < on_disk_reftable_entries;
452
- + refblock_index++)
453
- + {
454
- be64_to_cpus(&on_disk_reftable[refblock_index]);
455
- }
456
- s->refcount_table = on_disk_reftable;
457
- s->refcount_table_offset = reftable_offset;
458
- - s->refcount_table_size = reftable_size;
459
- + s->refcount_table_size = on_disk_reftable_entries;
460
- update_max_refcount_table_index(s);
461
-
462
- return 0;
463
- --
464
- 2.31.1
465
-
SOURCES/kvm-qed-Don-t-yield-in-bdrv_qed_co_drain_begin.patch ADDED
@@ -0,0 +1,84 @@
1
+ From f628a08d20b9ab6be24c2ab18b38a934a314c78b Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Fri, 18 Nov 2022 18:40:56 +0100
4
+ Subject: [PATCH 14/31] qed: Don't yield in bdrv_qed_co_drain_begin()
5
+
6
+ RH-Author: Stefano Garzarella <sgarzare@redhat.com>
7
+ RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
8
+ RH-Bugzilla: 2155112
9
+ RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
10
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
11
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
12
+ RH-Commit: [2/16] f18e9aebb7e04a62e309b656bac8f2ab83df657f (sgarzarella/qemu-kvm-c-9-s)
13
+
14
+ We want to change .bdrv_co_drained_begin() back to be a non-coroutine
15
+ callback, so in preparation, avoid yielding in its implementation.
16
+
17
+ Because we increase bs->in_flight and bdrv_drained_begin() polls, the
18
+ behaviour is unchanged.
19
+
20
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
21
+ Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
22
+ Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
23
+ Reviewed-by: Hanna Reitz <hreitz@redhat.com>
24
+ Message-Id: <20221118174110.55183-2-kwolf@redhat.com>
25
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26
+ (cherry picked from commit 6d47eb0c8bf2d50682c7dccae74d24104076fe23)
27
+ Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
28
+ ---
29
+ block/qed.c | 20 +++++++++++++++++---
30
+ 1 file changed, 17 insertions(+), 3 deletions(-)
31
+
32
+ diff --git a/block/qed.c b/block/qed.c
33
+ index 2f36ad342c..013f826c44 100644
34
+ --- a/block/qed.c
35
+ +++ b/block/qed.c
36
+ @@ -282,9 +282,8 @@ static void coroutine_fn qed_unplug_allocating_write_reqs(BDRVQEDState *s)
37
+ qemu_co_mutex_unlock(&s->table_lock);
38
+ }
39
+
40
+ -static void coroutine_fn qed_need_check_timer_entry(void *opaque)
41
+ +static void coroutine_fn qed_need_check_timer(BDRVQEDState *s)
42
+ {
43
+ - BDRVQEDState *s = opaque;
44
+ int ret;
45
+
46
+ trace_qed_need_check_timer_cb(s);
47
+ @@ -310,9 +309,20 @@ static void coroutine_fn qed_need_check_timer_entry(void *opaque)
48
+ (void) ret;
49
+ }
50
+
51
+ +static void coroutine_fn qed_need_check_timer_entry(void *opaque)
52
+ +{
53
+ + BDRVQEDState *s = opaque;
54
+ +
55
+ + qed_need_check_timer(opaque);
56
+ + bdrv_dec_in_flight(s->bs);
57
+ +}
58
+ +
59
+ static void qed_need_check_timer_cb(void *opaque)
60
+ {
61
+ + BDRVQEDState *s = opaque;
62
+ Coroutine *co = qemu_coroutine_create(qed_need_check_timer_entry, opaque);
63
+ +
64
+ + bdrv_inc_in_flight(s->bs);
65
+ qemu_coroutine_enter(co);
66
+ }
67
+
68
+ @@ -363,8 +373,12 @@ static void coroutine_fn bdrv_qed_co_drain_begin(BlockDriverState *bs)
69
+ * header is flushed.
70
+ */
71
+ if (s->need_check_timer && timer_pending(s->need_check_timer)) {
72
+ + Coroutine *co;
73
+ +
74
+ qed_cancel_need_check_timer(s);
75
+ - qed_need_check_timer_entry(s);
76
+ + co = qemu_coroutine_create(qed_need_check_timer_entry, s);
77
+ + bdrv_inc_in_flight(bs);
78
+ + aio_co_enter(bdrv_get_aio_context(bs), co);
79
+ }
80
+ }
81
+
82
+ --
83
+ 2.31.1
84
+
SOURCES/kvm-qemu-img-Change-info-key-names-for-protocol-nodes.patch ADDED
@@ -0,0 +1,197 @@
1
+ From b1970c733dc46b2a8f648997a7e1c5d12900ff54 Mon Sep 17 00:00:00 2001
2
+ From: Hanna Reitz <hreitz@redhat.com>
3
+ Date: Mon, 20 Jun 2022 18:27:04 +0200
4
+ Subject: [PATCH 17/20] qemu-img: Change info key names for protocol nodes
5
+
6
+ RH-Author: Hanna Czenczek <hreitz@redhat.com>
7
+ RH-MergeRequest: 145: Show protocol-level information in qemu-img info
8
+ RH-Bugzilla: 1860292
9
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
10
+ RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
11
+ RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
12
+ RH-Commit: [12/12] 67c260aaa05466410503fecee6210bf9d47e8c7c (hreitz/qemu-kvm-c-9-s)
13
+
14
+ Currently, when querying a qcow2 image, qemu-img info reports something
15
+ like this:
16
+
17
+ image: test.qcow2
18
+ file format: qcow2
19
+ virtual size: 64 MiB (67108864 bytes)
20
+ disk size: 196 KiB
21
+ cluster_size: 65536
22
+ Format specific information:
23
+ compat: 1.1
24
+ compression type: zlib
25
+ lazy refcounts: false
26
+ refcount bits: 16
27
+ corrupt: false
28
+ extended l2: false
29
+ Child node '/file':
30
+ image: test.qcow2
31
+ file format: file
32
+ virtual size: 192 KiB (197120 bytes)
33
+ disk size: 196 KiB
34
+ Format specific information:
35
+ extent size hint: 1048576
36
+
37
+ Notably, the way the keys are named is specific for image files: The
38
+ filename is shown under "image", the BDS driver under "file format", and
39
+ the BDS length under "virtual size". This does not make much sense for
40
+ nodes that are not actually supposed to be guest images, like the /file
41
+ child node shown above.
42
+
43
+ Give bdrv_node_info_dump() a @protocol parameter that gives a hint that
44
+ the respective node is probably just used for data storage and does not
45
+ necessarily present the data for a VM guest disk. This renames the keys
46
+ so that with this patch, the output becomes:
47
+
48
+ image: test.qcow2
49
+ [...]
50
+ Child node '/file':
51
+ filename: test.qcow2
52
+ protocol type: file
53
+ file length: 192 KiB (197120 bytes)
54
+ disk size: 196 KiB
55
+ Format specific information:
56
+ extent size hint: 1048576
57
+
58
+ (Perhaps we should also rename "Format specific information", but I
59
+ could not come up with anything better that will not become problematic
60
+ if we guess wrong with the protocol "heuristic".)
61
+
62
+ This change affects iotest 302, which has protocol node information in
63
+ its reference output.
64
+
65
+ Signed-off-by: Hanna Reitz <hreitz@redhat.com>
66
+ Message-Id: <20220620162704.80987-13-hreitz@redhat.com>
67
+ Reviewed-by: Kevin Wolf <kwolf@redhat.com>
68
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
69
+ (cherry picked from commit d570177b50c389f379f93183155a27d44856ab46)
70
+ Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
71
+ ---
72
+ block/monitor/block-hmp-cmds.c | 2 +-
73
+ block/qapi.c | 39 ++++++++++++++++++++++++++++------
74
+ include/block/qapi.h | 2 +-
75
+ qemu-img.c | 3 ++-
76
+ tests/qemu-iotests/302.out | 6 +++---
77
+ 5 files changed, 39 insertions(+), 13 deletions(-)
78
+
79
+ diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
80
+ index 72824d4e2e..4d83339a5d 100644
81
+ --- a/block/monitor/block-hmp-cmds.c
82
+ +++ b/block/monitor/block-hmp-cmds.c
83
+ @@ -734,7 +734,7 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
84
+ monitor_printf(mon, "\nImages:\n");
85
+ image_info = inserted->image;
86
+ while (1) {
87
+ - bdrv_node_info_dump(qapi_ImageInfo_base(image_info), 0);
88
+ + bdrv_node_info_dump(qapi_ImageInfo_base(image_info), 0, false);
89
+ if (image_info->has_backing_image) {
90
+ image_info = image_info->backing_image;
91
+ } else {
92
+ diff --git a/block/qapi.c b/block/qapi.c
93
+ index 3e35603f0c..56f398c500 100644
94
+ --- a/block/qapi.c
95
+ +++ b/block/qapi.c
96
+ @@ -934,24 +934,49 @@ void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec,
97
+ visit_free(v);
98
+ }
99
+
100
+ -void bdrv_node_info_dump(BlockNodeInfo *info, int indentation)
101
+ +/**
102
+ + * Print the given @info object in human-readable form. Every field is indented
103
+ + * using the given @indentation (four spaces per indentation level).
104
+ + *
105
+ + * When using this to print a whole block graph, @protocol can be set to true to
106
+ + * signify that the given information is associated with a protocol node, i.e.
107
+ + * just data storage for an image, such that the data it presents is not really
108
+ + * a full VM disk. If so, several fields change name: For example, "virtual
109
+ + * size" is printed as "file length".
110
+ + * (Consider a qcow2 image, which is represented by a qcow2 node and a file
111
+ + * node. Printing a "virtual size" for the file node does not make sense,
112
+ + * because without the qcow2 node, it is not really a guest disk, so it does not
113
+ + * have a "virtual size". Therefore, we call it "file length" instead.)
114
+ + *
115
+ + * @protocol is ignored when @indentation is 0, because we take that to mean
116
+ + * that the associated node is the root node in the queried block graph, and
117
+ + * thus is always to be interpreted as a standalone guest disk.
118
+ + */
119
+ +void bdrv_node_info_dump(BlockNodeInfo *info, int indentation, bool protocol)
120
+ {
121
+ char *size_buf, *dsize_buf;
122
+ g_autofree char *ind_s = g_strdup_printf("%*s", indentation * 4, "");
123
+
124
+ + if (indentation == 0) {
125
+ + /* Top level, consider this a normal image */
126
+ + protocol = false;
127
+ + }
128
+ +
129
+ if (!info->has_actual_size) {
130
+ dsize_buf = g_strdup("unavailable");
131
+ } else {
132
+ dsize_buf = size_to_str(info->actual_size);
133
+ }
134
+ size_buf = size_to_str(info->virtual_size);
135
+ - qemu_printf("%simage: %s\n"
136
+ - "%sfile format: %s\n"
137
+ - "%svirtual size: %s (%" PRId64 " bytes)\n"
138
+ + qemu_printf("%s%s: %s\n"
139
+ + "%s%s: %s\n"
140
+ + "%s%s: %s (%" PRId64 " bytes)\n"
141
+ "%sdisk size: %s\n",
142
+ - ind_s, info->filename,
143
+ - ind_s, info->format,
144
+ - ind_s, size_buf, info->virtual_size,
145
+ + ind_s, protocol ? "filename" : "image", info->filename,
146
+ + ind_s, protocol ? "protocol type" : "file format",
147
+ + info->format,
148
+ + ind_s, protocol ? "file length" : "virtual size",
149
+ + size_buf, info->virtual_size,
150
+ ind_s, dsize_buf);
151
+ g_free(size_buf);
152
+ g_free(dsize_buf);
153
+ diff --git a/include/block/qapi.h b/include/block/qapi.h
154
+ index 38855f2ae9..26113da21a 100644
155
+ --- a/include/block/qapi.h
156
+ +++ b/include/block/qapi.h
157
+ @@ -51,5 +51,5 @@ void bdrv_snapshot_dump(QEMUSnapshotInfo *sn);
158
+ void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec,
159
+ const char *prefix,
160
+ int indentation);
161
+ -void bdrv_node_info_dump(BlockNodeInfo *info, int indentation);
162
+ +void bdrv_node_info_dump(BlockNodeInfo *info, int indentation, bool protocol);
163
+ #endif
164
+ diff --git a/qemu-img.c b/qemu-img.c
165
+ index e281011245..2943625c67 100644
166
+ --- a/qemu-img.c
167
+ +++ b/qemu-img.c
168
+ @@ -2853,7 +2853,8 @@ static void dump_human_image_info(BlockGraphInfo *info, int indentation,
169
+ {
170
+ BlockChildInfoList *children_list;
171
+
172
+ - bdrv_node_info_dump(qapi_BlockGraphInfo_base(info), indentation);
173
+ + bdrv_node_info_dump(qapi_BlockGraphInfo_base(info), indentation,
174
+ + info->children == NULL);
175
+
176
+ for (children_list = info->children; children_list;
177
+ children_list = children_list->next)
178
+ diff --git a/tests/qemu-iotests/302.out b/tests/qemu-iotests/302.out
179
+ index edfa1c4f05..7b5014cdd8 100644
180
+ --- a/tests/qemu-iotests/302.out
181
+ +++ b/tests/qemu-iotests/302.out
182
+ @@ -5,9 +5,9 @@ file format: raw
183
+ virtual size: 448 KiB (458752 bytes)
184
+ disk size: unavailable
185
+ Child node '/file':
186
+ - image: nbd+unix:///exp?socket=SOCK_DIR/PID-nbd-sock
187
+ - file format: nbd
188
+ - virtual size: 448 KiB (458752 bytes)
189
+ + filename: nbd+unix:///exp?socket=SOCK_DIR/PID-nbd-sock
190
+ + protocol type: nbd
191
+ + file length: 448 KiB (458752 bytes)
192
+ disk size: unavailable
193
+
194
+ === Converted image info ===
195
+ --
196
+ 2.31.1
197
+
SOURCES/kvm-qemu-img-Let-info-print-block-graph.patch ADDED
@@ -0,0 +1,261 @@
1
+ From ea73e9de42b446ce1049805c23f7706e4f87ed1f Mon Sep 17 00:00:00 2001
2
+ From: Hanna Reitz <hreitz@redhat.com>
3
+ Date: Mon, 20 Jun 2022 18:27:03 +0200
4
+ Subject: [PATCH 16/20] qemu-img: Let info print block graph
5
+
6
+ RH-Author: Hanna Czenczek <hreitz@redhat.com>
7
+ RH-MergeRequest: 145: Show protocol-level information in qemu-img info
8
+ RH-Bugzilla: 1860292
9
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
10
+ RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
11
+ RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
12
+ RH-Commit: [11/12] 2c1b8a03c918484449e876acf4c6663766848ad8 (hreitz/qemu-kvm-c-9-s)
13
+
14
+ For every node in the backing chain, collect its BlockGraphInfo struct
15
+ using bdrv_query_block_graph_info(). Print all nodes' information,
16
+ indenting child nodes and labelling them with a path constructed from
17
+ the child names leading to the node from the root (e.g. /file/file).
18
+
19
+ Note that we open each image with BDRV_O_NO_BACKING, so its backing
20
+ child is omitted from this graph, and thus presented in the previous
21
+ manner: By simply concatenating all images' information, separated with
22
+ blank lines.
23
+
24
+ This affects two iotests:
25
+ - 065: Here we try to get the format node's format specific information.
26
+ The pre-patch code does so by taking all lines from "Format specific
27
+ information:" until an empty line. This format specific information
28
+ is no longer followed by an empty line, though, but by child node
29
+ information, so limit the range by "Child node '/file':".
30
+ - 302: Calls qemu_img() for qemu-img info directly, which does not
31
+ filter the output, so the child node information ends up in the
32
+ output.
33
+
34
+ Signed-off-by: Hanna Reitz <hreitz@redhat.com>
35
+ Message-Id: <20220620162704.80987-12-hreitz@redhat.com>
36
+ Reviewed-by: Kevin Wolf <kwolf@redhat.com>
37
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
38
+ (cherry picked from commit c04d0ab026201d21873a63f768cb69c4554dfec1)
39
+ Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
40
+ ---
41
+ qapi/block-core.json | 4 +--
42
+ qemu-img.c | 69 ++++++++++++++++++++++++++------------
43
+ tests/qemu-iotests/065 | 2 +-
44
+ tests/qemu-iotests/302.out | 5 +++
45
+ 4 files changed, 56 insertions(+), 24 deletions(-)
46
+
47
+ diff --git a/qapi/block-core.json b/qapi/block-core.json
48
+ index d703e0fb16..7f331eb8ea 100644
49
+ --- a/qapi/block-core.json
50
+ +++ b/qapi/block-core.json
51
+ @@ -5831,9 +5831,9 @@
52
+ ##
53
+ # @DummyBlockCoreForceArrays:
54
+ #
55
+ -# Not used by QMP; hack to let us use BlockNodeInfoList internally
56
+ +# Not used by QMP; hack to let us use BlockGraphInfoList internally
57
+ #
58
+ # Since: 8.0
59
+ ##
60
+ { 'struct': 'DummyBlockCoreForceArrays',
61
+ - 'data': { 'unused-block-node-info': ['BlockNodeInfo'] } }
62
+ + 'data': { 'unused-block-graph-info': ['BlockGraphInfo'] } }
63
+ diff --git a/qemu-img.c b/qemu-img.c
64
+ index 30b4ea58bb..e281011245 100644
65
+ --- a/qemu-img.c
66
+ +++ b/qemu-img.c
67
+ @@ -2816,13 +2816,13 @@ static void dump_snapshots(BlockDriverState *bs)
68
+ g_free(sn_tab);
69
+ }
70
+
71
+ -static void dump_json_block_node_info_list(BlockNodeInfoList *list)
72
+ +static void dump_json_block_graph_info_list(BlockGraphInfoList *list)
73
+ {
74
+ GString *str;
75
+ QObject *obj;
76
+ Visitor *v = qobject_output_visitor_new(&obj);
77
+
78
+ - visit_type_BlockNodeInfoList(v, NULL, &list, &error_abort);
79
+ + visit_type_BlockGraphInfoList(v, NULL, &list, &error_abort);
80
+ visit_complete(v, &obj);
81
+ str = qobject_to_json_pretty(obj, true);
82
+ assert(str != NULL);
83
+ @@ -2832,13 +2832,13 @@ static void dump_json_block_node_info_list(BlockNodeInfoList *list)
84
+ g_string_free(str, true);
85
+ }
86
+
87
+ -static void dump_json_block_node_info(BlockNodeInfo *info)
88
+ +static void dump_json_block_graph_info(BlockGraphInfo *info)
89
+ {
90
+ GString *str;
91
+ QObject *obj;
92
+ Visitor *v = qobject_output_visitor_new(&obj);
93
+
94
+ - visit_type_BlockNodeInfo(v, NULL, &info, &error_abort);
95
+ + visit_type_BlockGraphInfo(v, NULL, &info, &error_abort);
96
+ visit_complete(v, &obj);
97
+ str = qobject_to_json_pretty(obj, true);
98
+ assert(str != NULL);
99
+ @@ -2848,9 +2848,29 @@ static void dump_json_block_node_info(BlockNodeInfo *info)
100
+ g_string_free(str, true);
101
+ }
102
+
103
+ -static void dump_human_image_info_list(BlockNodeInfoList *list)
104
+ +static void dump_human_image_info(BlockGraphInfo *info, int indentation,
105
+ + const char *path)
106
+ {
107
+ - BlockNodeInfoList *elem;
108
+ + BlockChildInfoList *children_list;
109
+ +
110
+ + bdrv_node_info_dump(qapi_BlockGraphInfo_base(info), indentation);
111
+ +
112
+ + for (children_list = info->children; children_list;
113
+ + children_list = children_list->next)
114
+ + {
115
+ + BlockChildInfo *child = children_list->value;
116
+ + g_autofree char *child_path = NULL;
117
+ +
118
+ + printf("%*sChild node '%s%s':\n",
119
+ + indentation * 4, "", path, child->name);
120
+ + child_path = g_strdup_printf("%s%s/", path, child->name);
121
+ + dump_human_image_info(child->info, indentation + 1, child_path);
122
+ + }
123
+ +}
124
+ +
125
+ +static void dump_human_image_info_list(BlockGraphInfoList *list)
126
+ +{
127
+ + BlockGraphInfoList *elem;
128
+ bool delim = false;
129
+
130
+ for (elem = list; elem; elem = elem->next) {
131
+ @@ -2859,7 +2879,7 @@ static void dump_human_image_info_list(BlockNodeInfoList *list)
132
+ }
133
+ delim = true;
134
+
135
+ - bdrv_node_info_dump(elem->value, 0);
136
+ + dump_human_image_info(elem->value, 0, "/");
137
+ }
138
+ }
139
+
140
+ @@ -2869,7 +2889,7 @@ static gboolean str_equal_func(gconstpointer a, gconstpointer b)
141
+ }
142
+
143
+ /**
144
+ - * Open an image file chain and return an BlockNodeInfoList
145
+ + * Open an image file chain and return an BlockGraphInfoList
146
+ *
147
+ * @filename: topmost image filename
148
+ * @fmt: topmost image format (may be NULL to autodetect)
149
+ @@ -2880,13 +2900,13 @@ static gboolean str_equal_func(gconstpointer a, gconstpointer b)
150
+ * opening an image file. If there was an error a message will have been
151
+ * printed to stderr.
152
+ */
153
+ -static BlockNodeInfoList *collect_image_info_list(bool image_opts,
154
+ - const char *filename,
155
+ - const char *fmt,
156
+ - bool chain, bool force_share)
157
+ +static BlockGraphInfoList *collect_image_info_list(bool image_opts,
158
+ + const char *filename,
159
+ + const char *fmt,
160
+ + bool chain, bool force_share)
161
+ {
162
+ - BlockNodeInfoList *head = NULL;
163
+ - BlockNodeInfoList **tail = &head;
164
+ + BlockGraphInfoList *head = NULL;
165
+ + BlockGraphInfoList **tail = &head;
166
+ GHashTable *filenames;
167
+ Error *err = NULL;
168
+
169
+ @@ -2895,7 +2915,7 @@ static BlockNodeInfoList *collect_image_info_list(bool image_opts,
170
+ while (filename) {
171
+ BlockBackend *blk;
172
+ BlockDriverState *bs;
173
+ - BlockNodeInfo *info;
174
+ + BlockGraphInfo *info;
175
+
176
+ if (g_hash_table_lookup_extended(filenames, filename, NULL, NULL)) {
177
+ error_report("Backing file '%s' creates an infinite loop.",
178
+ @@ -2912,7 +2932,14 @@ static BlockNodeInfoList *collect_image_info_list(bool image_opts,
179
+ }
180
+ bs = blk_bs(blk);
181
+
182
+ - bdrv_query_block_node_info(bs, &info, &err);
183
+ + /*
184
+ + * Note that the returned BlockGraphInfo object will not have
185
+ + * information about this image's backing node, because we have opened
186
+ + * it with BDRV_O_NO_BACKING. Printing this object will therefore not
187
+ + * duplicate the backing chain information that we obtain by walking
188
+ + * the chain manually here.
189
+ + */
190
+ + bdrv_query_block_graph_info(bs, &info, &err);
191
+ if (err) {
192
+ error_report_err(err);
193
+ blk_unref(blk);
194
+ @@ -2945,7 +2972,7 @@ static BlockNodeInfoList *collect_image_info_list(bool image_opts,
195
+ return head;
196
+
197
+ err:
198
+ - qapi_free_BlockNodeInfoList(head);
199
+ + qapi_free_BlockGraphInfoList(head);
200
+ g_hash_table_destroy(filenames);
201
+ return NULL;
202
+ }
203
+ @@ -2956,7 +2983,7 @@ static int img_info(int argc, char **argv)
204
+ OutputFormat output_format = OFORMAT_HUMAN;
205
+ bool chain = false;
206
+ const char *filename, *fmt, *output;
207
+ - BlockNodeInfoList *list;
208
+ + BlockGraphInfoList *list;
209
+ bool image_opts = false;
210
+ bool force_share = false;
211
+
212
+ @@ -3035,14 +3062,14 @@ static int img_info(int argc, char **argv)
213
+ break;
214
+ case OFORMAT_JSON:
215
+ if (chain) {
216
+ - dump_json_block_node_info_list(list);
217
+ + dump_json_block_graph_info_list(list);
218
+ } else {
219
+ - dump_json_block_node_info(list->value);
220
+ + dump_json_block_graph_info(list->value);
221
+ }
222
+ break;
223
+ }
224
+
225
+ - qapi_free_BlockNodeInfoList(list);
226
+ + qapi_free_BlockGraphInfoList(list);
227
+ return 0;
228
+ }
229
+
230
+ diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065
231
+ index b724c89c7c..b76701c71e 100755
232
+ --- a/tests/qemu-iotests/065
233
+ +++ b/tests/qemu-iotests/065
234
+ @@ -56,7 +56,7 @@ class TestQemuImgInfo(TestImageInfoSpecific):
235
+ def test_human(self):
236
+ data = qemu_img('info', '--output=human', test_img).stdout.split('\n')
237
+ data = data[(data.index('Format specific information:') + 1)
238
+ - :data.index('')]
239
+ + :data.index("Child node '/file':")]
240
+ for field in data:
241
+ self.assertTrue(re.match('^ {4}[^ ]', field) is not None)
242
+ data = [line.strip() for line in data]
243
+ diff --git a/tests/qemu-iotests/302.out b/tests/qemu-iotests/302.out
244
+ index 3e7c281b91..edfa1c4f05 100644
245
+ --- a/tests/qemu-iotests/302.out
246
+ +++ b/tests/qemu-iotests/302.out
247
+ @@ -4,6 +4,11 @@ image: nbd+unix:///exp?socket=SOCK_DIR/PID-nbd-sock
248
+ file format: raw
249
+ virtual size: 448 KiB (458752 bytes)
250
+ disk size: unavailable
251
+ +Child node '/file':
252
+ + image: nbd+unix:///exp?socket=SOCK_DIR/PID-nbd-sock
253
+ + file format: nbd
254
+ + virtual size: 448 KiB (458752 bytes)
255
+ + disk size: unavailable
256
+
257
+ === Converted image info ===
258
+ image: TEST_IMG
259
+ --
260
+ 2.31.1
261
+
SOURCES/kvm-qemu-img-Use-BlockNodeInfo.patch ADDED
@@ -0,0 +1,241 @@
1
+ From dca4cbe680baff837ca8ac8bd39b77b46af3f64b Mon Sep 17 00:00:00 2001
2
+ From: Hanna Reitz <hreitz@redhat.com>
3
+ Date: Mon, 20 Jun 2022 18:26:57 +0200
4
+ Subject: [PATCH 10/20] qemu-img: Use BlockNodeInfo
5
+
6
+ RH-Author: Hanna Czenczek <hreitz@redhat.com>
7
+ RH-MergeRequest: 145: Show protocol-level information in qemu-img info
8
+ RH-Bugzilla: 1860292
9
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
10
+ RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
11
+ RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
12
+ RH-Commit: [5/12] b599af3ec05951a0ba11d9eae2ee19148d6bf624 (hreitz/qemu-kvm-c-9-s)
13
+
14
+ qemu-img info never uses ImageInfo's backing-image field, because it
15
+ opens the backing chain one by one with BDRV_O_NO_BACKING, and prints
16
+ all backing chain nodes' information consecutively. Use BlockNodeInfo
17
+ to make it clear that we only print information about a single node, and
18
+ that we are not using the backing-image field.
19
+
20
+ Notably, bdrv_image_info_dump() does not evaluate the backing-image
21
+ field, so we can easily make it take a BlockNodeInfo pointer (and
22
+ consequentially rename it to bdrv_node_info_dump()). It makes more
23
+ sense this way, because again, the interface now makes it syntactically
24
+ clear that backing-image is ignored by this function.
25
+
26
+ Signed-off-by: Hanna Reitz <hreitz@redhat.com>
27
+ Message-Id: <20220620162704.80987-6-hreitz@redhat.com>
28
+ Reviewed-by: Kevin Wolf <kwolf@redhat.com>
29
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
30
+ (cherry picked from commit b1f4cd1589a16fec02f264a09bd3560e4ccce3c2)
31
+ Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
32
+ ---
33
+ block/monitor/block-hmp-cmds.c | 2 +-
34
+ block/qapi.c | 2 +-
35
+ include/block/qapi.h | 2 +-
36
+ qapi/block-core.json | 4 +--
37
+ qemu-img.c | 48 +++++++++++++++++-----------------
38
+ 5 files changed, 29 insertions(+), 29 deletions(-)
39
+
40
+ diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
41
+ index b6135e9bfe..aa37faa601 100644
42
+ --- a/block/monitor/block-hmp-cmds.c
43
+ +++ b/block/monitor/block-hmp-cmds.c
44
+ @@ -734,7 +734,7 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
45
+ monitor_printf(mon, "\nImages:\n");
46
+ image_info = inserted->image;
47
+ while (1) {
48
+ - bdrv_image_info_dump(image_info);
49
+ + bdrv_node_info_dump(qapi_ImageInfo_base(image_info));
50
+ if (image_info->has_backing_image) {
51
+ image_info = image_info->backing_image;
52
+ } else {
53
+ diff --git a/block/qapi.c b/block/qapi.c
54
+ index e5022b4481..ad88bf9b38 100644
55
+ --- a/block/qapi.c
56
+ +++ b/block/qapi.c
57
+ @@ -865,7 +865,7 @@ void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec,
58
+ visit_free(v);
59
+ }
60
+
61
+ -void bdrv_image_info_dump(ImageInfo *info)
62
+ +void bdrv_node_info_dump(BlockNodeInfo *info)
63
+ {
64
+ char *size_buf, *dsize_buf;
65
+ if (!info->has_actual_size) {
66
+ diff --git a/include/block/qapi.h b/include/block/qapi.h
67
+ index c7de4e3fa9..22198dcd0c 100644
68
+ --- a/include/block/qapi.h
69
+ +++ b/include/block/qapi.h
70
+ @@ -45,5 +45,5 @@ void bdrv_query_image_info(BlockDriverState *bs,
71
+ void bdrv_snapshot_dump(QEMUSnapshotInfo *sn);
72
+ void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec,
73
+ const char *prefix);
74
+ -void bdrv_image_info_dump(ImageInfo *info);
75
+ +void bdrv_node_info_dump(BlockNodeInfo *info);
76
+ #endif
77
+ diff --git a/qapi/block-core.json b/qapi/block-core.json
78
+ index 7720da0498..4cf2deeb6c 100644
79
+ --- a/qapi/block-core.json
80
+ +++ b/qapi/block-core.json
81
+ @@ -5796,9 +5796,9 @@
82
+ ##
83
+ # @DummyBlockCoreForceArrays:
84
+ #
85
+ -# Not used by QMP; hack to let us use ImageInfoList internally
86
+ +# Not used by QMP; hack to let us use BlockNodeInfoList internally
87
+ #
88
+ # Since: 8.0
89
+ ##
90
+ { 'struct': 'DummyBlockCoreForceArrays',
91
+ - 'data': { 'unused-image-info': ['ImageInfo'] } }
92
+ + 'data': { 'unused-block-node-info': ['BlockNodeInfo'] } }
93
+ diff --git a/qemu-img.c b/qemu-img.c
94
+ index 2f85bb7ede..3b2ca3bbcb 100644
95
+ --- a/qemu-img.c
96
+ +++ b/qemu-img.c
97
+ @@ -2816,13 +2816,13 @@ static void dump_snapshots(BlockDriverState *bs)
98
+ g_free(sn_tab);
99
+ }
100
+
101
+ -static void dump_json_image_info_list(ImageInfoList *list)
102
+ +static void dump_json_block_node_info_list(BlockNodeInfoList *list)
103
+ {
104
+ GString *str;
105
+ QObject *obj;
106
+ Visitor *v = qobject_output_visitor_new(&obj);
107
+
108
+ - visit_type_ImageInfoList(v, NULL, &list, &error_abort);
109
+ + visit_type_BlockNodeInfoList(v, NULL, &list, &error_abort);
110
+ visit_complete(v, &obj);
111
+ str = qobject_to_json_pretty(obj, true);
112
+ assert(str != NULL);
113
+ @@ -2832,13 +2832,13 @@ static void dump_json_image_info_list(ImageInfoList *list)
114
+ g_string_free(str, true);
115
+ }
116
+
117
+ -static void dump_json_image_info(ImageInfo *info)
118
+ +static void dump_json_block_node_info(BlockNodeInfo *info)
119
+ {
120
+ GString *str;
121
+ QObject *obj;
122
+ Visitor *v = qobject_output_visitor_new(&obj);
123
+
124
+ - visit_type_ImageInfo(v, NULL, &info, &error_abort);
125
+ + visit_type_BlockNodeInfo(v, NULL, &info, &error_abort);
126
+ visit_complete(v, &obj);
127
+ str = qobject_to_json_pretty(obj, true);
128
+ assert(str != NULL);
129
+ @@ -2848,9 +2848,9 @@ static void dump_json_image_info(ImageInfo *info)
130
+ g_string_free(str, true);
131
+ }
132
+
133
+ -static void dump_human_image_info_list(ImageInfoList *list)
134
+ +static void dump_human_image_info_list(BlockNodeInfoList *list)
135
+ {
136
+ - ImageInfoList *elem;
137
+ + BlockNodeInfoList *elem;
138
+ bool delim = false;
139
+
140
+ for (elem = list; elem; elem = elem->next) {
141
+ @@ -2859,7 +2859,7 @@ static void dump_human_image_info_list(ImageInfoList *list)
142
+ }
143
+ delim = true;
144
+
145
+ - bdrv_image_info_dump(elem->value);
146
+ + bdrv_node_info_dump(elem->value);
147
+ }
148
+ }
149
+
150
+ @@ -2869,24 +2869,24 @@ static gboolean str_equal_func(gconstpointer a, gconstpointer b)
151
+ }
152
+
153
+ /**
154
+ - * Open an image file chain and return an ImageInfoList
155
+ + * Open an image file chain and return an BlockNodeInfoList
156
+ *
157
+ * @filename: topmost image filename
158
+ * @fmt: topmost image format (may be NULL to autodetect)
159
+ * @chain: true - enumerate entire backing file chain
160
+ * false - only topmost image file
161
+ *
162
+ - * Returns a list of ImageInfo objects or NULL if there was an error opening an
163
+ - * image file. If there was an error a message will have been printed to
164
+ - * stderr.
165
+ + * Returns a list of BlockNodeInfo objects or NULL if there was an error
166
+ + * opening an image file. If there was an error a message will have been
167
+ + * printed to stderr.
168
+ */
169
+ -static ImageInfoList *collect_image_info_list(bool image_opts,
170
+ - const char *filename,
171
+ - const char *fmt,
172
+ - bool chain, bool force_share)
173
+ +static BlockNodeInfoList *collect_image_info_list(bool image_opts,
174
+ + const char *filename,
175
+ + const char *fmt,
176
+ + bool chain, bool force_share)
177
+ {
178
+ - ImageInfoList *head = NULL;
179
+ - ImageInfoList **tail = &head;
180
+ + BlockNodeInfoList *head = NULL;
181
+ + BlockNodeInfoList **tail = &head;
182
+ GHashTable *filenames;
183
+ Error *err = NULL;
184
+
185
+ @@ -2895,7 +2895,7 @@ static ImageInfoList *collect_image_info_list(bool image_opts,
186
+ while (filename) {
187
+ BlockBackend *blk;
188
+ BlockDriverState *bs;
189
+ - ImageInfo *info;
190
+ + BlockNodeInfo *info;
191
+
192
+ if (g_hash_table_lookup_extended(filenames, filename, NULL, NULL)) {
193
+ error_report("Backing file '%s' creates an infinite loop.",
194
+ @@ -2912,7 +2912,7 @@ static ImageInfoList *collect_image_info_list(bool image_opts,
195
+ }
196
+ bs = blk_bs(blk);
197
+
198
+ - bdrv_query_image_info(bs, &info, &err);
199
+ + bdrv_query_block_node_info(bs, &info, &err);
200
+ if (err) {
201
+ error_report_err(err);
202
+ blk_unref(blk);
203
+ @@ -2945,7 +2945,7 @@ static ImageInfoList *collect_image_info_list(bool image_opts,
204
+ return head;
205
+
206
+ err:
207
+ - qapi_free_ImageInfoList(head);
208
+ + qapi_free_BlockNodeInfoList(head);
209
+ g_hash_table_destroy(filenames);
210
+ return NULL;
211
+ }
212
+ @@ -2956,7 +2956,7 @@ static int img_info(int argc, char **argv)
213
+ OutputFormat output_format = OFORMAT_HUMAN;
214
+ bool chain = false;
215
+ const char *filename, *fmt, *output;
216
+ - ImageInfoList *list;
217
+ + BlockNodeInfoList *list;
218
+ bool image_opts = false;
219
+ bool force_share = false;
220
+
221
+ @@ -3035,14 +3035,14 @@ static int img_info(int argc, char **argv)
222
+ break;
223
+ case OFORMAT_JSON:
224
+ if (chain) {
225
+ - dump_json_image_info_list(list);
226
+ + dump_json_block_node_info_list(list);
227
+ } else {
228
+ - dump_json_image_info(list->value);
229
+ + dump_json_block_node_info(list->value);
230
+ }
231
+ break;
232
+ }
233
+
234
+ - qapi_free_ImageInfoList(list);
235
+ + qapi_free_BlockNodeInfoList(list);
236
+ return 0;
237
+ }
238
+
239
+ --
240
+ 2.31.1
241
+
SOURCES/kvm-qemu-img-bitmap-Report-errors-while-closing-the-imag.patch ADDED
@@ -0,0 +1,70 @@
1
+ From d0d3d694b3a8d200442484ae0c9d263e0439cd04 Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Thu, 12 Jan 2023 20:14:53 +0100
4
+ Subject: [PATCH 03/20] qemu-img bitmap: Report errors while closing the image
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Kevin Wolf <kwolf@redhat.com>
10
+ RH-MergeRequest: 143: qemu-img: Fix exit code for errors closing the image
11
+ RH-Bugzilla: 2150180
12
+ RH-Acked-by: Thomas Huth <thuth@redhat.com>
13
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
14
+ RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
15
+ RH-Commit: [3/4] 4a704fec2e3bcb47b2be1529e27fd1833d58c517 (kmwolf/centos-qemu-kvm)
16
+
17
+ blk_unref() can't report any errors that happen while closing the image.
18
+ For example, if qcow2 hits an -ENOSPC error while writing out dirty
19
+ bitmaps when it's closed, it prints error messages to stderr, but
20
+ 'qemu-img bitmap' won't see any error return value and will therefore
21
+ look successful with exit code 0.
22
+
23
+ In order to fix this, manually inactivate the image first before calling
24
+ blk_unref(). This already performs the operations that would be most
25
+ likely to fail while closing the image, but it can still return errors.
26
+
27
+ Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1330
28
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
29
+ Message-Id: <20230112191454.169353-4-kwolf@redhat.com>
30
+ Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
31
+ Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
32
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
33
+ (cherry picked from commit c5e477110dcb8ef4642dce399777c3dee68fa96c)
34
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
35
+ ---
36
+ qemu-img.c | 11 +++++++++++
37
+ 1 file changed, 11 insertions(+)
38
+
39
+ diff --git a/qemu-img.c b/qemu-img.c
40
+ index 3cbdda9f76..2f85bb7ede 100644
41
+ --- a/qemu-img.c
42
+ +++ b/qemu-img.c
43
+ @@ -4646,6 +4646,7 @@ static int img_bitmap(int argc, char **argv)
44
+ QSIMPLEQ_HEAD(, ImgBitmapAction) actions;
45
+ ImgBitmapAction *act, *act_next;
46
+ const char *op;
47
+ + int inactivate_ret;
48
+
49
+ QSIMPLEQ_INIT(&actions);
50
+
51
+ @@ -4830,6 +4831,16 @@ static int img_bitmap(int argc, char **argv)
52
+ ret = 0;
53
+
54
+ out:
55
+ + /*
56
+ + * Manually inactivate the images first because this way we can know whether
57
+ + * an error occurred. blk_unref() doesn't tell us about failures.
58
+ + */
59
+ + inactivate_ret = bdrv_inactivate_all();
60
+ + if (inactivate_ret < 0) {
61
+ + error_report("Error while closing the image: %s", strerror(-inactivate_ret));
62
+ + ret = 1;
63
+ + }
64
+ +
65
+ blk_unref(src);
66
+ blk_unref(blk);
67
+ qemu_opts_del(opts);
68
+ --
69
+ 2.31.1
70
+
SOURCES/kvm-qemu-img-commit-Report-errors-while-closing-the-imag.patch ADDED
@@ -0,0 +1,67 @@
1
+ From 2f5369f0effaa23be746f9b5d9f6a0bfc346fb7d Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Thu, 12 Jan 2023 20:14:52 +0100
4
+ Subject: [PATCH 02/20] qemu-img commit: Report errors while closing the image
5
+
6
+ RH-Author: Kevin Wolf <kwolf@redhat.com>
7
+ RH-MergeRequest: 143: qemu-img: Fix exit code for errors closing the image
8
+ RH-Bugzilla: 2150180
9
+ RH-Acked-by: Thomas Huth <thuth@redhat.com>
10
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
11
+ RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
12
+ RH-Commit: [2/4] faedd43355463b1210a3f21ecd430f478bd06f5a (kmwolf/centos-qemu-kvm)
13
+
14
+ blk_unref() can't report any errors that happen while closing the image.
15
+ For example, if qcow2 hits an -ENOSPC error while writing out dirty
16
+ bitmaps when it's closed, it prints error messages to stderr, but
17
+ 'qemu-img commit' won't see any error return value and will therefore
18
+ look successful with exit code 0.
19
+
20
+ In order to fix this, manually inactivate the image first before calling
21
+ blk_unref(). This already performs the operations that would be most
22
+ likely to fail while closing the image, but it can still return errors.
23
+
24
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
25
+ Message-Id: <20230112191454.169353-3-kwolf@redhat.com>
26
+ Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
27
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
28
+ (cherry picked from commit 44efba2d713aca076c411594d0c1a2b99155eeb3)
29
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
30
+ ---
31
+ qemu-img.c | 13 +++++++++++++
32
+ 1 file changed, 13 insertions(+)
33
+
34
+ diff --git a/qemu-img.c b/qemu-img.c
35
+ index a9b3a8103c..3cbdda9f76 100644
36
+ --- a/qemu-img.c
37
+ +++ b/qemu-img.c
38
+ @@ -449,6 +449,11 @@ static BlockBackend *img_open(bool image_opts,
39
+ blk = img_open_file(filename, NULL, fmt, flags, writethrough, quiet,
40
+ force_share);
41
+ }
42
+ +
43
+ + if (blk) {
44
+ + blk_set_force_allow_inactivate(blk);
45
+ + }
46
+ +
47
+ return blk;
48
+ }
49
+
50
+ @@ -1119,6 +1124,14 @@ unref_backing:
51
+ done:
52
+ qemu_progress_end();
53
+
54
+ + /*
55
+ + * Manually inactivate the image first because this way we can know whether
56
+ + * an error occurred. blk_unref() doesn't tell us about failures.
57
+ + */
58
+ + ret = bdrv_inactivate_all();
59
+ + if (ret < 0 && !local_err) {
60
+ + error_setg_errno(&local_err, -ret, "Error while closing the image");
61
+ + }
62
+ blk_unref(blk);
63
+
64
+ if (local_err) {
65
+ --
66
+ 2.31.1
67
+
SOURCES/kvm-qemu-iotests-Test-qemu-img-bitmap-commit-exit-code-o.patch ADDED
@@ -0,0 +1,166 @@
1
+ From 06030aa79fcb2d90d6a670e75d959aa0c3204b5c Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Thu, 12 Jan 2023 20:14:54 +0100
4
+ Subject: [PATCH 04/20] qemu-iotests: Test qemu-img bitmap/commit exit code on
5
+ error
6
+
7
+ RH-Author: Kevin Wolf <kwolf@redhat.com>
8
+ RH-MergeRequest: 143: qemu-img: Fix exit code for errors closing the image
9
+ RH-Bugzilla: 2150180
10
+ RH-Acked-by: Thomas Huth <thuth@redhat.com>
11
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
12
+ RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
13
+ RH-Commit: [4/4] b96bb671bcfb7ae18015fda14db70f42a83a6ea7 (kmwolf/centos-qemu-kvm)
14
+
15
+ This tests that when an error happens while writing back bitmaps to the
16
+ image file in qcow2_inactivate(), 'qemu-img bitmap/commit' actually
17
+ return an error value in their exit code instead of making the operation
18
+ look successful to scripts.
19
+
20
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
21
+ Message-Id: <20230112191454.169353-5-kwolf@redhat.com>
22
+ Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
23
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
24
+ (cherry picked from commit 07a4e1f8e5418f36424cd57d5d061b090a238c65)
25
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26
+ ---
27
+ .../qemu-iotests/tests/qemu-img-close-errors | 96 +++++++++++++++++++
28
+ .../tests/qemu-img-close-errors.out | 23 +++++
29
+ 2 files changed, 119 insertions(+)
30
+ create mode 100755 tests/qemu-iotests/tests/qemu-img-close-errors
31
+ create mode 100644 tests/qemu-iotests/tests/qemu-img-close-errors.out
32
+
33
+ diff --git a/tests/qemu-iotests/tests/qemu-img-close-errors b/tests/qemu-iotests/tests/qemu-img-close-errors
34
+ new file mode 100755
35
+ index 0000000000..50bfb6cfa2
36
+ --- /dev/null
37
+ +++ b/tests/qemu-iotests/tests/qemu-img-close-errors
38
+ @@ -0,0 +1,96 @@
39
+ +#!/usr/bin/env bash
40
+ +# group: rw auto quick
41
+ +#
42
+ +# Check that errors while closing the image, in particular writing back dirty
43
+ +# bitmaps, is correctly reported with a failing qemu-img exit code.
44
+ +#
45
+ +# Copyright (C) 2023 Red Hat, Inc.
46
+ +#
47
+ +# This program is free software; you can redistribute it and/or modify
48
+ +# it under the terms of the GNU General Public License as published by
49
+ +# the Free Software Foundation; either version 2 of the License, or
50
+ +# (at your option) any later version.
51
+ +#
52
+ +# This program is distributed in the hope that it will be useful,
53
+ +# but WITHOUT ANY WARRANTY; without even the implied warranty of
54
+ +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
55
+ +# GNU General Public License for more details.
56
+ +#
57
+ +# You should have received a copy of the GNU General Public License
58
+ +# along with this program. If not, see <http://www.gnu.org/licenses/>.
59
+ +#
60
+ +
61
+ +# creator
62
+ +owner=kwolf@redhat.com
63
+ +
64
+ +seq="$(basename $0)"
65
+ +echo "QA output created by $seq"
66
+ +
67
+ +status=1 # failure is the default!
68
+ +
69
+ +_cleanup()
70
+ +{
71
+ + _cleanup_test_img
72
+ +}
73
+ +trap "_cleanup; exit \$status" 0 1 2 3 15
74
+ +
75
+ +# get standard environment, filters and checks
76
+ +cd ..
77
+ +. ./common.rc
78
+ +. ./common.filter
79
+ +
80
+ +_supported_fmt qcow2
81
+ +_supported_proto file
82
+ +_supported_os Linux
83
+ +
84
+ +size=1G
85
+ +
86
+ +# The error we are going to use is ENOSPC. Depending on how many bitmaps we
87
+ +# create in the backing file (and therefore increase the used up space), we get
88
+ +# failures in different places. With a low number, only merging the bitmap
89
+ +# fails, whereas with a higher number, already 'qemu-img commit' fails.
90
+ +for max_bitmap in 6 7; do
91
+ + echo
92
+ + echo "=== Test with $max_bitmap bitmaps ==="
93
+ +
94
+ + TEST_IMG="$TEST_IMG.base" _make_test_img -q $size
95
+ + for i in $(seq 1 $max_bitmap); do
96
+ + $QEMU_IMG bitmap --add "$TEST_IMG.base" "stale-bitmap-$i"
97
+ + done
98
+ +
99
+ + # Simulate a block device of 128 MB by resizing the image file accordingly
100
+ + # and then enforcing the size with the raw driver
101
+ + $QEMU_IO -f raw -c "truncate 128M" "$TEST_IMG.base"
102
+ + BASE_JSON='json:{
103
+ + "driver": "qcow2",
104
+ + "file": {
105
+ + "driver": "raw",
106
+ + "size": 134217728,
107
+ + "file": {
108
+ + "driver": "file",
109
+ + "filename":"'"$TEST_IMG.base"'"
110
+ + }
111
+ + }
112
+ + }'
113
+ +
114
+ + _make_test_img -q -b "$BASE_JSON" -F $IMGFMT
115
+ + $QEMU_IMG bitmap --add "$TEST_IMG" "good-bitmap"
116
+ +
117
+ + $QEMU_IO -c 'write 0 126m' "$TEST_IMG" | _filter_qemu_io
118
+ +
119
+ + $QEMU_IMG commit -d "$TEST_IMG" 2>&1 | _filter_generated_node_ids
120
+ + echo "qemu-img commit exit code: ${PIPESTATUS[0]}"
121
+ +
122
+ + $QEMU_IMG bitmap --add "$BASE_JSON" "good-bitmap"
123
+ + echo "qemu-img bitmap --add exit code: $?"
124
+ +
125
+ + $QEMU_IMG bitmap --merge "good-bitmap" -b "$TEST_IMG" "$BASE_JSON" \
126
+ + "good-bitmap" 2>&1 | _filter_generated_node_ids
127
+ + echo "qemu-img bitmap --merge exit code: ${PIPESTATUS[0]}"
128
+ +done
129
+ +
130
+ +# success, all done
131
+ +echo "*** done"
132
+ +rm -f $seq.full
133
+ +status=0
134
+ +
135
+ diff --git a/tests/qemu-iotests/tests/qemu-img-close-errors.out b/tests/qemu-iotests/tests/qemu-img-close-errors.out
136
+ new file mode 100644
137
+ index 0000000000..1bfe88f176
138
+ --- /dev/null
139
+ +++ b/tests/qemu-iotests/tests/qemu-img-close-errors.out
140
+ @@ -0,0 +1,23 @@
141
+ +QA output created by qemu-img-close-errors
142
+ +
143
+ +=== Test with 6 bitmaps ===
144
+ +wrote 132120576/132120576 bytes at offset 0
145
+ +126 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
146
+ +Image committed.
147
+ +qemu-img commit exit code: 0
148
+ +qemu-img bitmap --add exit code: 0
149
+ +qemu-img: Lost persistent bitmaps during inactivation of node 'NODE_NAME': Failed to write bitmap 'good-bitmap' to file: No space left on device
150
+ +qemu-img: Error while closing the image: Invalid argument
151
+ +qemu-img: Lost persistent bitmaps during inactivation of node 'NODE_NAME': Failed to write bitmap 'good-bitmap' to file: No space left on device
152
+ +qemu-img bitmap --merge exit code: 1
153
+ +
154
+ +=== Test with 7 bitmaps ===
155
+ +wrote 132120576/132120576 bytes at offset 0
156
+ +126 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
157
+ +qemu-img: Lost persistent bitmaps during inactivation of node 'NODE_NAME': Failed to write bitmap 'stale-bitmap-7' to file: No space left on device
158
+ +qemu-img: Lost persistent bitmaps during inactivation of node 'NODE_NAME': Failed to write bitmap 'stale-bitmap-7' to file: No space left on device
159
+ +qemu-img: Error while closing the image: Invalid argument
160
+ +qemu-img commit exit code: 1
161
+ +qemu-img bitmap --add exit code: 0
162
+ +qemu-img bitmap --merge exit code: 0
163
+ +*** done
164
+ --
165
+ 2.31.1
166
+
SOURCES/kvm-qemu-nbd-Pass-max-connections-to-blockdev-layer.patch DELETED
@@ -1,92 +0,0 @@
1
- From e6aae1d0368a152924c38775e517f4e83c1d898b Mon Sep 17 00:00:00 2001
2
- From: Eric Blake <eblake@redhat.com>
3
- Date: Wed, 11 May 2022 19:49:23 -0500
4
- Subject: [PATCH 1/2] qemu-nbd: Pass max connections to blockdev layer
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eric Blake <eblake@redhat.com>
10
- RH-MergeRequest: 90: Advertise MULTI_CONN on writeable NBD servers
11
- RH-Commit: [1/2] b0e33fd125bf3523b8b9a4dead3c8bb2342bfd4e (ebblake/centos-qemu-kvm)
12
- RH-Bugzilla: 1708300
13
- RH-Acked-by: Nir Soffer <None>
14
- RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
15
- RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
16
-
17
- The next patch wants to adjust whether the NBD server code advertises
18
- MULTI_CONN based on whether it is known if the server limits to
19
- exactly one client. For a server started by QMP, this information is
20
- obtained through nbd_server_start (which can support more than one
21
- export); but for qemu-nbd (which supports exactly one export), it is
22
- controlled only by the command-line option -e/--shared. Since we
23
- already have a hook function used by qemu-nbd, it's easiest to just
24
- alter its signature to fit our needs.
25
-
26
- Signed-off-by: Eric Blake <eblake@redhat.com>
27
- Message-Id: <20220512004924.417153-2-eblake@redhat.com>
28
- Signed-off-by: Kevin Wolf <kwolf@redhat.com>
29
- (cherry picked from commit a5fced40212ed73c715ca298a2929dd4d99c9999)
30
- Signed-off-by: Eric Blake <eblake@redhat.com>
31
- ---
32
- blockdev-nbd.c | 8 ++++----
33
- include/block/nbd.h | 2 +-
34
- qemu-nbd.c | 2 +-
35
- 3 files changed, 6 insertions(+), 6 deletions(-)
36
-
37
- diff --git a/blockdev-nbd.c b/blockdev-nbd.c
38
- index 9840d25a82..add41a23af 100644
39
- --- a/blockdev-nbd.c
40
- +++ b/blockdev-nbd.c
41
- @@ -30,18 +30,18 @@ typedef struct NBDServerData {
42
- } NBDServerData;
43
-
44
- static NBDServerData *nbd_server;
45
- -static bool is_qemu_nbd;
46
- +static int qemu_nbd_connections = -1; /* Non-negative if this is qemu-nbd */
47
-
48
- static void nbd_update_server_watch(NBDServerData *s);
49
-
50
- -void nbd_server_is_qemu_nbd(bool value)
51
- +void nbd_server_is_qemu_nbd(int max_connections)
52
- {
53
- - is_qemu_nbd = value;
54
- + qemu_nbd_connections = max_connections;
55
- }
56
-
57
- bool nbd_server_is_running(void)
58
- {
59
- - return nbd_server || is_qemu_nbd;
60
- + return nbd_server || qemu_nbd_connections >= 0;
61
- }
62
-
63
- static void nbd_blockdev_client_closed(NBDClient *client, bool ignored)
64
- diff --git a/include/block/nbd.h b/include/block/nbd.h
65
- index a98eb665da..c5a29ce1c6 100644
66
- --- a/include/block/nbd.h
67
- +++ b/include/block/nbd.h
68
- @@ -344,7 +344,7 @@ void nbd_client_new(QIOChannelSocket *sioc,
69
- void nbd_client_get(NBDClient *client);
70
- void nbd_client_put(NBDClient *client);
71
-
72
- -void nbd_server_is_qemu_nbd(bool value);
73
- +void nbd_server_is_qemu_nbd(int max_connections);
74
- bool nbd_server_is_running(void);
75
- void nbd_server_start(SocketAddress *addr, const char *tls_creds,
76
- const char *tls_authz, uint32_t max_connections,
77
- diff --git a/qemu-nbd.c b/qemu-nbd.c
78
- index 713e7557a9..8c25ae93df 100644
79
- --- a/qemu-nbd.c
80
- +++ b/qemu-nbd.c
81
- @@ -1087,7 +1087,7 @@ int main(int argc, char **argv)
82
-
83
- bs->detect_zeroes = detect_zeroes;
84
-
85
- - nbd_server_is_qemu_nbd(true);
86
- + nbd_server_is_qemu_nbd(shared);
87
-
88
- export_opts = g_new(BlockExportOptions, 1);
89
- *export_opts = (BlockExportOptions) {
90
- --
91
- 2.31.1
92
-
SOURCES/kvm-qga-linux-add-usb-support-to-guest-get-fsinfo.patch ADDED
@@ -0,0 +1,49 @@
1
+ From 48f45171b89b8ed24f2b2484d63b00ea7818b5c3 Mon Sep 17 00:00:00 2001
2
+ From: Kfir Manor <kfir@daynix.com>
3
+ Date: Sun, 22 Jan 2023 17:33:07 +0200
4
+ Subject: [PATCH 9/9] qga/linux: add usb support to guest-get-fsinfo
5
+
6
+ RH-Author: Kostiantyn Kostiuk <kkostiuk@redhat.com>
7
+ RH-MergeRequest: 140: qga/linux: add usb support to guest-get-fsinfo
8
+ RH-Bugzilla: 2149191
9
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
10
+ RH-Acked-by: yvugenfi <None>
11
+ RH-Commit: [1/1] bae929a2d0d0ad20e7308ede69c26499fc2119c7 (kostyanf14/redhat_centos-stream_src_qemu-kvm)
12
+
13
+ Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2149191
14
+ Upstream patch: https://patchew.org/QEMU/20230122153307.1050593-1-kfir@daynix.com/
15
+
16
+ Signed-off-by: Kfir Manor <kfir@daynix.com>
17
+ Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com>
18
+ Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
19
+ ---
20
+ qga/commands-posix.c | 6 +++++-
21
+ 1 file changed, 5 insertions(+), 1 deletion(-)
22
+
23
+ diff --git a/qga/commands-posix.c b/qga/commands-posix.c
24
+ index 32493d6383..f1b2b87c13 100644
25
+ --- a/qga/commands-posix.c
26
+ +++ b/qga/commands-posix.c
27
+ @@ -877,7 +877,9 @@ static bool build_guest_fsinfo_for_pci_dev(char const *syspath,
28
+ g_str_equal(driver, "sym53c8xx") ||
29
+ g_str_equal(driver, "virtio-pci") ||
30
+ g_str_equal(driver, "ahci") ||
31
+ - g_str_equal(driver, "nvme"))) {
32
+ + g_str_equal(driver, "nvme") ||
33
+ + g_str_equal(driver, "xhci_hcd") ||
34
+ + g_str_equal(driver, "ehci-pci"))) {
35
+ break;
36
+ }
37
+
38
+ @@ -974,6 +976,8 @@ static bool build_guest_fsinfo_for_pci_dev(char const *syspath,
39
+ }
40
+ } else if (strcmp(driver, "nvme") == 0) {
41
+ disk->bus_type = GUEST_DISK_BUS_TYPE_NVME;
42
+ + } else if (strcmp(driver, "ehci-pci") == 0 || strcmp(driver, "xhci_hcd") == 0) {
43
+ + disk->bus_type = GUEST_DISK_BUS_TYPE_USB;
44
+ } else {
45
+ g_debug("unknown driver '%s' (sysfs path '%s')", driver, syspath);
46
+ goto cleanup;
47
+ --
48
+ 2.31.1
49
+
SOURCES/kvm-qtest-numa-test-Correct-CPU-and-NUMA-association-in-.patch DELETED
@@ -1,100 +0,0 @@
1
- From a039ed652e6d2f5edcef9d5d1d3baec17ce7f929 Mon Sep 17 00:00:00 2001
2
- From: Gavin Shan <gshan@redhat.com>
3
- Date: Wed, 11 May 2022 18:01:35 +0800
4
- Subject: [PATCH 04/16] qtest/numa-test: Correct CPU and NUMA association in
5
- aarch64_numa_cpu()
6
-
7
- RH-Author: Gavin Shan <gshan@redhat.com>
8
- RH-MergeRequest: 86: hw/arm/virt: Fix the default CPU topology
9
- RH-Commit: [4/6] 64e9908a179eb4fb586d662f70f275a81808e50c (gwshan/qemu-rhel-9)
10
- RH-Bugzilla: 2041823
11
- RH-Acked-by: Eric Auger <eric.auger@redhat.com>
12
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
13
- RH-Acked-by: Andrew Jones <drjones@redhat.com>
14
-
15
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2041823
16
-
17
- In aarch64_numa_cpu(), the CPU and NUMA association is something
18
- like below. Two threads in the same core/cluster/socket are
19
- associated with two individual NUMA nodes, which is unreal as
20
- Igor Mammedov mentioned. We don't expect the association to break
21
- NUMA-to-socket boundary, which matches with the real world.
22
-
23
- NUMA-node socket cluster core thread
24
- ------------------------------------------
25
- 0 0 0 0 0
26
- 1 0 0 0 1
27
-
28
- This corrects the topology for CPUs and their association with
29
- NUMA nodes. After this patch is applied, the CPU and NUMA
30
- association becomes something like below, which looks real.
31
- Besides, socket/cluster/core/thread IDs are all checked when
32
- the NUMA node IDs are verified. It helps to check if the CPU
33
- topology is properly populated or not.
34
-
35
- NUMA-node socket cluster core thread
36
- ------------------------------------------
37
- 0 1 0 0 0
38
- 1 0 0 0 0
39
-
40
- Suggested-by: Igor Mammedov <imammedo@redhat.com>
41
- Signed-off-by: Gavin Shan <gshan@redhat.com>
42
- Acked-by: Igor Mammedov <imammedo@redhat.com>
43
- Message-id: 20220503140304.855514-5-gshan@redhat.com
44
- Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
45
- (cherry picked from commit e280ecb39bc1629f74ea5479d464fd1608dc8f76)
46
- Signed-off-by: Gavin Shan <gshan@redhat.com>
47
- ---
48
- tests/qtest/numa-test.c | 18 ++++++++++++------
49
- 1 file changed, 12 insertions(+), 6 deletions(-)
50
-
51
- diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c
52
- index aeda8c774c..32e35daaae 100644
53
- --- a/tests/qtest/numa-test.c
54
- +++ b/tests/qtest/numa-test.c
55
- @@ -224,17 +224,17 @@ static void aarch64_numa_cpu(const void *data)
56
- g_autofree char *cli = NULL;
57
-
58
- cli = make_cli(data, "-machine "
59
- - "smp.cpus=2,smp.sockets=1,smp.clusters=1,smp.cores=1,smp.threads=2 "
60
- + "smp.cpus=2,smp.sockets=2,smp.clusters=1,smp.cores=1,smp.threads=1 "
61
- "-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 "
62
- - "-numa cpu,node-id=1,thread-id=0 "
63
- - "-numa cpu,node-id=0,thread-id=1");
64
- + "-numa cpu,node-id=0,socket-id=1,cluster-id=0,core-id=0,thread-id=0 "
65
- + "-numa cpu,node-id=1,socket-id=0,cluster-id=0,core-id=0,thread-id=0");
66
- qts = qtest_init(cli);
67
- cpus = get_cpus(qts, &resp);
68
- g_assert(cpus);
69
-
70
- while ((e = qlist_pop(cpus))) {
71
- QDict *cpu, *props;
72
- - int64_t thread, node;
73
- + int64_t socket, cluster, core, thread, node;
74
-
75
- cpu = qobject_to(QDict, e);
76
- g_assert(qdict_haskey(cpu, "props"));
77
- @@ -242,12 +242,18 @@ static void aarch64_numa_cpu(const void *data)
78
-
79
- g_assert(qdict_haskey(props, "node-id"));
80
- node = qdict_get_int(props, "node-id");
81
- + g_assert(qdict_haskey(props, "socket-id"));
82
- + socket = qdict_get_int(props, "socket-id");
83
- + g_assert(qdict_haskey(props, "cluster-id"));
84
- + cluster = qdict_get_int(props, "cluster-id");
85
- + g_assert(qdict_haskey(props, "core-id"));
86
- + core = qdict_get_int(props, "core-id");
87
- g_assert(qdict_haskey(props, "thread-id"));
88
- thread = qdict_get_int(props, "thread-id");
89
-
90
- - if (thread == 0) {
91
- + if (socket == 0 && cluster == 0 && core == 0 && thread == 0) {
92
- g_assert_cmpint(node, ==, 1);
93
- - } else if (thread == 1) {
94
- + } else if (socket == 1 && cluster == 0 && core == 0 && thread == 0) {
95
- g_assert_cmpint(node, ==, 0);
96
- } else {
97
- g_assert(false);
98
- --
99
- 2.31.1
100
-
SOURCES/kvm-qtest-numa-test-Specify-CPU-topology-in-aarch64_numa.patch DELETED
@@ -1,68 +0,0 @@
1
- From 66f3928b40991d8467a3da086688f73d061886c8 Mon Sep 17 00:00:00 2001
2
- From: Gavin Shan <gshan@redhat.com>
3
- Date: Wed, 11 May 2022 18:01:35 +0800
4
- Subject: [PATCH 02/16] qtest/numa-test: Specify CPU topology in
5
- aarch64_numa_cpu()
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Gavin Shan <gshan@redhat.com>
11
- RH-MergeRequest: 86: hw/arm/virt: Fix the default CPU topology
12
- RH-Commit: [2/6] b851e7ad59e057825392ddf75e9040cc102a0385 (gwshan/qemu-rhel-9)
13
- RH-Bugzilla: 2041823
14
- RH-Acked-by: Eric Auger <eric.auger@redhat.com>
15
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
16
- RH-Acked-by: Andrew Jones <drjones@redhat.com>
17
-
18
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2041823
19
-
20
- The CPU topology isn't enabled on arm/virt machine yet, but we're
21
- going to do it in next patch. After the CPU topology is enabled by
22
- next patch, "thread-id=1" becomes invalid because the CPU core is
23
- preferred on arm/virt machine. It means these two CPUs have 0/1
24
- as their core IDs, but their thread IDs are all 0. It will trigger
25
- test failure as the following message indicates:
26
-
27
- [14/21 qemu:qtest+qtest-aarch64 / qtest-aarch64/numa-test ERROR
28
- 1.48s killed by signal 6 SIGABRT
29
- >>> G_TEST_DBUS_DAEMON=/home/gavin/sandbox/qemu.main/tests/dbus-vmstate-daemon.sh \
30
- QTEST_QEMU_STORAGE_DAEMON_BINARY=./storage-daemon/qemu-storage-daemon \
31
- QTEST_QEMU_BINARY=./qemu-system-aarch64 \
32
- QTEST_QEMU_IMG=./qemu-img MALLOC_PERTURB_=83 \
33
- /home/gavin/sandbox/qemu.main/build/tests/qtest/numa-test --tap -k
34
- ――――――――――――――――――――――――――――――――――――――――――――――
35
- stderr:
36
- qemu-system-aarch64: -numa cpu,node-id=0,thread-id=1: no match found
37
-
38
- This fixes the issue by providing comprehensive SMP configurations
39
- in aarch64_numa_cpu(). The SMP configurations aren't used before
40
- the CPU topology is enabled in next patch.
41
-
42
- Signed-off-by: Gavin Shan <gshan@redhat.com>
43
- Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
44
- Message-id: 20220503140304.855514-3-gshan@redhat.com
45
- Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
46
- (cherry picked from commit ac7199a2523ce2ccf8e685087a5d177eeca89b09)
47
- Signed-off-by: Gavin Shan <gshan@redhat.com>
48
- ---
49
- tests/qtest/numa-test.c | 3 ++-
50
- 1 file changed, 2 insertions(+), 1 deletion(-)
51
-
52
- diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c
53
- index 90bf68a5b3..aeda8c774c 100644
54
- --- a/tests/qtest/numa-test.c
55
- +++ b/tests/qtest/numa-test.c
56
- @@ -223,7 +223,8 @@ static void aarch64_numa_cpu(const void *data)
57
- QTestState *qts;
58
- g_autofree char *cli = NULL;
59
-
60
- - cli = make_cli(data, "-machine smp.cpus=2 "
61
- + cli = make_cli(data, "-machine "
62
- + "smp.cpus=2,smp.sockets=1,smp.clusters=1,smp.cores=1,smp.threads=2 "
63
- "-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 "
64
- "-numa cpu,node-id=1,thread-id=0 "
65
- "-numa cpu,node-id=0,thread-id=1");
66
- --
67
- 2.31.1
68
-
SOURCES/kvm-redhat-Update-linux-headers-linux-kvm.h-to-v5.18-rc6.patch DELETED
@@ -1,106 +0,0 @@
1
- From 236f216309261bc924e49014267998fdc2ef7f46 Mon Sep 17 00:00:00 2001
2
- From: Thomas Huth <thuth@redhat.com>
3
- Date: Fri, 29 Jul 2022 16:55:34 +0200
4
- Subject: [PATCH 28/32] redhat: Update linux-headers/linux/kvm.h to v5.18-rc6
5
-
6
- RH-Author: Thomas Huth <thuth@redhat.com>
7
- RH-MergeRequest: 109: Honor storage keys during emulation of I/O instructions
8
- RH-Commit: [1/2] f306d7ff8efa64b14158388b95815ac556a25d8a (thuth/qemu-kvm-cs9)
9
- RH-Bugzilla: 2111994
10
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
11
- RH-Acked-by: David Hildenbrand <david@redhat.com>
12
- RH-Acked-by: Claudio Imbrenda <None>
13
-
14
- Upstream Status: RHEL-only
15
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2111994
16
-
17
- Based on upstream commit e4082063e47e9731dbeb1c26174c17f6038f577f
18
- ("linux-headers: Update to v5.18-rc6"), but this is focusing on
19
- the file linux-headers/linux/kvm.h only (since the other changes
20
- related to the VFIO renaming might break some stuff).
21
-
22
- Signed-off-by: Thomas Huth <thuth@redhat.com>
23
- ---
24
- linux-headers/linux/kvm.h | 27 +++++++++++++++++++++------
25
- 1 file changed, 21 insertions(+), 6 deletions(-)
26
-
27
- diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
28
- index d232feaae9..0d05d02ee4 100644
29
- --- a/linux-headers/linux/kvm.h
30
- +++ b/linux-headers/linux/kvm.h
31
- @@ -445,7 +445,11 @@ struct kvm_run {
32
- #define KVM_SYSTEM_EVENT_RESET 2
33
- #define KVM_SYSTEM_EVENT_CRASH 3
34
- __u32 type;
35
- - __u64 flags;
36
- + __u32 ndata;
37
- + union {
38
- + __u64 flags;
39
- + __u64 data[16];
40
- + };
41
- } system_event;
42
- /* KVM_EXIT_S390_STSI */
43
- struct {
44
- @@ -562,9 +566,12 @@ struct kvm_s390_mem_op {
45
- __u32 op; /* type of operation */
46
- __u64 buf; /* buffer in userspace */
47
- union {
48
- - __u8 ar; /* the access register number */
49
- + struct {
50
- + __u8 ar; /* the access register number */
51
- + __u8 key; /* access key, ignored if flag unset */
52
- + };
53
- __u32 sida_offset; /* offset into the sida */
54
- - __u8 reserved[32]; /* should be set to 0 */
55
- + __u8 reserved[32]; /* ignored */
56
- };
57
- };
58
- /* types for kvm_s390_mem_op->op */
59
- @@ -572,9 +579,12 @@ struct kvm_s390_mem_op {
60
- #define KVM_S390_MEMOP_LOGICAL_WRITE 1
61
- #define KVM_S390_MEMOP_SIDA_READ 2
62
- #define KVM_S390_MEMOP_SIDA_WRITE 3
63
- +#define KVM_S390_MEMOP_ABSOLUTE_READ 4
64
- +#define KVM_S390_MEMOP_ABSOLUTE_WRITE 5
65
- /* flags for kvm_s390_mem_op->flags */
66
- #define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0)
67
- #define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1)
68
- +#define KVM_S390_MEMOP_F_SKEY_PROTECTION (1ULL << 2)
69
-
70
- /* for KVM_INTERRUPT */
71
- struct kvm_interrupt {
72
- @@ -1134,6 +1144,12 @@ struct kvm_ppc_resize_hpt {
73
- #define KVM_CAP_VM_GPA_BITS 207
74
- #define KVM_CAP_XSAVE2 208
75
- #define KVM_CAP_SYS_ATTRIBUTES 209
76
- +#define KVM_CAP_PPC_AIL_MODE_3 210
77
- +#define KVM_CAP_S390_MEM_OP_EXTENSION 211
78
- +#define KVM_CAP_PMU_CAPABILITY 212
79
- +#define KVM_CAP_DISABLE_QUIRKS2 213
80
- +/* #define KVM_CAP_VM_TSC_CONTROL 214 */
81
- +#define KVM_CAP_SYSTEM_EVENT_DATA 215
82
-
83
- #ifdef KVM_CAP_IRQ_ROUTING
84
-
85
- @@ -1624,9 +1640,6 @@ struct kvm_enc_region {
86
- #define KVM_S390_NORMAL_RESET _IO(KVMIO, 0xc3)
87
- #define KVM_S390_CLEAR_RESET _IO(KVMIO, 0xc4)
88
-
89
- -/* Available with KVM_CAP_XSAVE2 */
90
- -#define KVM_GET_XSAVE2 _IOR(KVMIO, 0xcf, struct kvm_xsave)
91
- -
92
- struct kvm_s390_pv_sec_parm {
93
- __u64 origin;
94
- __u64 length;
95
- @@ -1973,6 +1986,8 @@ struct kvm_dirty_gfn {
96
- #define KVM_BUS_LOCK_DETECTION_OFF (1 << 0)
97
- #define KVM_BUS_LOCK_DETECTION_EXIT (1 << 1)
98
-
99
- +#define KVM_PMU_CAP_DISABLE (1 << 0)
100
- +
101
- /**
102
- * struct kvm_stats_header - Header of per vm/vcpu binary statistics data.
103
- * @flags: Some extra information for header, always 0 for now.
104
- --
105
- 2.31.1
106
-
SOURCES/kvm-redhat-fix-virt-rhel9.2.0-compat-props.patch ADDED
@@ -0,0 +1,43 @@
1
+ From 546e4213c4e8a7b2e369315a71bc9aec091eed6e Mon Sep 17 00:00:00 2001
2
+ From: Cornelia Huck <cohuck@redhat.com>
3
+ Date: Mon, 19 Dec 2022 10:30:26 +0100
4
+ Subject: redhat: fix virt-rhel9.2.0 compat props
5
+
6
+ RH-Author: Cornelia Huck <cohuck@redhat.com>
7
+ RH-MergeRequest: 127: redhat: fix virt-rhel9.2.0 compat props
8
+ RH-Bugzilla: 2154640
9
+ RH-Acked-by: Eric Auger <eric.auger@redhat.com>
10
+ RH-Acked-by: Gavin Shan <gshan@redhat.com>
11
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
+ RH-Commit: [1/1] 49635fdc1d9a934ece78abd160b07c19909f876a (cohuck/qemu-kvm-c9s)
13
+
14
+ We need to include arm_rhel_compat props in the latest machine.
15
+
16
+ Signed-off-by: Cornelia Huck <cohuck@redhat.com>
17
+ ---
18
+ hw/arm/virt.c | 2 +-
19
+ 1 file changed, 1 insertion(+), 1 deletion(-)
20
+
21
+ diff --git a/hw/arm/virt.c b/hw/arm/virt.c
22
+ index 0a94f31dd1..bf18838b87 100644
23
+ --- a/hw/arm/virt.c
24
+ +++ b/hw/arm/virt.c
25
+ @@ -3520,6 +3520,7 @@ type_init(rhel_machine_init);
26
+
27
+ static void rhel920_virt_options(MachineClass *mc)
28
+ {
29
+ + compat_props_add(mc->compat_props, arm_rhel_compat, arm_rhel_compat_len);
30
+ }
31
+ DEFINE_RHEL_MACHINE_AS_LATEST(9, 2, 0)
32
+
33
+ @@ -3529,7 +3530,6 @@ static void rhel900_virt_options(MachineClass *mc)
34
+
35
+ rhel920_virt_options(mc);
36
+
37
+ - compat_props_add(mc->compat_props, arm_rhel_compat, arm_rhel_compat_len);
38
+ compat_props_add(mc->compat_props, hw_compat_rhel_9_1, hw_compat_rhel_9_1_len);
39
+
40
+ /* Disable FEAT_LPA2 since old kernels (<= v5.12) don't boot with that feature */
41
+ --
42
+ 2.38.1
43
+
SOURCES/kvm-s390x-pci-coalesce-unmap-operations.patch ADDED
@@ -0,0 +1,125 @@
1
+ From ed90f91b61844abd2dff2eb970f721a6cf072235 Mon Sep 17 00:00:00 2001
2
+ From: Matthew Rosato <mjrosato@linux.ibm.com>
3
+ Date: Fri, 28 Oct 2022 15:47:57 -0400
4
+ Subject: [PATCH 6/9] s390x/pci: coalesce unmap operations
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Cédric Le Goater <clg@redhat.com>
10
+ RH-MergeRequest: 141: s390x/pci: reset ISM passthrough devices on shutdown and system reset
11
+ RH-Bugzilla: 2163701
12
+ RH-Acked-by: Thomas Huth <thuth@redhat.com>
13
+ RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [1/3] 80c3a2c1d720057ae2a80b338ea06c9c6c804532 (clegoate/qemu-kvm-c9s)
16
+
17
+ Currently, each unmapped page is handled as an individual iommu
18
+ region notification. Attempt to group contiguous unmap operations
19
+ into fewer notifications to reduce overhead.
20
+
21
+ Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
22
+ Message-Id: <20221028194758.204007-3-mjrosato@linux.ibm.com>
23
+ Reviewed-by: Eric Farman <farman@linux.ibm.com>
24
+ Signed-off-by: Thomas Huth <thuth@redhat.com>
25
+ (cherry picked from commit ef536007c3301bbd6a787e4c2210ea289adaa6f0)
26
+ Signed-off-by: Cédric Le Goater <clg@redhat.com>
27
+ ---
28
+ hw/s390x/s390-pci-inst.c | 51 ++++++++++++++++++++++++++++++++++++++++
29
+ 1 file changed, 51 insertions(+)
30
+
31
+ diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
32
+ index 7cc4bcf850..66e764f901 100644
33
+ --- a/hw/s390x/s390-pci-inst.c
34
+ +++ b/hw/s390x/s390-pci-inst.c
35
+ @@ -640,6 +640,8 @@ static uint32_t s390_pci_update_iotlb(S390PCIIOMMU *iommu,
36
+ }
37
+ g_hash_table_remove(iommu->iotlb, &entry->iova);
38
+ inc_dma_avail(iommu);
39
+ + /* Don't notify the iommu yet, maybe we can bundle contiguous unmaps */
40
+ + goto out;
41
+ } else {
42
+ if (cache) {
43
+ if (cache->perm == entry->perm &&
44
+ @@ -663,15 +665,44 @@ static uint32_t s390_pci_update_iotlb(S390PCIIOMMU *iommu,
45
+ dec_dma_avail(iommu);
46
+ }
47
+
48
+ + /*
49
+ + * All associated iotlb entries have already been cleared, trigger the
50
+ + * unmaps.
51
+ + */
52
+ memory_region_notify_iommu(&iommu->iommu_mr, 0, event);
53
+
54
+ out:
55
+ return iommu->dma_limit ? iommu->dma_limit->avail : 1;
56
+ }
57
+
58
+ +static void s390_pci_batch_unmap(S390PCIIOMMU *iommu, uint64_t iova,
59
+ + uint64_t len)
60
+ +{
61
+ + uint64_t remain = len, start = iova, end = start + len - 1, mask, size;
62
+ + IOMMUTLBEvent event = {
63
+ + .type = IOMMU_NOTIFIER_UNMAP,
64
+ + .entry = {
65
+ + .target_as = &address_space_memory,
66
+ + .translated_addr = 0,
67
+ + .perm = IOMMU_NONE,
68
+ + },
69
+ + };
70
+ +
71
+ + while (remain >= TARGET_PAGE_SIZE) {
72
+ + mask = dma_aligned_pow2_mask(start, end, 64);
73
+ + size = mask + 1;
74
+ + event.entry.iova = start;
75
+ + event.entry.addr_mask = mask;
76
+ + memory_region_notify_iommu(&iommu->iommu_mr, 0, event);
77
+ + start += size;
78
+ + remain -= size;
79
+ + }
80
+ +}
81
+ +
82
+ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2, uintptr_t ra)
83
+ {
84
+ CPUS390XState *env = &cpu->env;
85
+ + uint64_t iova, coalesce = 0;
86
+ uint32_t fh;
87
+ uint16_t error = 0;
88
+ S390PCIBusDevice *pbdev;
89
+ @@ -742,6 +773,21 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2, uintptr_t ra)
90
+ break;
91
+ }
92
+
93
+ + /*
94
+ + * If this is an unmap of a PTE, let's try to coalesce multiple unmaps
95
+ + * into as few notifier events as possible.
96
+ + */
97
+ + if (entry.perm == IOMMU_NONE && entry.len == TARGET_PAGE_SIZE) {
98
+ + if (coalesce == 0) {
99
+ + iova = entry.iova;
100
+ + }
101
+ + coalesce += entry.len;
102
+ + } else if (coalesce > 0) {
103
+ + /* Unleash the coalesced unmap before processing a new map */
104
+ + s390_pci_batch_unmap(iommu, iova, coalesce);
105
+ + coalesce = 0;
106
+ + }
107
+ +
108
+ start += entry.len;
109
+ while (entry.iova < start && entry.iova < end) {
110
+ if (dma_avail > 0 || entry.perm == IOMMU_NONE) {
111
+ @@ -759,6 +805,11 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2, uintptr_t ra)
112
+ }
113
+ }
114
+ }
115
+ + if (coalesce) {
116
+ + /* Unleash the coalesced unmap before finishing rpcit */
117
+ + s390_pci_batch_unmap(iommu, iova, coalesce);
118
+ + coalesce = 0;
119
+ + }
120
+ if (again && dma_avail > 0)
121
+ goto retry;
122
+ err:
123
+ --
124
+ 2.31.1
125
+
SOURCES/kvm-s390x-pci-reset-ISM-passthrough-devices-on-shutdown-.patch ADDED
@@ -0,0 +1,147 @@
1
+ From 1ed1f8fc20a4883bc0bc1f58d299b0278abc5442 Mon Sep 17 00:00:00 2001
2
+ From: Matthew Rosato <mjrosato@linux.ibm.com>
3
+ Date: Fri, 9 Dec 2022 14:57:00 -0500
4
+ Subject: [PATCH 8/9] s390x/pci: reset ISM passthrough devices on shutdown and
5
+ system reset
6
+ MIME-Version: 1.0
7
+ Content-Type: text/plain; charset=UTF-8
8
+ Content-Transfer-Encoding: 8bit
9
+
10
+ RH-Author: Cédric Le Goater <clg@redhat.com>
11
+ RH-MergeRequest: 141: s390x/pci: reset ISM passthrough devices on shutdown and system reset
12
+ RH-Bugzilla: 2163701
13
+ RH-Acked-by: Thomas Huth <thuth@redhat.com>
14
+ RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
15
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
16
+ RH-Commit: [3/3] c531352b9d57f51ba938d4c46ee19a5706ade697 (clegoate/qemu-kvm-c9s)
17
+
18
+ ISM device firmware stores unique state information that can
19
+ can cause a wholesale unmap of the associated IOMMU (e.g. when
20
+ we get a termination signal for QEMU) to trigger firmware errors
21
+ because firmware believes we are attempting to invalidate entries
22
+ that are still in-use by the guest OS (when in fact that guest is
23
+ in the process of being terminated or rebooted).
24
+ To alleviate this, register both a shutdown notifier (for unexpected
25
+ termination cases e.g. virsh destroy) as well as a reset callback
26
+ (for cases like guest OS reboot). For each of these scenarios, trigger
27
+ PCI device reset; this is enough to indicate to firmware that the IOMMU
28
+ is no longer in-use by the guest OS, making it safe to invalidate any
29
+ associated IOMMU entries.
30
+
31
+ Fixes: 15d0e7942d3b ("s390x/pci: don't fence interpreted devices without MSI-X")
32
+ Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
33
+ Message-Id: <20221209195700.263824-1-mjrosato@linux.ibm.com>
34
+ Reviewed-by: Eric Farman <farman@linux.ibm.com>
35
+ [thuth: Adjusted the hunk in s390-pci-vfio.c due to different context]
36
+ Signed-off-by: Thomas Huth <thuth@redhat.com>
37
+ (cherry picked from commit 03451953c79e6b31f7860ee0c35b28e181d573c1)
38
+ Signed-off-by: Cédric Le Goater <clg@redhat.com>
39
+ ---
40
+ hw/s390x/s390-pci-bus.c | 28 ++++++++++++++++++++++++++++
41
+ hw/s390x/s390-pci-vfio.c | 2 ++
42
+ include/hw/s390x/s390-pci-bus.h | 5 +++++
43
+ 3 files changed, 35 insertions(+)
44
+
45
+ diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
46
+ index 977e7daa15..02751f3597 100644
47
+ --- a/hw/s390x/s390-pci-bus.c
48
+ +++ b/hw/s390x/s390-pci-bus.c
49
+ @@ -24,6 +24,8 @@
50
+ #include "hw/pci/msi.h"
51
+ #include "qemu/error-report.h"
52
+ #include "qemu/module.h"
53
+ +#include "sysemu/reset.h"
54
+ +#include "sysemu/runstate.h"
55
+
56
+ #ifndef DEBUG_S390PCI_BUS
57
+ #define DEBUG_S390PCI_BUS 0
58
+ @@ -150,10 +152,30 @@ out:
59
+ psccb->header.response_code = cpu_to_be16(rc);
60
+ }
61
+
62
+ +static void s390_pci_shutdown_notifier(Notifier *n, void *opaque)
63
+ +{
64
+ + S390PCIBusDevice *pbdev = container_of(n, S390PCIBusDevice,
65
+ + shutdown_notifier);
66
+ +
67
+ + pci_device_reset(pbdev->pdev);
68
+ +}
69
+ +
70
+ +static void s390_pci_reset_cb(void *opaque)
71
+ +{
72
+ + S390PCIBusDevice *pbdev = opaque;
73
+ +
74
+ + pci_device_reset(pbdev->pdev);
75
+ +}
76
+ +
77
+ static void s390_pci_perform_unplug(S390PCIBusDevice *pbdev)
78
+ {
79
+ HotplugHandler *hotplug_ctrl;
80
+
81
+ + if (pbdev->pft == ZPCI_PFT_ISM) {
82
+ + notifier_remove(&pbdev->shutdown_notifier);
83
+ + qemu_unregister_reset(s390_pci_reset_cb, pbdev);
84
+ + }
85
+ +
86
+ /* Unplug the PCI device */
87
+ if (pbdev->pdev) {
88
+ DeviceState *pdev = DEVICE(pbdev->pdev);
89
+ @@ -1111,6 +1133,12 @@ static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
90
+ pbdev->fh |= FH_SHM_VFIO;
91
+ pbdev->forwarding_assist = false;
92
+ }
93
+ + /* Register shutdown notifier and reset callback for ISM devices */
94
+ + if (pbdev->pft == ZPCI_PFT_ISM) {
95
+ + pbdev->shutdown_notifier.notify = s390_pci_shutdown_notifier;
96
+ + qemu_register_shutdown_notifier(&pbdev->shutdown_notifier);
97
+ + qemu_register_reset(s390_pci_reset_cb, pbdev);
98
+ + }
99
+ } else {
100
+ pbdev->fh |= FH_SHM_EMUL;
101
+ /* Always intercept emulated devices */
102
+ diff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c
103
+ index f7bf36cec8..f51190d466 100644
104
+ --- a/hw/s390x/s390-pci-vfio.c
105
+ +++ b/hw/s390x/s390-pci-vfio.c
106
+ @@ -124,6 +124,8 @@ static void s390_pci_read_base(S390PCIBusDevice *pbdev,
107
+ /* The following values remain 0 until we support other FMB formats */
108
+ pbdev->zpci_fn.fmbl = 0;
109
+ pbdev->zpci_fn.pft = 0;
110
+ + /* Store function type separately for type-specific behavior */
111
+ + pbdev->pft = cap->pft;
112
+
113
+ /*
114
+ * If appropriate, reduce the size of the supported DMA aperture reported
115
+ diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bus.h
116
+ index 1c46e3a269..e0a9f9385b 100644
117
+ --- a/include/hw/s390x/s390-pci-bus.h
118
+ +++ b/include/hw/s390x/s390-pci-bus.h
119
+ @@ -39,6 +39,9 @@
120
+ #define UID_CHECKING_ENABLED 0x01
121
+ #define ZPCI_DTSM 0x40
122
+
123
+ +/* zPCI Function Types */
124
+ +#define ZPCI_PFT_ISM 5
125
+ +
126
+ OBJECT_DECLARE_SIMPLE_TYPE(S390pciState, S390_PCI_HOST_BRIDGE)
127
+ OBJECT_DECLARE_SIMPLE_TYPE(S390PCIBus, S390_PCI_BUS)
128
+ OBJECT_DECLARE_SIMPLE_TYPE(S390PCIBusDevice, S390_PCI_DEVICE)
129
+ @@ -344,6 +347,7 @@ struct S390PCIBusDevice {
130
+ uint16_t noi;
131
+ uint16_t maxstbl;
132
+ uint8_t sum;
133
+ + uint8_t pft;
134
+ S390PCIGroup *pci_group;
135
+ ClpRspQueryPci zpci_fn;
136
+ S390MsixInfo msix;
137
+ @@ -352,6 +356,7 @@ struct S390PCIBusDevice {
138
+ MemoryRegion msix_notify_mr;
139
+ IndAddr *summary_ind;
140
+ IndAddr *indicator;
141
+ + Notifier shutdown_notifier;
142
+ bool pci_unplug_request_processed;
143
+ bool unplug_requested;
144
+ bool interp;
145
+ --
146
+ 2.31.1
147
+
SOURCES/kvm-s390x-pci-shrink-DMA-aperture-to-be-bound-by-vfio-DM.patch ADDED
@@ -0,0 +1,91 @@
1
+ From ee69c8c57fe62fc200f749c4ce3927c88803644d Mon Sep 17 00:00:00 2001
2
+ From: Matthew Rosato <mjrosato@linux.ibm.com>
3
+ Date: Fri, 28 Oct 2022 15:47:58 -0400
4
+ Subject: [PATCH 7/9] s390x/pci: shrink DMA aperture to be bound by vfio DMA
5
+ limit
6
+ MIME-Version: 1.0
7
+ Content-Type: text/plain; charset=UTF-8
8
+ Content-Transfer-Encoding: 8bit
9
+
10
+ RH-Author: Cédric Le Goater <clg@redhat.com>
11
+ RH-MergeRequest: 141: s390x/pci: reset ISM passthrough devices on shutdown and system reset
12
+ RH-Bugzilla: 2163701
13
+ RH-Acked-by: Thomas Huth <thuth@redhat.com>
14
+ RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
15
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
16
+ RH-Commit: [2/3] 0956bbb4773dd0085f6aed59d6284c704b4fed3b (clegoate/qemu-kvm-c9s)
17
+
18
+ Currently, s390x-pci performs accounting against the vfio DMA
19
+ limit and triggers the guest to clean up mappings when the limit
20
+ is reached. Let's go a step further and also limit the size of
21
+ the supported DMA aperture reported to the guest based upon the
22
+ initial vfio DMA limit reported for the container (if less than
23
+ than the size reported by the firmware/host zPCI layer). This
24
+ avoids processing sections of the guest DMA table during global
25
+ refresh that, for common use cases, will never be used anway, and
26
+ makes exhausting the vfio DMA limit due to mismatch between guest
27
+ aperture size and host limit far less likely and more indicitive
28
+ of an error.
29
+
30
+ Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
31
+ Message-Id: <20221028194758.204007-4-mjrosato@linux.ibm.com>
32
+ Reviewed-by: Eric Farman <farman@linux.ibm.com>
33
+ Signed-off-by: Thomas Huth <thuth@redhat.com>
34
+ (cherry picked from commit df202e3ff3fccb49868e08f20d0bda86cb953fbe)
35
+ Signed-off-by: Cédric Le Goater <clg@redhat.com>
36
+ ---
37
+ hw/s390x/s390-pci-vfio.c | 11 +++++++++++
38
+ include/hw/s390x/s390-pci-bus.h | 1 +
39
+ 2 files changed, 12 insertions(+)
40
+
41
+ diff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c
42
+ index 5f0adb0b4a..f7bf36cec8 100644
43
+ --- a/hw/s390x/s390-pci-vfio.c
44
+ +++ b/hw/s390x/s390-pci-vfio.c
45
+ @@ -84,6 +84,7 @@ S390PCIDMACount *s390_pci_start_dma_count(S390pciState *s,
46
+ cnt->users = 1;
47
+ cnt->avail = avail;
48
+ QTAILQ_INSERT_TAIL(&s->zpci_dma_limit, cnt, link);
49
+ + pbdev->iommu->max_dma_limit = avail;
50
+ return cnt;
51
+ }
52
+
53
+ @@ -103,6 +104,7 @@ static void s390_pci_read_base(S390PCIBusDevice *pbdev,
54
+ struct vfio_info_cap_header *hdr;
55
+ struct vfio_device_info_cap_zpci_base *cap;
56
+ VFIOPCIDevice *vpci = container_of(pbdev->pdev, VFIOPCIDevice, pdev);
57
+ + uint64_t vfio_size;
58
+
59
+ hdr = vfio_get_device_info_cap(info, VFIO_DEVICE_INFO_CAP_ZPCI_BASE);
60
+
61
+ @@ -122,6 +124,15 @@ static void s390_pci_read_base(S390PCIBusDevice *pbdev,
62
+ /* The following values remain 0 until we support other FMB formats */
63
+ pbdev->zpci_fn.fmbl = 0;
64
+ pbdev->zpci_fn.pft = 0;
65
+ +
66
+ + /*
67
+ + * If appropriate, reduce the size of the supported DMA aperture reported
68
+ + * to the guest based upon the vfio DMA limit.
69
+ + */
70
+ + vfio_size = pbdev->iommu->max_dma_limit << TARGET_PAGE_BITS;
71
+ + if (vfio_size < (cap->end_dma - cap->start_dma + 1)) {
72
+ + pbdev->zpci_fn.edma = cap->start_dma + vfio_size - 1;
73
+ + }
74
+ }
75
+
76
+ static bool get_host_fh(S390PCIBusDevice *pbdev, struct vfio_device_info *info,
77
+ diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bus.h
78
+ index 0605fcea24..1c46e3a269 100644
79
+ --- a/include/hw/s390x/s390-pci-bus.h
80
+ +++ b/include/hw/s390x/s390-pci-bus.h
81
+ @@ -278,6 +278,7 @@ struct S390PCIIOMMU {
82
+ uint64_t g_iota;
83
+ uint64_t pba;
84
+ uint64_t pal;
85
+ + uint64_t max_dma_limit;
86
+ GHashTable *iotlb;
87
+ S390PCIDMACount *dma_limit;
88
+ };
89
+ --
90
+ 2.31.1
91
+
SOURCES/kvm-s390x-pv-Implement-a-CGS-check-helper.patch ADDED
@@ -0,0 +1,109 @@
1
+ From 9452246e59a5f16f44fdf9a7d514b947faf1d5fc Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= <clg@redhat.com>
3
+ Date: Mon, 16 Jan 2023 18:46:05 +0100
4
+ Subject: [PATCH 5/9] s390x/pv: Implement a CGS check helper
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Cédric Le Goater <clg@redhat.com>
10
+ RH-MergeRequest: 139: s390x/pv: Implement a CGS check helper
11
+ RH-Bugzilla: 2122523
12
+ RH-Acked-by: Thomas Huth <thuth@redhat.com>
13
+ RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
14
+ RH-Acked-by: David Hildenbrand <david@redhat.com>
15
+ RH-Commit: [1/1] 8551ce772b10de653b4e1c8be60aae60ec98b421 (clegoate/qemu-kvm-c9s)
16
+
17
+ When a protected VM is started with the maximum number of CPUs (248),
18
+ the service call providing information on the CPUs requires more
19
+ buffer space than allocated and QEMU disgracefully aborts :
20
+
21
+ LOADPARM=[........]
22
+ Using virtio-blk.
23
+ Using SCSI scheme.
24
+ ...................................................................................
25
+ qemu-system-s390x: KVM_S390_MEM_OP failed: Argument list too long
26
+
27
+ When protected virtualization is initialized, compute the maximum
28
+ number of vCPUs supported by the machine and return useful information
29
+ to the user before the machine starts in case of error.
30
+
31
+ Suggested-by: Thomas Huth <thuth@redhat.com>
32
+ Reviewed-by: Thomas Huth <thuth@redhat.com>
33
+ Signed-off-by: Cédric Le Goater <clg@redhat.com>
34
+ Message-Id: <20230116174607.2459498-2-clg@kaod.org>
35
+ Signed-off-by: Thomas Huth <thuth@redhat.com>
36
+ (cherry picked from commit 75d7150c636569f6687f7e70a33be893be43eb5f)
37
+ Signed-off-by: Cédric Le Goater <clg@redhat.com>
38
+ ---
39
+ hw/s390x/pv.c | 40 ++++++++++++++++++++++++++++++++++++++++
40
+ 1 file changed, 40 insertions(+)
41
+
42
+ diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c
43
+ index 8dfe92d8df..8a1c71436b 100644
44
+ --- a/hw/s390x/pv.c
45
+ +++ b/hw/s390x/pv.c
46
+ @@ -20,6 +20,7 @@
47
+ #include "exec/confidential-guest-support.h"
48
+ #include "hw/s390x/ipl.h"
49
+ #include "hw/s390x/pv.h"
50
+ +#include "hw/s390x/sclp.h"
51
+ #include "target/s390x/kvm/kvm_s390x.h"
52
+
53
+ static bool info_valid;
54
+ @@ -249,6 +250,41 @@ struct S390PVGuestClass {
55
+ ConfidentialGuestSupportClass parent_class;
56
+ };
57
+
58
+ +/*
59
+ + * If protected virtualization is enabled, the amount of data that the
60
+ + * Read SCP Info Service Call can use is limited to one page. The
61
+ + * available space also depends on the Extended-Length SCCB (ELS)
62
+ + * feature which can take more buffer space to store feature
63
+ + * information. This impacts the maximum number of CPUs supported in
64
+ + * the machine.
65
+ + */
66
+ +static uint32_t s390_pv_get_max_cpus(void)
67
+ +{
68
+ + int offset_cpu = s390_has_feat(S390_FEAT_EXTENDED_LENGTH_SCCB) ?
69
+ + offsetof(ReadInfo, entries) : SCLP_READ_SCP_INFO_FIXED_CPU_OFFSET;
70
+ +
71
+ + return (TARGET_PAGE_SIZE - offset_cpu) / sizeof(CPUEntry);
72
+ +}
73
+ +
74
+ +static bool s390_pv_check_cpus(Error **errp)
75
+ +{
76
+ + MachineState *ms = MACHINE(qdev_get_machine());
77
+ + uint32_t pv_max_cpus = s390_pv_get_max_cpus();
78
+ +
79
+ + if (ms->smp.max_cpus > pv_max_cpus) {
80
+ + error_setg(errp, "Protected VMs support a maximum of %d CPUs",
81
+ + pv_max_cpus);
82
+ + return false;
83
+ + }
84
+ +
85
+ + return true;
86
+ +}
87
+ +
88
+ +static bool s390_pv_guest_check(ConfidentialGuestSupport *cgs, Error **errp)
89
+ +{
90
+ + return s390_pv_check_cpus(errp);
91
+ +}
92
+ +
93
+ int s390_pv_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
94
+ {
95
+ if (!object_dynamic_cast(OBJECT(cgs), TYPE_S390_PV_GUEST)) {
96
+ @@ -261,6 +297,10 @@ int s390_pv_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
97
+ return -1;
98
+ }
99
+
100
+ + if (!s390_pv_guest_check(cgs, errp)) {
101
+ + return -1;
102
+ + }
103
+ +
104
+ cgs->ready = true;
105
+
106
+ return 0;
107
+ --
108
+ 2.31.1
109
+
SOURCES/kvm-s390x-s390-virtio-ccw-Activate-zPCI-features-on-s390.patch ADDED
@@ -0,0 +1,70 @@
1
+ From 51fcf352a97f2e99a6a3fb8ae663b45436304120 Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= <clg@redhat.com>
3
+ Date: Tue, 10 Jan 2023 14:25:34 +0100
4
+ Subject: [PATCH 11/31] s390x/s390-virtio-ccw: Activate zPCI features on
5
+ s390-ccw-virtio-rhel8.6.0
6
+ MIME-Version: 1.0
7
+ Content-Type: text/plain; charset=UTF-8
8
+ Content-Transfer-Encoding: 8bit
9
+
10
+ RH-Author: Cédric Le Goater <clg@redhat.com>
11
+ RH-MergeRequest: 133: s390x/s390-virtio-ccw: Activate zPCI features on s390-ccw-virtio-rhel8.6.0
12
+ RH-Bugzilla: 2159408
13
+ RH-Acked-by: Thomas Huth <thuth@redhat.com>
14
+ RH-Acked-by: David Hildenbrand <david@redhat.com>
15
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
16
+ RH-Commit: [1/1] 1ed82e56fe74a283a1726c4893dc3387e645072c (clegoate/qemu-kvm-c9s)
17
+
18
+ commit c7b14d3af7 ("s390x/s390-virtio-ccw: Switch off zPCI enhancements
19
+ on older machines") activated zPCI enhancement features (interpretation
20
+ and forward assist) silently on the s390-ccw-virtio-rhel8.6.0 machine
21
+ for RHEL8.8. It didn't seem to be a problem since migration is not
22
+ possible but it broke LEAPP upgrade to RHEL9 when the machine is
23
+ defined with a passthrough device. Activate the zPCI features also on
24
+ RHEL9.2 for the machines to be alike in both latest RHEL distros.
25
+
26
+ Upstream Status: RHEL-only
27
+ Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2159408
28
+
29
+ Signed-off-by: Cédric Le Goater <clg@redhat.com>
30
+ ---
31
+ hw/s390x/s390-virtio-ccw.c | 12 ++++++++++++
32
+ 1 file changed, 12 insertions(+)
33
+
34
+ diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
35
+ index aa142a1a4e..4cdd59c394 100644
36
+ --- a/hw/s390x/s390-virtio-ccw.c
37
+ +++ b/hw/s390x/s390-virtio-ccw.c
38
+ @@ -1234,8 +1234,14 @@ static void ccw_machine_rhel860_instance_options(MachineState *machine)
39
+
40
+ static void ccw_machine_rhel860_class_options(MachineClass *mc)
41
+ {
42
+ + static GlobalProperty compat[] = {
43
+ + { TYPE_S390_PCI_DEVICE, "interpret", "on", },
44
+ + { TYPE_S390_PCI_DEVICE, "forwarding-assist", "on", },
45
+ + };
46
+ +
47
+ ccw_machine_rhel900_class_options(mc);
48
+ compat_props_add(mc->compat_props, hw_compat_rhel_8_6, hw_compat_rhel_8_6_len);
49
+ + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
50
+
51
+ /* All RHEL machines for prior major releases are deprecated */
52
+ mc->deprecation_reason = rhel_old_machine_deprecation;
53
+ @@ -1259,8 +1265,14 @@ static void ccw_machine_rhel850_instance_options(MachineState *machine)
54
+
55
+ static void ccw_machine_rhel850_class_options(MachineClass *mc)
56
+ {
57
+ + static GlobalProperty compat[] = {
58
+ + { TYPE_S390_PCI_DEVICE, "interpret", "off", },
59
+ + { TYPE_S390_PCI_DEVICE, "forwarding-assist", "off", },
60
+ + };
61
+ +
62
+ ccw_machine_rhel860_class_options(mc);
63
+ compat_props_add(mc->compat_props, hw_compat_rhel_8_5, hw_compat_rhel_8_5_len);
64
+ + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
65
+ mc->smp_props.prefer_sockets = true;
66
+ }
67
+ DEFINE_CCW_MACHINE(rhel850, "rhel8.5.0", false);
68
+ --
69
+ 2.31.1
70
+
SOURCES/kvm-stream-Replace-subtree-drain-with-a-single-node-drai.patch ADDED
@@ -0,0 +1,159 @@
1
+ From 5defda06ec4c24818a34126c5048be5e274b63f5 Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Fri, 18 Nov 2022 18:41:04 +0100
4
+ Subject: [PATCH 22/31] stream: Replace subtree drain with a single node drain
5
+
6
+ RH-Author: Stefano Garzarella <sgarzare@redhat.com>
7
+ RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
8
+ RH-Bugzilla: 2155112
9
+ RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
10
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
11
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
12
+ RH-Commit: [10/16] a93250b1f6ef296e903df0ba5d8b29bc2ed540a8 (sgarzarella/qemu-kvm-c-9-s)
13
+
14
+ The subtree drain was introduced in commit b1e1af394d9 as a way to avoid
15
+ graph changes between finding the base node and changing the block graph
16
+ as necessary on completion of the image streaming job.
17
+
18
+ The block graph could change between these two points because
19
+ bdrv_set_backing_hd() first drains the parent node, which involved
20
+ polling and can do anything.
21
+
22
+ Subtree draining was an imperfect way to make this less likely (because
23
+ with it, fewer callbacks are called during this window). Everyone agreed
24
+ that it's not really the right solution, and it was only committed as a
25
+ stopgap solution.
26
+
27
+ This replaces the subtree drain with a solution that simply drains the
28
+ parent node before we try to find the base node, and then call a version
29
+ of bdrv_set_backing_hd() that doesn't drain, but just asserts that the
30
+ parent node is already drained.
31
+
32
+ This way, any graph changes caused by draining happen before we start
33
+ looking at the graph and things stay consistent between finding the base
34
+ node and changing the graph.
35
+
36
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
37
+ Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
38
+ Reviewed-by: Hanna Reitz <hreitz@redhat.com>
39
+ Message-Id: <20221118174110.55183-10-kwolf@redhat.com>
40
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
41
+ (cherry picked from commit 92140b9f3f07d80e2c27edcc6e32f392be2135e6)
42
+ Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
43
+ ---
44
+ block.c | 17 ++++++++++++++---
45
+ block/stream.c | 26 ++++++++++++++++----------
46
+ include/block/block-global-state.h | 3 +++
47
+ 3 files changed, 33 insertions(+), 13 deletions(-)
48
+
49
+ diff --git a/block.c b/block.c
50
+ index b3449a312e..5330e89903 100644
51
+ --- a/block.c
52
+ +++ b/block.c
53
+ @@ -3403,14 +3403,15 @@ static int bdrv_set_backing_noperm(BlockDriverState *bs,
54
+ return bdrv_set_file_or_backing_noperm(bs, backing_hd, true, tran, errp);
55
+ }
56
+
57
+ -int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd,
58
+ - Error **errp)
59
+ +int bdrv_set_backing_hd_drained(BlockDriverState *bs,
60
+ + BlockDriverState *backing_hd,
61
+ + Error **errp)
62
+ {
63
+ int ret;
64
+ Transaction *tran = tran_new();
65
+
66
+ GLOBAL_STATE_CODE();
67
+ - bdrv_drained_begin(bs);
68
+ + assert(bs->quiesce_counter > 0);
69
+
70
+ ret = bdrv_set_backing_noperm(bs, backing_hd, tran, errp);
71
+ if (ret < 0) {
72
+ @@ -3420,7 +3421,17 @@ int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd,
73
+ ret = bdrv_refresh_perms(bs, errp);
74
+ out:
75
+ tran_finalize(tran, ret);
76
+ + return ret;
77
+ +}
78
+
79
+ +int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd,
80
+ + Error **errp)
81
+ +{
82
+ + int ret;
83
+ + GLOBAL_STATE_CODE();
84
+ +
85
+ + bdrv_drained_begin(bs);
86
+ + ret = bdrv_set_backing_hd_drained(bs, backing_hd, errp);
87
+ bdrv_drained_end(bs);
88
+
89
+ return ret;
90
+ diff --git a/block/stream.c b/block/stream.c
91
+ index 694709bd25..8744ad103f 100644
92
+ --- a/block/stream.c
93
+ +++ b/block/stream.c
94
+ @@ -64,13 +64,16 @@ static int stream_prepare(Job *job)
95
+ bdrv_cor_filter_drop(s->cor_filter_bs);
96
+ s->cor_filter_bs = NULL;
97
+
98
+ - bdrv_subtree_drained_begin(s->above_base);
99
+ + /*
100
+ + * bdrv_set_backing_hd() requires that unfiltered_bs is drained. Drain
101
+ + * already here and use bdrv_set_backing_hd_drained() instead because
102
+ + * the polling during drained_begin() might change the graph, and if we do
103
+ + * this only later, we may end up working with the wrong base node (or it
104
+ + * might even have gone away by the time we want to use it).
105
+ + */
106
+ + bdrv_drained_begin(unfiltered_bs);
107
+
108
+ base = bdrv_filter_or_cow_bs(s->above_base);
109
+ - if (base) {
110
+ - bdrv_ref(base);
111
+ - }
112
+ -
113
+ unfiltered_base = bdrv_skip_filters(base);
114
+
115
+ if (bdrv_cow_child(unfiltered_bs)) {
116
+ @@ -82,7 +85,13 @@ static int stream_prepare(Job *job)
117
+ }
118
+ }
119
+
120
+ - bdrv_set_backing_hd(unfiltered_bs, base, &local_err);
121
+ + bdrv_set_backing_hd_drained(unfiltered_bs, base, &local_err);
122
+ +
123
+ + /*
124
+ + * This call will do I/O, so the graph can change again from here on.
125
+ + * We have already completed the graph change, so we are not in danger
126
+ + * of operating on the wrong node any more if this happens.
127
+ + */
128
+ ret = bdrv_change_backing_file(unfiltered_bs, base_id, base_fmt, false);
129
+ if (local_err) {
130
+ error_report_err(local_err);
131
+ @@ -92,10 +101,7 @@ static int stream_prepare(Job *job)
132
+ }
133
+
134
+ out:
135
+ - if (base) {
136
+ - bdrv_unref(base);
137
+ - }
138
+ - bdrv_subtree_drained_end(s->above_base);
139
+ + bdrv_drained_end(unfiltered_bs);
140
+ return ret;
141
+ }
142
+
143
+ diff --git a/include/block/block-global-state.h b/include/block/block-global-state.h
144
+ index c7bd4a2088..00e0cf8aea 100644
145
+ --- a/include/block/block-global-state.h
146
+ +++ b/include/block/block-global-state.h
147
+ @@ -82,6 +82,9 @@ int bdrv_open_file_child(const char *filename,
148
+ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp);
149
+ int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd,
150
+ Error **errp);
151
+ +int bdrv_set_backing_hd_drained(BlockDriverState *bs,
152
+ + BlockDriverState *backing_hd,
153
+ + Error **errp);
154
+ int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options,
155
+ const char *bdref_key, Error **errp);
156
+ BlockDriverState *bdrv_open(const char *filename, const char *reference,
157
+ --
158
+ 2.31.1
159
+
SOURCES/kvm-sysemu-tpm-Add-a-stub-function-for-TPM_IS_CRB.patch DELETED
@@ -1,54 +0,0 @@
1
- From 74b3e92dcb9e343e135a681259514b4fd28086ea Mon Sep 17 00:00:00 2001
2
- From: Eric Auger <eric.auger@redhat.com>
3
- Date: Fri, 6 May 2022 15:25:09 +0200
4
- Subject: [PATCH 4/5] sysemu: tpm: Add a stub function for TPM_IS_CRB
5
-
6
- RH-Author: Eric Auger <eric.auger@redhat.com>
7
- RH-MergeRequest: 84: vfio/common: Remove spurious tpm-crb-cmd misalignment warning
8
- RH-Commit: [1/2] 0ab55ca1aa12a3a7cbdef5a378928f75e030e536 (eauger1/centos-qemu-kvm)
9
- RH-Bugzilla: 2037612
10
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
12
- RH-Acked-by: Andrew Jones <drjones@redhat.com>
13
-
14
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2037612
15
- Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=45166961
16
- Upstream Status: YES
17
- Tested: With TPM-CRB and VFIO
18
-
19
- In a subsequent patch, VFIO will need to recognize if
20
- a memory region owner is a TPM CRB device. Hence VFIO
21
- needs to use TPM_IS_CRB() even if CONFIG_TPM is unset. So
22
- let's add a stub function.
23
-
24
- Signed-off-by: Eric Auger <eric.auger@redhat.com>
25
- Suggested-by: Cornelia Huck <cohuck@redhat.com>
26
- Reviewed-by: Stefan Berger <stefanb@linnux.ibm.com>
27
- Link: https://lore.kernel.org/r/20220506132510.1847942-2-eric.auger@redhat.com
28
- Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
29
- (cherry picked from commit 4168cdad398843ed53d650a27651868b4d3e21c9)
30
- Signed-off-by: Eric Auger <eric.auger@redhat.com>
31
- ---
32
- include/sysemu/tpm.h | 6 ++++++
33
- 1 file changed, 6 insertions(+)
34
-
35
- diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
36
- index 68b2206463..fb40e30ff6 100644
37
- --- a/include/sysemu/tpm.h
38
- +++ b/include/sysemu/tpm.h
39
- @@ -80,6 +80,12 @@ static inline TPMVersion tpm_get_version(TPMIf *ti)
40
- #define tpm_init() (0)
41
- #define tpm_cleanup()
42
-
43
- +/* needed for an alignment check in non-tpm code */
44
- +static inline Object *TPM_IS_CRB(Object *obj)
45
- +{
46
- + return NULL;
47
- +}
48
- +
49
- #endif /* CONFIG_TPM */
50
-
51
- #endif /* QEMU_TPM_H */
52
- --
53
- 2.31.1
54
-
SOURCES/kvm-target-arm-deprecate-named-CPU-models.patch DELETED
@@ -1,129 +0,0 @@
1
- From 1f8528b71d96c01dd6106f11681f4a4e2776ef5f Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
3
- Date: Mon, 21 Mar 2022 12:05:42 +0000
4
- Subject: [PATCH 06/18] target/arm: deprecate named CPU models
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Daniel P. Berrangé <berrange@redhat.com>
10
- RH-MergeRequest: 94: i386, aarch64, s390x: deprecate many named CPU models
11
- RH-Commit: [6/6] afddeb9e898206fd04499f01c48caf7dc1a8b8ef (berrange/centos-src-qemu)
12
- RH-Bugzilla: 2060839
13
- RH-Acked-by: Thomas Huth <thuth@redhat.com>
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
16
-
17
- KVM requires use of the 'host' CPU model, so named CPU models are only
18
- needed for TCG. Since we don't consider TCG to be supported we can
19
- deprecate all the named CPU models. TCG users can rely on 'max' model.
20
-
21
- Note: this has the effect of deprecating the default built-in CPU
22
- model 'cortex-a57'. Applications using QEMU are expected to make an
23
- explicit choice about which CPU model they want, since no builtin
24
- default can suit all purposes.
25
-
26
- https://bugzilla.redhat.com/show_bug.cgi?id=2060839
27
- Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
28
- ---
29
- target/arm/cpu-qom.h | 1 +
30
- target/arm/cpu.c | 5 +++++
31
- target/arm/cpu.h | 2 ++
32
- target/arm/cpu64.c | 8 +++++++-
33
- target/arm/helper.c | 2 ++
34
- 5 files changed, 17 insertions(+), 1 deletion(-)
35
-
36
- diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h
37
- index 64c44cef2d..82e97249bc 100644
38
- --- a/target/arm/cpu-qom.h
39
- +++ b/target/arm/cpu-qom.h
40
- @@ -35,6 +35,7 @@ typedef struct ARMCPUInfo {
41
- const char *name;
42
- void (*initfn)(Object *obj);
43
- void (*class_init)(ObjectClass *oc, void *data);
44
- + const char *deprecation_note;
45
- } ARMCPUInfo;
46
-
47
- void arm_cpu_register(const ARMCPUInfo *info);
48
- diff --git a/target/arm/cpu.c b/target/arm/cpu.c
49
- index 5d4ca7a227..c74b0fb462 100644
50
- --- a/target/arm/cpu.c
51
- +++ b/target/arm/cpu.c
52
- @@ -2105,8 +2105,13 @@ static void arm_cpu_instance_init(Object *obj)
53
- static void cpu_register_class_init(ObjectClass *oc, void *data)
54
- {
55
- ARMCPUClass *acc = ARM_CPU_CLASS(oc);
56
- + CPUClass *cc = CPU_CLASS(oc);
57
-
58
- acc->info = data;
59
- +
60
- + if (acc->info->deprecation_note) {
61
- + cc->deprecation_note = acc->info->deprecation_note;
62
- + }
63
- }
64
-
65
- void arm_cpu_register(const ARMCPUInfo *info)
66
- diff --git a/target/arm/cpu.h b/target/arm/cpu.h
67
- index 23879de5fa..c0c9f680e5 100644
68
- --- a/target/arm/cpu.h
69
- +++ b/target/arm/cpu.h
70
- @@ -33,6 +33,8 @@
71
- #define KVM_HAVE_MCE_INJECTION 1
72
- #endif
73
-
74
- +#define RHEL_CPU_DEPRECATION "use 'host' / 'max'"
75
- +
76
- #define EXCP_UDEF 1 /* undefined instruction */
77
- #define EXCP_SWI 2 /* software interrupt */
78
- #define EXCP_PREFETCH_ABORT 3
79
- diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
80
- index e80b831073..c8f152891c 100644
81
- --- a/target/arm/cpu64.c
82
- +++ b/target/arm/cpu64.c
83
- @@ -975,7 +975,8 @@ static void aarch64_a64fx_initfn(Object *obj)
84
- #endif /* disabled for RHEL */
85
-
86
- static const ARMCPUInfo aarch64_cpus[] = {
87
- - { .name = "cortex-a57", .initfn = aarch64_a57_initfn },
88
- + { .name = "cortex-a57", .initfn = aarch64_a57_initfn,
89
- + .deprecation_note = RHEL_CPU_DEPRECATION },
90
- #if 0 /* Disabled for Red Hat Enterprise Linux */
91
- { .name = "cortex-a53", .initfn = aarch64_a53_initfn },
92
- { .name = "cortex-a72", .initfn = aarch64_a72_initfn },
93
- @@ -1052,8 +1053,13 @@ static void aarch64_cpu_instance_init(Object *obj)
94
- static void cpu_register_class_init(ObjectClass *oc, void *data)
95
- {
96
- ARMCPUClass *acc = ARM_CPU_CLASS(oc);
97
- + CPUClass *cc = CPU_CLASS(oc);
98
-
99
- acc->info = data;
100
- +
101
- + if (acc->info->deprecation_note) {
102
- + cc->deprecation_note = acc->info->deprecation_note;
103
- + }
104
- }
105
-
106
- void aarch64_cpu_register(const ARMCPUInfo *info)
107
- diff --git a/target/arm/helper.c b/target/arm/helper.c
108
- index 7d14650615..3d34f63e49 100644
109
- --- a/target/arm/helper.c
110
- +++ b/target/arm/helper.c
111
- @@ -8560,6 +8560,7 @@ void arm_cpu_list(void)
112
- static void arm_cpu_add_definition(gpointer data, gpointer user_data)
113
- {
114
- ObjectClass *oc = data;
115
- + CPUClass *cc = CPU_CLASS(oc);
116
- CpuDefinitionInfoList **cpu_list = user_data;
117
- CpuDefinitionInfo *info;
118
- const char *typename;
119
- @@ -8569,6 +8570,7 @@ static void arm_cpu_add_definition(gpointer data, gpointer user_data)
120
- info->name = g_strndup(typename,
121
- strlen(typename) - strlen("-" TYPE_ARM_CPU));
122
- info->q_typename = g_strdup(typename);
123
- + info->deprecated = !!cc->deprecation_note;
124
-
125
- QAPI_LIST_PREPEND(*cpu_list, info);
126
- }
127
- --
128
- 2.35.3
129
-
SOURCES/kvm-target-i386-deprecate-CPUs-older-than-x86_64-v2-ABI.patch DELETED
@@ -1,273 +0,0 @@
1
- From 577b04770e47aed0f88acb4a415ed04ddbe087f1 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
3
- Date: Thu, 17 Mar 2022 17:59:22 +0000
4
- Subject: [PATCH 04/18] target/i386: deprecate CPUs older than x86_64-v2 ABI
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Daniel P. Berrangé <berrange@redhat.com>
10
- RH-MergeRequest: 94: i386, aarch64, s390x: deprecate many named CPU models
11
- RH-Commit: [4/6] 71f6043f11b31ffa841a2e14d24972e571c18a9e (berrange/centos-src-qemu)
12
- RH-Bugzilla: 2060839
13
- RH-Acked-by: Thomas Huth <thuth@redhat.com>
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
16
-
17
- RHEL-9 is compiled with the x86_64-v2 ABI. We use this as a baseline to
18
- select which CPUs we want to support, such that there is at least one
19
- supported guest CPU that can be launched for every physical machine
20
- capable of running RHEL-9 KVM.
21
-
22
- Supported CPUs:
23
-
24
- * QEMU models
25
-
26
- base (QEMU internal)
27
- host (host passthrough)
28
- max (host passthrough for KVM,
29
- all emulated features for TCG)
30
-
31
- * Intel models
32
-
33
- Icelake-Server
34
- Icelake-Server-noTSX
35
- Cascadelake-Server (2019)
36
- Cascadelake-Server-noTSX (2019)
37
- Skylake-Server (2016)
38
- Skylake-Server-IBRS (2016)
39
- Skylake-Server-noTSX-IBRS (2016)
40
- Skylake-Client (2015)
41
- Skylake-Client-IBRS (2015)
42
- Skylake-Client-noTSX-IBRS (2015)
43
- Broadwell (2014)
44
- Broadwell-IBRS (2014)
45
- Broadwell-noTSX (2014)
46
- Broadwell-noTSX-IBRS (2014)
47
- Haswell (2013)
48
- Haswell-IBRS (2013)
49
- Haswell-noTSX (2013)
50
- Haswell-noTSX-IBRS (2013)
51
- IvyBridge (2012)
52
- IvyBridge-IBRS (2012)
53
- SandyBridge (2011)
54
- SandyBridge-IBRS (2011)
55
- Westmere (2010)
56
- Westmere-IBRS (2010)
57
- Nehalem (2008)
58
- Nehalem-IBRS (2008)
59
-
60
- Cooperlake (2020)
61
- Snowridge (2019)
62
- KnightsMill (2017)
63
- Denverton (2016)
64
-
65
- * AMD models
66
-
67
- EPYC-Milan (2021)
68
- EPYC-Rome (2019)
69
- EPYC (2017)
70
- EPYC-IBPB (2017)
71
- Opteron_G5 (2012)
72
- Opteron_G4 (2011)
73
-
74
- * Other
75
-
76
- Dhyana (2018)
77
-
78
- (I've omitted the many -vNNN versions for brevity)
79
-
80
- Deprecated CPUs:
81
-
82
- 486
83
- athlon
84
- Conroe
85
- core2duo
86
- coreduo
87
- Icelake-Client (already deprecated upstream)
88
- Icelake-Client-noTSX (already deprecated upstream)
89
- kvm32
90
- kvm64
91
- n270
92
- Opteron_G1
93
- Opteron_G2
94
- Opteron_G3
95
- Penryn
96
- pentium2
97
- pentium3
98
- pentium
99
- phenom
100
- qemu32
101
- qemu64
102
-
103
- The deprecated CPU models are subject to removal in a future
104
- major version of RHEL.
105
-
106
- Note: this has the effect of deprecating the default built-in CPU
107
- model 'qemu64'. Applications using QEMU are expected to make an
108
- explicit choice about which CPU model they want, since no builtin
109
- default can suit all purposes.
110
-
111
- https://bugzilla.redhat.com/show_bug.cgi?id=2060839
112
- Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
113
- ---
114
- target/i386/cpu.c | 21 +++++++++++++++++++++
115
- 1 file changed, 21 insertions(+)
116
-
117
- diff --git a/target/i386/cpu.c b/target/i386/cpu.c
118
- index cb6b5467d0..87cb641b5f 100644
119
- --- a/target/i386/cpu.c
120
- +++ b/target/i386/cpu.c
121
- @@ -1780,9 +1780,13 @@ static const CPUCaches epyc_milan_cache_info = {
122
- * PT in VMX operation
123
- */
124
-
125
- +#define RHEL_CPU_DEPRECATION \
126
- + "use at least 'Nehalem' / 'Opteron_G4', or 'host' / 'max'"
127
- +
128
- static const X86CPUDefinition builtin_x86_defs[] = {
129
- {
130
- .name = "qemu64",
131
- + .deprecation_note = RHEL_CPU_DEPRECATION,
132
- .level = 0xd,
133
- .vendor = CPUID_VENDOR_AMD,
134
- .family = 15,
135
- @@ -1803,6 +1807,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
136
- },
137
- {
138
- .name = "phenom",
139
- + .deprecation_note = RHEL_CPU_DEPRECATION,
140
- .level = 5,
141
- .vendor = CPUID_VENDOR_AMD,
142
- .family = 16,
143
- @@ -1835,6 +1840,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
144
- },
145
- {
146
- .name = "core2duo",
147
- + .deprecation_note = RHEL_CPU_DEPRECATION,
148
- .level = 10,
149
- .vendor = CPUID_VENDOR_INTEL,
150
- .family = 6,
151
- @@ -1877,6 +1883,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
152
- },
153
- {
154
- .name = "kvm64",
155
- + .deprecation_note = RHEL_CPU_DEPRECATION,
156
- .level = 0xd,
157
- .vendor = CPUID_VENDOR_INTEL,
158
- .family = 15,
159
- @@ -1918,6 +1925,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
160
- },
161
- {
162
- .name = "qemu32",
163
- + .deprecation_note = RHEL_CPU_DEPRECATION,
164
- .level = 4,
165
- .vendor = CPUID_VENDOR_INTEL,
166
- .family = 6,
167
- @@ -1932,6 +1940,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
168
- },
169
- {
170
- .name = "kvm32",
171
- + .deprecation_note = RHEL_CPU_DEPRECATION,
172
- .level = 5,
173
- .vendor = CPUID_VENDOR_INTEL,
174
- .family = 15,
175
- @@ -1962,6 +1971,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
176
- },
177
- {
178
- .name = "coreduo",
179
- + .deprecation_note = RHEL_CPU_DEPRECATION,
180
- .level = 10,
181
- .vendor = CPUID_VENDOR_INTEL,
182
- .family = 6,
183
- @@ -1995,6 +2005,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
184
- },
185
- {
186
- .name = "486",
187
- + .deprecation_note = RHEL_CPU_DEPRECATION,
188
- .level = 1,
189
- .vendor = CPUID_VENDOR_INTEL,
190
- .family = 4,
191
- @@ -2007,6 +2018,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
192
- },
193
- {
194
- .name = "pentium",
195
- + .deprecation_note = RHEL_CPU_DEPRECATION,
196
- .level = 1,
197
- .vendor = CPUID_VENDOR_INTEL,
198
- .family = 5,
199
- @@ -2019,6 +2031,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
200
- },
201
- {
202
- .name = "pentium2",
203
- + .deprecation_note = RHEL_CPU_DEPRECATION,
204
- .level = 2,
205
- .vendor = CPUID_VENDOR_INTEL,
206
- .family = 6,
207
- @@ -2031,6 +2044,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
208
- },
209
- {
210
- .name = "pentium3",
211
- + .deprecation_note = RHEL_CPU_DEPRECATION,
212
- .level = 3,
213
- .vendor = CPUID_VENDOR_INTEL,
214
- .family = 6,
215
- @@ -2043,6 +2057,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
216
- },
217
- {
218
- .name = "athlon",
219
- + .deprecation_note = RHEL_CPU_DEPRECATION,
220
- .level = 2,
221
- .vendor = CPUID_VENDOR_AMD,
222
- .family = 6,
223
- @@ -2058,6 +2073,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
224
- },
225
- {
226
- .name = "n270",
227
- + .deprecation_note = RHEL_CPU_DEPRECATION,
228
- .level = 10,
229
- .vendor = CPUID_VENDOR_INTEL,
230
- .family = 6,
231
- @@ -2083,6 +2099,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
232
- },
233
- {
234
- .name = "Conroe",
235
- + .deprecation_note = RHEL_CPU_DEPRECATION,
236
- .level = 10,
237
- .vendor = CPUID_VENDOR_INTEL,
238
- .family = 6,
239
- @@ -2123,6 +2140,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
240
- },
241
- {
242
- .name = "Penryn",
243
- + .deprecation_note = RHEL_CPU_DEPRECATION,
244
- .level = 10,
245
- .vendor = CPUID_VENDOR_INTEL,
246
- .family = 6,
247
- @@ -3832,6 +3850,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
248
- },
249
- {
250
- .name = "Opteron_G1",
251
- + .deprecation_note = RHEL_CPU_DEPRECATION,
252
- .level = 5,
253
- .vendor = CPUID_VENDOR_AMD,
254
- .family = 15,
255
- @@ -3852,6 +3871,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
256
- },
257
- {
258
- .name = "Opteron_G2",
259
- + .deprecation_note = RHEL_CPU_DEPRECATION,
260
- .level = 5,
261
- .vendor = CPUID_VENDOR_AMD,
262
- .family = 15,
263
- @@ -3874,6 +3894,7 @@ static const X86CPUDefinition builtin_x86_defs[] = {
264
- },
265
- {
266
- .name = "Opteron_G3",
267
- + .deprecation_note = RHEL_CPU_DEPRECATION,
268
- .level = 5,
269
- .vendor = CPUID_VENDOR_AMD,
270
- .family = 16,
271
- --
272
- 2.35.3
273
-
SOURCES/kvm-target-ppc-cpu-models-Fix-ppc_cpu_aliases-list-for-R.patch DELETED
@@ -1,48 +0,0 @@
1
- From 39642d0d37e2ef61ce7fde0bc284d37a365e4482 Mon Sep 17 00:00:00 2001
2
- From: Murilo Opsfelder Araujo <muriloo@linux.ibm.com>
3
- Date: Mon, 2 May 2022 17:59:11 -0300
4
- Subject: [PATCH 2/2] target/ppc/cpu-models: Fix ppc_cpu_aliases list for RHEL
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Murilo Opsfelder Araújo <muriloo@linux.ibm.com>
10
- RH-MergeRequest: 81: target/ppc/cpu-models: remove extraneous "#endif"
11
- RH-Commit: [1/1] 5fff003ad3deb84c6a8e69ab90552a31edb3b058 (mopsfelder/centos-stream-src-qemu-kvm)
12
- RH-Bugzilla: 2081022
13
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
14
- RH-Acked-by: Thomas Huth <thuth@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- The commit b9d28ecdedaf ("Enable/disable devices for RHEL") removed the
18
- "#if 0" from the beginning of the ppc_cpu_aliases list, which broke the
19
- build on ppc64le:
20
-
21
- ../target/ppc/cpu-models.c:904:2: error: #endif without #if
22
- #endif
23
- ^
24
- 1 error generated.
25
-
26
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2081022
27
-
28
- Fixes: b9d28ecdedaf (Enable/disable devices for RHEL)
29
- Signed-off-by: Murilo Opsfelder Araujo <muriloo@linux.ibm.com>
30
- ---
31
- target/ppc/cpu-models.c | 1 +
32
- 1 file changed, 1 insertion(+)
33
-
34
- diff --git a/target/ppc/cpu-models.c b/target/ppc/cpu-models.c
35
- index dd78883410..528467eac1 100644
36
- --- a/target/ppc/cpu-models.c
37
- +++ b/target/ppc/cpu-models.c
38
- @@ -746,6 +746,7 @@
39
- /* PowerPC CPU aliases */
40
-
41
- PowerPCCPUAlias ppc_cpu_aliases[] = {
42
- +#if 0 /* Disabled for Red Hat Enterprise Linux */
43
- { "405", "405d4" },
44
- { "405cr", "405crc" },
45
- { "405gp", "405gpd" },
46
- --
47
- 2.35.1
48
-
SOURCES/kvm-target-s390x-arch_dump-Fix-memory-corruption-in-s390.patch ADDED
@@ -0,0 +1,50 @@
1
+ From b330bf0a2ad5af73d3c62997f7f0fa5b61f1796b Mon Sep 17 00:00:00 2001
2
+ From: Thomas Huth <thuth@redhat.com>
3
+ Date: Tue, 14 Feb 2023 14:48:37 +0100
4
+ Subject: [PATCH 8/8] target/s390x/arch_dump: Fix memory corruption in
5
+ s390x_write_elf64_notes()
6
+ MIME-Version: 1.0
7
+ Content-Type: text/plain; charset=UTF-8
8
+ Content-Transfer-Encoding: 8bit
9
+
10
+ RH-Author: Thomas Huth <thuth@redhat.com>
11
+ RH-MergeRequest: 152: Fix memory corruption in s390x_write_elf64_notes()
12
+ RH-Bugzilla: 2168172
13
+ RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
14
+ RH-Acked-by: David Hildenbrand <david@redhat.com>
15
+ RH-Acked-by: Cédric Le Goater <clg@redhat.com>
16
+ RH-Commit: [1/1] 37a2c997b2c8b7524e0b6299891bf3ea7c9a46d0 (thuth/qemu-kvm-cs9)
17
+
18
+ Bugzilla: https://bugzilla.redhat.com/2168172
19
+ Upstream-Status: Posted (and reviewed, but not merged yet)
20
+
21
+ "note_size" can be smaller than sizeof(note), so unconditionally calling
22
+ memset(notep, 0, sizeof(note)) could cause a memory corruption here in
23
+ case notep has been allocated dynamically, thus let's use note_size as
24
+ length argument for memset() instead.
25
+
26
+ Fixes: 113d8f4e95 ("s390x: pv: Add dump support")
27
+ Message-Id: <20230214141056.680969-1-thuth@redhat.com>
28
+ Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
29
+ Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
30
+ Signed-off-by: Thomas Huth <thuth@redhat.com>
31
+ ---
32
+ target/s390x/arch_dump.c | 2 +-
33
+ 1 file changed, 1 insertion(+), 1 deletion(-)
34
+
35
+ diff --git a/target/s390x/arch_dump.c b/target/s390x/arch_dump.c
36
+ index a2329141e8..a7c44ba49d 100644
37
+ --- a/target/s390x/arch_dump.c
38
+ +++ b/target/s390x/arch_dump.c
39
+ @@ -248,7 +248,7 @@ static int s390x_write_elf64_notes(const char *note_name,
40
+ notep = g_malloc(note_size);
41
+ }
42
+
43
+ - memset(notep, 0, sizeof(note));
44
+ + memset(notep, 0, note_size);
45
+
46
+ /* Setup note header data */
47
+ notep->hdr.n_descsz = cpu_to_be32(content_size);
48
+ --
49
+ 2.31.1
50
+
SOURCES/kvm-target-s390x-deprecate-CPUs-older-than-z14.patch DELETED
@@ -1,194 +0,0 @@
1
- From 8459c305914e2a7a19dcd1662d54a89def7acfa6 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
3
- Date: Thu, 17 Mar 2022 17:59:22 +0000
4
- Subject: [PATCH 05/18] target/s390x: deprecate CPUs older than z14
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Daniel P. Berrangé <berrange@redhat.com>
10
- RH-MergeRequest: 94: i386, aarch64, s390x: deprecate many named CPU models
11
- RH-Commit: [5/6] 2da9e06cf452287673f94f880a7eb8b2b37b7278 (berrange/centos-src-qemu)
12
- RH-Bugzilla: 2060839
13
- RH-Acked-by: Thomas Huth <thuth@redhat.com>
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
16
-
17
- RHEL-9 is compiled with the z14 ABI. We use this as a baseline to
18
- select which CPUs we want to support, such that there is at least one
19
- supported guest CPU that can be launched for every physical
20
- machine capable of running RHEL-9 KVM.
21
-
22
- Supported CPUs:
23
-
24
- gen15a-base
25
- gen15a
26
- gen15b-base
27
- gen15b
28
- gen16a-base
29
- gen16a
30
- gen16b-base
31
- gen16b
32
- max
33
- qemu
34
- z14.2-base
35
- z14.2
36
- z14-base
37
- z14
38
- z14ZR1-base
39
- z14ZR1
40
-
41
- Deprecated CPUs:
42
-
43
- z10BC.2-base
44
- z10BC.2
45
- z10BC-base
46
- z10BC
47
- z10EC.2-base
48
- z10EC.2
49
- z10EC.3-base
50
- z10EC.3
51
- z10EC-base
52
- z10EC
53
- z114-base
54
- z114
55
- z13.2-base
56
- z13.2
57
- z13-base
58
- z13s-base
59
- z13s
60
- z13
61
- z196.2-base
62
- z196.2
63
- z196-base
64
- z196
65
- z800-base
66
- z800
67
- z890.2-base
68
- z890.2
69
- z890.3-base
70
- z890.3
71
- z890-base
72
- z890
73
- z900.2-base
74
- z900.2
75
- z900.3-base
76
- z900.3
77
- z900-base
78
- z900
79
- z990.2-base
80
- z990.2
81
- z990.3-base
82
- z990.3
83
- z990.4-base
84
- z990.4
85
- z990.5-base
86
- z990.5
87
- z990-base
88
- z990
89
- z9BC.2-base
90
- z9BC.2
91
- z9BC-base
92
- z9BC
93
- z9EC.2-base
94
- z9EC.2
95
- z9EC.3-base
96
- z9EC.3
97
- z9EC-base
98
- z9EC
99
- zBC12-base
100
- zBC12
101
- zEC12.2-base
102
- zEC12.2
103
- zEC12-base
104
- zEC12
105
-
106
- https://bugzilla.redhat.com/show_bug.cgi?id=2060839
107
- Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
108
- ---
109
- target/s390x/cpu_models.c | 11 +++++++++++
110
- target/s390x/cpu_models.h | 2 ++
111
- target/s390x/cpu_models_sysemu.c | 2 ++
112
- 3 files changed, 15 insertions(+)
113
-
114
- diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
115
- index 6d71428056..9b9fc41676 100644
116
- --- a/target/s390x/cpu_models.c
117
- +++ b/target/s390x/cpu_models.c
118
- @@ -45,6 +45,9 @@
119
- * of a following release have been a superset of the previous release. With
120
- * generation 15 one base feature and one optional feature have been deprecated.
121
- */
122
- +
123
- +#define RHEL_CPU_DEPRECATION "use at least 'z14', or 'host' / 'qemu' / 'max'"
124
- +
125
- static S390CPUDef s390_cpu_defs[] = {
126
- CPUDEF_INIT(0x2064, 7, 1, 38, 0x00000000U, "z900", "IBM zSeries 900 GA1"),
127
- CPUDEF_INIT(0x2064, 7, 2, 38, 0x00000000U, "z900.2", "IBM zSeries 900 GA2"),
128
- @@ -852,22 +855,30 @@ static void s390_host_cpu_model_class_init(ObjectClass *oc, void *data)
129
- static void s390_base_cpu_model_class_init(ObjectClass *oc, void *data)
130
- {
131
- S390CPUClass *xcc = S390_CPU_CLASS(oc);
132
- + CPUClass *cc = CPU_CLASS(oc);
133
-
134
- /* all base models are migration safe */
135
- xcc->cpu_def = (const S390CPUDef *) data;
136
- xcc->is_migration_safe = true;
137
- xcc->is_static = true;
138
- xcc->desc = xcc->cpu_def->desc;
139
- + if (xcc->cpu_def->gen < 14) {
140
- + cc->deprecation_note = RHEL_CPU_DEPRECATION;
141
- + }
142
- }
143
-
144
- static void s390_cpu_model_class_init(ObjectClass *oc, void *data)
145
- {
146
- S390CPUClass *xcc = S390_CPU_CLASS(oc);
147
- + CPUClass *cc = CPU_CLASS(oc);
148
-
149
- /* model that can change between QEMU versions */
150
- xcc->cpu_def = (const S390CPUDef *) data;
151
- xcc->is_migration_safe = true;
152
- xcc->desc = xcc->cpu_def->desc;
153
- + if (xcc->cpu_def->gen < 14) {
154
- + cc->deprecation_note = RHEL_CPU_DEPRECATION;
155
- + }
156
- }
157
-
158
- static void s390_qemu_cpu_model_class_init(ObjectClass *oc, void *data)
159
- diff --git a/target/s390x/cpu_models.h b/target/s390x/cpu_models.h
160
- index 74d1f87e4f..372160bcd7 100644
161
- --- a/target/s390x/cpu_models.h
162
- +++ b/target/s390x/cpu_models.h
163
- @@ -38,6 +38,8 @@ struct S390CPUDef {
164
- S390FeatBitmap full_feat;
165
- /* used to init full_feat from generated data */
166
- S390FeatInit full_init;
167
- + /* if deprecated, provides a suggestion */
168
- + const char *deprecation_note;
169
- };
170
-
171
- /* CPU model based on a CPU definition */
172
- diff --git a/target/s390x/cpu_models_sysemu.c b/target/s390x/cpu_models_sysemu.c
173
- index 6a04ccab1b..f3b7c304ec 100644
174
- --- a/target/s390x/cpu_models_sysemu.c
175
- +++ b/target/s390x/cpu_models_sysemu.c
176
- @@ -61,6 +61,7 @@ static void create_cpu_model_list(ObjectClass *klass, void *opaque)
177
- CpuDefinitionInfo *info;
178
- char *name = g_strdup(object_class_get_name(klass));
179
- S390CPUClass *scc = S390_CPU_CLASS(klass);
180
- + CPUClass *cc = CPU_CLASS(klass);
181
-
182
- /* strip off the -s390x-cpu */
183
- g_strrstr(name, "-" TYPE_S390_CPU)[0] = 0;
184
- @@ -70,6 +71,7 @@ static void create_cpu_model_list(ObjectClass *klass, void *opaque)
185
- info->migration_safe = scc->is_migration_safe;
186
- info->q_static = scc->is_static;
187
- info->q_typename = g_strdup(object_class_get_name(klass));
188
- + info->deprecated = !!cc->deprecation_note;
189
- /* check for unavailable features */
190
- if (cpu_list_data->model) {
191
- Object *obj;
192
- --
193
- 2.35.3
194
-
SOURCES/kvm-target-s390x-kvm-Honor-storage-keys-during-emulation.patch DELETED
@@ -1,103 +0,0 @@
1
- From 27c1d979a994f5afc59c3520af58d15aa5aae723 Mon Sep 17 00:00:00 2001
2
- From: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
3
- Date: Fri, 6 May 2022 17:39:56 +0200
4
- Subject: [PATCH 29/32] target/s390x: kvm: Honor storage keys during emulation
5
-
6
- RH-Author: Thomas Huth <thuth@redhat.com>
7
- RH-MergeRequest: 109: Honor storage keys during emulation of I/O instructions
8
- RH-Commit: [2/2] 346dee1e13bfe1c074e4c6a4417091711d852f9c (thuth/qemu-kvm-cs9)
9
- RH-Bugzilla: 2111994
10
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
11
- RH-Acked-by: David Hildenbrand <david@redhat.com>
12
- RH-Acked-by: Claudio Imbrenda <None>
13
-
14
- Storage key controlled protection is currently not honored when
15
- emulating instructions.
16
- If available, enable key protection for the MEM_OP ioctl, thereby
17
- enabling it for the s390_cpu_virt_mem_* functions, when using kvm.
18
- As a result, the emulation of the following instructions honors storage
19
- keys:
20
-
21
- * CLP
22
- The Synch I/O CLP command would need special handling in order
23
- to support storage keys, but is currently not supported.
24
- * CHSC
25
- Performing commands asynchronously would require special
26
- handling, but commands are currently always synchronous.
27
- * STSI
28
- * TSCH
29
- Must (and does) not change channel if terminated due to
30
- protection.
31
- * MSCH
32
- Suppressed on protection, works because fetching instruction.
33
- * SSCH
34
- Suppressed on protection, works because fetching instruction.
35
- * STSCH
36
- * STCRW
37
- Suppressed on protection, this works because no partial store is
38
- possible, because the operand cannot span multiple pages.
39
- * PCISTB
40
- * MPCIFC
41
- * STPCIFC
42
-
43
- Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
44
- Message-Id: <20220506153956.2217601-3-scgl@linux.ibm.com>
45
- Signed-off-by: Thomas Huth <thuth@redhat.com>
46
-
47
- (cherry picked from commit 54354861d21b69ec0781f43e67b8d4f6edad7e3f)
48
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2111994
49
- Signed-off-by: Thomas Huth <thuth@redhat.com>
50
- ---
51
- target/s390x/kvm/kvm.c | 9 +++++++++
52
- 1 file changed, 9 insertions(+)
53
-
54
- diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c
55
- index 74f089d87f..1f1d1a33b8 100644
56
- --- a/target/s390x/kvm/kvm.c
57
- +++ b/target/s390x/kvm/kvm.c
58
- @@ -152,12 +152,15 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
59
- static int cap_sync_regs;
60
- static int cap_async_pf;
61
- static int cap_mem_op;
62
- +static int cap_mem_op_extension;
63
- static int cap_s390_irq;
64
- static int cap_ri;
65
- static int cap_hpage_1m;
66
- static int cap_vcpu_resets;
67
- static int cap_protected;
68
-
69
- +static bool mem_op_storage_key_support;
70
- +
71
- static int active_cmma;
72
-
73
- static int kvm_s390_query_mem_limit(uint64_t *memory_limit)
74
- @@ -355,6 +358,8 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
75
- cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
76
- cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF);
77
- cap_mem_op = kvm_check_extension(s, KVM_CAP_S390_MEM_OP);
78
- + cap_mem_op_extension = kvm_check_extension(s, KVM_CAP_S390_MEM_OP_EXTENSION);
79
- + mem_op_storage_key_support = cap_mem_op_extension > 0;
80
- cap_s390_irq = kvm_check_extension(s, KVM_CAP_S390_INJECT_IRQ);
81
- cap_vcpu_resets = kvm_check_extension(s, KVM_CAP_S390_VCPU_RESETS);
82
- cap_protected = kvm_check_extension(s, KVM_CAP_S390_PROTECTED);
83
- @@ -843,6 +848,7 @@ int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar, void *hostbuf,
84
- : KVM_S390_MEMOP_LOGICAL_READ,
85
- .buf = (uint64_t)hostbuf,
86
- .ar = ar,
87
- + .key = (cpu->env.psw.mask & PSW_MASK_KEY) >> PSW_SHIFT_KEY,
88
- };
89
- int ret;
90
-
91
- @@ -852,6 +858,9 @@ int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar, void *hostbuf,
92
- if (!hostbuf) {
93
- mem_op.flags |= KVM_S390_MEMOP_F_CHECK_ONLY;
94
- }
95
- + if (mem_op_storage_key_support) {
96
- + mem_op.flags |= KVM_S390_MEMOP_F_SKEY_PROTECTION;
97
- + }
98
-
99
- ret = kvm_vcpu_ioctl(CPU(cpu), KVM_S390_MEM_OP, &mem_op);
100
- if (ret < 0) {
101
- --
102
- 2.31.1
103
-
SOURCES/kvm-test-bdrv-drain-Don-t-yield-in-.bdrv_co_drained_begi.patch ADDED
@@ -0,0 +1,153 @@
1
+ From 093c4a6834f3ec5a05390a3630ae4edec80885b8 Mon Sep 17 00:00:00 2001
2
+ From: Kevin Wolf <kwolf@redhat.com>
3
+ Date: Fri, 18 Nov 2022 18:40:57 +0100
4
+ Subject: [PATCH 15/31] test-bdrv-drain: Don't yield in
5
+ .bdrv_co_drained_begin/end()
6
+
7
+ RH-Author: Stefano Garzarella <sgarzare@redhat.com>
8
+ RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
9
+ RH-Bugzilla: 2155112
10
+ RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
11
+ RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
12
+ RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
13
+ RH-Commit: [3/16] 5282d3e13cb85dfb480edb11b7eb2769248465df (sgarzarella/qemu-kvm-c-9-s)
14
+
15
+ We want to change .bdrv_co_drained_begin/end() back to be non-coroutine
16
+ callbacks, so in preparation, avoid yielding in their implementation.
17
+
18
+ This does almost the same as the existing logic in bdrv_drain_invoke(),
19
+ by creating and entering coroutines internally. However, since the test
20
+ case is by far the heaviest user of coroutine code in drain callbacks,
21
+ it is preferable to have the complexity in the test case rather than the
22
+ drain core, which is already complicated enough without this.
23
+
24
+ The behaviour for bdrv_drain_begin() is unchanged because we increase
25
+ bs->in_flight and this is still polled. However, bdrv_drain_end()
26
+ doesn't wait for the spawned coroutine to complete any more. This is
27
+ fine, we don't rely on bdrv_drain_end() restarting all operations
28
+ immediately before the next aio_poll().
29
+
30
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
31
+ Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
32
+ Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
33
+ Reviewed-by: Hanna Reitz <hreitz@redhat.com>
34
+ Message-Id: <20221118174110.55183-3-kwolf@redhat.com>
35
+ Signed-off-by: Kevin Wolf <kwolf@redhat.com>
36
+ (cherry picked from commit 7bce1c299834557bffd92294608ea528648cfe75)
37
+ Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
38
+ ---
39
+ tests/unit/test-bdrv-drain.c | 64 ++++++++++++++++++++++++++----------
40
+ 1 file changed, 46 insertions(+), 18 deletions(-)
41
+
42
+ diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c
43
+ index 09dc4a4891..24f34e24ad 100644
44
+ --- a/tests/unit/test-bdrv-drain.c
45
+ +++ b/tests/unit/test-bdrv-drain.c
46
+ @@ -38,12 +38,22 @@ typedef struct BDRVTestState {
47
+ bool sleep_in_drain_begin;
48
+ } BDRVTestState;
49
+
50
+ +static void coroutine_fn sleep_in_drain_begin(void *opaque)
51
+ +{
52
+ + BlockDriverState *bs = opaque;
53
+ +
54
+ + qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, 100000);
55
+ + bdrv_dec_in_flight(bs);
56
+ +}
57
+ +
58
+ static void coroutine_fn bdrv_test_co_drain_begin(BlockDriverState *bs)
59
+ {
60
+ BDRVTestState *s = bs->opaque;
61
+ s->drain_count++;
62
+ if (s->sleep_in_drain_begin) {
63
+ - qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, 100000);
64
+ + Coroutine *co = qemu_coroutine_create(sleep_in_drain_begin, bs);
65
+ + bdrv_inc_in_flight(bs);
66
+ + aio_co_enter(bdrv_get_aio_context(bs), co);
67
+ }
68
+ }
69
+
70
+ @@ -1916,6 +1926,21 @@ static int coroutine_fn bdrv_replace_test_co_preadv(BlockDriverState *bs,
71
+ return 0;
72
+ }
73
+
74
+ +static void coroutine_fn bdrv_replace_test_drain_co(void *opaque)
75
+ +{
76
+ + BlockDriverState *bs = opaque;
77
+ + BDRVReplaceTestState *s = bs->opaque;
78
+ +
79
+ + /* Keep waking io_co up until it is done */
80
+ + while (s->io_co) {
81
+ + aio_co_wake(s->io_co);
82
+ + s->io_co = NULL;
83
+ + qemu_coroutine_yield();
84
+ + }
85
+ + s->drain_co = NULL;
86
+ + bdrv_dec_in_flight(bs);
87
+ +}
88
+ +
89
+ /**
90
+ * If .drain_count is 0, wake up .io_co if there is one; and set
91
+ * .was_drained.
92
+ @@ -1926,20 +1951,27 @@ static void coroutine_fn bdrv_replace_test_co_drain_begin(BlockDriverState *bs)
93
+ BDRVReplaceTestState *s = bs->opaque;
94
+
95
+ if (!s->drain_count) {
96
+ - /* Keep waking io_co up until it is done */
97
+ - s->drain_co = qemu_coroutine_self();
98
+ - while (s->io_co) {
99
+ - aio_co_wake(s->io_co);
100
+ - s->io_co = NULL;
101
+ - qemu_coroutine_yield();
102
+ - }
103
+ - s->drain_co = NULL;
104
+ -
105
+ + s->drain_co = qemu_coroutine_create(bdrv_replace_test_drain_co, bs);
106
+ + bdrv_inc_in_flight(bs);
107
+ + aio_co_enter(bdrv_get_aio_context(bs), s->drain_co);
108
+ s->was_drained = true;
109
+ }
110
+ s->drain_count++;
111
+ }
112
+
113
+ +static void coroutine_fn bdrv_replace_test_read_entry(void *opaque)
114
+ +{
115
+ + BlockDriverState *bs = opaque;
116
+ + char data;
117
+ + QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, &data, 1);
118
+ + int ret;
119
+ +
120
+ + /* Queue a read request post-drain */
121
+ + ret = bdrv_replace_test_co_preadv(bs, 0, 1, &qiov, 0);
122
+ + g_assert(ret >= 0);
123
+ + bdrv_dec_in_flight(bs);
124
+ +}
125
+ +
126
+ /**
127
+ * Reduce .drain_count, set .was_undrained once it reaches 0.
128
+ * If .drain_count reaches 0 and the node has a backing file, issue a
129
+ @@ -1951,17 +1983,13 @@ static void coroutine_fn bdrv_replace_test_co_drain_end(BlockDriverState *bs)
130
+
131
+ g_assert(s->drain_count > 0);
132
+ if (!--s->drain_count) {
133
+ - int ret;
134
+ -
135
+ s->was_undrained = true;
136
+
137
+ if (bs->backing) {
138
+ - char data;
139
+ - QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, &data, 1);
140
+ -
141
+ - /* Queue a read request post-drain */
142
+ - ret = bdrv_replace_test_co_preadv(bs, 0, 1, &qiov, 0);
143
+ - g_assert(ret >= 0);
144
+ + Coroutine *co = qemu_coroutine_create(bdrv_replace_test_read_entry,
145
+ + bs);
146
+ + bdrv_inc_in_flight(bs);
147
+ + aio_co_enter(bdrv_get_aio_context(bs), co);
148
+ }
149
+ }
150
+ }
151
+ --
152
+ 2.31.1
153
+
SOURCES/kvm-tests-avocado-update-aarch64_virt-test-to-exercise-c.patch DELETED
@@ -1,157 +0,0 @@
1
- From f52aa60217634c96fef59ce76b803a94610bf5c8 Mon Sep 17 00:00:00 2001
2
- From: Andrew Jones <drjones@redhat.com>
3
- Date: Wed, 15 Jun 2022 15:28:27 +0200
4
- Subject: [PATCH 01/18] tests/avocado: update aarch64_virt test to exercise
5
- -cpu max
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Daniel P. Berrangé <berrange@redhat.com>
11
- RH-MergeRequest: 94: i386, aarch64, s390x: deprecate many named CPU models
12
- RH-Commit: [1/6] df6839e567180a4c32afd98852f68b2279e00f7c (berrange/centos-src-qemu)
13
- RH-Bugzilla: 2060839
14
- RH-Acked-by: Thomas Huth <thuth@redhat.com>
15
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
16
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
17
-
18
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2066824
19
-
20
- commit 11593544df6f8febb3ce87015c22b429bf43c4c7
21
- Author: Alex Bennée <alex.bennee@linaro.org>
22
- Date: Tue Apr 19 10:09:56 2022 +0100
23
-
24
- tests/avocado: update aarch64_virt test to exercise -cpu max
25
-
26
- The Fedora 29 kernel is quite old and importantly fails when running
27
- in LPA2 scenarios. As it's not really exercising much of the CPU space
28
- replace it with a custom 5.16.12 kernel with all the architecture
29
- options turned on. There is a minimal buildroot initramfs included in
30
- the kernel which has a few tools for stress testing the memory
31
- subsystem. The userspace also targets the Neoverse N1 processor so
32
- would fail with a v8.0 cpu like cortex-a53.
33
-
34
- While we are at it move the test into its own file so it can have an
35
- assigned maintainer.
36
-
37
- Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
38
- Acked-by: Richard Henderson <richard.henderson@linaro.org>
39
- Tested-by: Richard Henderson <richard.henderson@linaro.org>
40
- Message-Id: <20220419091020.3008144-2-alex.bennee@linaro.org>
41
-
42
- Signed-off-by: Andrew Jones <drjones@redhat.com>
43
- ---
44
- MAINTAINERS | 1 +
45
- tests/avocado/boot_linux_console.py | 25 -------------
46
- tests/avocado/machine_aarch64_virt.py | 51 +++++++++++++++++++++++++++
47
- 3 files changed, 52 insertions(+), 25 deletions(-)
48
- create mode 100644 tests/avocado/machine_aarch64_virt.py
49
-
50
- diff --git a/MAINTAINERS b/MAINTAINERS
51
- index 2fe20a49ab..bfe8806f60 100644
52
- --- a/MAINTAINERS
53
- +++ b/MAINTAINERS
54
- @@ -942,6 +942,7 @@ S: Maintained
55
- F: hw/arm/virt*
56
- F: include/hw/arm/virt.h
57
- F: docs/system/arm/virt.rst
58
- +F: tests/avocado/machine_aarch64_virt.py
59
-
60
- Xilinx Zynq
61
- M: Edgar E. Iglesias <edgar.iglesias@gmail.com>
62
- diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py
63
- index b40a3abc81..45a2ceda22 100644
64
- --- a/tests/avocado/boot_linux_console.py
65
- +++ b/tests/avocado/boot_linux_console.py
66
- @@ -325,31 +325,6 @@ def test_mips_malta32el_nanomips_64k_dbg(self):
67
- kernel_hash = '18d1c68f2e23429e266ca39ba5349ccd0aeb7180'
68
- self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)
69
-
70
- - def test_aarch64_virt(self):
71
- - """
72
- - :avocado: tags=arch:aarch64
73
- - :avocado: tags=machine:virt
74
- - :avocado: tags=accel:tcg
75
- - :avocado: tags=cpu:cortex-a53
76
- - """
77
- - kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
78
- - '/linux/releases/29/Everything/aarch64/os/images/pxeboot'
79
- - '/vmlinuz')
80
- - kernel_hash = '8c73e469fc6ea06a58dc83a628fc695b693b8493'
81
- - kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
82
- -
83
- - self.vm.set_console()
84
- - kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
85
- - 'console=ttyAMA0')
86
- - self.require_accelerator("tcg")
87
- - self.vm.add_args('-cpu', 'cortex-a53',
88
- - '-accel', 'tcg',
89
- - '-kernel', kernel_path,
90
- - '-append', kernel_command_line)
91
- - self.vm.launch()
92
- - console_pattern = 'Kernel command line: %s' % kernel_command_line
93
- - self.wait_for_console_pattern(console_pattern)
94
- -
95
- def test_aarch64_xlnx_versal_virt(self):
96
- """
97
- :avocado: tags=arch:aarch64
98
- diff --git a/tests/avocado/machine_aarch64_virt.py b/tests/avocado/machine_aarch64_virt.py
99
- new file mode 100644
100
- index 0000000000..21848cba70
101
- --- /dev/null
102
- +++ b/tests/avocado/machine_aarch64_virt.py
103
- @@ -0,0 +1,51 @@
104
- +# Functional test that boots a Linux kernel and checks the console
105
- +#
106
- +# Copyright (c) 2022 Linaro Ltd.
107
- +#
108
- +# Author:
109
- +# Alex Bennée <alex.bennee@linaro.org>
110
- +#
111
- +# SPDX-License-Identifier: GPL-2.0-or-later
112
- +
113
- +import time
114
- +
115
- +from avocado_qemu import QemuSystemTest
116
- +from avocado_qemu import wait_for_console_pattern
117
- +from avocado_qemu import exec_command
118
- +
119
- +class Aarch64VirtMachine(QemuSystemTest):
120
- + KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
121
- +
122
- + def wait_for_console_pattern(self, success_message, vm=None):
123
- + wait_for_console_pattern(self, success_message,
124
- + failure_message='Kernel panic - not syncing',
125
- + vm=vm)
126
- +
127
- + def test_aarch64_virt(self):
128
- + """
129
- + :avocado: tags=arch:aarch64
130
- + :avocado: tags=machine:virt
131
- + :avocado: tags=accel:tcg
132
- + :avocado: tags=cpu:max
133
- + """
134
- + kernel_url = ('https://fileserver.linaro.org/s/'
135
- + 'z6B2ARM7DQT3HWN/download')
136
- +
137
- + kernel_hash = 'ed11daab50c151dde0e1e9c9cb8b2d9bd3215347'
138
- + kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
139
- +
140
- + self.vm.set_console()
141
- + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
142
- + 'console=ttyAMA0')
143
- + self.require_accelerator("tcg")
144
- + self.vm.add_args('-cpu', 'max,pauth-impdef=on',
145
- + '-accel', 'tcg',
146
- + '-kernel', kernel_path,
147
- + '-append', kernel_command_line)
148
- + self.vm.launch()
149
- + self.wait_for_console_pattern('Welcome to Buildroot')
150
- + time.sleep(0.1)
151
- + exec_command(self, 'root')
152
- + time.sleep(0.1)
153
- + exec_command(self, 'cat /proc/self/maps')
154
- + time.sleep(0.1)
155
- --
156
- 2.35.3
157
-
SOURCES/kvm-tests-qtest-fdc-test-Add-a-regression-test-for-CVE-2.patch DELETED
@@ -1,119 +0,0 @@
1
- From cea7b15c613a11ea15a1458d6990be7044df6643 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@redhat.com>
3
- Date: Thu, 18 Nov 2021 12:57:33 +0100
4
- Subject: [PATCH 17/17] tests/qtest/fdc-test: Add a regression test for
5
- CVE-2021-3507
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Jon Maloy <jmaloy@redhat.com>
11
- RH-MergeRequest: 107: hw/block/fdc: Prevent end-of-track overrun (CVE-2021-3507)
12
- RH-Commit: [2/2] 067c052df790959c28c1fcc16547676d36523bd9 (mrezanin/centos-src-qemu-kvm)
13
- RH-Bugzilla: 1951522
14
- RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
15
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
16
-
17
- Add the reproducer from https://gitlab.com/qemu-project/qemu/-/issues/339
18
-
19
- Without the previous commit, when running 'make check-qtest-i386'
20
- with QEMU configured with '--enable-sanitizers' we get:
21
-
22
- ==4028352==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x619000062a00 at pc 0x5626d03c491a bp 0x7ffdb4199410 sp 0x7ffdb4198bc0
23
- READ of size 786432 at 0x619000062a00 thread T0
24
- #0 0x5626d03c4919 in __asan_memcpy (qemu-system-i386+0x1e65919)
25
- #1 0x5626d1c023cc in flatview_write_continue softmmu/physmem.c:2787:13
26
- #2 0x5626d1bf0c0f in flatview_write softmmu/physmem.c:2822:14
27
- #3 0x5626d1bf0798 in address_space_write softmmu/physmem.c:2914:18
28
- #4 0x5626d1bf0f37 in address_space_rw softmmu/physmem.c:2924:16
29
- #5 0x5626d1bf14c8 in cpu_physical_memory_rw softmmu/physmem.c:2933:5
30
- #6 0x5626d0bd5649 in cpu_physical_memory_write include/exec/cpu-common.h:82:5
31
- #7 0x5626d0bd0a07 in i8257_dma_write_memory hw/dma/i8257.c:452:9
32
- #8 0x5626d09f825d in fdctrl_transfer_handler hw/block/fdc.c:1616:13
33
- #9 0x5626d0a048b4 in fdctrl_start_transfer hw/block/fdc.c:1539:13
34
- #10 0x5626d09f4c3e in fdctrl_write_data hw/block/fdc.c:2266:13
35
- #11 0x5626d09f22f7 in fdctrl_write hw/block/fdc.c:829:9
36
- #12 0x5626d1c20bc5 in portio_write softmmu/ioport.c:207:17
37
-
38
- 0x619000062a00 is located 0 bytes to the right of 512-byte region [0x619000062800,0x619000062a00)
39
- allocated by thread T0 here:
40
- #0 0x5626d03c66ec in posix_memalign (qemu-system-i386+0x1e676ec)
41
- #1 0x5626d2b988d4 in qemu_try_memalign util/oslib-posix.c:210:11
42
- #2 0x5626d2b98b0c in qemu_memalign util/oslib-posix.c:226:27
43
- #3 0x5626d09fbaf0 in fdctrl_realize_common hw/block/fdc.c:2341:20
44
- #4 0x5626d0a150ed in isabus_fdc_realize hw/block/fdc-isa.c:113:5
45
- #5 0x5626d2367935 in device_set_realized hw/core/qdev.c:531:13
46
-
47
- SUMMARY: AddressSanitizer: heap-buffer-overflow (qemu-system-i386+0x1e65919) in __asan_memcpy
48
- Shadow bytes around the buggy address:
49
- 0x0c32800044f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
50
- 0x0c3280004500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
51
- 0x0c3280004510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
52
- 0x0c3280004520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
53
- 0x0c3280004530: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
54
- =>0x0c3280004540:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
55
- 0x0c3280004550: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
56
- 0x0c3280004560: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
57
- 0x0c3280004570: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
58
- 0x0c3280004580: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
59
- 0x0c3280004590: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
60
- Shadow byte legend (one shadow byte represents 8 application bytes):
61
- Addressable: 00
62
- Heap left redzone: fa
63
- Freed heap region: fd
64
- ==4028352==ABORTING
65
-
66
- [ kwolf: Added snapshot=on to prevent write file lock failure ]
67
-
68
- Reported-by: Alexander Bulekov <alxndr@bu.edu>
69
- Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
70
- Reviewed-by: Alexander Bulekov <alxndr@bu.edu>
71
- Signed-off-by: Kevin Wolf <kwolf@redhat.com>
72
- (cherry picked from commit 46609b90d9e3a6304def11038a76b58ff43f77bc)
73
- Signed-off-by: Jon Maloy <jmaloy@redhat.com>
74
- ---
75
- tests/qtest/fdc-test.c | 21 +++++++++++++++++++++
76
- 1 file changed, 21 insertions(+)
77
-
78
- diff --git a/tests/qtest/fdc-test.c b/tests/qtest/fdc-test.c
79
- index b0d40012e6..1d4f852128 100644
80
- --- a/tests/qtest/fdc-test.c
81
- +++ b/tests/qtest/fdc-test.c
82
- @@ -583,6 +583,26 @@ static void test_cve_2021_20196(void)
83
- qtest_quit(s);
84
- }
85
-
86
- +static void test_cve_2021_3507(void)
87
- +{
88
- + QTestState *s;
89
- +
90
- + s = qtest_initf("-nographic -m 32M -nodefaults "
91
- + "-drive file=%s,format=raw,if=floppy,snapshot=on",
92
- + test_image);
93
- + qtest_outl(s, 0x9, 0x0a0206);
94
- + qtest_outw(s, 0x3f4, 0x1600);
95
- + qtest_outw(s, 0x3f4, 0x0000);
96
- + qtest_outw(s, 0x3f4, 0x0000);
97
- + qtest_outw(s, 0x3f4, 0x0000);
98
- + qtest_outw(s, 0x3f4, 0x0200);
99
- + qtest_outw(s, 0x3f4, 0x0200);
100
- + qtest_outw(s, 0x3f4, 0x0000);
101
- + qtest_outw(s, 0x3f4, 0x0000);
102
- + qtest_outw(s, 0x3f4, 0x0000);
103
- + qtest_quit(s);
104
- +}
105
- +
106
- int main(int argc, char **argv)
107
- {
108
- int fd;
109
- @@ -614,6 +634,7 @@ int main(int argc, char **argv)
110
- qtest_add_func("/fdc/read_no_dma_19", test_read_no_dma_19);
111
- qtest_add_func("/fdc/fuzz-registers", fuzz_registers);
112
- qtest_add_func("/fdc/fuzz/cve_2021_20196", test_cve_2021_20196);
113
- + qtest_add_func("/fdc/fuzz/cve_2021_3507", test_cve_2021_3507);
114
-
115
- ret = g_test_run();
116
-
117
- --
118
- 2.31.1
119
-
SOURCES/kvm-tests-qtest-netdev-test-stream-and-dgram-backends.patch ADDED
@@ -0,0 +1,505 @@
1
+ From 39d5761fe1f546e764dedf2ea32c55d8f5222696 Mon Sep 17 00:00:00 2001
2
+ From: Laurent Vivier <lvivier@redhat.com>
3
+ Date: Wed, 18 Jan 2023 13:04:05 +0100
4
+ Subject: [PATCH 1/8] tests/qtest: netdev: test stream and dgram backends
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Laurent Vivier <lvivier@redhat.com>
10
+ RH-MergeRequest: 148: net: stream: add a new option to automatically reconnect
11
+ RH-Bugzilla: 2169232
12
+ RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
13
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
14
+ RH-Acked-by: MST <mst@redhat.com>
15
+ RH-Acked-by: David Gibson (Red Hat) <dgibson@redhat.com>
16
+ RH-Commit: [1/2] 75c71b47eea072e14651a96612d402b50d2b8f1e (lvivier/qemu-kvm-centos)
17
+
18
+ Signed-off-by: Laurent Vivier <lvivier@redhat.com>
19
+ Acked-by: Michael S. Tsirkin <mst@redhat.com>
20
+ Message-Id: <20230118120405.1876329-1-lvivier@redhat.com>
21
+ Signed-off-by: Thomas Huth <thuth@redhat.com>
22
+ (cherry picked from commit c95031a19f0d7f418a597243f6f84b031a858997)
23
+ ---
24
+ tests/qtest/meson.build | 2 +
25
+ tests/qtest/netdev-socket.c | 448 ++++++++++++++++++++++++++++++++++++
26
+ 2 files changed, 450 insertions(+)
27
+ create mode 100644 tests/qtest/netdev-socket.c
28
+
29
+ diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
30
+ index 9df3f9f8b9..2e7c6fe5e3 100644
31
+ --- a/tests/qtest/meson.build
32
+ +++ b/tests/qtest/meson.build
33
+ @@ -27,6 +27,7 @@ qtests_generic = [
34
+ 'test-hmp',
35
+ 'qos-test',
36
+ 'readconfig-test',
37
+ + 'netdev-socket',
38
+ ]
39
+ if config_host.has_key('CONFIG_MODULES')
40
+ qtests_generic += [ 'modules-test' ]
41
+ @@ -299,6 +300,7 @@ qtests = {
42
+ 'tpm-tis-device-swtpm-test': [io, tpmemu_files, 'tpm-tis-util.c'],
43
+ 'tpm-tis-device-test': [io, tpmemu_files, 'tpm-tis-util.c'],
44
+ 'vmgenid-test': files('boot-sector.c', 'acpi-utils.c'),
45
+ + 'netdev-socket': files('netdev-socket.c', '../unit/socket-helpers.c'),
46
+ }
47
+
48
+ gvnc = dependency('gvnc-1.0', required: false)
49
+ diff --git a/tests/qtest/netdev-socket.c b/tests/qtest/netdev-socket.c
50
+ new file mode 100644
51
+ index 0000000000..6ba256e173
52
+ --- /dev/null
53
+ +++ b/tests/qtest/netdev-socket.c
54
+ @@ -0,0 +1,448 @@
55
+ +/*
56
+ + * QTest testcase for netdev stream and dgram
57
+ + *
58
+ + * Copyright (c) 2022 Red Hat, Inc.
59
+ + *
60
+ + * SPDX-License-Identifier: GPL-2.0-or-later
61
+ + */
62
+ +
63
+ +#include "qemu/osdep.h"
64
+ +#include "qemu/sockets.h"
65
+ +#include <glib/gstdio.h>
66
+ +#include "../unit/socket-helpers.h"
67
+ +#include "libqtest.h"
68
+ +
69
+ +#define CONNECTION_TIMEOUT 5
70
+ +
71
+ +#define EXPECT_STATE(q, e, t) \
72
+ +do { \
73
+ + char *resp = NULL; \
74
+ + g_test_timer_start(); \
75
+ + do { \
76
+ + g_free(resp); \
77
+ + resp = qtest_hmp(q, "info network"); \
78
+ + if (t) { \
79
+ + strrchr(resp, t)[0] = 0; \
80
+ + } \
81
+ + if (g_str_equal(resp, e)) { \
82
+ + break; \
83
+ + } \
84
+ + } while (g_test_timer_elapsed() < CONNECTION_TIMEOUT); \
85
+ + g_assert_cmpstr(resp, ==, e); \
86
+ + g_free(resp); \
87
+ +} while (0)
88
+ +
89
+ +static gchar *tmpdir;
90
+ +
91
+ +static int inet_get_free_port_socket_ipv4(int sock)
92
+ +{
93
+ + struct sockaddr_in addr;
94
+ + socklen_t len;
95
+ +
96
+ + memset(&addr, 0, sizeof(addr));
97
+ + addr.sin_family = AF_INET;
98
+ + addr.sin_addr.s_addr = INADDR_ANY;
99
+ + addr.sin_port = 0;
100
+ + if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
101
+ + return -1;
102
+ + }
103
+ +
104
+ + len = sizeof(addr);
105
+ + if (getsockname(sock, (struct sockaddr *)&addr, &len) < 0) {
106
+ + return -1;
107
+ + }
108
+ +
109
+ + return ntohs(addr.sin_port);
110
+ +}
111
+ +
112
+ +static int inet_get_free_port_socket_ipv6(int sock)
113
+ +{
114
+ + struct sockaddr_in6 addr;
115
+ + socklen_t len;
116
+ +
117
+ + memset(&addr, 0, sizeof(addr));
118
+ + addr.sin6_family = AF_INET6;
119
+ + addr.sin6_addr = in6addr_any;
120
+ + addr.sin6_port = 0;
121
+ + if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
122
+ + return -1;
123
+ + }
124
+ +
125
+ + len = sizeof(addr);
126
+ + if (getsockname(sock, (struct sockaddr *)&addr, &len) < 0) {
127
+ + return -1;
128
+ + }
129
+ +
130
+ + return ntohs(addr.sin6_port);
131
+ +}
132
+ +
133
+ +static int inet_get_free_port_multiple(int nb, int *port, bool ipv6)
134
+ +{
135
+ + int sock[nb];
136
+ + int i;
137
+ +
138
+ + for (i = 0; i < nb; i++) {
139
+ + sock[i] = socket(ipv6 ? AF_INET6 : AF_INET, SOCK_STREAM, 0);
140
+ + if (sock[i] < 0) {
141
+ + break;
142
+ + }
143
+ + port[i] = ipv6 ? inet_get_free_port_socket_ipv6(sock[i]) :
144
+ + inet_get_free_port_socket_ipv4(sock[i]);
145
+ + if (port[i] == -1) {
146
+ + break;
147
+ + }
148
+ + }
149
+ +
150
+ + nb = i;
151
+ + for (i = 0; i < nb; i++) {
152
+ + closesocket(sock[i]);
153
+ + }
154
+ +
155
+ + return nb;
156
+ +}
157
+ +
158
+ +static int inet_get_free_port(bool ipv6)
159
+ +{
160
+ + int nb, port;
161
+ +
162
+ + nb = inet_get_free_port_multiple(1, &port, ipv6);
163
+ + g_assert_cmpint(nb, ==, 1);
164
+ +
165
+ + return port;
166
+ +}
167
+ +
168
+ +static void test_stream_inet_ipv4(void)
169
+ +{
170
+ + QTestState *qts0, *qts1;
171
+ + char *expect;
172
+ + int port;
173
+ +
174
+ + port = inet_get_free_port(false);
175
+ + qts0 = qtest_initf("-nodefaults -M none "
176
+ + "-netdev stream,id=st0,server=true,addr.type=inet,"
177
+ + "addr.ipv4=on,addr.ipv6=off,"
178
+ + "addr.host=127.0.0.1,addr.port=%d", port);
179
+ +
180
+ + EXPECT_STATE(qts0, "st0: index=0,type=stream,\r\n", 0);
181
+ +
182
+ + qts1 = qtest_initf("-nodefaults -M none "
183
+ + "-netdev stream,server=false,id=st0,addr.type=inet,"
184
+ + "addr.ipv4=on,addr.ipv6=off,"
185
+ + "addr.host=127.0.0.1,addr.port=%d", port);
186
+ +
187
+ + expect = g_strdup_printf("st0: index=0,type=stream,tcp:127.0.0.1:%d\r\n",
188
+ + port);
189
+ + EXPECT_STATE(qts1, expect, 0);
190
+ + g_free(expect);
191
+ +
192
+ + /* the port is unknown, check only the address */
193
+ + EXPECT_STATE(qts0, "st0: index=0,type=stream,tcp:127.0.0.1", ':');
194
+ +
195
+ + qtest_quit(qts1);
196
+ + qtest_quit(qts0);
197
+ +}
198
+ +
199
+ +static void test_stream_inet_ipv6(void)
200
+ +{
201
+ + QTestState *qts0, *qts1;
202
+ + char *expect;
203
+ + int port;
204
+ +
205
+ + port = inet_get_free_port(true);
206
+ + qts0 = qtest_initf("-nodefaults -M none "
207
+ + "-netdev stream,id=st0,server=true,addr.type=inet,"
208
+ + "addr.ipv4=off,addr.ipv6=on,"
209
+ + "addr.host=::1,addr.port=%d", port);
210
+ +
211
+ + EXPECT_STATE(qts0, "st0: index=0,type=stream,\r\n", 0);
212
+ +
213
+ + qts1 = qtest_initf("-nodefaults -M none "
214
+ + "-netdev stream,server=false,id=st0,addr.type=inet,"
215
+ + "addr.ipv4=off,addr.ipv6=on,"
216
+ + "addr.host=::1,addr.port=%d", port);
217
+ +
218
+ + expect = g_strdup_printf("st0: index=0,type=stream,tcp:::1:%d\r\n",
219
+ + port);
220
+ + EXPECT_STATE(qts1, expect, 0);
221
+ + g_free(expect);
222
+ +
223
+ + /* the port is unknown, check only the address */
224
+ + EXPECT_STATE(qts0, "st0: index=0,type=stream,tcp:::1", ':');
225
+ +
226
+ + qtest_quit(qts1);
227
+ + qtest_quit(qts0);
228
+ +}
229
+ +
230
+ +static void test_stream_unix(void)
231
+ +{
232
+ + QTestState *qts0, *qts1;
233
+ + char *expect;
234
+ + gchar *path;
235
+ +
236
+ + path = g_strconcat(tmpdir, "/stream_unix", NULL);
237
+ +
238
+ + qts0 = qtest_initf("-nodefaults -M none "
239
+ + "-netdev stream,id=st0,server=true,"
240
+ + "addr.type=unix,addr.path=%s,",
241
+ + path);
242
+ +
243
+ + EXPECT_STATE(qts0, "st0: index=0,type=stream,\r\n", 0);
244
+ +
245
+ + qts1 = qtest_initf("-nodefaults -M none "
246
+ + "-netdev stream,id=st0,server=false,"
247
+ + "addr.type=unix,addr.path=%s",
248
+ + path);
249
+ +
250
+ + expect = g_strdup_printf("st0: index=0,type=stream,unix:%s\r\n", path);
251
+ + EXPECT_STATE(qts1, expect, 0);
252
+ + EXPECT_STATE(qts0, expect, 0);
253
+ + g_free(expect);
254
+ + g_free(path);
255
+ +
256
+ + qtest_quit(qts1);
257
+ + qtest_quit(qts0);
258
+ +}
259
+ +
260
+ +#ifdef CONFIG_LINUX
261
+ +static void test_stream_unix_abstract(void)
262
+ +{
263
+ + QTestState *qts0, *qts1;
264
+ + char *expect;
265
+ + gchar *path;
266
+ +
267
+ + path = g_strconcat(tmpdir, "/stream_unix_abstract", NULL);
268
+ +
269
+ + qts0 = qtest_initf("-nodefaults -M none "
270
+ + "-netdev stream,id=st0,server=true,"
271
+ + "addr.type=unix,addr.path=%s,"
272
+ + "addr.abstract=on",
273
+ + path);
274
+ +
275
+ + EXPECT_STATE(qts0, "st0: index=0,type=stream,\r\n", 0);
276
+ +
277
+ + qts1 = qtest_initf("-nodefaults -M none "
278
+ + "-netdev stream,id=st0,server=false,"
279
+ + "addr.type=unix,addr.path=%s,addr.abstract=on",
280
+ + path);
281
+ +
282
+ + expect = g_strdup_printf("st0: index=0,type=stream,unix:%s\r\n", path);
283
+ + EXPECT_STATE(qts1, expect, 0);
284
+ + EXPECT_STATE(qts0, expect, 0);
285
+ + g_free(expect);
286
+ + g_free(path);
287
+ +
288
+ + qtest_quit(qts1);
289
+ + qtest_quit(qts0);
290
+ +}
291
+ +#endif
292
+ +
293
+ +#ifndef _WIN32
294
+ +static void test_stream_fd(void)
295
+ +{
296
+ + QTestState *qts0, *qts1;
297
+ + int sock[2];
298
+ + int ret;
299
+ +
300
+ + ret = socketpair(AF_LOCAL, SOCK_STREAM, 0, sock);
301
+ + g_assert_true(ret == 0);
302
+ +
303
+ + qts0 = qtest_initf("-nodefaults -M none "
304
+ + "-netdev stream,id=st0,addr.type=fd,addr.str=%d",
305
+ + sock[0]);
306
+ +
307
+ + EXPECT_STATE(qts0, "st0: index=0,type=stream,unix:\r\n", 0);
308
+ +
309
+ + qts1 = qtest_initf("-nodefaults -M none "
310
+ + "-netdev stream,id=st0,addr.type=fd,addr.str=%d",
311
+ + sock[1]);
312
+ +
313
+ + EXPECT_STATE(qts1, "st0: index=0,type=stream,unix:\r\n", 0);
314
+ + EXPECT_STATE(qts0, "st0: index=0,type=stream,unix:\r\n", 0);
315
+ +
316
+ + qtest_quit(qts1);
317
+ + qtest_quit(qts0);
318
+ +
319
+ + closesocket(sock[0]);
320
+ + closesocket(sock[1]);
321
+ +}
322
+ +#endif
323
+ +
324
+ +static void test_dgram_inet(void)
325
+ +{
326
+ + QTestState *qts0, *qts1;
327
+ + char *expect;
328
+ + int port[2];
329
+ + int nb;
330
+ +
331
+ + nb = inet_get_free_port_multiple(2, port, false);
332
+ + g_assert_cmpint(nb, ==, 2);
333
+ +
334
+ + qts0 = qtest_initf("-nodefaults -M none "
335
+ + "-netdev dgram,id=st0,"
336
+ + "local.type=inet,local.host=127.0.0.1,local.port=%d,"
337
+ + "remote.type=inet,remote.host=127.0.0.1,remote.port=%d",
338
+ + port[0], port[1]);
339
+ +
340
+ + expect = g_strdup_printf("st0: index=0,type=dgram,"
341
+ + "udp=127.0.0.1:%d/127.0.0.1:%d\r\n",
342
+ + port[0], port[1]);
343
+ + EXPECT_STATE(qts0, expect, 0);
344
+ + g_free(expect);
345
+ +
346
+ + qts1 = qtest_initf("-nodefaults -M none "
347
+ + "-netdev dgram,id=st0,"
348
+ + "local.type=inet,local.host=127.0.0.1,local.port=%d,"
349
+ + "remote.type=inet,remote.host=127.0.0.1,remote.port=%d",
350
+ + port[1], port[0]);
351
+ +
352
+ + expect = g_strdup_printf("st0: index=0,type=dgram,"
353
+ + "udp=127.0.0.1:%d/127.0.0.1:%d\r\n",
354
+ + port[1], port[0]);
355
+ + EXPECT_STATE(qts1, expect, 0);
356
+ + g_free(expect);
357
+ +
358
+ + qtest_quit(qts1);
359
+ + qtest_quit(qts0);
360
+ +}
361
+ +
362
+ +#ifndef _WIN32
363
+ +static void test_dgram_mcast(void)
364
+ +{
365
+ + QTestState *qts;
366
+ +
367
+ + qts = qtest_initf("-nodefaults -M none "
368
+ + "-netdev dgram,id=st0,"
369
+ + "remote.type=inet,remote.host=230.0.0.1,remote.port=1234");
370
+ +
371
+ + EXPECT_STATE(qts, "st0: index=0,type=dgram,mcast=230.0.0.1:1234\r\n", 0);
372
+ +
373
+ + qtest_quit(qts);
374
+ +}
375
+ +
376
+ +static void test_dgram_unix(void)
377
+ +{
378
+ + QTestState *qts0, *qts1;
379
+ + char *expect;
380
+ + gchar *path0, *path1;
381
+ +
382
+ + path0 = g_strconcat(tmpdir, "/dgram_unix0", NULL);
383
+ + path1 = g_strconcat(tmpdir, "/dgram_unix1", NULL);
384
+ +
385
+ + qts0 = qtest_initf("-nodefaults -M none "
386
+ + "-netdev dgram,id=st0,local.type=unix,local.path=%s,"
387
+ + "remote.type=unix,remote.path=%s",
388
+ + path0, path1);
389
+ +
390
+ + expect = g_strdup_printf("st0: index=0,type=dgram,udp=%s:%s\r\n",
391
+ + path0, path1);
392
+ + EXPECT_STATE(qts0, expect, 0);
393
+ + g_free(expect);
394
+ +
395
+ + qts1 = qtest_initf("-nodefaults -M none "
396
+ + "-netdev dgram,id=st0,local.type=unix,local.path=%s,"
397
+ + "remote.type=unix,remote.path=%s",
398
+ + path1, path0);
399
+ +
400
+ +
401
+ + expect = g_strdup_printf("st0: index=0,type=dgram,udp=%s:%s\r\n",
402
+ + path1, path0);
403
+ + EXPECT_STATE(qts1, expect, 0);
404
+ + g_free(expect);
405
+ +
406
+ + unlink(path0);
407
+ + g_free(path0);
408
+ + unlink(path1);
409
+ + g_free(path1);
410
+ +
411
+ + qtest_quit(qts1);
412
+ + qtest_quit(qts0);
413
+ +}
414
+ +
415
+ +static void test_dgram_fd(void)
416
+ +{
417
+ + QTestState *qts0, *qts1;
418
+ + char *expect;
419
+ + int ret;
420
+ + int sv[2];
421
+ +
422
+ + ret = socketpair(PF_UNIX, SOCK_DGRAM, 0, sv);
423
+ + g_assert_cmpint(ret, !=, -1);
424
+ +
425
+ + qts0 = qtest_initf("-nodefaults -M none "
426
+ + "-netdev dgram,id=st0,local.type=fd,local.str=%d",
427
+ + sv[0]);
428
+ +
429
+ + expect = g_strdup_printf("st0: index=0,type=dgram,fd=%d unix\r\n", sv[0]);
430
+ + EXPECT_STATE(qts0, expect, 0);
431
+ + g_free(expect);
432
+ +
433
+ + qts1 = qtest_initf("-nodefaults -M none "
434
+ + "-netdev dgram,id=st0,local.type=fd,local.str=%d",
435
+ + sv[1]);
436
+ +
437
+ +
438
+ + expect = g_strdup_printf("st0: index=0,type=dgram,fd=%d unix\r\n", sv[1]);
439
+ + EXPECT_STATE(qts1, expect, 0);
440
+ + g_free(expect);
441
+ +
442
+ + qtest_quit(qts1);
443
+ + qtest_quit(qts0);
444
+ +
445
+ + closesocket(sv[0]);
446
+ + closesocket(sv[1]);
447
+ +}
448
+ +#endif
449
+ +
450
+ +int main(int argc, char **argv)
451
+ +{
452
+ + int ret;
453
+ + bool has_ipv4, has_ipv6, has_afunix;
454
+ + g_autoptr(GError) err = NULL;
455
+ +
456
+ + socket_init();
457
+ + g_test_init(&argc, &argv, NULL);
458
+ +
459
+ + if (socket_check_protocol_support(&has_ipv4, &has_ipv6) < 0) {
460
+ + g_error("socket_check_protocol_support() failed\n");
461
+ + }
462
+ +
463
+ + tmpdir = g_dir_make_tmp("netdev-socket.XXXXXX", &err);
464
+ + if (tmpdir == NULL) {
465
+ + g_error("Can't create temporary directory in %s: %s",
466
+ + g_get_tmp_dir(), err->message);
467
+ + }
468
+ +
469
+ + if (has_ipv4) {
470
+ + qtest_add_func("/netdev/stream/inet/ipv4", test_stream_inet_ipv4);
471
+ + qtest_add_func("/netdev/dgram/inet", test_dgram_inet);
472
+ +#ifndef _WIN32
473
+ + qtest_add_func("/netdev/dgram/mcast", test_dgram_mcast);
474
+ +#endif
475
+ + }
476
+ + if (has_ipv6) {
477
+ + qtest_add_func("/netdev/stream/inet/ipv6", test_stream_inet_ipv6);
478
+ + }
479
+ +
480
+ + socket_check_afunix_support(&has_afunix);
481
+ + if (has_afunix) {
482
+ +#ifndef _WIN32
483
+ + qtest_add_func("/netdev/dgram/unix", test_dgram_unix);
484
+ +#endif
485
+ + qtest_add_func("/netdev/stream/unix", test_stream_unix);
486
+ +#ifdef CONFIG_LINUX
487
+ + qtest_add_func("/netdev/stream/unix/abstract",
488
+ + test_stream_unix_abstract);
489
+ +#endif
490
+ +#ifndef _WIN32
491
+ + qtest_add_func("/netdev/stream/fd", test_stream_fd);
492
+ + qtest_add_func("/netdev/dgram/fd", test_dgram_fd);
493
+ +#endif
494
+ + }
495
+ +
496
+ + ret = g_test_run();
497
+ +
498
+ + g_rmdir(tmpdir);
499
+ + g_free(tmpdir);
500
+ +
501
+ + return ret;
502
+ +}
503
+ --
504
+ 2.31.1
505
+
SOURCES/kvm-util-event-loop-base-Introduce-options-to-set-the-th.patch DELETED
@@ -1,385 +0,0 @@
1
- From 7a6fa42d4a4263c94b9bf18290f9e7680ea9e7f4 Mon Sep 17 00:00:00 2001
2
- From: Nicolas Saenz Julienne <nsaenzju@redhat.com>
3
- Date: Mon, 25 Apr 2022 09:57:23 +0200
4
- Subject: [PATCH 03/16] util/event-loop-base: Introduce options to set the
5
- thread pool size
6
-
7
- RH-Author: Nicolas Saenz Julienne <nsaenzju@redhat.com>
8
- RH-MergeRequest: 93: util/thread-pool: Expose minimum and maximum size
9
- RH-Commit: [3/3] af78a88ff3c69701cbb5f9e980c3d6ebbd13ff98
10
- RH-Bugzilla: 2031024
11
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
13
- RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
14
-
15
- The thread pool regulates itself: when idle, it kills threads until
16
- empty, when in demand, it creates new threads until full. This behaviour
17
- doesn't play well with latency sensitive workloads where the price of
18
- creating a new thread is too high. For example, when paired with qemu's
19
- '-mlock', or using safety features like SafeStack, creating a new thread
20
- has been measured take multiple milliseconds.
21
-
22
- In order to mitigate this let's introduce a new 'EventLoopBase'
23
- property to set the thread pool size. The threads will be created during
24
- the pool's initialization or upon updating the property's value, remain
25
- available during its lifetime regardless of demand, and destroyed upon
26
- freeing it. A properly characterized workload will then be able to
27
- configure the pool to avoid any latency spikes.
28
-
29
- Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
30
- Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
31
- Acked-by: Markus Armbruster <armbru@redhat.com>
32
- Message-id: 20220425075723.20019-4-nsaenzju@redhat.com
33
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
34
- (cherry picked from commit 71ad4713cc1d7fca24388b828ef31ae6cb38a31c)
35
- ---
36
- event-loop-base.c | 23 +++++++++++++
37
- include/block/aio.h | 10 ++++++
38
- include/block/thread-pool.h | 3 ++
39
- include/sysemu/event-loop-base.h | 4 +++
40
- iothread.c | 3 ++
41
- qapi/qom.json | 10 +++++-
42
- util/aio-posix.c | 1 +
43
- util/async.c | 20 ++++++++++++
44
- util/main-loop.c | 9 ++++++
45
- util/thread-pool.c | 55 +++++++++++++++++++++++++++++---
46
- 10 files changed, 133 insertions(+), 5 deletions(-)
47
-
48
- diff --git a/event-loop-base.c b/event-loop-base.c
49
- index e7f99a6ec8..d5be4dc6fc 100644
50
- --- a/event-loop-base.c
51
- +++ b/event-loop-base.c
52
- @@ -14,6 +14,7 @@
53
- #include "qemu/osdep.h"
54
- #include "qom/object_interfaces.h"
55
- #include "qapi/error.h"
56
- +#include "block/thread-pool.h"
57
- #include "sysemu/event-loop-base.h"
58
-
59
- typedef struct {
60
- @@ -21,9 +22,22 @@ typedef struct {
61
- ptrdiff_t offset; /* field's byte offset in EventLoopBase struct */
62
- } EventLoopBaseParamInfo;
63
-
64
- +static void event_loop_base_instance_init(Object *obj)
65
- +{
66
- + EventLoopBase *base = EVENT_LOOP_BASE(obj);
67
- +
68
- + base->thread_pool_max = THREAD_POOL_MAX_THREADS_DEFAULT;
69
- +}
70
- +
71
- static EventLoopBaseParamInfo aio_max_batch_info = {
72
- "aio-max-batch", offsetof(EventLoopBase, aio_max_batch),
73
- };
74
- +static EventLoopBaseParamInfo thread_pool_min_info = {
75
- + "thread-pool-min", offsetof(EventLoopBase, thread_pool_min),
76
- +};
77
- +static EventLoopBaseParamInfo thread_pool_max_info = {
78
- + "thread-pool-max", offsetof(EventLoopBase, thread_pool_max),
79
- +};
80
-
81
- static void event_loop_base_get_param(Object *obj, Visitor *v,
82
- const char *name, void *opaque, Error **errp)
83
- @@ -95,12 +109,21 @@ static void event_loop_base_class_init(ObjectClass *klass, void *class_data)
84
- event_loop_base_get_param,
85
- event_loop_base_set_param,
86
- NULL, &aio_max_batch_info);
87
- + object_class_property_add(klass, "thread-pool-min", "int",
88
- + event_loop_base_get_param,
89
- + event_loop_base_set_param,
90
- + NULL, &thread_pool_min_info);
91
- + object_class_property_add(klass, "thread-pool-max", "int",
92
- + event_loop_base_get_param,
93
- + event_loop_base_set_param,
94
- + NULL, &thread_pool_max_info);
95
- }
96
-
97
- static const TypeInfo event_loop_base_info = {
98
- .name = TYPE_EVENT_LOOP_BASE,
99
- .parent = TYPE_OBJECT,
100
- .instance_size = sizeof(EventLoopBase),
101
- + .instance_init = event_loop_base_instance_init,
102
- .class_size = sizeof(EventLoopBaseClass),
103
- .class_init = event_loop_base_class_init,
104
- .abstract = true,
105
- diff --git a/include/block/aio.h b/include/block/aio.h
106
- index 5634173b12..d128558f1d 100644
107
- --- a/include/block/aio.h
108
- +++ b/include/block/aio.h
109
- @@ -192,6 +192,8 @@ struct AioContext {
110
- QSLIST_HEAD(, Coroutine) scheduled_coroutines;
111
- QEMUBH *co_schedule_bh;
112
-
113
- + int thread_pool_min;
114
- + int thread_pool_max;
115
- /* Thread pool for performing work and receiving completion callbacks.
116
- * Has its own locking.
117
- */
118
- @@ -769,4 +771,12 @@ void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns,
119
- void aio_context_set_aio_params(AioContext *ctx, int64_t max_batch,
120
- Error **errp);
121
-
122
- +/**
123
- + * aio_context_set_thread_pool_params:
124
- + * @ctx: the aio context
125
- + * @min: min number of threads to have readily available in the thread pool
126
- + * @min: max number of threads the thread pool can contain
127
- + */
128
- +void aio_context_set_thread_pool_params(AioContext *ctx, int64_t min,
129
- + int64_t max, Error **errp);
130
- #endif
131
- diff --git a/include/block/thread-pool.h b/include/block/thread-pool.h
132
- index 7dd7d730a0..2020bcc92d 100644
133
- --- a/include/block/thread-pool.h
134
- +++ b/include/block/thread-pool.h
135
- @@ -20,6 +20,8 @@
136
-
137
- #include "block/block.h"
138
-
139
- +#define THREAD_POOL_MAX_THREADS_DEFAULT 64
140
- +
141
- typedef int ThreadPoolFunc(void *opaque);
142
-
143
- typedef struct ThreadPool ThreadPool;
144
- @@ -33,5 +35,6 @@ BlockAIOCB *thread_pool_submit_aio(ThreadPool *pool,
145
- int coroutine_fn thread_pool_submit_co(ThreadPool *pool,
146
- ThreadPoolFunc *func, void *arg);
147
- void thread_pool_submit(ThreadPool *pool, ThreadPoolFunc *func, void *arg);
148
- +void thread_pool_update_params(ThreadPool *pool, struct AioContext *ctx);
149
-
150
- #endif
151
- diff --git a/include/sysemu/event-loop-base.h b/include/sysemu/event-loop-base.h
152
- index fced4c9fea..2748bf6ae1 100644
153
- --- a/include/sysemu/event-loop-base.h
154
- +++ b/include/sysemu/event-loop-base.h
155
- @@ -33,5 +33,9 @@ struct EventLoopBase {
156
-
157
- /* AioContext AIO engine parameters */
158
- int64_t aio_max_batch;
159
- +
160
- + /* AioContext thread pool parameters */
161
- + int64_t thread_pool_min;
162
- + int64_t thread_pool_max;
163
- };
164
- #endif
165
- diff --git a/iothread.c b/iothread.c
166
- index 8fa2f3bfb8..529194a566 100644
167
- --- a/iothread.c
168
- +++ b/iothread.c
169
- @@ -174,6 +174,9 @@ static void iothread_set_aio_context_params(EventLoopBase *base, Error **errp)
170
- aio_context_set_aio_params(iothread->ctx,
171
- iothread->parent_obj.aio_max_batch,
172
- errp);
173
- +
174
- + aio_context_set_thread_pool_params(iothread->ctx, base->thread_pool_min,
175
- + base->thread_pool_max, errp);
176
- }
177
-
178
-
179
- diff --git a/qapi/qom.json b/qapi/qom.json
180
- index 7d4a2ac1b9..6a653c6636 100644
181
- --- a/qapi/qom.json
182
- +++ b/qapi/qom.json
183
- @@ -508,10 +508,18 @@
184
- # 0 means that the engine will use its default.
185
- # (default: 0)
186
- #
187
- +# @thread-pool-min: minimum number of threads reserved in the thread pool
188
- +# (default:0)
189
- +#
190
- +# @thread-pool-max: maximum number of threads the thread pool can contain
191
- +# (default:64)
192
- +#
193
- # Since: 7.1
194
- ##
195
- { 'struct': 'EventLoopBaseProperties',
196
- - 'data': { '*aio-max-batch': 'int' } }
197
- + 'data': { '*aio-max-batch': 'int',
198
- + '*thread-pool-min': 'int',
199
- + '*thread-pool-max': 'int' } }
200
-
201
- ##
202
- # @IothreadProperties:
203
- diff --git a/util/aio-posix.c b/util/aio-posix.c
204
- index be0182a3c6..731f3826c0 100644
205
- --- a/util/aio-posix.c
206
- +++ b/util/aio-posix.c
207
- @@ -15,6 +15,7 @@
208
-
209
- #include "qemu/osdep.h"
210
- #include "block/block.h"
211
- +#include "block/thread-pool.h"
212
- #include "qemu/main-loop.h"
213
- #include "qemu/rcu.h"
214
- #include "qemu/rcu_queue.h"
215
- diff --git a/util/async.c b/util/async.c
216
- index 2ea1172f3e..554ba70cca 100644
217
- --- a/util/async.c
218
- +++ b/util/async.c
219
- @@ -563,6 +563,9 @@ AioContext *aio_context_new(Error **errp)
220
-
221
- ctx->aio_max_batch = 0;
222
-
223
- + ctx->thread_pool_min = 0;
224
- + ctx->thread_pool_max = THREAD_POOL_MAX_THREADS_DEFAULT;
225
- +
226
- return ctx;
227
- fail:
228
- g_source_destroy(&ctx->source);
229
- @@ -696,3 +699,20 @@ void qemu_set_current_aio_context(AioContext *ctx)
230
- assert(!get_my_aiocontext());
231
- set_my_aiocontext(ctx);
232
- }
233
- +
234
- +void aio_context_set_thread_pool_params(AioContext *ctx, int64_t min,
235
- + int64_t max, Error **errp)
236
- +{
237
- +
238
- + if (min > max || !max || min > INT_MAX || max > INT_MAX) {
239
- + error_setg(errp, "bad thread-pool-min/thread-pool-max values");
240
- + return;
241
- + }
242
- +
243
- + ctx->thread_pool_min = min;
244
- + ctx->thread_pool_max = max;
245
- +
246
- + if (ctx->thread_pool) {
247
- + thread_pool_update_params(ctx->thread_pool, ctx);
248
- + }
249
- +}
250
- diff --git a/util/main-loop.c b/util/main-loop.c
251
- index 5b13f456fa..a0f48186ab 100644
252
- --- a/util/main-loop.c
253
- +++ b/util/main-loop.c
254
- @@ -30,6 +30,7 @@
255
- #include "sysemu/replay.h"
256
- #include "qemu/main-loop.h"
257
- #include "block/aio.h"
258
- +#include "block/thread-pool.h"
259
- #include "qemu/error-report.h"
260
- #include "qemu/queue.h"
261
- #include "qemu/compiler.h"
262
- @@ -187,12 +188,20 @@ int qemu_init_main_loop(Error **errp)
263
-
264
- static void main_loop_update_params(EventLoopBase *base, Error **errp)
265
- {
266
- + ERRP_GUARD();
267
- +
268
- if (!qemu_aio_context) {
269
- error_setg(errp, "qemu aio context not ready");
270
- return;
271
- }
272
-
273
- aio_context_set_aio_params(qemu_aio_context, base->aio_max_batch, errp);
274
- + if (*errp) {
275
- + return;
276
- + }
277
- +
278
- + aio_context_set_thread_pool_params(qemu_aio_context, base->thread_pool_min,
279
- + base->thread_pool_max, errp);
280
- }
281
-
282
- MainLoop *mloop;
283
- diff --git a/util/thread-pool.c b/util/thread-pool.c
284
- index d763cea505..196835b4d3 100644
285
- --- a/util/thread-pool.c
286
- +++ b/util/thread-pool.c
287
- @@ -58,7 +58,6 @@ struct ThreadPool {
288
- QemuMutex lock;
289
- QemuCond worker_stopped;
290
- QemuSemaphore sem;
291
- - int max_threads;
292
- QEMUBH *new_thread_bh;
293
-
294
- /* The following variables are only accessed from one AioContext. */
295
- @@ -71,8 +70,27 @@ struct ThreadPool {
296
- int new_threads; /* backlog of threads we need to create */
297
- int pending_threads; /* threads created but not running yet */
298
- bool stopping;
299
- + int min_threads;
300
- + int max_threads;
301
- };
302
-
303
- +static inline bool back_to_sleep(ThreadPool *pool, int ret)
304
- +{
305
- + /*
306
- + * The semaphore timed out, we should exit the loop except when:
307
- + * - There is work to do, we raced with the signal.
308
- + * - The max threads threshold just changed, we raced with the signal.
309
- + * - The thread pool forces a minimum number of readily available threads.
310
- + */
311
- + if (ret == -1 && (!QTAILQ_EMPTY(&pool->request_list) ||
312
- + pool->cur_threads > pool->max_threads ||
313
- + pool->cur_threads <= pool->min_threads)) {
314
- + return true;
315
- + }
316
- +
317
- + return false;
318
- +}
319
- +
320
- static void *worker_thread(void *opaque)
321
- {
322
- ThreadPool *pool = opaque;
323
- @@ -91,8 +109,9 @@ static void *worker_thread(void *opaque)
324
- ret = qemu_sem_timedwait(&pool->sem, 10000);
325
- qemu_mutex_lock(&pool->lock);
326
- pool->idle_threads--;
327
- - } while (ret == -1 && !QTAILQ_EMPTY(&pool->request_list));
328
- - if (ret == -1 || pool->stopping) {
329
- + } while (back_to_sleep(pool, ret));
330
- + if (ret == -1 || pool->stopping ||
331
- + pool->cur_threads > pool->max_threads) {
332
- break;
333
- }
334
-
335
- @@ -294,6 +313,33 @@ void thread_pool_submit(ThreadPool *pool, ThreadPoolFunc *func, void *arg)
336
- thread_pool_submit_aio(pool, func, arg, NULL, NULL);
337
- }
338
-
339
- +void thread_pool_update_params(ThreadPool *pool, AioContext *ctx)
340
- +{
341
- + qemu_mutex_lock(&pool->lock);
342
- +
343
- + pool->min_threads = ctx->thread_pool_min;
344
- + pool->max_threads = ctx->thread_pool_max;
345
- +
346
- + /*
347
- + * We either have to:
348
- + * - Increase the number available of threads until over the min_threads
349
- + * threshold.
350
- + * - Decrease the number of available threads until under the max_threads
351
- + * threshold.
352
- + * - Do nothing. The current number of threads fall in between the min and
353
- + * max thresholds. We'll let the pool manage itself.
354
- + */
355
- + for (int i = pool->cur_threads; i < pool->min_threads; i++) {
356
- + spawn_thread(pool);
357
- + }
358
- +
359
- + for (int i = pool->cur_threads; i > pool->max_threads; i--) {
360
- + qemu_sem_post(&pool->sem);
361
- + }
362
- +
363
- + qemu_mutex_unlock(&pool->lock);
364
- +}
365
- +
366
- static void thread_pool_init_one(ThreadPool *pool, AioContext *ctx)
367
- {
368
- if (!ctx) {
369
- @@ -306,11 +352,12 @@ static void thread_pool_init_one(ThreadPool *pool, AioContext *ctx)
370
- qemu_mutex_init(&pool->lock);
371
- qemu_cond_init(&pool->worker_stopped);
372
- qemu_sem_init(&pool->sem, 0);
373
- - pool->max_threads = 64;
374
- pool->new_thread_bh = aio_bh_new(ctx, spawn_thread_bh_fn, pool);
375
-
376
- QLIST_INIT(&pool->head);
377
- QTAILQ_INIT(&pool->request_list);
378
- +
379
- + thread_pool_update_params(pool, ctx);
380
- }
381
-
382
- ThreadPool *thread_pool_new(AioContext *ctx)
383
- --
384
- 2.31.1
385
-
SOURCES/kvm-util-main-loop-Introduce-the-main-loop-into-QOM.patch DELETED
@@ -1,233 +0,0 @@
1
- From b4969662de01848f887a3918e97e516efc213f71 Mon Sep 17 00:00:00 2001
2
- From: Nicolas Saenz Julienne <nsaenzju@redhat.com>
3
- Date: Mon, 25 Apr 2022 09:57:22 +0200
4
- Subject: [PATCH 02/16] util/main-loop: Introduce the main loop into QOM
5
-
6
- RH-Author: Nicolas Saenz Julienne <nsaenzju@redhat.com>
7
- RH-MergeRequest: 93: util/thread-pool: Expose minimum and maximum size
8
- RH-Commit: [2/3] a481b77e25ad50d13dcbe26b36c551b18c89bddd
9
- RH-Bugzilla: 2031024
10
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
12
- RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
13
-
14
- 'event-loop-base' provides basic property handling for all 'AioContext'
15
- based event loops. So let's define a new 'MainLoopClass' that inherits
16
- from it. This will permit tweaking the main loop's properties through
17
- qapi as well as through the command line using the '-object' keyword[1].
18
- Only one instance of 'MainLoopClass' might be created at any time.
19
-
20
- 'EventLoopBaseClass' learns a new callback, 'can_be_deleted()' so as to
21
- mark 'MainLoop' as non-deletable.
22
-
23
- [1] For example:
24
- -object main-loop,id=main-loop,aio-max-batch=<value>
25
-
26
- Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
27
- Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
28
- Acked-by: Markus Armbruster <armbru@redhat.com>
29
- Message-id: 20220425075723.20019-3-nsaenzju@redhat.com
30
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
31
- (cherry picked from commit 70ac26b9e5ca8374bb3ef3f30b871726673c9f27)
32
- ---
33
- event-loop-base.c | 13 ++++++++
34
- include/qemu/main-loop.h | 10 ++++++
35
- include/sysemu/event-loop-base.h | 1 +
36
- meson.build | 3 +-
37
- qapi/qom.json | 13 ++++++++
38
- util/main-loop.c | 56 ++++++++++++++++++++++++++++++++
39
- 6 files changed, 95 insertions(+), 1 deletion(-)
40
-
41
- diff --git a/event-loop-base.c b/event-loop-base.c
42
- index a924c73a7c..e7f99a6ec8 100644
43
- --- a/event-loop-base.c
44
- +++ b/event-loop-base.c
45
- @@ -73,10 +73,23 @@ static void event_loop_base_complete(UserCreatable *uc, Error **errp)
46
- }
47
- }
48
-
49
- +static bool event_loop_base_can_be_deleted(UserCreatable *uc)
50
- +{
51
- + EventLoopBaseClass *bc = EVENT_LOOP_BASE_GET_CLASS(uc);
52
- + EventLoopBase *backend = EVENT_LOOP_BASE(uc);
53
- +
54
- + if (bc->can_be_deleted) {
55
- + return bc->can_be_deleted(backend);
56
- + }
57
- +
58
- + return true;
59
- +}
60
- +
61
- static void event_loop_base_class_init(ObjectClass *klass, void *class_data)
62
- {
63
- UserCreatableClass *ucc = USER_CREATABLE_CLASS(klass);
64
- ucc->complete = event_loop_base_complete;
65
- + ucc->can_be_deleted = event_loop_base_can_be_deleted;
66
-
67
- object_class_property_add(klass, "aio-max-batch", "int",
68
- event_loop_base_get_param,
69
- diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h
70
- index d3750c8e76..20c9387654 100644
71
- --- a/include/qemu/main-loop.h
72
- +++ b/include/qemu/main-loop.h
73
- @@ -26,9 +26,19 @@
74
- #define QEMU_MAIN_LOOP_H
75
-
76
- #include "block/aio.h"
77
- +#include "qom/object.h"
78
- +#include "sysemu/event-loop-base.h"
79
-
80
- #define SIG_IPI SIGUSR1
81
-
82
- +#define TYPE_MAIN_LOOP "main-loop"
83
- +OBJECT_DECLARE_TYPE(MainLoop, MainLoopClass, MAIN_LOOP)
84
- +
85
- +struct MainLoop {
86
- + EventLoopBase parent_obj;
87
- +};
88
- +typedef struct MainLoop MainLoop;
89
- +
90
- /**
91
- * qemu_init_main_loop: Set up the process so that it can run the main loop.
92
- *
93
- diff --git a/include/sysemu/event-loop-base.h b/include/sysemu/event-loop-base.h
94
- index 8e77d8b69f..fced4c9fea 100644
95
- --- a/include/sysemu/event-loop-base.h
96
- +++ b/include/sysemu/event-loop-base.h
97
- @@ -25,6 +25,7 @@ struct EventLoopBaseClass {
98
-
99
- void (*init)(EventLoopBase *base, Error **errp);
100
- void (*update_params)(EventLoopBase *base, Error **errp);
101
- + bool (*can_be_deleted)(EventLoopBase *base);
102
- };
103
-
104
- struct EventLoopBase {
105
- diff --git a/meson.build b/meson.build
106
- index b9c919a55e..5a7c10e639 100644
107
- --- a/meson.build
108
- +++ b/meson.build
109
- @@ -2832,7 +2832,8 @@ libqemuutil = static_library('qemuutil',
110
- sources: util_ss.sources() + stub_ss.sources() + genh,
111
- dependencies: [util_ss.dependencies(), libm, threads, glib, socket, malloc, pixman])
112
- qemuutil = declare_dependency(link_with: libqemuutil,
113
- - sources: genh + version_res)
114
- + sources: genh + version_res,
115
- + dependencies: [event_loop_base])
116
-
117
- if have_system or have_user
118
- decodetree = generator(find_program('scripts/decodetree.py'),
119
- diff --git a/qapi/qom.json b/qapi/qom.json
120
- index a2439533c5..7d4a2ac1b9 100644
121
- --- a/qapi/qom.json
122
- +++ b/qapi/qom.json
123
- @@ -540,6 +540,17 @@
124
- '*poll-grow': 'int',
125
- '*poll-shrink': 'int' } }
126
-
127
- +##
128
- +# @MainLoopProperties:
129
- +#
130
- +# Properties for the main-loop object.
131
- +#
132
- +# Since: 7.1
133
- +##
134
- +{ 'struct': 'MainLoopProperties',
135
- + 'base': 'EventLoopBaseProperties',
136
- + 'data': {} }
137
- +
138
- ##
139
- # @MemoryBackendProperties:
140
- #
141
- @@ -830,6 +841,7 @@
142
- { 'name': 'input-linux',
143
- 'if': 'CONFIG_LINUX' },
144
- 'iothread',
145
- + 'main-loop',
146
- { 'name': 'memory-backend-epc',
147
- 'if': 'CONFIG_LINUX' },
148
- 'memory-backend-file',
149
- @@ -895,6 +907,7 @@
150
- 'input-linux': { 'type': 'InputLinuxProperties',
151
- 'if': 'CONFIG_LINUX' },
152
- 'iothread': 'IothreadProperties',
153
- + 'main-loop': 'MainLoopProperties',
154
- 'memory-backend-epc': { 'type': 'MemoryBackendEpcProperties',
155
- 'if': 'CONFIG_LINUX' },
156
- 'memory-backend-file': 'MemoryBackendFileProperties',
157
- diff --git a/util/main-loop.c b/util/main-loop.c
158
- index b7b0ce4ca0..5b13f456fa 100644
159
- --- a/util/main-loop.c
160
- +++ b/util/main-loop.c
161
- @@ -33,6 +33,7 @@
162
- #include "qemu/error-report.h"
163
- #include "qemu/queue.h"
164
- #include "qemu/compiler.h"
165
- +#include "qom/object.h"
166
-
167
- #ifndef _WIN32
168
- #include <sys/wait.h>
169
- @@ -184,6 +185,61 @@ int qemu_init_main_loop(Error **errp)
170
- return 0;
171
- }
172
-
173
- +static void main_loop_update_params(EventLoopBase *base, Error **errp)
174
- +{
175
- + if (!qemu_aio_context) {
176
- + error_setg(errp, "qemu aio context not ready");
177
- + return;
178
- + }
179
- +
180
- + aio_context_set_aio_params(qemu_aio_context, base->aio_max_batch, errp);
181
- +}
182
- +
183
- +MainLoop *mloop;
184
- +
185
- +static void main_loop_init(EventLoopBase *base, Error **errp)
186
- +{
187
- + MainLoop *m = MAIN_LOOP(base);
188
- +
189
- + if (mloop) {
190
- + error_setg(errp, "only one main-loop instance allowed");
191
- + return;
192
- + }
193
- +
194
- + main_loop_update_params(base, errp);
195
- +
196
- + mloop = m;
197
- + return;
198
- +}
199
- +
200
- +static bool main_loop_can_be_deleted(EventLoopBase *base)
201
- +{
202
- + return false;
203
- +}
204
- +
205
- +static void main_loop_class_init(ObjectClass *oc, void *class_data)
206
- +{
207
- + EventLoopBaseClass *bc = EVENT_LOOP_BASE_CLASS(oc);
208
- +
209
- + bc->init = main_loop_init;
210
- + bc->update_params = main_loop_update_params;
211
- + bc->can_be_deleted = main_loop_can_be_deleted;
212
- +}
213
- +
214
- +static const TypeInfo main_loop_info = {
215
- + .name = TYPE_MAIN_LOOP,
216
- + .parent = TYPE_EVENT_LOOP_BASE,
217
- + .class_init = main_loop_class_init,
218
- + .instance_size = sizeof(MainLoop),
219
- +};
220
- +
221
- +static void main_loop_register_types(void)
222
- +{
223
- + type_register_static(&main_loop_info);
224
- +}
225
- +
226
- +type_init(main_loop_register_types)
227
- +
228
- static int max_priority;
229
-
230
- #ifndef _WIN32
231
- --
232
- 2.31.1
233
-
SOURCES/kvm-util-userfaultfd-Add-uffd_open.patch ADDED
@@ -0,0 +1,169 @@
1
+ From 80445fed73a7d1a87e8ce96f6cb7d505e437f845 Mon Sep 17 00:00:00 2001
2
+ From: Peter Xu <peterx@redhat.com>
3
+ Date: Wed, 1 Feb 2023 16:10:54 -0500
4
+ Subject: [PATCH 4/8] util/userfaultfd: Add uffd_open()
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Peter Xu <peterx@redhat.com>
10
+ RH-MergeRequest: 149: Support /dev/userfaultfd
11
+ RH-Bugzilla: 2158704
12
+ RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
13
+ RH-Acked-by: quintela1 <quintela@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [2/3] 4c81696314ab26db47c3415fa2c2501c6a572b5c (peterx/qemu-kvm)
16
+
17
+ Add a helper to create the uffd handle.
18
+
19
+ Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
20
+ Reviewed-by: Juan Quintela <quintela@redhat.com>
21
+ Signed-off-by: Peter Xu <peterx@redhat.com>
22
+ Signed-off-by: Juan Quintela <quintela@redhat.com>
23
+ (cherry picked from commit d5890ea0722831eea76a0efd23a496b3e8815fe8)
24
+ Signed-off-by: Peter Xu <peterx@redhat.com>
25
+ ---
26
+ include/qemu/userfaultfd.h | 12 ++++++++++++
27
+ migration/postcopy-ram.c | 11 +++++------
28
+ tests/qtest/migration-test.c | 4 ++--
29
+ util/userfaultfd.c | 13 +++++++++++--
30
+ 4 files changed, 30 insertions(+), 10 deletions(-)
31
+
32
+ diff --git a/include/qemu/userfaultfd.h b/include/qemu/userfaultfd.h
33
+ index 6b74f92792..d764496f0b 100644
34
+ --- a/include/qemu/userfaultfd.h
35
+ +++ b/include/qemu/userfaultfd.h
36
+ @@ -13,10 +13,20 @@
37
+ #ifndef USERFAULTFD_H
38
+ #define USERFAULTFD_H
39
+
40
+ +#ifdef CONFIG_LINUX
41
+ +
42
+ #include "qemu/osdep.h"
43
+ #include "exec/hwaddr.h"
44
+ #include <linux/userfaultfd.h>
45
+
46
+ +/**
47
+ + * uffd_open(): Open an userfaultfd handle for current context.
48
+ + *
49
+ + * @flags: The flags we want to pass in when creating the handle.
50
+ + *
51
+ + * Returns: the uffd handle if >=0, or <0 if error happens.
52
+ + */
53
+ +int uffd_open(int flags);
54
+ int uffd_query_features(uint64_t *features);
55
+ int uffd_create_fd(uint64_t features, bool non_blocking);
56
+ void uffd_close_fd(int uffd_fd);
57
+ @@ -32,4 +42,6 @@ int uffd_wakeup(int uffd_fd, void *addr, uint64_t length);
58
+ int uffd_read_events(int uffd_fd, struct uffd_msg *msgs, int count);
59
+ bool uffd_poll_events(int uffd_fd, int tmo);
60
+
61
+ +#endif /* CONFIG_LINUX */
62
+ +
63
+ #endif /* USERFAULTFD_H */
64
+ diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
65
+ index b9a37ef255..0c55df0e52 100644
66
+ --- a/migration/postcopy-ram.c
67
+ +++ b/migration/postcopy-ram.c
68
+ @@ -37,6 +37,7 @@
69
+ #include "qemu-file.h"
70
+ #include "yank_functions.h"
71
+ #include "tls.h"
72
+ +#include "qemu/userfaultfd.h"
73
+
74
+ /* Arbitrary limit on size of each discard command,
75
+ * keeps them around ~200 bytes
76
+ @@ -226,11 +227,9 @@ static bool receive_ufd_features(uint64_t *features)
77
+ int ufd;
78
+ bool ret = true;
79
+
80
+ - /* if we are here __NR_userfaultfd should exists */
81
+ - ufd = syscall(__NR_userfaultfd, O_CLOEXEC);
82
+ + ufd = uffd_open(O_CLOEXEC);
83
+ if (ufd == -1) {
84
+ - error_report("%s: syscall __NR_userfaultfd failed: %s", __func__,
85
+ - strerror(errno));
86
+ + error_report("%s: uffd_open() failed: %s", __func__, strerror(errno));
87
+ return false;
88
+ }
89
+
90
+ @@ -375,7 +374,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis)
91
+ goto out;
92
+ }
93
+
94
+ - ufd = syscall(__NR_userfaultfd, O_CLOEXEC);
95
+ + ufd = uffd_open(O_CLOEXEC);
96
+ if (ufd == -1) {
97
+ error_report("%s: userfaultfd not available: %s", __func__,
98
+ strerror(errno));
99
+ @@ -1160,7 +1159,7 @@ static int postcopy_temp_pages_setup(MigrationIncomingState *mis)
100
+ int postcopy_ram_incoming_setup(MigrationIncomingState *mis)
101
+ {
102
+ /* Open the fd for the kernel to give us userfaults */
103
+ - mis->userfault_fd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK);
104
+ + mis->userfault_fd = uffd_open(O_CLOEXEC | O_NONBLOCK);
105
+ if (mis->userfault_fd == -1) {
106
+ error_report("%s: Failed to open userfault fd: %s", __func__,
107
+ strerror(errno));
108
+ diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
109
+ index dbde726adf..0100e1bdbc 100644
110
+ --- a/tests/qtest/migration-test.c
111
+ +++ b/tests/qtest/migration-test.c
112
+ @@ -61,14 +61,14 @@ static bool uffd_feature_thread_id;
113
+ #if defined(__linux__) && defined(__NR_userfaultfd) && defined(CONFIG_EVENTFD)
114
+ #include <sys/eventfd.h>
115
+ #include <sys/ioctl.h>
116
+ -#include <linux/userfaultfd.h>
117
+ +#include "qemu/userfaultfd.h"
118
+
119
+ static bool ufd_version_check(void)
120
+ {
121
+ struct uffdio_api api_struct;
122
+ uint64_t ioctl_mask;
123
+
124
+ - int ufd = syscall(__NR_userfaultfd, O_CLOEXEC);
125
+ + int ufd = uffd_open(O_CLOEXEC);
126
+
127
+ if (ufd == -1) {
128
+ g_test_message("Skipping test: userfaultfd not available");
129
+ diff --git a/util/userfaultfd.c b/util/userfaultfd.c
130
+ index f1cd6af2b1..4953b3137d 100644
131
+ --- a/util/userfaultfd.c
132
+ +++ b/util/userfaultfd.c
133
+ @@ -19,6 +19,15 @@
134
+ #include <sys/syscall.h>
135
+ #include <sys/ioctl.h>
136
+
137
+ +int uffd_open(int flags)
138
+ +{
139
+ +#if defined(__NR_userfaultfd)
140
+ + return syscall(__NR_userfaultfd, flags);
141
+ +#else
142
+ + return -EINVAL;
143
+ +#endif
144
+ +}
145
+ +
146
+ /**
147
+ * uffd_query_features: query UFFD features
148
+ *
149
+ @@ -32,7 +41,7 @@ int uffd_query_features(uint64_t *features)
150
+ struct uffdio_api api_struct = { 0 };
151
+ int ret = -1;
152
+
153
+ - uffd_fd = syscall(__NR_userfaultfd, O_CLOEXEC);
154
+ + uffd_fd = uffd_open(O_CLOEXEC);
155
+ if (uffd_fd < 0) {
156
+ trace_uffd_query_features_nosys(errno);
157
+ return -1;
158
+ @@ -69,7 +78,7 @@ int uffd_create_fd(uint64_t features, bool non_blocking)
159
+ uint64_t ioctl_mask = BIT(_UFFDIO_REGISTER) | BIT(_UFFDIO_UNREGISTER);
160
+
161
+ flags = O_CLOEXEC | (non_blocking ? O_NONBLOCK : 0);
162
+ - uffd_fd = syscall(__NR_userfaultfd, flags);
163
+ + uffd_fd = uffd_open(flags);
164
+ if (uffd_fd < 0) {
165
+ trace_uffd_create_fd_nosys(errno);
166
+ return -1;
167
+ --
168
+ 2.31.1
169
+
SOURCES/kvm-util-userfaultfd-Support-dev-userfaultfd.patch ADDED
@@ -0,0 +1,94 @@
1
+ From a91da7741464dadeb306a741b4fb562e49ffea57 Mon Sep 17 00:00:00 2001
2
+ From: Peter Xu <peterx@redhat.com>
3
+ Date: Tue, 7 Feb 2023 15:57:11 -0500
4
+ Subject: [PATCH 5/8] util/userfaultfd: Support /dev/userfaultfd
5
+
6
+ RH-Author: Peter Xu <peterx@redhat.com>
7
+ RH-MergeRequest: 149: Support /dev/userfaultfd
8
+ RH-Bugzilla: 2158704
9
+ RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
10
+ RH-Acked-by: quintela1 <quintela@redhat.com>
11
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
+ RH-Commit: [3/3] 5f427d8c18c210ff8f66724c9e358a7120619e69 (peterx/qemu-kvm)
13
+
14
+ Teach QEMU to use /dev/userfaultfd when it existed and fallback to the
15
+ system call if either it's not there or doesn't have enough permission.
16
+
17
+ Firstly, as long as the app has permission to access /dev/userfaultfd, it
18
+ always have the ability to trap kernel faults which QEMU mostly wants.
19
+ Meanwhile, in some context (e.g. containers) the userfaultfd syscall can be
20
+ forbidden, so it can be the major way to use postcopy in a restricted
21
+ environment with strict seccomp setup.
22
+
23
+ Signed-off-by: Peter Xu <peterx@redhat.com>
24
+ Reviewed-by: Juan Quintela <quintela@redhat.com>
25
+ Signed-off-by: Juan Quintela <quintela@redhat.com>
26
+ (cherry picked from commit c40c0463413b941c13fe5f99a90c02d7d6584828)
27
+ Signed-off-by: Peter Xu <peterx@redhat.com>
28
+ ---
29
+ util/trace-events | 1 +
30
+ util/userfaultfd.c | 32 ++++++++++++++++++++++++++++++++
31
+ 2 files changed, 33 insertions(+)
32
+
33
+ diff --git a/util/trace-events b/util/trace-events
34
+ index c8f53d7d9f..16f78d8fe5 100644
35
+ --- a/util/trace-events
36
+ +++ b/util/trace-events
37
+ @@ -93,6 +93,7 @@ qemu_vfio_region_info(const char *desc, uint64_t region_ofs, uint64_t region_siz
38
+ qemu_vfio_pci_map_bar(int index, uint64_t region_ofs, uint64_t region_size, int ofs, void *host) "map region bar#%d addr 0x%"PRIx64" size 0x%"PRIx64" ofs 0x%x host %p"
39
+
40
+ #userfaultfd.c
41
+ +uffd_detect_open_mode(int mode) "%d"
42
+ uffd_query_features_nosys(int err) "errno: %i"
43
+ uffd_query_features_api_failed(int err) "errno: %i"
44
+ uffd_create_fd_nosys(int err) "errno: %i"
45
+ diff --git a/util/userfaultfd.c b/util/userfaultfd.c
46
+ index 4953b3137d..fdff4867e8 100644
47
+ --- a/util/userfaultfd.c
48
+ +++ b/util/userfaultfd.c
49
+ @@ -18,10 +18,42 @@
50
+ #include <poll.h>
51
+ #include <sys/syscall.h>
52
+ #include <sys/ioctl.h>
53
+ +#include <fcntl.h>
54
+ +
55
+ +typedef enum {
56
+ + UFFD_UNINITIALIZED = 0,
57
+ + UFFD_USE_DEV_PATH,
58
+ + UFFD_USE_SYSCALL,
59
+ +} uffd_open_mode;
60
+
61
+ int uffd_open(int flags)
62
+ {
63
+ #if defined(__NR_userfaultfd)
64
+ + static uffd_open_mode open_mode;
65
+ + static int uffd_dev;
66
+ +
67
+ + /* Detect how to generate uffd desc when run the 1st time */
68
+ + if (open_mode == UFFD_UNINITIALIZED) {
69
+ + /*
70
+ + * Make /dev/userfaultfd the default approach because it has better
71
+ + * permission controls, meanwhile allows kernel faults without any
72
+ + * privilege requirement (e.g. SYS_CAP_PTRACE).
73
+ + */
74
+ + uffd_dev = open("/dev/userfaultfd", O_RDWR | O_CLOEXEC);
75
+ + if (uffd_dev >= 0) {
76
+ + open_mode = UFFD_USE_DEV_PATH;
77
+ + } else {
78
+ + /* Fallback to the system call */
79
+ + open_mode = UFFD_USE_SYSCALL;
80
+ + }
81
+ + trace_uffd_detect_open_mode(open_mode);
82
+ + }
83
+ +
84
+ + if (open_mode == UFFD_USE_DEV_PATH) {
85
+ + assert(uffd_dev >= 0);
86
+ + return ioctl(uffd_dev, USERFAULTFD_IOC_NEW, flags);
87
+ + }
88
+ +
89
+ return syscall(__NR_userfaultfd, flags);
90
+ #else
91
+ return -EINVAL;
92
+ --
93
+ 2.31.1
94
+
SOURCES/kvm-vdpa-Add-device-migration-blocker.patch DELETED
@@ -1,106 +0,0 @@
1
- From 8e0fdce814af4cfc84dce5e5920da989b1f1a86d Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 16:06:05 +0200
4
- Subject: [PATCH 26/32] vdpa: Add device migration blocker
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [26/27] 53d94d45b5e5e88f12b95f9b0f243696cfcbd7ce (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit c156d5bf2b142dcc06808ccee06882144f230aec
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Wed Jul 20 08:59:45 2022 +0200
24
-
25
- vdpa: Add device migration blocker
26
-
27
- Since the vhost-vdpa device is exposing _F_LOG, adding a migration blocker if
28
- it uses CVQ.
29
-
30
- However, qemu is able to migrate simple devices with no CVQ as long as
31
- they use SVQ. To allow it, add a placeholder error to vhost_vdpa, and
32
- only add to vhost_dev when used. vhost_dev machinery place the migration
33
- blocker if needed.
34
-
35
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
36
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
37
- Signed-off-by: Jason Wang <jasowang@redhat.com>
38
-
39
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
40
- ---
41
- hw/virtio/vhost-vdpa.c | 15 +++++++++++++++
42
- include/hw/virtio/vhost-vdpa.h | 1 +
43
- 2 files changed, 16 insertions(+)
44
-
45
- diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
46
- index 49effe5462..e3e5bce4bb 100644
47
- --- a/hw/virtio/vhost-vdpa.c
48
- +++ b/hw/virtio/vhost-vdpa.c
49
- @@ -20,6 +20,7 @@
50
- #include "hw/virtio/vhost-shadow-virtqueue.h"
51
- #include "hw/virtio/vhost-vdpa.h"
52
- #include "exec/address-spaces.h"
53
- +#include "migration/blocker.h"
54
- #include "qemu/main-loop.h"
55
- #include "cpu.h"
56
- #include "trace.h"
57
- @@ -1020,6 +1021,13 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *dev)
58
- return true;
59
- }
60
-
61
- + if (v->migration_blocker) {
62
- + int r = migrate_add_blocker(v->migration_blocker, &err);
63
- + if (unlikely(r < 0)) {
64
- + return false;
65
- + }
66
- + }
67
- +
68
- for (i = 0; i < v->shadow_vqs->len; ++i) {
69
- VirtQueue *vq = virtio_get_queue(dev->vdev, dev->vq_index + i);
70
- VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
71
- @@ -1062,6 +1070,10 @@ err:
72
- vhost_svq_stop(svq);
73
- }
74
-
75
- + if (v->migration_blocker) {
76
- + migrate_del_blocker(v->migration_blocker);
77
- + }
78
- +
79
- return false;
80
- }
81
-
82
- @@ -1081,6 +1093,9 @@ static bool vhost_vdpa_svqs_stop(struct vhost_dev *dev)
83
- }
84
- }
85
-
86
- + if (v->migration_blocker) {
87
- + migrate_del_blocker(v->migration_blocker);
88
- + }
89
- return true;
90
- }
91
-
92
- diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
93
- index 1111d85643..d10a89303e 100644
94
- --- a/include/hw/virtio/vhost-vdpa.h
95
- +++ b/include/hw/virtio/vhost-vdpa.h
96
- @@ -35,6 +35,7 @@ typedef struct vhost_vdpa {
97
- bool shadow_vqs_enabled;
98
- /* IOVA mapping used by the Shadow Virtqueue */
99
- VhostIOVATree *iova_tree;
100
- + Error *migration_blocker;
101
- GPtrArray *shadow_vqs;
102
- const VhostShadowVirtqueueOps *shadow_vq_ops;
103
- void *shadow_vq_ops_opaque;
104
- --
105
- 2.31.1
106
-
SOURCES/kvm-vdpa-Add-x-svq-to-NetdevVhostVDPAOptions.patch DELETED
@@ -1,223 +0,0 @@
1
- From 0b27781f9984c67625c49a516c3e38fbf5fa1b1b Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 16:06:16 +0200
4
- Subject: [PATCH 27/32] vdpa: Add x-svq to NetdevVhostVDPAOptions
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [27/27] bd85496c2a8c1ebf34f908fca2be2ab9852fd0e9 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit 1576dbb5bbc49344c606e969ec749be70c0fd94e
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Wed Jul 20 08:59:46 2022 +0200
24
-
25
- vdpa: Add x-svq to NetdevVhostVDPAOptions
26
-
27
- Finally offering the possibility to enable SVQ from the command line.
28
-
29
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
30
- Acked-by: Markus Armbruster <armbru@redhat.com>
31
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
32
- Signed-off-by: Jason Wang <jasowang@redhat.com>
33
-
34
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
35
- ---
36
- net/vhost-vdpa.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++--
37
- qapi/net.json | 9 +++++-
38
- 2 files changed, 77 insertions(+), 4 deletions(-)
39
-
40
- diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
41
- index 8b76dac966..50672bcd66 100644
42
- --- a/net/vhost-vdpa.c
43
- +++ b/net/vhost-vdpa.c
44
- @@ -75,6 +75,28 @@ const int vdpa_feature_bits[] = {
45
- VHOST_INVALID_FEATURE_BIT
46
- };
47
-
48
- +/** Supported device specific feature bits with SVQ */
49
- +static const uint64_t vdpa_svq_device_features =
50
- + BIT_ULL(VIRTIO_NET_F_CSUM) |
51
- + BIT_ULL(VIRTIO_NET_F_GUEST_CSUM) |
52
- + BIT_ULL(VIRTIO_NET_F_MTU) |
53
- + BIT_ULL(VIRTIO_NET_F_MAC) |
54
- + BIT_ULL(VIRTIO_NET_F_GUEST_TSO4) |
55
- + BIT_ULL(VIRTIO_NET_F_GUEST_TSO6) |
56
- + BIT_ULL(VIRTIO_NET_F_GUEST_ECN) |
57
- + BIT_ULL(VIRTIO_NET_F_GUEST_UFO) |
58
- + BIT_ULL(VIRTIO_NET_F_HOST_TSO4) |
59
- + BIT_ULL(VIRTIO_NET_F_HOST_TSO6) |
60
- + BIT_ULL(VIRTIO_NET_F_HOST_ECN) |
61
- + BIT_ULL(VIRTIO_NET_F_HOST_UFO) |
62
- + BIT_ULL(VIRTIO_NET_F_MRG_RXBUF) |
63
- + BIT_ULL(VIRTIO_NET_F_STATUS) |
64
- + BIT_ULL(VIRTIO_NET_F_CTRL_VQ) |
65
- + BIT_ULL(VIRTIO_F_ANY_LAYOUT) |
66
- + BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR) |
67
- + BIT_ULL(VIRTIO_NET_F_RSC_EXT) |
68
- + BIT_ULL(VIRTIO_NET_F_STANDBY);
69
- +
70
- VHostNetState *vhost_vdpa_get_vhost_net(NetClientState *nc)
71
- {
72
- VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
73
- @@ -133,9 +155,13 @@ err_init:
74
- static void vhost_vdpa_cleanup(NetClientState *nc)
75
- {
76
- VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
77
- + struct vhost_dev *dev = &s->vhost_net->dev;
78
-
79
- qemu_vfree(s->cvq_cmd_out_buffer);
80
- qemu_vfree(s->cvq_cmd_in_buffer);
81
- + if (dev->vq_index + dev->nvqs == dev->vq_index_end) {
82
- + g_clear_pointer(&s->vhost_vdpa.iova_tree, vhost_iova_tree_delete);
83
- + }
84
- if (s->vhost_net) {
85
- vhost_net_cleanup(s->vhost_net);
86
- g_free(s->vhost_net);
87
- @@ -437,7 +463,9 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
88
- int vdpa_device_fd,
89
- int queue_pair_index,
90
- int nvqs,
91
- - bool is_datapath)
92
- + bool is_datapath,
93
- + bool svq,
94
- + VhostIOVATree *iova_tree)
95
- {
96
- NetClientState *nc = NULL;
97
- VhostVDPAState *s;
98
- @@ -455,6 +483,8 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
99
-
100
- s->vhost_vdpa.device_fd = vdpa_device_fd;
101
- s->vhost_vdpa.index = queue_pair_index;
102
- + s->vhost_vdpa.shadow_vqs_enabled = svq;
103
- + s->vhost_vdpa.iova_tree = iova_tree;
104
- if (!is_datapath) {
105
- s->cvq_cmd_out_buffer = qemu_memalign(qemu_real_host_page_size,
106
- vhost_vdpa_net_cvq_cmd_page_len());
107
- @@ -465,6 +495,8 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
108
-
109
- s->vhost_vdpa.shadow_vq_ops = &vhost_vdpa_net_svq_ops;
110
- s->vhost_vdpa.shadow_vq_ops_opaque = s;
111
- + error_setg(&s->vhost_vdpa.migration_blocker,
112
- + "Migration disabled: vhost-vdpa uses CVQ.");
113
- }
114
- ret = vhost_vdpa_add(nc, (void *)&s->vhost_vdpa, queue_pair_index, nvqs);
115
- if (ret) {
116
- @@ -474,6 +506,14 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
117
- return nc;
118
- }
119
-
120
- +static int vhost_vdpa_get_iova_range(int fd,
121
- + struct vhost_vdpa_iova_range *iova_range)
122
- +{
123
- + int ret = ioctl(fd, VHOST_VDPA_GET_IOVA_RANGE, iova_range);
124
- +
125
- + return ret < 0 ? -errno : 0;
126
- +}
127
- +
128
- static int vhost_vdpa_get_features(int fd, uint64_t *features, Error **errp)
129
- {
130
- int ret = ioctl(fd, VHOST_GET_FEATURES, features);
131
- @@ -524,6 +564,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
132
- uint64_t features;
133
- int vdpa_device_fd;
134
- g_autofree NetClientState **ncs = NULL;
135
- + g_autoptr(VhostIOVATree) iova_tree = NULL;
136
- NetClientState *nc;
137
- int queue_pairs, r, i, has_cvq = 0;
138
-
139
- @@ -551,22 +592,45 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
140
- return queue_pairs;
141
- }
142
-
143
- + if (opts->x_svq) {
144
- + struct vhost_vdpa_iova_range iova_range;
145
- +
146
- + uint64_t invalid_dev_features =
147
- + features & ~vdpa_svq_device_features &
148
- + /* Transport are all accepted at this point */
149
- + ~MAKE_64BIT_MASK(VIRTIO_TRANSPORT_F_START,
150
- + VIRTIO_TRANSPORT_F_END - VIRTIO_TRANSPORT_F_START);
151
- +
152
- + if (invalid_dev_features) {
153
- + error_setg(errp, "vdpa svq does not work with features 0x%" PRIx64,
154
- + invalid_dev_features);
155
- + goto err_svq;
156
- + }
157
- +
158
- + vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range);
159
- + iova_tree = vhost_iova_tree_new(iova_range.first, iova_range.last);
160
- + }
161
- +
162
- ncs = g_malloc0(sizeof(*ncs) * queue_pairs);
163
-
164
- for (i = 0; i < queue_pairs; i++) {
165
- ncs[i] = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name,
166
- - vdpa_device_fd, i, 2, true);
167
- + vdpa_device_fd, i, 2, true, opts->x_svq,
168
- + iova_tree);
169
- if (!ncs[i])
170
- goto err;
171
- }
172
-
173
- if (has_cvq) {
174
- nc = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name,
175
- - vdpa_device_fd, i, 1, false);
176
- + vdpa_device_fd, i, 1, false,
177
- + opts->x_svq, iova_tree);
178
- if (!nc)
179
- goto err;
180
- }
181
-
182
- + /* iova_tree ownership belongs to last NetClientState */
183
- + g_steal_pointer(&iova_tree);
184
- return 0;
185
-
186
- err:
187
- @@ -575,6 +639,8 @@ err:
188
- qemu_del_net_client(ncs[i]);
189
- }
190
- }
191
- +
192
- +err_svq:
193
- qemu_close(vdpa_device_fd);
194
-
195
- return -1;
196
- diff --git a/qapi/net.json b/qapi/net.json
197
- index b92f3f5fb4..92848e4362 100644
198
- --- a/qapi/net.json
199
- +++ b/qapi/net.json
200
- @@ -445,12 +445,19 @@
201
- # @queues: number of queues to be created for multiqueue vhost-vdpa
202
- # (default: 1)
203
- #
204
- +# @x-svq: Start device with (experimental) shadow virtqueue. (Since 7.1)
205
- +# (default: false)
206
- +#
207
- +# Features:
208
- +# @unstable: Member @x-svq is experimental.
209
- +#
210
- # Since: 5.1
211
- ##
212
- { 'struct': 'NetdevVhostVDPAOptions',
213
- 'data': {
214
- '*vhostdev': 'str',
215
- - '*queues': 'int' } }
216
- + '*queues': 'int',
217
- + '*x-svq': {'type': 'bool', 'features' : [ 'unstable'] } } }
218
-
219
- ##
220
- # @NetClientDriver:
221
- --
222
- 2.31.1
223
-
SOURCES/kvm-vdpa-Avoid-compiler-to-squash-reads-to-used-idx.patch DELETED
@@ -1,65 +0,0 @@
1
- From df06ce560ddfefde98bef822ec2020382059921f Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:38:55 +0200
4
- Subject: [PATCH 10/32] vdpa: Avoid compiler to squash reads to used idx
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [10/27] b28789302d4f64749da26f413763f918161d9b70 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit c381abc37f0aba42ed2e3b41cdace8f8438829e4
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Wed Jul 20 08:59:29 2022 +0200
24
-
25
- vdpa: Avoid compiler to squash reads to used idx
26
-
27
- In the next patch we will allow busypolling of this value. The compiler
28
- have a running path where shadow_used_idx, last_used_idx, and vring used
29
- idx are not modified within the same thread busypolling.
30
-
31
- This was not an issue before since we always cleared device event
32
- notifier before checking it, and that could act as memory barrier.
33
- However, the busypoll needs something similar to kernel READ_ONCE.
34
-
35
- Let's add it here, sepparated from the polling.
36
-
37
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
38
- Signed-off-by: Jason Wang <jasowang@redhat.com>
39
-
40
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
41
- ---
42
- hw/virtio/vhost-shadow-virtqueue.c | 3 ++-
43
- 1 file changed, 2 insertions(+), 1 deletion(-)
44
-
45
- diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
46
- index 3fbda1e3d4..9c46c3a8fa 100644
47
- --- a/hw/virtio/vhost-shadow-virtqueue.c
48
- +++ b/hw/virtio/vhost-shadow-virtqueue.c
49
- @@ -327,11 +327,12 @@ static void vhost_handle_guest_kick_notifier(EventNotifier *n)
50
-
51
- static bool vhost_svq_more_used(VhostShadowVirtqueue *svq)
52
- {
53
- + uint16_t *used_idx = &svq->vring.used->idx;
54
- if (svq->last_used_idx != svq->shadow_used_idx) {
55
- return true;
56
- }
57
-
58
- - svq->shadow_used_idx = cpu_to_le16(svq->vring.used->idx);
59
- + svq->shadow_used_idx = cpu_to_le16(*(volatile uint16_t *)used_idx);
60
-
61
- return svq->last_used_idx != svq->shadow_used_idx;
62
- }
63
- --
64
- 2.31.1
65
-
SOURCES/kvm-vdpa-Buffer-CVQ-support-on-shadow-virtqueue.patch DELETED
@@ -1,323 +0,0 @@
1
- From 881945094c0e4d33614d40959bfc20e395f5a478 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 16:05:40 +0200
4
- Subject: [PATCH 24/32] vdpa: Buffer CVQ support on shadow virtqueue
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [24/27] 5486f80141a3ad968a32e782bdcdead32f417352 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit 2df4dd31e194c94da7d28c02e92449f4a989fca9
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Wed Jul 20 08:59:43 2022 +0200
24
-
25
- vdpa: Buffer CVQ support on shadow virtqueue
26
-
27
- Introduce the control virtqueue support for vDPA shadow virtqueue. This
28
- is needed for advanced networking features like rx filtering.
29
-
30
- Virtio-net control VQ copies the descriptors to qemu's VA, so we avoid
31
- TOCTOU with the guest's or device's memory every time there is a device
32
- model change. Otherwise, the guest could change the memory content in
33
- the time between qemu and the device read it.
34
-
35
- To demonstrate command handling, VIRTIO_NET_F_CTRL_MACADDR is
36
- implemented. If the virtio-net driver changes MAC the virtio-net device
37
- model will be updated with the new one, and a rx filtering change event
38
- will be raised.
39
-
40
- More cvq commands could be added here straightforwardly but they have
41
- not been tested.
42
-
43
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
44
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
45
- Signed-off-by: Jason Wang <jasowang@redhat.com>
46
-
47
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
48
- ---
49
- net/vhost-vdpa.c | 213 +++++++++++++++++++++++++++++++++++++++++++++--
50
- 1 file changed, 205 insertions(+), 8 deletions(-)
51
-
52
- diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
53
- index 2e3b6b10d8..df42822463 100644
54
- --- a/net/vhost-vdpa.c
55
- +++ b/net/vhost-vdpa.c
56
- @@ -33,6 +33,9 @@ typedef struct VhostVDPAState {
57
- NetClientState nc;
58
- struct vhost_vdpa vhost_vdpa;
59
- VHostNetState *vhost_net;
60
- +
61
- + /* Control commands shadow buffers */
62
- + void *cvq_cmd_out_buffer, *cvq_cmd_in_buffer;
63
- bool started;
64
- } VhostVDPAState;
65
-
66
- @@ -131,6 +134,8 @@ static void vhost_vdpa_cleanup(NetClientState *nc)
67
- {
68
- VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
69
-
70
- + qemu_vfree(s->cvq_cmd_out_buffer);
71
- + qemu_vfree(s->cvq_cmd_in_buffer);
72
- if (s->vhost_net) {
73
- vhost_net_cleanup(s->vhost_net);
74
- g_free(s->vhost_net);
75
- @@ -190,24 +195,191 @@ static NetClientInfo net_vhost_vdpa_info = {
76
- .check_peer_type = vhost_vdpa_check_peer_type,
77
- };
78
-
79
- +static void vhost_vdpa_cvq_unmap_buf(struct vhost_vdpa *v, void *addr)
80
- +{
81
- + VhostIOVATree *tree = v->iova_tree;
82
- + DMAMap needle = {
83
- + /*
84
- + * No need to specify size or to look for more translations since
85
- + * this contiguous chunk was allocated by us.
86
- + */
87
- + .translated_addr = (hwaddr)(uintptr_t)addr,
88
- + };
89
- + const DMAMap *map = vhost_iova_tree_find_iova(tree, &needle);
90
- + int r;
91
- +
92
- + if (unlikely(!map)) {
93
- + error_report("Cannot locate expected map");
94
- + return;
95
- + }
96
- +
97
- + r = vhost_vdpa_dma_unmap(v, map->iova, map->size + 1);
98
- + if (unlikely(r != 0)) {
99
- + error_report("Device cannot unmap: %s(%d)", g_strerror(r), r);
100
- + }
101
- +
102
- + vhost_iova_tree_remove(tree, map);
103
- +}
104
- +
105
- +static size_t vhost_vdpa_net_cvq_cmd_len(void)
106
- +{
107
- + /*
108
- + * MAC_TABLE_SET is the ctrl command that produces the longer out buffer.
109
- + * In buffer is always 1 byte, so it should fit here
110
- + */
111
- + return sizeof(struct virtio_net_ctrl_hdr) +
112
- + 2 * sizeof(struct virtio_net_ctrl_mac) +
113
- + MAC_TABLE_ENTRIES * ETH_ALEN;
114
- +}
115
- +
116
- +static size_t vhost_vdpa_net_cvq_cmd_page_len(void)
117
- +{
118
- + return ROUND_UP(vhost_vdpa_net_cvq_cmd_len(), qemu_real_host_page_size);
119
- +}
120
- +
121
- +/** Copy and map a guest buffer. */
122
- +static bool vhost_vdpa_cvq_map_buf(struct vhost_vdpa *v,
123
- + const struct iovec *out_data,
124
- + size_t out_num, size_t data_len, void *buf,
125
- + size_t *written, bool write)
126
- +{
127
- + DMAMap map = {};
128
- + int r;
129
- +
130
- + if (unlikely(!data_len)) {
131
- + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid legnth of %s buffer\n",
132
- + __func__, write ? "in" : "out");
133
- + return false;
134
- + }
135
- +
136
- + *written = iov_to_buf(out_data, out_num, 0, buf, data_len);
137
- + map.translated_addr = (hwaddr)(uintptr_t)buf;
138
- + map.size = vhost_vdpa_net_cvq_cmd_page_len() - 1;
139
- + map.perm = write ? IOMMU_RW : IOMMU_RO,
140
- + r = vhost_iova_tree_map_alloc(v->iova_tree, &map);
141
- + if (unlikely(r != IOVA_OK)) {
142
- + error_report("Cannot map injected element");
143
- + return false;
144
- + }
145
- +
146
- + r = vhost_vdpa_dma_map(v, map.iova, vhost_vdpa_net_cvq_cmd_page_len(), buf,
147
- + !write);
148
- + if (unlikely(r < 0)) {
149
- + goto dma_map_err;
150
- + }
151
- +
152
- + return true;
153
- +
154
- +dma_map_err:
155
- + vhost_iova_tree_remove(v->iova_tree, &map);
156
- + return false;
157
- +}
158
- +
159
- /**
160
- - * Forward buffer for the moment.
161
- + * Copy the guest element into a dedicated buffer suitable to be sent to NIC
162
- + *
163
- + * @iov: [0] is the out buffer, [1] is the in one
164
- + */
165
- +static bool vhost_vdpa_net_cvq_map_elem(VhostVDPAState *s,
166
- + VirtQueueElement *elem,
167
- + struct iovec *iov)
168
- +{
169
- + size_t in_copied;
170
- + bool ok;
171
- +
172
- + iov[0].iov_base = s->cvq_cmd_out_buffer;
173
- + ok = vhost_vdpa_cvq_map_buf(&s->vhost_vdpa, elem->out_sg, elem->out_num,
174
- + vhost_vdpa_net_cvq_cmd_len(), iov[0].iov_base,
175
- + &iov[0].iov_len, false);
176
- + if (unlikely(!ok)) {
177
- + return false;
178
- + }
179
- +
180
- + iov[1].iov_base = s->cvq_cmd_in_buffer;
181
- + ok = vhost_vdpa_cvq_map_buf(&s->vhost_vdpa, NULL, 0,
182
- + sizeof(virtio_net_ctrl_ack), iov[1].iov_base,
183
- + &in_copied, true);
184
- + if (unlikely(!ok)) {
185
- + vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer);
186
- + return false;
187
- + }
188
- +
189
- + iov[1].iov_len = sizeof(virtio_net_ctrl_ack);
190
- + return true;
191
- +}
192
- +
193
- +/**
194
- + * Do not forward commands not supported by SVQ. Otherwise, the device could
195
- + * accept it and qemu would not know how to update the device model.
196
- + */
197
- +static bool vhost_vdpa_net_cvq_validate_cmd(const struct iovec *out,
198
- + size_t out_num)
199
- +{
200
- + struct virtio_net_ctrl_hdr ctrl;
201
- + size_t n;
202
- +
203
- + n = iov_to_buf(out, out_num, 0, &ctrl, sizeof(ctrl));
204
- + if (unlikely(n < sizeof(ctrl))) {
205
- + qemu_log_mask(LOG_GUEST_ERROR,
206
- + "%s: invalid legnth of out buffer %zu\n", __func__, n);
207
- + return false;
208
- + }
209
- +
210
- + switch (ctrl.class) {
211
- + case VIRTIO_NET_CTRL_MAC:
212
- + switch (ctrl.cmd) {
213
- + case VIRTIO_NET_CTRL_MAC_ADDR_SET:
214
- + return true;
215
- + default:
216
- + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid mac cmd %u\n",
217
- + __func__, ctrl.cmd);
218
- + };
219
- + break;
220
- + default:
221
- + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid control class %u\n",
222
- + __func__, ctrl.class);
223
- + };
224
- +
225
- + return false;
226
- +}
227
- +
228
- +/**
229
- + * Validate and copy control virtqueue commands.
230
- + *
231
- + * Following QEMU guidelines, we offer a copy of the buffers to the device to
232
- + * prevent TOCTOU bugs.
233
- */
234
- static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq,
235
- VirtQueueElement *elem,
236
- void *opaque)
237
- {
238
- - unsigned int n = elem->out_num + elem->in_num;
239
- - g_autofree struct iovec *dev_buffers = g_new(struct iovec, n);
240
- + VhostVDPAState *s = opaque;
241
- size_t in_len, dev_written;
242
- virtio_net_ctrl_ack status = VIRTIO_NET_ERR;
243
- - int r;
244
- + /* out and in buffers sent to the device */
245
- + struct iovec dev_buffers[2] = {
246
- + { .iov_base = s->cvq_cmd_out_buffer },
247
- + { .iov_base = s->cvq_cmd_in_buffer },
248
- + };
249
- + /* in buffer used for device model */
250
- + const struct iovec in = {
251
- + .iov_base = &status,
252
- + .iov_len = sizeof(status),
253
- + };
254
- + int r = -EINVAL;
255
- + bool ok;
256
- +
257
- + ok = vhost_vdpa_net_cvq_map_elem(s, elem, dev_buffers);
258
- + if (unlikely(!ok)) {
259
- + goto out;
260
- + }
261
-
262
- - memcpy(dev_buffers, elem->out_sg, elem->out_num);
263
- - memcpy(dev_buffers + elem->out_num, elem->in_sg, elem->in_num);
264
- + ok = vhost_vdpa_net_cvq_validate_cmd(&dev_buffers[0], 1);
265
- + if (unlikely(!ok)) {
266
- + goto out;
267
- + }
268
-
269
- - r = vhost_svq_add(svq, &dev_buffers[0], elem->out_num, &dev_buffers[1],
270
- - elem->in_num, elem);
271
- + r = vhost_svq_add(svq, &dev_buffers[0], 1, &dev_buffers[1], 1, elem);
272
- if (unlikely(r != 0)) {
273
- if (unlikely(r == -ENOSPC)) {
274
- qemu_log_mask(LOG_GUEST_ERROR, "%s: No space on device queue\n",
275
- @@ -224,6 +396,18 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq,
276
- dev_written = vhost_svq_poll(svq);
277
- if (unlikely(dev_written < sizeof(status))) {
278
- error_report("Insufficient written data (%zu)", dev_written);
279
- + goto out;
280
- + }
281
- +
282
- + memcpy(&status, dev_buffers[1].iov_base, sizeof(status));
283
- + if (status != VIRTIO_NET_OK) {
284
- + goto out;
285
- + }
286
- +
287
- + status = VIRTIO_NET_ERR;
288
- + virtio_net_handle_ctrl_iov(svq->vdev, &in, 1, dev_buffers, 1);
289
- + if (status != VIRTIO_NET_OK) {
290
- + error_report("Bad CVQ processing in model");
291
- }
292
-
293
- out:
294
- @@ -234,6 +418,12 @@ out:
295
- }
296
- vhost_svq_push_elem(svq, elem, MIN(in_len, sizeof(status)));
297
- g_free(elem);
298
- + if (dev_buffers[0].iov_base) {
299
- + vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, dev_buffers[0].iov_base);
300
- + }
301
- + if (dev_buffers[1].iov_base) {
302
- + vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, dev_buffers[1].iov_base);
303
- + }
304
- return r;
305
- }
306
-
307
- @@ -266,6 +456,13 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
308
- s->vhost_vdpa.device_fd = vdpa_device_fd;
309
- s->vhost_vdpa.index = queue_pair_index;
310
- if (!is_datapath) {
311
- + s->cvq_cmd_out_buffer = qemu_memalign(qemu_real_host_page_size,
312
- + vhost_vdpa_net_cvq_cmd_page_len());
313
- + memset(s->cvq_cmd_out_buffer, 0, vhost_vdpa_net_cvq_cmd_page_len());
314
- + s->cvq_cmd_in_buffer = qemu_memalign(qemu_real_host_page_size,
315
- + vhost_vdpa_net_cvq_cmd_page_len());
316
- + memset(s->cvq_cmd_in_buffer, 0, vhost_vdpa_net_cvq_cmd_page_len());
317
- +
318
- s->vhost_vdpa.shadow_vq_ops = &vhost_vdpa_net_svq_ops;
319
- s->vhost_vdpa.shadow_vq_ops_opaque = s;
320
- }
321
- --
322
- 2.31.1
323
-
SOURCES/kvm-vdpa-Export-vhost_vdpa_dma_map-and-unmap-calls.patch DELETED
@@ -1,84 +0,0 @@
1
- From 3a5d325fcb2958318262efac31d5fd25fb062523 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:38:55 +0200
4
- Subject: [PATCH 21/32] vdpa: Export vhost_vdpa_dma_map and unmap calls
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [21/27] 97e7a583bbd3c12a0786d53132812ec41702c190 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit 463ba1e3b8cf080812895c5f26d95d8d7db2e692
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Wed Jul 20 08:59:40 2022 +0200
24
-
25
- vdpa: Export vhost_vdpa_dma_map and unmap calls
26
-
27
- Shadow CVQ will copy buffers on qemu VA, so we avoid TOCTOU attacks from
28
- the guest that could set a different state in qemu device model and vdpa
29
- device.
30
-
31
- To do so, it needs to be able to map these new buffers to the device.
32
-
33
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
34
- Acked-by: Jason Wang <jasowang@redhat.com>
35
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
36
- Signed-off-by: Jason Wang <jasowang@redhat.com>
37
-
38
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
39
- ---
40
- hw/virtio/vhost-vdpa.c | 7 +++----
41
- include/hw/virtio/vhost-vdpa.h | 4 ++++
42
- 2 files changed, 7 insertions(+), 4 deletions(-)
43
-
44
- diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
45
- index 28df57b12e..14b02fe079 100644
46
- --- a/hw/virtio/vhost-vdpa.c
47
- +++ b/hw/virtio/vhost-vdpa.c
48
- @@ -71,8 +71,8 @@ static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *section,
49
- return false;
50
- }
51
-
52
- -static int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
53
- - void *vaddr, bool readonly)
54
- +int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
55
- + void *vaddr, bool readonly)
56
- {
57
- struct vhost_msg_v2 msg = {};
58
- int fd = v->device_fd;
59
- @@ -97,8 +97,7 @@ static int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
60
- return ret;
61
- }
62
-
63
- -static int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, hwaddr iova,
64
- - hwaddr size)
65
- +int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, hwaddr iova, hwaddr size)
66
- {
67
- struct vhost_msg_v2 msg = {};
68
- int fd = v->device_fd;
69
- diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
70
- index a29dbb3f53..7214eb47dc 100644
71
- --- a/include/hw/virtio/vhost-vdpa.h
72
- +++ b/include/hw/virtio/vhost-vdpa.h
73
- @@ -39,4 +39,8 @@ typedef struct vhost_vdpa {
74
- VhostVDPAHostNotifier notifier[VIRTIO_QUEUE_MAX];
75
- } VhostVDPA;
76
-
77
- +int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
78
- + void *vaddr, bool readonly);
79
- +int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, hwaddr iova, hwaddr size);
80
- +
81
- #endif
82
- --
83
- 2.31.1
84
-
SOURCES/kvm-vdpa-Extract-get-features-part-from-vhost_vdpa_get_m.patch DELETED
@@ -1,108 +0,0 @@
1
- From 9a290bd74f983f3a65aa9ec5df2da9aa94bfdecd Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 16:05:42 +0200
4
- Subject: [PATCH 25/32] vdpa: Extract get features part from
5
- vhost_vdpa_get_max_queue_pairs
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
11
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
12
- RH-Commit: [25/27] 654ad68e10a4df84cced923c64e72d500721ad67 (eperezmartin/qemu-kvm)
13
- RH-Bugzilla: 1939363
14
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
15
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
16
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
17
-
18
- Bugzilla: https://bugzilla.redhat.com/1939363
19
-
20
- Upstream Status: git://git.qemu.org/qemu.git
21
-
22
- commit 8170ab3f43989680491d00f1017f60b25d346114
23
- Author: Eugenio Pérez <eperezma@redhat.com>
24
- Date: Wed Jul 20 08:59:44 2022 +0200
25
-
26
- vdpa: Extract get features part from vhost_vdpa_get_max_queue_pairs
27
-
28
- To know the device features is needed for CVQ SVQ, so SVQ knows if it
29
- can handle all commands or not. Extract from
30
- vhost_vdpa_get_max_queue_pairs so we can reuse it.
31
-
32
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
33
- Acked-by: Jason Wang <jasowang@redhat.com>
34
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
35
- Signed-off-by: Jason Wang <jasowang@redhat.com>
36
-
37
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
38
- ---
39
- net/vhost-vdpa.c | 30 ++++++++++++++++++++----------
40
- 1 file changed, 20 insertions(+), 10 deletions(-)
41
-
42
- diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
43
- index df42822463..8b76dac966 100644
44
- --- a/net/vhost-vdpa.c
45
- +++ b/net/vhost-vdpa.c
46
- @@ -474,20 +474,24 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
47
- return nc;
48
- }
49
-
50
- -static int vhost_vdpa_get_max_queue_pairs(int fd, int *has_cvq, Error **errp)
51
- +static int vhost_vdpa_get_features(int fd, uint64_t *features, Error **errp)
52
- +{
53
- + int ret = ioctl(fd, VHOST_GET_FEATURES, features);
54
- + if (unlikely(ret < 0)) {
55
- + error_setg_errno(errp, errno,
56
- + "Fail to query features from vhost-vDPA device");
57
- + }
58
- + return ret;
59
- +}
60
- +
61
- +static int vhost_vdpa_get_max_queue_pairs(int fd, uint64_t features,
62
- + int *has_cvq, Error **errp)
63
- {
64
- unsigned long config_size = offsetof(struct vhost_vdpa_config, buf);
65
- g_autofree struct vhost_vdpa_config *config = NULL;
66
- __virtio16 *max_queue_pairs;
67
- - uint64_t features;
68
- int ret;
69
-
70
- - ret = ioctl(fd, VHOST_GET_FEATURES, &features);
71
- - if (ret) {
72
- - error_setg(errp, "Fail to query features from vhost-vDPA device");
73
- - return ret;
74
- - }
75
- -
76
- if (features & (1 << VIRTIO_NET_F_CTRL_VQ)) {
77
- *has_cvq = 1;
78
- } else {
79
- @@ -517,10 +521,11 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
80
- NetClientState *peer, Error **errp)
81
- {
82
- const NetdevVhostVDPAOptions *opts;
83
- + uint64_t features;
84
- int vdpa_device_fd;
85
- g_autofree NetClientState **ncs = NULL;
86
- NetClientState *nc;
87
- - int queue_pairs, i, has_cvq = 0;
88
- + int queue_pairs, r, i, has_cvq = 0;
89
-
90
- assert(netdev->type == NET_CLIENT_DRIVER_VHOST_VDPA);
91
- opts = &netdev->u.vhost_vdpa;
92
- @@ -534,7 +539,12 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
93
- return -errno;
94
- }
95
-
96
- - queue_pairs = vhost_vdpa_get_max_queue_pairs(vdpa_device_fd,
97
- + r = vhost_vdpa_get_features(vdpa_device_fd, &features, errp);
98
- + if (unlikely(r < 0)) {
99
- + return r;
100
- + }
101
- +
102
- + queue_pairs = vhost_vdpa_get_max_queue_pairs(vdpa_device_fd, features,
103
- &has_cvq, errp);
104
- if (queue_pairs < 0) {
105
- qemu_close(vdpa_device_fd);
106
- --
107
- 2.31.1
108
-
SOURCES/kvm-vdpa-Fix-bad-index-calculus-at-vhost_vdpa_get_vring_.patch DELETED
@@ -1,50 +0,0 @@
1
- From e19adb058502e24580dbc4f6f944cd951ca288ed Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 12 May 2022 19:57:44 +0200
4
- Subject: [PATCH 08/11] vdpa: Fix bad index calculus at
5
- vhost_vdpa_get_vring_base
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
11
- RH-MergeRequest: 114: vdpa: Fix memory listener deletions of iova tree
12
- RH-Commit: [1/4] 754fb8960684fa7a91bddb18c8df58c3b947ee75 (eperezmartin/qemu-kvm)
13
- RH-Bugzilla: 2116876
14
- RH-Acked-by: Jason Wang <jasowang@redhat.com>
15
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
16
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
17
-
18
- Fixes: 6d0b222666 ("vdpa: Adapt vhost_vdpa_get_vring_base to SVQ")
19
-
20
- Acked-by: Jason Wang <jasowang@redhat.com>
21
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
22
- Message-Id: <20220512175747.142058-4-eperezma@redhat.com>
23
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
24
- Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
25
- (cherry picked from commit 639036477ef890958415967e753ca2cbb348c16c)
26
- ---
27
- hw/virtio/vhost-vdpa.c | 4 ++--
28
- 1 file changed, 2 insertions(+), 2 deletions(-)
29
-
30
- diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
31
- index e3e5bce4bb..a7dfac530f 100644
32
- --- a/hw/virtio/vhost-vdpa.c
33
- +++ b/hw/virtio/vhost-vdpa.c
34
- @@ -1193,11 +1193,11 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
35
- struct vhost_vring_state *ring)
36
- {
37
- struct vhost_vdpa *v = dev->opaque;
38
- + int vdpa_idx = ring->index - dev->vq_index;
39
- int ret;
40
-
41
- if (v->shadow_vqs_enabled) {
42
- - VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs,
43
- - ring->index);
44
- + VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, vdpa_idx);
45
-
46
- /*
47
- * Setting base as last used idx, so destination will see as available
48
- --
49
- 2.31.1
50
-
SOURCES/kvm-vdpa-Fix-file-descriptor-leak-on-get-features-error.patch DELETED
@@ -1,58 +0,0 @@
1
- From 71857062b7aea29fc418e107244cf4083cd78cd7 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Tue, 2 Aug 2022 13:24:46 +0200
4
- Subject: [PATCH 11/11] vdpa: Fix file descriptor leak on get features error
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 114: vdpa: Fix memory listener deletions of iova tree
11
- RH-Commit: [4/4] bdfe6ed4539ecf68dc8bc4519755f9d5c096447d (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 2116876
13
- RH-Acked-by: Jason Wang <jasowang@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- File descriptor vdpa_device_fd is not free in the case of returning
18
- error from vhost_vdpa_get_features. Fixing it by making all errors go to
19
- the same error path.
20
-
21
- Resolves: Coverity CID 1490785
22
- Fixes: 8170ab3f43 ("vdpa: Extract get features part from vhost_vdpa_get_max_queue_pairs")
23
-
24
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
25
- Reviewed-by: Laurent Vivier <lvivier@redhat.com>
26
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
27
- Message-Id: <20220802112447.249436-2-eperezma@redhat.com>
28
- Signed-off-by: Laurent Vivier <laurent@vivier.eu>
29
- (cherry picked from commit aed5da45daf734ddc543c0791e877dac75e16f61)
30
- ---
31
- net/vhost-vdpa.c | 4 ++--
32
- 1 file changed, 2 insertions(+), 2 deletions(-)
33
-
34
- diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
35
- index 50672bcd66..411e71e6c2 100644
36
- --- a/net/vhost-vdpa.c
37
- +++ b/net/vhost-vdpa.c
38
- @@ -566,7 +566,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
39
- g_autofree NetClientState **ncs = NULL;
40
- g_autoptr(VhostIOVATree) iova_tree = NULL;
41
- NetClientState *nc;
42
- - int queue_pairs, r, i, has_cvq = 0;
43
- + int queue_pairs, r, i = 0, has_cvq = 0;
44
-
45
- assert(netdev->type == NET_CLIENT_DRIVER_VHOST_VDPA);
46
- opts = &netdev->u.vhost_vdpa;
47
- @@ -582,7 +582,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
48
-
49
- r = vhost_vdpa_get_features(vdpa_device_fd, &features, errp);
50
- if (unlikely(r < 0)) {
51
- - return r;
52
- + goto err;
53
- }
54
-
55
- queue_pairs = vhost_vdpa_get_max_queue_pairs(vdpa_device_fd, features,
56
- --
57
- 2.31.1
58
-
SOURCES/kvm-vdpa-Fix-index-calculus-at-vhost_vdpa_svqs_start.patch DELETED
@@ -1,45 +0,0 @@
1
- From 6335431b70dd55c1d52152d726fa462db2e10eb8 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 12 May 2022 19:57:45 +0200
4
- Subject: [PATCH 09/11] vdpa: Fix index calculus at vhost_vdpa_svqs_start
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 114: vdpa: Fix memory listener deletions of iova tree
11
- RH-Commit: [2/4] 9ce732e6bba426f8e00020ee6ad77f972f3e75b5 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 2116876
13
- RH-Acked-by: Jason Wang <jasowang@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- With the introduction of MQ the index of the vq needs to be calculated
18
- with the device model vq_index.
19
-
20
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
21
- Acked-by: Jason Wang <jasowang@redhat.com>
22
- Message-Id: <20220512175747.142058-5-eperezma@redhat.com>
23
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
24
- Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
25
- (cherry picked from commit 1c82fdfef8a227518ffecae9d419bcada995c202)
26
- ---
27
- hw/virtio/vhost-vdpa.c | 2 +-
28
- 1 file changed, 1 insertion(+), 1 deletion(-)
29
-
30
- diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
31
- index a7dfac530f..f877b354fa 100644
32
- --- a/hw/virtio/vhost-vdpa.c
33
- +++ b/hw/virtio/vhost-vdpa.c
34
- @@ -1032,7 +1032,7 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *dev)
35
- VirtQueue *vq = virtio_get_queue(dev->vdev, dev->vq_index + i);
36
- VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
37
- struct vhost_vring_addr addr = {
38
- - .index = i,
39
- + .index = dev->vq_index + i,
40
- };
41
- int r;
42
- bool ok = vhost_vdpa_svq_setup(dev, svq, i, &err);
43
- --
44
- 2.31.1
45
-
SOURCES/kvm-vdpa-Fix-memory-listener-deletions-of-iova-tree.patch DELETED
@@ -1,61 +0,0 @@
1
- From b212edc97a471c75f8b8b44ee2a3a2cf82ef14d9 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Fri, 22 Jul 2022 10:26:30 +0200
4
- Subject: [PATCH 10/11] vdpa: Fix memory listener deletions of iova tree
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 114: vdpa: Fix memory listener deletions of iova tree
11
- RH-Commit: [3/4] ad71f098b3fa8654962ac7872b5393c37c9825f2 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 2116876
13
- RH-Acked-by: Jason Wang <jasowang@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- vhost_vdpa_listener_region_del is always deleting the first iova entry
18
- of the tree, since it's using the needle iova instead of the result's
19
- one.
20
-
21
- This was detected using a vga virtual device in the VM using vdpa SVQ.
22
- It makes some extra memory adding and deleting, so the wrong one was
23
- mapped / unmapped. This was undetected before since all the memory was
24
- mappend and unmapped totally without that device, but other conditions
25
- could trigger it too:
26
-
27
- * mem_region was with .iova = 0, .translated_addr = (correct GPA).
28
- * iova_tree_find_iova returned right result, but does not update
29
- mem_region.
30
- * iova_tree_remove always removed region with .iova = 0. Right iova were
31
- sent to the device.
32
- * Next map will fill the first region with .iova = 0, causing a mapping
33
- with the same iova and device complains, if the next action is a map.
34
- * Next unmap will cause to try to unmap again iova = 0, causing the
35
- device to complain that no region was mapped at iova = 0.
36
-
37
- Fixes: 34e3c94edaef ("vdpa: Add custom IOTLB translations to SVQ")
38
- Reported-by: Lei Yang <leiyang@redhat.com>
39
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
40
- Signed-off-by: Jason Wang <jasowang@redhat.com>
41
- (cherry picked from commit 75a8ce64f6e37513698857fb4284170da163ed06)
42
- ---
43
- hw/virtio/vhost-vdpa.c | 2 +-
44
- 1 file changed, 1 insertion(+), 1 deletion(-)
45
-
46
- diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
47
- index f877b354fa..03dc6014b0 100644
48
- --- a/hw/virtio/vhost-vdpa.c
49
- +++ b/hw/virtio/vhost-vdpa.c
50
- @@ -288,7 +288,7 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,
51
-
52
- result = vhost_iova_tree_find_iova(v->iova_tree, &mem_region);
53
- iova = result->iova;
54
- - vhost_iova_tree_remove(v->iova_tree, &mem_region);
55
- + vhost_iova_tree_remove(v->iova_tree, result);
56
- }
57
- vhost_vdpa_iotlb_batch_begin_once(v);
58
- ret = vhost_vdpa_dma_unmap(v, iova, int128_get64(llsize));
59
- --
60
- 2.31.1
61
-
SOURCES/kvm-vdpa-add-asid-parameter-to-vhost_vdpa_dma_map-unmap.patch ADDED
@@ -0,0 +1,221 @@
1
+ From d0e7f24a8d941ab142f2a1973ae18ed1bfdc074f Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
+ Date: Thu, 15 Dec 2022 12:31:41 +0100
4
+ Subject: [PATCH 09/14] vdpa: add asid parameter to vhost_vdpa_dma_map/unmap
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
+ RH-MergeRequest: 136: vDPA ASID support in Qemu
11
+ RH-Bugzilla: 2104412
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [9/13] 3e7f89e57f73661017ccf0206f2ea77a72ca46bb (eperezmartin/qemu-kvm)
16
+
17
+ So the caller can choose which ASID is destined.
18
+
19
+ No need to update the batch functions as they will always be called from
20
+ memory listener updates at the moment. Memory listener updates will
21
+ always update ASID 0, as it's the passthrough ASID.
22
+
23
+ All vhost devices's ASID are 0 at this moment.
24
+
25
+ Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
26
+ Acked-by: Jason Wang <jasowang@redhat.com>
27
+ Message-Id: <20221215113144.322011-10-eperezma@redhat.com>
28
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
29
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
30
+ (cherry picked from commit cd831ed5c4add8ed6ee980c3645b241cbef5130f)
31
+ ---
32
+ hw/virtio/trace-events | 4 ++--
33
+ hw/virtio/vhost-vdpa.c | 36 +++++++++++++++++++++++-----------
34
+ include/hw/virtio/vhost-vdpa.h | 14 ++++++++++---
35
+ net/vhost-vdpa.c | 6 +++---
36
+ 4 files changed, 41 insertions(+), 19 deletions(-)
37
+
38
+ diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
39
+ index 46f2faf04e..a87c5f39a2 100644
40
+ --- a/hw/virtio/trace-events
41
+ +++ b/hw/virtio/trace-events
42
+ @@ -30,8 +30,8 @@ vhost_user_write(uint32_t req, uint32_t flags) "req:%d flags:0x%"PRIx32""
43
+ vhost_user_create_notifier(int idx, void *n) "idx:%d n:%p"
44
+
45
+ # vhost-vdpa.c
46
+ -vhost_vdpa_dma_map(void *vdpa, int fd, uint32_t msg_type, uint64_t iova, uint64_t size, uint64_t uaddr, uint8_t perm, uint8_t type) "vdpa:%p fd: %d msg_type: %"PRIu32" iova: 0x%"PRIx64" size: 0x%"PRIx64" uaddr: 0x%"PRIx64" perm: 0x%"PRIx8" type: %"PRIu8
47
+ -vhost_vdpa_dma_unmap(void *vdpa, int fd, uint32_t msg_type, uint64_t iova, uint64_t size, uint8_t type) "vdpa:%p fd: %d msg_type: %"PRIu32" iova: 0x%"PRIx64" size: 0x%"PRIx64" type: %"PRIu8
48
+ +vhost_vdpa_dma_map(void *vdpa, int fd, uint32_t msg_type, uint32_t asid, uint64_t iova, uint64_t size, uint64_t uaddr, uint8_t perm, uint8_t type) "vdpa:%p fd: %d msg_type: %"PRIu32" asid: %"PRIu32" iova: 0x%"PRIx64" size: 0x%"PRIx64" uaddr: 0x%"PRIx64" perm: 0x%"PRIx8" type: %"PRIu8
49
+ +vhost_vdpa_dma_unmap(void *vdpa, int fd, uint32_t msg_type, uint32_t asid, uint64_t iova, uint64_t size, uint8_t type) "vdpa:%p fd: %d msg_type: %"PRIu32" asid: %"PRIu32" iova: 0x%"PRIx64" size: 0x%"PRIx64" type: %"PRIu8
50
+ vhost_vdpa_listener_begin_batch(void *v, int fd, uint32_t msg_type, uint8_t type) "vdpa:%p fd: %d msg_type: %"PRIu32" type: %"PRIu8
51
+ vhost_vdpa_listener_commit(void *v, int fd, uint32_t msg_type, uint8_t type) "vdpa:%p fd: %d msg_type: %"PRIu32" type: %"PRIu8
52
+ vhost_vdpa_listener_region_add(void *vdpa, uint64_t iova, uint64_t llend, void *vaddr, bool readonly) "vdpa: %p iova 0x%"PRIx64" llend 0x%"PRIx64" vaddr: %p read-only: %d"
53
+ diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
54
+ index dd2768634b..0ecf2bbaa0 100644
55
+ --- a/hw/virtio/vhost-vdpa.c
56
+ +++ b/hw/virtio/vhost-vdpa.c
57
+ @@ -72,22 +72,28 @@ static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *section,
58
+ return false;
59
+ }
60
+
61
+ -int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
62
+ - void *vaddr, bool readonly)
63
+ +/*
64
+ + * The caller must set asid = 0 if the device does not support asid.
65
+ + * This is not an ABI break since it is set to 0 by the initializer anyway.
66
+ + */
67
+ +int vhost_vdpa_dma_map(struct vhost_vdpa *v, uint32_t asid, hwaddr iova,
68
+ + hwaddr size, void *vaddr, bool readonly)
69
+ {
70
+ struct vhost_msg_v2 msg = {};
71
+ int fd = v->device_fd;
72
+ int ret = 0;
73
+
74
+ msg.type = v->msg_type;
75
+ + msg.asid = asid;
76
+ msg.iotlb.iova = iova;
77
+ msg.iotlb.size = size;
78
+ msg.iotlb.uaddr = (uint64_t)(uintptr_t)vaddr;
79
+ msg.iotlb.perm = readonly ? VHOST_ACCESS_RO : VHOST_ACCESS_RW;
80
+ msg.iotlb.type = VHOST_IOTLB_UPDATE;
81
+
82
+ - trace_vhost_vdpa_dma_map(v, fd, msg.type, msg.iotlb.iova, msg.iotlb.size,
83
+ - msg.iotlb.uaddr, msg.iotlb.perm, msg.iotlb.type);
84
+ + trace_vhost_vdpa_dma_map(v, fd, msg.type, msg.asid, msg.iotlb.iova,
85
+ + msg.iotlb.size, msg.iotlb.uaddr, msg.iotlb.perm,
86
+ + msg.iotlb.type);
87
+
88
+ if (write(fd, &msg, sizeof(msg)) != sizeof(msg)) {
89
+ error_report("failed to write, fd=%d, errno=%d (%s)",
90
+ @@ -98,18 +104,24 @@ int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
91
+ return ret;
92
+ }
93
+
94
+ -int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, hwaddr iova, hwaddr size)
95
+ +/*
96
+ + * The caller must set asid = 0 if the device does not support asid.
97
+ + * This is not an ABI break since it is set to 0 by the initializer anyway.
98
+ + */
99
+ +int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, uint32_t asid, hwaddr iova,
100
+ + hwaddr size)
101
+ {
102
+ struct vhost_msg_v2 msg = {};
103
+ int fd = v->device_fd;
104
+ int ret = 0;
105
+
106
+ msg.type = v->msg_type;
107
+ + msg.asid = asid;
108
+ msg.iotlb.iova = iova;
109
+ msg.iotlb.size = size;
110
+ msg.iotlb.type = VHOST_IOTLB_INVALIDATE;
111
+
112
+ - trace_vhost_vdpa_dma_unmap(v, fd, msg.type, msg.iotlb.iova,
113
+ + trace_vhost_vdpa_dma_unmap(v, fd, msg.type, msg.asid, msg.iotlb.iova,
114
+ msg.iotlb.size, msg.iotlb.type);
115
+
116
+ if (write(fd, &msg, sizeof(msg)) != sizeof(msg)) {
117
+ @@ -229,8 +241,8 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener,
118
+ }
119
+
120
+ vhost_vdpa_iotlb_batch_begin_once(v);
121
+ - ret = vhost_vdpa_dma_map(v, iova, int128_get64(llsize),
122
+ - vaddr, section->readonly);
123
+ + ret = vhost_vdpa_dma_map(v, VHOST_VDPA_GUEST_PA_ASID, iova,
124
+ + int128_get64(llsize), vaddr, section->readonly);
125
+ if (ret) {
126
+ error_report("vhost vdpa map fail!");
127
+ goto fail_map;
128
+ @@ -303,7 +315,8 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,
129
+ vhost_iova_tree_remove(v->iova_tree, *result);
130
+ }
131
+ vhost_vdpa_iotlb_batch_begin_once(v);
132
+ - ret = vhost_vdpa_dma_unmap(v, iova, int128_get64(llsize));
133
+ + ret = vhost_vdpa_dma_unmap(v, VHOST_VDPA_GUEST_PA_ASID, iova,
134
+ + int128_get64(llsize));
135
+ if (ret) {
136
+ error_report("vhost_vdpa dma unmap error!");
137
+ }
138
+ @@ -876,7 +889,7 @@ static void vhost_vdpa_svq_unmap_ring(struct vhost_vdpa *v, hwaddr addr)
139
+ }
140
+
141
+ size = ROUND_UP(result->size, qemu_real_host_page_size());
142
+ - r = vhost_vdpa_dma_unmap(v, result->iova, size);
143
+ + r = vhost_vdpa_dma_unmap(v, v->address_space_id, result->iova, size);
144
+ if (unlikely(r < 0)) {
145
+ error_report("Unable to unmap SVQ vring: %s (%d)", g_strerror(-r), -r);
146
+ return;
147
+ @@ -916,7 +929,8 @@ static bool vhost_vdpa_svq_map_ring(struct vhost_vdpa *v, DMAMap *needle,
148
+ return false;
149
+ }
150
+
151
+ - r = vhost_vdpa_dma_map(v, needle->iova, needle->size + 1,
152
+ + r = vhost_vdpa_dma_map(v, v->address_space_id, needle->iova,
153
+ + needle->size + 1,
154
+ (void *)(uintptr_t)needle->translated_addr,
155
+ needle->perm == IOMMU_RO);
156
+ if (unlikely(r != 0)) {
157
+ diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
158
+ index 1111d85643..e57dfa1fd1 100644
159
+ --- a/include/hw/virtio/vhost-vdpa.h
160
+ +++ b/include/hw/virtio/vhost-vdpa.h
161
+ @@ -19,6 +19,12 @@
162
+ #include "hw/virtio/virtio.h"
163
+ #include "standard-headers/linux/vhost_types.h"
164
+
165
+ +/*
166
+ + * ASID dedicated to map guest's addresses. If SVQ is disabled it maps GPA to
167
+ + * qemu's IOVA. If SVQ is enabled it maps also the SVQ vring here
168
+ + */
169
+ +#define VHOST_VDPA_GUEST_PA_ASID 0
170
+ +
171
+ typedef struct VhostVDPAHostNotifier {
172
+ MemoryRegion mr;
173
+ void *addr;
174
+ @@ -29,6 +35,7 @@ typedef struct vhost_vdpa {
175
+ int index;
176
+ uint32_t msg_type;
177
+ bool iotlb_batch_begin_sent;
178
+ + uint32_t address_space_id;
179
+ MemoryListener listener;
180
+ struct vhost_vdpa_iova_range iova_range;
181
+ uint64_t acked_features;
182
+ @@ -42,8 +49,9 @@ typedef struct vhost_vdpa {
183
+ VhostVDPAHostNotifier notifier[VIRTIO_QUEUE_MAX];
184
+ } VhostVDPA;
185
+
186
+ -int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
187
+ - void *vaddr, bool readonly);
188
+ -int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, hwaddr iova, hwaddr size);
189
+ +int vhost_vdpa_dma_map(struct vhost_vdpa *v, uint32_t asid, hwaddr iova,
190
+ + hwaddr size, void *vaddr, bool readonly);
191
+ +int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, uint32_t asid, hwaddr iova,
192
+ + hwaddr size);
193
+
194
+ #endif
195
+ diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
196
+ index 85aa0da39a..c2f319eb88 100644
197
+ --- a/net/vhost-vdpa.c
198
+ +++ b/net/vhost-vdpa.c
199
+ @@ -258,7 +258,7 @@ static void vhost_vdpa_cvq_unmap_buf(struct vhost_vdpa *v, void *addr)
200
+ return;
201
+ }
202
+
203
+ - r = vhost_vdpa_dma_unmap(v, map->iova, map->size + 1);
204
+ + r = vhost_vdpa_dma_unmap(v, v->address_space_id, map->iova, map->size + 1);
205
+ if (unlikely(r != 0)) {
206
+ error_report("Device cannot unmap: %s(%d)", g_strerror(r), r);
207
+ }
208
+ @@ -298,8 +298,8 @@ static int vhost_vdpa_cvq_map_buf(struct vhost_vdpa *v, void *buf, size_t size,
209
+ return r;
210
+ }
211
+
212
+ - r = vhost_vdpa_dma_map(v, map.iova, vhost_vdpa_net_cvq_cmd_page_len(), buf,
213
+ - !write);
214
+ + r = vhost_vdpa_dma_map(v, v->address_space_id, map.iova,
215
+ + vhost_vdpa_net_cvq_cmd_page_len(), buf, !write);
216
+ if (unlikely(r < 0)) {
217
+ goto dma_map_err;
218
+ }
219
+ --
220
+ 2.31.1
221
+
SOURCES/kvm-vdpa-add-shadow_data-to-vhost_vdpa.patch ADDED
@@ -0,0 +1,94 @@
1
+ From 6282a83619f274ca45a52d61577c10a05a0714dc Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
+ Date: Thu, 15 Dec 2022 12:31:43 +0100
4
+ Subject: [PATCH 11/14] vdpa: add shadow_data to vhost_vdpa
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
+ RH-MergeRequest: 136: vDPA ASID support in Qemu
11
+ RH-Bugzilla: 2104412
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [11/13] 9d317add1318b555ba06e19e4c67849069e047b9 (eperezmartin/qemu-kvm)
16
+
17
+ The memory listener that thells the device how to convert GPA to qemu's
18
+ va is registered against CVQ vhost_vdpa. memory listener translations
19
+ are always ASID 0, CVQ ones are ASID 1 if supported.
20
+
21
+ Let's tell the listener if it needs to register them on iova tree or
22
+ not.
23
+
24
+ Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
25
+ Acked-by: Jason Wang <jasowang@redhat.com>
26
+ Message-Id: <20221215113144.322011-12-eperezma@redhat.com>
27
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
28
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
29
+ (cherry picked from commit 6188d78a19894ac8f2bf9484d48a5235a529d3b7)
30
+ ---
31
+ hw/virtio/vhost-vdpa.c | 6 +++---
32
+ include/hw/virtio/vhost-vdpa.h | 2 ++
33
+ net/vhost-vdpa.c | 1 +
34
+ 3 files changed, 6 insertions(+), 3 deletions(-)
35
+
36
+ diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
37
+ index 0ecf2bbaa0..dc3498e995 100644
38
+ --- a/hw/virtio/vhost-vdpa.c
39
+ +++ b/hw/virtio/vhost-vdpa.c
40
+ @@ -224,7 +224,7 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener,
41
+ vaddr, section->readonly);
42
+
43
+ llsize = int128_sub(llend, int128_make64(iova));
44
+ - if (v->shadow_vqs_enabled) {
45
+ + if (v->shadow_data) {
46
+ int r;
47
+
48
+ mem_region.translated_addr = (hwaddr)(uintptr_t)vaddr,
49
+ @@ -251,7 +251,7 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener,
50
+ return;
51
+
52
+ fail_map:
53
+ - if (v->shadow_vqs_enabled) {
54
+ + if (v->shadow_data) {
55
+ vhost_iova_tree_remove(v->iova_tree, mem_region);
56
+ }
57
+
58
+ @@ -296,7 +296,7 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,
59
+
60
+ llsize = int128_sub(llend, int128_make64(iova));
61
+
62
+ - if (v->shadow_vqs_enabled) {
63
+ + if (v->shadow_data) {
64
+ const DMAMap *result;
65
+ const void *vaddr = memory_region_get_ram_ptr(section->mr) +
66
+ section->offset_within_region +
67
+ diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
68
+ index e57dfa1fd1..45b969a311 100644
69
+ --- a/include/hw/virtio/vhost-vdpa.h
70
+ +++ b/include/hw/virtio/vhost-vdpa.h
71
+ @@ -40,6 +40,8 @@ typedef struct vhost_vdpa {
72
+ struct vhost_vdpa_iova_range iova_range;
73
+ uint64_t acked_features;
74
+ bool shadow_vqs_enabled;
75
+ + /* Vdpa must send shadow addresses as IOTLB key for data queues, not GPA */
76
+ + bool shadow_data;
77
+ /* IOVA mapping used by the Shadow Virtqueue */
78
+ VhostIOVATree *iova_tree;
79
+ GPtrArray *shadow_vqs;
80
+ diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
81
+ index 1757f1d028..eea7a0df12 100644
82
+ --- a/net/vhost-vdpa.c
83
+ +++ b/net/vhost-vdpa.c
84
+ @@ -581,6 +581,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
85
+ s->always_svq = svq;
86
+ s->vhost_vdpa.shadow_vqs_enabled = svq;
87
+ s->vhost_vdpa.iova_range = iova_range;
88
+ + s->vhost_vdpa.shadow_data = svq;
89
+ s->vhost_vdpa.iova_tree = iova_tree;
90
+ if (!is_datapath) {
91
+ s->cvq_cmd_out_buffer = qemu_memalign(qemu_real_host_page_size(),
92
+ --
93
+ 2.31.1
94
+
SOURCES/kvm-vdpa-add-vhost_vdpa_net_valid_svq_features.patch ADDED
@@ -0,0 +1,76 @@
1
+ From 0f3a28e1e128754184c4af6a578f27e16c6a61d5 Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
+ Date: Thu, 15 Dec 2022 12:31:37 +0100
4
+ Subject: [PATCH 05/14] vdpa: add vhost_vdpa_net_valid_svq_features
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
+ RH-MergeRequest: 136: vDPA ASID support in Qemu
11
+ RH-Bugzilla: 2104412
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [5/13] 0b27e04f178ec73cb800f4fb05c17a92576142e4 (eperezmartin/qemu-kvm)
16
+
17
+ It will be reused at vdpa device start so let's extract in its own
18
+ function.
19
+
20
+ Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
21
+ Acked-by: Jason Wang <jasowang@redhat.com>
22
+ Message-Id: <20221215113144.322011-6-eperezma@redhat.com>
23
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
24
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
25
+ (cherry picked from commit 36e4647247f200b6fa4d2f656133f567036e8a85)
26
+ ---
27
+ net/vhost-vdpa.c | 26 +++++++++++++++++---------
28
+ 1 file changed, 17 insertions(+), 9 deletions(-)
29
+
30
+ diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
31
+ index b06540ac89..16a5ebe2dd 100644
32
+ --- a/net/vhost-vdpa.c
33
+ +++ b/net/vhost-vdpa.c
34
+ @@ -106,6 +106,22 @@ VHostNetState *vhost_vdpa_get_vhost_net(NetClientState *nc)
35
+ return s->vhost_net;
36
+ }
37
+
38
+ +static bool vhost_vdpa_net_valid_svq_features(uint64_t features, Error **errp)
39
+ +{
40
+ + uint64_t invalid_dev_features =
41
+ + features & ~vdpa_svq_device_features &
42
+ + /* Transport are all accepted at this point */
43
+ + ~MAKE_64BIT_MASK(VIRTIO_TRANSPORT_F_START,
44
+ + VIRTIO_TRANSPORT_F_END - VIRTIO_TRANSPORT_F_START);
45
+ +
46
+ + if (invalid_dev_features) {
47
+ + error_setg(errp, "vdpa svq does not work with features 0x%" PRIx64,
48
+ + invalid_dev_features);
49
+ + }
50
+ +
51
+ + return !invalid_dev_features;
52
+ +}
53
+ +
54
+ static int vhost_vdpa_net_check_device_id(struct vhost_net *net)
55
+ {
56
+ uint32_t device_id;
57
+ @@ -684,15 +700,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
58
+ if (opts->x_svq) {
59
+ struct vhost_vdpa_iova_range iova_range;
60
+
61
+ - uint64_t invalid_dev_features =
62
+ - features & ~vdpa_svq_device_features &
63
+ - /* Transport are all accepted at this point */
64
+ - ~MAKE_64BIT_MASK(VIRTIO_TRANSPORT_F_START,
65
+ - VIRTIO_TRANSPORT_F_END - VIRTIO_TRANSPORT_F_START);
66
+ -
67
+ - if (invalid_dev_features) {
68
+ - error_setg(errp, "vdpa svq does not work with features 0x%" PRIx64,
69
+ - invalid_dev_features);
70
+ + if (!vhost_vdpa_net_valid_svq_features(features, errp)) {
71
+ goto err_svq;
72
+ }
73
+
74
+ --
75
+ 2.31.1
76
+
SOURCES/kvm-vdpa-allocate-SVQ-array-unconditionally.patch ADDED
@@ -0,0 +1,50 @@
1
+ From 72f296870805750df8dfe5eaad77dd7d435a8f41 Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
+ Date: Thu, 15 Dec 2022 12:31:40 +0100
4
+ Subject: [PATCH 08/14] vdpa: allocate SVQ array unconditionally
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
+ RH-MergeRequest: 136: vDPA ASID support in Qemu
11
+ RH-Bugzilla: 2104412
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [8/13] 08cd86d0859f82d768794e29241cfeff25df667c (eperezmartin/qemu-kvm)
16
+
17
+ SVQ may run or not in a device depending on runtime conditions (for
18
+ example, if the device can move CVQ to its own group or not).
19
+
20
+ Allocate the SVQ array unconditionally at startup, since its hard to
21
+ move this allocation elsewhere.
22
+
23
+ Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
24
+ Acked-by: Jason Wang <jasowang@redhat.com>
25
+ Message-Id: <20221215113144.322011-9-eperezma@redhat.com>
26
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
27
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
28
+ (cherry picked from commit 273e0003f0005cc17292dedae01e5edb0064b69c)
29
+ ---
30
+ hw/virtio/vhost-vdpa.c | 4 ----
31
+ 1 file changed, 4 deletions(-)
32
+
33
+ diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
34
+ index 84218ce078..dd2768634b 100644
35
+ --- a/hw/virtio/vhost-vdpa.c
36
+ +++ b/hw/virtio/vhost-vdpa.c
37
+ @@ -532,10 +532,6 @@ static void vhost_vdpa_svq_cleanup(struct vhost_dev *dev)
38
+ struct vhost_vdpa *v = dev->opaque;
39
+ size_t idx;
40
+
41
+ - if (!v->shadow_vqs) {
42
+ - return;
43
+ - }
44
+ -
45
+ for (idx = 0; idx < v->shadow_vqs->len; ++idx) {
46
+ vhost_svq_stop(g_ptr_array_index(v->shadow_vqs, idx));
47
+ }
48
+ --
49
+ 2.31.1
50
+
SOURCES/kvm-vdpa-always-start-CVQ-in-SVQ-mode-if-possible.patch ADDED
@@ -0,0 +1,193 @@
1
+ From 84c203faa570b85eec006215768c83371c9f0399 Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
+ Date: Thu, 15 Dec 2022 12:31:44 +0100
4
+ Subject: [PATCH 12/14] vdpa: always start CVQ in SVQ mode if possible
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
+ RH-MergeRequest: 136: vDPA ASID support in Qemu
11
+ RH-Bugzilla: 2104412
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [12/13] 83f94b3e163ca38d08dbf7c111a4cfa7a44e3dc2 (eperezmartin/qemu-kvm)
16
+
17
+ Isolate control virtqueue in its own group, allowing to intercept control
18
+ commands but letting dataplane run totally passthrough to the guest.
19
+
20
+ Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
21
+ Message-Id: <20221215113144.322011-13-eperezma@redhat.com>
22
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
23
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
24
+ Acked-by: Jason Wang <jasowang@redhat.com>
25
+ (cherry picked from commit c1a1008685af0327d9d03f03d43bdb77e7af5bea)
26
+ ---
27
+ hw/virtio/vhost-vdpa.c | 3 +-
28
+ net/vhost-vdpa.c | 110 ++++++++++++++++++++++++++++++++++++++++-
29
+ 2 files changed, 111 insertions(+), 2 deletions(-)
30
+
31
+ diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
32
+ index dc3498e995..72ff06673c 100644
33
+ --- a/hw/virtio/vhost-vdpa.c
34
+ +++ b/hw/virtio/vhost-vdpa.c
35
+ @@ -638,7 +638,8 @@ static int vhost_vdpa_set_backend_cap(struct vhost_dev *dev)
36
+ {
37
+ uint64_t features;
38
+ uint64_t f = 0x1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2 |
39
+ - 0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH;
40
+ + 0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH |
41
+ + 0x1ULL << VHOST_BACKEND_F_IOTLB_ASID;
42
+ int r;
43
+
44
+ if (vhost_vdpa_call(dev, VHOST_GET_BACKEND_FEATURES, &features)) {
45
+ diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
46
+ index eea7a0df12..07d33dae26 100644
47
+ --- a/net/vhost-vdpa.c
48
+ +++ b/net/vhost-vdpa.c
49
+ @@ -101,6 +101,8 @@ static const uint64_t vdpa_svq_device_features =
50
+ BIT_ULL(VIRTIO_NET_F_RSC_EXT) |
51
+ BIT_ULL(VIRTIO_NET_F_STANDBY);
52
+
53
+ +#define VHOST_VDPA_NET_CVQ_ASID 1
54
+ +
55
+ VHostNetState *vhost_vdpa_get_vhost_net(NetClientState *nc)
56
+ {
57
+ VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
58
+ @@ -242,6 +244,40 @@ static NetClientInfo net_vhost_vdpa_info = {
59
+ .check_peer_type = vhost_vdpa_check_peer_type,
60
+ };
61
+
62
+ +static int64_t vhost_vdpa_get_vring_group(int device_fd, unsigned vq_index)
63
+ +{
64
+ + struct vhost_vring_state state = {
65
+ + .index = vq_index,
66
+ + };
67
+ + int r = ioctl(device_fd, VHOST_VDPA_GET_VRING_GROUP, &state);
68
+ +
69
+ + if (unlikely(r < 0)) {
70
+ + error_report("Cannot get VQ %u group: %s", vq_index,
71
+ + g_strerror(errno));
72
+ + return r;
73
+ + }
74
+ +
75
+ + return state.num;
76
+ +}
77
+ +
78
+ +static int vhost_vdpa_set_address_space_id(struct vhost_vdpa *v,
79
+ + unsigned vq_group,
80
+ + unsigned asid_num)
81
+ +{
82
+ + struct vhost_vring_state asid = {
83
+ + .index = vq_group,
84
+ + .num = asid_num,
85
+ + };
86
+ + int r;
87
+ +
88
+ + r = ioctl(v->device_fd, VHOST_VDPA_SET_GROUP_ASID, &asid);
89
+ + if (unlikely(r < 0)) {
90
+ + error_report("Can't set vq group %u asid %u, errno=%d (%s)",
91
+ + asid.index, asid.num, errno, g_strerror(errno));
92
+ + }
93
+ + return r;
94
+ +}
95
+ +
96
+ static void vhost_vdpa_cvq_unmap_buf(struct vhost_vdpa *v, void *addr)
97
+ {
98
+ VhostIOVATree *tree = v->iova_tree;
99
+ @@ -316,11 +352,75 @@ dma_map_err:
100
+ static int vhost_vdpa_net_cvq_start(NetClientState *nc)
101
+ {
102
+ VhostVDPAState *s;
103
+ - int r;
104
+ + struct vhost_vdpa *v;
105
+ + uint64_t backend_features;
106
+ + int64_t cvq_group;
107
+ + int cvq_index, r;
108
+
109
+ assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA);
110
+
111
+ s = DO_UPCAST(VhostVDPAState, nc, nc);
112
+ + v = &s->vhost_vdpa;
113
+ +
114
+ + v->shadow_data = s->always_svq;
115
+ + v->shadow_vqs_enabled = s->always_svq;
116
+ + s->vhost_vdpa.address_space_id = VHOST_VDPA_GUEST_PA_ASID;
117
+ +
118
+ + if (s->always_svq) {
119
+ + /* SVQ is already configured for all virtqueues */
120
+ + goto out;
121
+ + }
122
+ +
123
+ + /*
124
+ + * If we early return in these cases SVQ will not be enabled. The migration
125
+ + * will be blocked as long as vhost-vdpa backends will not offer _F_LOG.
126
+ + *
127
+ + * Calling VHOST_GET_BACKEND_FEATURES as they are not available in v->dev
128
+ + * yet.
129
+ + */
130
+ + r = ioctl(v->device_fd, VHOST_GET_BACKEND_FEATURES, &backend_features);
131
+ + if (unlikely(r < 0)) {
132
+ + error_report("Cannot get vdpa backend_features: %s(%d)",
133
+ + g_strerror(errno), errno);
134
+ + return -1;
135
+ + }
136
+ + if (!(backend_features & VHOST_BACKEND_F_IOTLB_ASID) ||
137
+ + !vhost_vdpa_net_valid_svq_features(v->dev->features, NULL)) {
138
+ + return 0;
139
+ + }
140
+ +
141
+ + /*
142
+ + * Check if all the virtqueues of the virtio device are in a different vq
143
+ + * than the last vq. VQ group of last group passed in cvq_group.
144
+ + */
145
+ + cvq_index = v->dev->vq_index_end - 1;
146
+ + cvq_group = vhost_vdpa_get_vring_group(v->device_fd, cvq_index);
147
+ + if (unlikely(cvq_group < 0)) {
148
+ + return cvq_group;
149
+ + }
150
+ + for (int i = 0; i < cvq_index; ++i) {
151
+ + int64_t group = vhost_vdpa_get_vring_group(v->device_fd, i);
152
+ +
153
+ + if (unlikely(group < 0)) {
154
+ + return group;
155
+ + }
156
+ +
157
+ + if (group == cvq_group) {
158
+ + return 0;
159
+ + }
160
+ + }
161
+ +
162
+ + r = vhost_vdpa_set_address_space_id(v, cvq_group, VHOST_VDPA_NET_CVQ_ASID);
163
+ + if (unlikely(r < 0)) {
164
+ + return r;
165
+ + }
166
+ +
167
+ + v->iova_tree = vhost_iova_tree_new(v->iova_range.first,
168
+ + v->iova_range.last);
169
+ + v->shadow_vqs_enabled = true;
170
+ + s->vhost_vdpa.address_space_id = VHOST_VDPA_NET_CVQ_ASID;
171
+ +
172
+ +out:
173
+ if (!s->vhost_vdpa.shadow_vqs_enabled) {
174
+ return 0;
175
+ }
176
+ @@ -349,6 +449,14 @@ static void vhost_vdpa_net_cvq_stop(NetClientState *nc)
177
+ if (s->vhost_vdpa.shadow_vqs_enabled) {
178
+ vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer);
179
+ vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->status);
180
+ + if (!s->always_svq) {
181
+ + /*
182
+ + * If only the CVQ is shadowed we can delete this safely.
183
+ + * If all the VQs are shadows this will be needed by the time the
184
+ + * device is started again to register SVQ vrings and similar.
185
+ + */
186
+ + g_clear_pointer(&s->vhost_vdpa.iova_tree, vhost_iova_tree_delete);
187
+ + }
188
+ }
189
+ }
190
+
191
+ --
192
+ 2.31.1
193
+
SOURCES/kvm-vdpa-do-not-handle-VIRTIO_NET_F_GUEST_ANNOUNCE-in-vh.patch ADDED
@@ -0,0 +1,44 @@
1
+ From fbb177ad84d562a20e51e71c73257d2ef85be2d9 Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
+ Date: Wed, 21 Dec 2022 12:50:15 +0100
4
+ Subject: [PATCH 4/9] vdpa: do not handle VIRTIO_NET_F_GUEST_ANNOUNCE in
5
+ vhost-vdpa
6
+ MIME-Version: 1.0
7
+ Content-Type: text/plain; charset=UTF-8
8
+ Content-Transfer-Encoding: 8bit
9
+
10
+ RH-Author: Eugenio Pérez <eperezma@redhat.com>
11
+ RH-MergeRequest: 137: vDPA net SVQ guest announce support
12
+ RH-Bugzilla: 2141088
13
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
14
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
+ RH-Acked-by: Jason Wang <jasowang@redhat.com>
16
+ RH-Commit: [4/4] b3960a8b3e4ca569b1b1e6ceccf2051d8c4b1079 (eperezmartin/qemu-kvm)
17
+
18
+ So qemu emulates it even in case the device does not support it.
19
+
20
+ Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
21
+ Acked-by: Jason Wang <jasowang@redhat.com>
22
+ Message-Id: <20221221115015.1400889-5-eperezma@redhat.com>
23
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
24
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
25
+ (cherry picked from commit 980003debddd18306ea2e1364b96598383c0e257)
26
+ ---
27
+ net/vhost-vdpa.c | 1 -
28
+ 1 file changed, 1 deletion(-)
29
+
30
+ diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
31
+ index 52ef9cb3a2..b06540ac89 100644
32
+ --- a/net/vhost-vdpa.c
33
+ +++ b/net/vhost-vdpa.c
34
+ @@ -72,7 +72,6 @@ const int vdpa_feature_bits[] = {
35
+ VIRTIO_F_RING_RESET,
36
+ VIRTIO_NET_F_RSS,
37
+ VIRTIO_NET_F_HASH_REPORT,
38
+ - VIRTIO_NET_F_GUEST_ANNOUNCE,
39
+ VIRTIO_NET_F_STATUS,
40
+ VHOST_INVALID_FEATURE_BIT
41
+ };
42
+ --
43
+ 2.31.1
44
+
SOURCES/kvm-vdpa-fix-VHOST_BACKEND_F_IOTLB_ASID-flag-check.patch ADDED
@@ -0,0 +1,48 @@
1
+ From 46e80a9350a02fdb5689638df96bc7389e953cf8 Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
+ Date: Tue, 17 Jan 2023 11:53:08 +0100
4
+ Subject: [PATCH 13/14] vdpa: fix VHOST_BACKEND_F_IOTLB_ASID flag check
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
+ RH-MergeRequest: 136: vDPA ASID support in Qemu
11
+ RH-Bugzilla: 2104412
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [13/13] b7fb4b8e9ea26b6664a9179ed0a88376acf5115f (eperezmartin/qemu-kvm)
16
+
17
+ VHOST_BACKEND_F_IOTLB_ASID is the feature bit, not the bitmask. Since
18
+ the device under test also provided VHOST_BACKEND_F_IOTLB_MSG_V2 and
19
+ VHOST_BACKEND_F_IOTLB_BATCH, this went unnoticed.
20
+
21
+ Fixes: c1a1008685 ("vdpa: always start CVQ in SVQ mode if possible")
22
+ Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
23
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
24
+ Acked-by: Jason Wang <jasowang@redhat.com>
25
+ Signed-off-by: Jason Wang <jasowang@redhat.com>
26
+
27
+ Upstream status: git@github.com:jasowang/qemu.git
28
+ (cherry picked from commit 2bd492bca521ee8594f1d5db8dc9aac126fc4f85)
29
+ ---
30
+ net/vhost-vdpa.c | 2 +-
31
+ 1 file changed, 1 insertion(+), 1 deletion(-)
32
+
33
+ diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
34
+ index 07d33dae26..7d9c4ea09d 100644
35
+ --- a/net/vhost-vdpa.c
36
+ +++ b/net/vhost-vdpa.c
37
+ @@ -384,7 +384,7 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc)
38
+ g_strerror(errno), errno);
39
+ return -1;
40
+ }
41
+ - if (!(backend_features & VHOST_BACKEND_F_IOTLB_ASID) ||
42
+ + if (!(backend_features & BIT_ULL(VHOST_BACKEND_F_IOTLB_ASID)) ||
43
+ !vhost_vdpa_net_valid_svq_features(v->dev->features, NULL)) {
44
+ return 0;
45
+ }
46
+ --
47
+ 2.31.1
48
+
SOURCES/kvm-vdpa-handle-VIRTIO_NET_CTRL_ANNOUNCE-in-vhost_vdpa_n.patch ADDED
@@ -0,0 +1,59 @@
1
+ From b71724e94c94acd6e09fed2b47be2901799c2353 Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
+ Date: Wed, 21 Dec 2022 12:50:14 +0100
4
+ Subject: [PATCH 3/9] vdpa: handle VIRTIO_NET_CTRL_ANNOUNCE in
5
+ vhost_vdpa_net_handle_ctrl_avail
6
+ MIME-Version: 1.0
7
+ Content-Type: text/plain; charset=UTF-8
8
+ Content-Transfer-Encoding: 8bit
9
+
10
+ RH-Author: Eugenio Pérez <eperezma@redhat.com>
11
+ RH-MergeRequest: 137: vDPA net SVQ guest announce support
12
+ RH-Bugzilla: 2141088
13
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
14
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
+ RH-Acked-by: Jason Wang <jasowang@redhat.com>
16
+ RH-Commit: [3/4] c4ef5b62a5d41911565b8960a88bb48d746ff6c7 (eperezmartin/qemu-kvm)
17
+
18
+ Since this capability is emulated by qemu shadowed CVQ cannot forward it
19
+ to the device. Process all that command within qemu.
20
+
21
+ Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
22
+ Message-Id: <20221221115015.1400889-4-eperezma@redhat.com>
23
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
24
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
25
+ Acked-by: Jason Wang <jasowang@redhat.com>
26
+ (cherry picked from commit 3f9a3eeb7ca6acd899e2205a9118928b4cd94e47)
27
+ ---
28
+ net/vhost-vdpa.c | 15 ++++++++++++---
29
+ 1 file changed, 12 insertions(+), 3 deletions(-)
30
+
31
+ diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
32
+ index 2b4b85d8f8..52ef9cb3a2 100644
33
+ --- a/net/vhost-vdpa.c
34
+ +++ b/net/vhost-vdpa.c
35
+ @@ -489,9 +489,18 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq,
36
+ out.iov_len = iov_to_buf(elem->out_sg, elem->out_num, 0,
37
+ s->cvq_cmd_out_buffer,
38
+ vhost_vdpa_net_cvq_cmd_len());
39
+ - dev_written = vhost_vdpa_net_cvq_add(s, out.iov_len, sizeof(status));
40
+ - if (unlikely(dev_written < 0)) {
41
+ - goto out;
42
+ + if (*(uint8_t *)s->cvq_cmd_out_buffer == VIRTIO_NET_CTRL_ANNOUNCE) {
43
+ + /*
44
+ + * Guest announce capability is emulated by qemu, so don't forward to
45
+ + * the device.
46
+ + */
47
+ + dev_written = sizeof(status);
48
+ + *s->status = VIRTIO_NET_OK;
49
+ + } else {
50
+ + dev_written = vhost_vdpa_net_cvq_add(s, out.iov_len, sizeof(status));
51
+ + if (unlikely(dev_written < 0)) {
52
+ + goto out;
53
+ + }
54
+ }
55
+
56
+ if (unlikely(dev_written < sizeof(status))) {
57
+ --
58
+ 2.31.1
59
+
SOURCES/kvm-vdpa-manual-forward-CVQ-buffers.patch DELETED
@@ -1,166 +0,0 @@
1
- From c33bc0b7f2b5cfa330a6d89d60ee94de129c65c1 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 16:05:38 +0200
4
- Subject: [PATCH 23/32] vdpa: manual forward CVQ buffers
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [23/27] ce128d5152be7eebf87e186eb8b58c2ed95aff6d (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit bd907ae4b00ebedad5e586af05ea3d6490318d45
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Wed Jul 20 08:59:42 2022 +0200
24
-
25
- vdpa: manual forward CVQ buffers
26
-
27
- Do a simple forwarding of CVQ buffers, the same work SVQ could do but
28
- through callbacks. No functional change intended.
29
-
30
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
31
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
32
- Signed-off-by: Jason Wang <jasowang@redhat.com>
33
-
34
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
35
- ---
36
- hw/virtio/vhost-vdpa.c | 3 +-
37
- include/hw/virtio/vhost-vdpa.h | 3 ++
38
- net/vhost-vdpa.c | 58 ++++++++++++++++++++++++++++++++++
39
- 3 files changed, 63 insertions(+), 1 deletion(-)
40
-
41
- diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
42
- index 14b02fe079..49effe5462 100644
43
- --- a/hw/virtio/vhost-vdpa.c
44
- +++ b/hw/virtio/vhost-vdpa.c
45
- @@ -417,7 +417,8 @@ static int vhost_vdpa_init_svq(struct vhost_dev *hdev, struct vhost_vdpa *v,
46
- for (unsigned n = 0; n < hdev->nvqs; ++n) {
47
- g_autoptr(VhostShadowVirtqueue) svq;
48
-
49
- - svq = vhost_svq_new(v->iova_tree, NULL, NULL);
50
- + svq = vhost_svq_new(v->iova_tree, v->shadow_vq_ops,
51
- + v->shadow_vq_ops_opaque);
52
- if (unlikely(!svq)) {
53
- error_setg(errp, "Cannot create svq %u", n);
54
- return -1;
55
- diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
56
- index 7214eb47dc..1111d85643 100644
57
- --- a/include/hw/virtio/vhost-vdpa.h
58
- +++ b/include/hw/virtio/vhost-vdpa.h
59
- @@ -15,6 +15,7 @@
60
- #include <gmodule.h>
61
-
62
- #include "hw/virtio/vhost-iova-tree.h"
63
- +#include "hw/virtio/vhost-shadow-virtqueue.h"
64
- #include "hw/virtio/virtio.h"
65
- #include "standard-headers/linux/vhost_types.h"
66
-
67
- @@ -35,6 +36,8 @@ typedef struct vhost_vdpa {
68
- /* IOVA mapping used by the Shadow Virtqueue */
69
- VhostIOVATree *iova_tree;
70
- GPtrArray *shadow_vqs;
71
- + const VhostShadowVirtqueueOps *shadow_vq_ops;
72
- + void *shadow_vq_ops_opaque;
73
- struct vhost_dev *dev;
74
- VhostVDPAHostNotifier notifier[VIRTIO_QUEUE_MAX];
75
- } VhostVDPA;
76
- diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
77
- index df1e69ee72..2e3b6b10d8 100644
78
- --- a/net/vhost-vdpa.c
79
- +++ b/net/vhost-vdpa.c
80
- @@ -11,11 +11,14 @@
81
-
82
- #include "qemu/osdep.h"
83
- #include "clients.h"
84
- +#include "hw/virtio/virtio-net.h"
85
- #include "net/vhost_net.h"
86
- #include "net/vhost-vdpa.h"
87
- #include "hw/virtio/vhost-vdpa.h"
88
- #include "qemu/config-file.h"
89
- #include "qemu/error-report.h"
90
- +#include "qemu/log.h"
91
- +#include "qemu/memalign.h"
92
- #include "qemu/option.h"
93
- #include "qapi/error.h"
94
- #include <linux/vhost.h>
95
- @@ -187,6 +190,57 @@ static NetClientInfo net_vhost_vdpa_info = {
96
- .check_peer_type = vhost_vdpa_check_peer_type,
97
- };
98
-
99
- +/**
100
- + * Forward buffer for the moment.
101
- + */
102
- +static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq,
103
- + VirtQueueElement *elem,
104
- + void *opaque)
105
- +{
106
- + unsigned int n = elem->out_num + elem->in_num;
107
- + g_autofree struct iovec *dev_buffers = g_new(struct iovec, n);
108
- + size_t in_len, dev_written;
109
- + virtio_net_ctrl_ack status = VIRTIO_NET_ERR;
110
- + int r;
111
- +
112
- + memcpy(dev_buffers, elem->out_sg, elem->out_num);
113
- + memcpy(dev_buffers + elem->out_num, elem->in_sg, elem->in_num);
114
- +
115
- + r = vhost_svq_add(svq, &dev_buffers[0], elem->out_num, &dev_buffers[1],
116
- + elem->in_num, elem);
117
- + if (unlikely(r != 0)) {
118
- + if (unlikely(r == -ENOSPC)) {
119
- + qemu_log_mask(LOG_GUEST_ERROR, "%s: No space on device queue\n",
120
- + __func__);
121
- + }
122
- + goto out;
123
- + }
124
- +
125
- + /*
126
- + * We can poll here since we've had BQL from the time we sent the
127
- + * descriptor. Also, we need to take the answer before SVQ pulls by itself,
128
- + * when BQL is released
129
- + */
130
- + dev_written = vhost_svq_poll(svq);
131
- + if (unlikely(dev_written < sizeof(status))) {
132
- + error_report("Insufficient written data (%zu)", dev_written);
133
- + }
134
- +
135
- +out:
136
- + in_len = iov_from_buf(elem->in_sg, elem->in_num, 0, &status,
137
- + sizeof(status));
138
- + if (unlikely(in_len < sizeof(status))) {
139
- + error_report("Bad device CVQ written length");
140
- + }
141
- + vhost_svq_push_elem(svq, elem, MIN(in_len, sizeof(status)));
142
- + g_free(elem);
143
- + return r;
144
- +}
145
- +
146
- +static const VhostShadowVirtqueueOps vhost_vdpa_net_svq_ops = {
147
- + .avail_handler = vhost_vdpa_net_handle_ctrl_avail,
148
- +};
149
- +
150
- static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
151
- const char *device,
152
- const char *name,
153
- @@ -211,6 +265,10 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
154
-
155
- s->vhost_vdpa.device_fd = vdpa_device_fd;
156
- s->vhost_vdpa.index = queue_pair_index;
157
- + if (!is_datapath) {
158
- + s->vhost_vdpa.shadow_vq_ops = &vhost_vdpa_net_svq_ops;
159
- + s->vhost_vdpa.shadow_vq_ops_opaque = s;
160
- + }
161
- ret = vhost_vdpa_add(nc, (void *)&s->vhost_vdpa, queue_pair_index, nvqs);
162
- if (ret) {
163
- qemu_del_net_client(nc);
164
- --
165
- 2.31.1
166
-
SOURCES/kvm-vdpa-move-SVQ-vring-features-check-to-net.patch ADDED
@@ -0,0 +1,118 @@
1
+ From 63a45add7c9f7bb2b7775ae4cb2d7df22f7f2033 Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
+ Date: Thu, 15 Dec 2022 12:31:39 +0100
4
+ Subject: [PATCH 07/14] vdpa: move SVQ vring features check to net/
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
+ RH-MergeRequest: 136: vDPA ASID support in Qemu
11
+ RH-Bugzilla: 2104412
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [7/13] a24189aea4dbde3ed4486f685d0d88aeee1a0ee7 (eperezmartin/qemu-kvm)
16
+
17
+ The next patches will start control SVQ if possible. However, we don't
18
+ know if that will be possible at qemu boot anymore.
19
+
20
+ Since the moved checks will be already evaluated at net/ to know if it
21
+ is ok to shadow CVQ, move them.
22
+
23
+ Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
24
+ Acked-by: Jason Wang <jasowang@redhat.com>
25
+ Message-Id: <20221215113144.322011-8-eperezma@redhat.com>
26
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
27
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
28
+ (cherry picked from commit 258a03941fd23108a322d09abc9c55341e09688d)
29
+ ---
30
+ hw/virtio/vhost-vdpa.c | 32 ++------------------------------
31
+ net/vhost-vdpa.c | 3 ++-
32
+ 2 files changed, 4 insertions(+), 31 deletions(-)
33
+
34
+ diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
35
+ index 9e7cbf1776..84218ce078 100644
36
+ --- a/hw/virtio/vhost-vdpa.c
37
+ +++ b/hw/virtio/vhost-vdpa.c
38
+ @@ -389,29 +389,9 @@ static int vhost_vdpa_get_dev_features(struct vhost_dev *dev,
39
+ return ret;
40
+ }
41
+
42
+ -static int vhost_vdpa_init_svq(struct vhost_dev *hdev, struct vhost_vdpa *v,
43
+ - Error **errp)
44
+ +static void vhost_vdpa_init_svq(struct vhost_dev *hdev, struct vhost_vdpa *v)
45
+ {
46
+ g_autoptr(GPtrArray) shadow_vqs = NULL;
47
+ - uint64_t dev_features, svq_features;
48
+ - int r;
49
+ - bool ok;
50
+ -
51
+ - if (!v->shadow_vqs_enabled) {
52
+ - return 0;
53
+ - }
54
+ -
55
+ - r = vhost_vdpa_get_dev_features(hdev, &dev_features);
56
+ - if (r != 0) {
57
+ - error_setg_errno(errp, -r, "Can't get vdpa device features");
58
+ - return r;
59
+ - }
60
+ -
61
+ - svq_features = dev_features;
62
+ - ok = vhost_svq_valid_features(svq_features, errp);
63
+ - if (unlikely(!ok)) {
64
+ - return -1;
65
+ - }
66
+
67
+ shadow_vqs = g_ptr_array_new_full(hdev->nvqs, vhost_svq_free);
68
+ for (unsigned n = 0; n < hdev->nvqs; ++n) {
69
+ @@ -422,7 +402,6 @@ static int vhost_vdpa_init_svq(struct vhost_dev *hdev, struct vhost_vdpa *v,
70
+ }
71
+
72
+ v->shadow_vqs = g_steal_pointer(&shadow_vqs);
73
+ - return 0;
74
+ }
75
+
76
+ static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp)
77
+ @@ -447,10 +426,7 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp)
78
+ dev->opaque = opaque ;
79
+ v->listener = vhost_vdpa_memory_listener;
80
+ v->msg_type = VHOST_IOTLB_MSG_V2;
81
+ - ret = vhost_vdpa_init_svq(dev, v, errp);
82
+ - if (ret) {
83
+ - goto err;
84
+ - }
85
+ + vhost_vdpa_init_svq(dev, v);
86
+
87
+ if (!vhost_vdpa_first_dev(dev)) {
88
+ return 0;
89
+ @@ -460,10 +436,6 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp)
90
+ VIRTIO_CONFIG_S_DRIVER);
91
+
92
+ return 0;
93
+ -
94
+ -err:
95
+ - ram_block_discard_disable(false);
96
+ - return ret;
97
+ }
98
+
99
+ static void vhost_vdpa_host_notifier_uninit(struct vhost_dev *dev,
100
+ diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
101
+ index 8d3ed095d0..85aa0da39a 100644
102
+ --- a/net/vhost-vdpa.c
103
+ +++ b/net/vhost-vdpa.c
104
+ @@ -117,9 +117,10 @@ static bool vhost_vdpa_net_valid_svq_features(uint64_t features, Error **errp)
105
+ if (invalid_dev_features) {
106
+ error_setg(errp, "vdpa svq does not work with features 0x%" PRIx64,
107
+ invalid_dev_features);
108
+ + return false;
109
+ }
110
+
111
+ - return !invalid_dev_features;
112
+ + return vhost_svq_valid_features(features, errp);
113
+ }
114
+
115
+ static int vhost_vdpa_net_check_device_id(struct vhost_net *net)
116
+ --
117
+ 2.31.1
118
+
SOURCES/kvm-vdpa-request-iova_range-only-once.patch ADDED
@@ -0,0 +1,145 @@
1
+ From 760169d538a4e6ba61006f6796cd55af967a7f1e Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
+ Date: Thu, 15 Dec 2022 12:31:38 +0100
4
+ Subject: [PATCH 06/14] vdpa: request iova_range only once
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
+ RH-MergeRequest: 136: vDPA ASID support in Qemu
11
+ RH-Bugzilla: 2104412
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [6/13] 2a8ae2f46ae88f01c5535038f38cb7895098b610 (eperezmartin/qemu-kvm)
16
+
17
+ Currently iova range is requested once per queue pair in the case of
18
+ net. Reduce the number of ioctls asking it once at initialization and
19
+ reusing that value for each vhost_vdpa.
20
+
21
+ Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
22
+ Message-Id: <20221215113144.322011-7-eperezma@redhat.com>
23
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
24
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
25
+ Acked-by: Jason Wang <jasonwang@redhat.com>
26
+ (cherry picked from commit a585fad26b2e6ccca156d9e65158ad1c5efd268d)
27
+ ---
28
+ hw/virtio/vhost-vdpa.c | 15 ---------------
29
+ net/vhost-vdpa.c | 27 ++++++++++++++-------------
30
+ 2 files changed, 14 insertions(+), 28 deletions(-)
31
+
32
+ diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
33
+ index e65603022f..9e7cbf1776 100644
34
+ --- a/hw/virtio/vhost-vdpa.c
35
+ +++ b/hw/virtio/vhost-vdpa.c
36
+ @@ -365,19 +365,6 @@ static int vhost_vdpa_add_status(struct vhost_dev *dev, uint8_t status)
37
+ return 0;
38
+ }
39
+
40
+ -static void vhost_vdpa_get_iova_range(struct vhost_vdpa *v)
41
+ -{
42
+ - int ret = vhost_vdpa_call(v->dev, VHOST_VDPA_GET_IOVA_RANGE,
43
+ - &v->iova_range);
44
+ - if (ret != 0) {
45
+ - v->iova_range.first = 0;
46
+ - v->iova_range.last = UINT64_MAX;
47
+ - }
48
+ -
49
+ - trace_vhost_vdpa_get_iova_range(v->dev, v->iova_range.first,
50
+ - v->iova_range.last);
51
+ -}
52
+ -
53
+ /*
54
+ * The use of this function is for requests that only need to be
55
+ * applied once. Typically such request occurs at the beginning
56
+ @@ -465,8 +452,6 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp)
57
+ goto err;
58
+ }
59
+
60
+ - vhost_vdpa_get_iova_range(v);
61
+ -
62
+ if (!vhost_vdpa_first_dev(dev)) {
63
+ return 0;
64
+ }
65
+ diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
66
+ index 16a5ebe2dd..8d3ed095d0 100644
67
+ --- a/net/vhost-vdpa.c
68
+ +++ b/net/vhost-vdpa.c
69
+ @@ -549,14 +549,15 @@ static const VhostShadowVirtqueueOps vhost_vdpa_net_svq_ops = {
70
+ };
71
+
72
+ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
73
+ - const char *device,
74
+ - const char *name,
75
+ - int vdpa_device_fd,
76
+ - int queue_pair_index,
77
+ - int nvqs,
78
+ - bool is_datapath,
79
+ - bool svq,
80
+ - VhostIOVATree *iova_tree)
81
+ + const char *device,
82
+ + const char *name,
83
+ + int vdpa_device_fd,
84
+ + int queue_pair_index,
85
+ + int nvqs,
86
+ + bool is_datapath,
87
+ + bool svq,
88
+ + struct vhost_vdpa_iova_range iova_range,
89
+ + VhostIOVATree *iova_tree)
90
+ {
91
+ NetClientState *nc = NULL;
92
+ VhostVDPAState *s;
93
+ @@ -575,6 +576,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
94
+ s->vhost_vdpa.device_fd = vdpa_device_fd;
95
+ s->vhost_vdpa.index = queue_pair_index;
96
+ s->vhost_vdpa.shadow_vqs_enabled = svq;
97
+ + s->vhost_vdpa.iova_range = iova_range;
98
+ s->vhost_vdpa.iova_tree = iova_tree;
99
+ if (!is_datapath) {
100
+ s->cvq_cmd_out_buffer = qemu_memalign(qemu_real_host_page_size(),
101
+ @@ -654,6 +656,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
102
+ int vdpa_device_fd;
103
+ g_autofree NetClientState **ncs = NULL;
104
+ g_autoptr(VhostIOVATree) iova_tree = NULL;
105
+ + struct vhost_vdpa_iova_range iova_range;
106
+ NetClientState *nc;
107
+ int queue_pairs, r, i = 0, has_cvq = 0;
108
+
109
+ @@ -697,14 +700,12 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
110
+ return queue_pairs;
111
+ }
112
+
113
+ + vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range);
114
+ if (opts->x_svq) {
115
+ - struct vhost_vdpa_iova_range iova_range;
116
+ -
117
+ if (!vhost_vdpa_net_valid_svq_features(features, errp)) {
118
+ goto err_svq;
119
+ }
120
+
121
+ - vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range);
122
+ iova_tree = vhost_iova_tree_new(iova_range.first, iova_range.last);
123
+ }
124
+
125
+ @@ -713,7 +714,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
126
+ for (i = 0; i < queue_pairs; i++) {
127
+ ncs[i] = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name,
128
+ vdpa_device_fd, i, 2, true, opts->x_svq,
129
+ - iova_tree);
130
+ + iova_range, iova_tree);
131
+ if (!ncs[i])
132
+ goto err;
133
+ }
134
+ @@ -721,7 +722,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
135
+ if (has_cvq) {
136
+ nc = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name,
137
+ vdpa_device_fd, i, 1, false,
138
+ - opts->x_svq, iova_tree);
139
+ + opts->x_svq, iova_range, iova_tree);
140
+ if (!nc)
141
+ goto err;
142
+ }
143
+ --
144
+ 2.31.1
145
+
SOURCES/kvm-vdpa-store-x-svq-parameter-in-VhostVDPAState.patch ADDED
@@ -0,0 +1,62 @@
1
+ From 28163d7d61b6b0b8312b78d57dabc8f44bf39c46 Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
+ Date: Thu, 15 Dec 2022 12:31:42 +0100
4
+ Subject: [PATCH 10/14] vdpa: store x-svq parameter in VhostVDPAState
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
+ RH-MergeRequest: 136: vDPA ASID support in Qemu
11
+ RH-Bugzilla: 2104412
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [10/13] 53f3b2698b4a5caca434f55e4300103a78778548 (eperezmartin/qemu-kvm)
16
+
17
+ CVQ can be shadowed two ways:
18
+ - Device has x-svq=on parameter (current way)
19
+ - The device can isolate CVQ in its own vq group
20
+
21
+ QEMU needs to check for the second condition dynamically, because CVQ
22
+ index is not known before the driver ack the features. Since this is
23
+ dynamic, the CVQ isolation could vary with different conditions, making
24
+ it possible to go from "not isolated group" to "isolated".
25
+
26
+ Saving the cmdline parameter in an extra field so we never disable CVQ
27
+ SVQ in case the device was started with x-svq cmdline.
28
+
29
+ Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
30
+ Acked-by: Jason Wang <jasowang@redhat.com>
31
+ Message-Id: <20221215113144.322011-11-eperezma@redhat.com>
32
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
33
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
34
+ (cherry picked from commit 7f211a28fd5482f76583988beecd8ee61588d45e)
35
+ ---
36
+ net/vhost-vdpa.c | 3 +++
37
+ 1 file changed, 3 insertions(+)
38
+
39
+ diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
40
+ index c2f319eb88..1757f1d028 100644
41
+ --- a/net/vhost-vdpa.c
42
+ +++ b/net/vhost-vdpa.c
43
+ @@ -38,6 +38,8 @@ typedef struct VhostVDPAState {
44
+ void *cvq_cmd_out_buffer;
45
+ virtio_net_ctrl_ack *status;
46
+
47
+ + /* The device always have SVQ enabled */
48
+ + bool always_svq;
49
+ bool started;
50
+ } VhostVDPAState;
51
+
52
+ @@ -576,6 +578,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
53
+
54
+ s->vhost_vdpa.device_fd = vdpa_device_fd;
55
+ s->vhost_vdpa.index = queue_pair_index;
56
+ + s->always_svq = svq;
57
+ s->vhost_vdpa.shadow_vqs_enabled = svq;
58
+ s->vhost_vdpa.iova_range = iova_range;
59
+ s->vhost_vdpa.iova_tree = iova_tree;
60
+ --
61
+ 2.31.1
62
+
SOURCES/kvm-vdpa-use-v-shadow_vqs_enabled-in-vhost_vdpa_svqs_sta.patch ADDED
@@ -0,0 +1,58 @@
1
+ From cb974f2f9a0c5b9520b6ac80bd1d1e4a6b12bbdc Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
+ Date: Thu, 15 Dec 2022 12:31:33 +0100
4
+ Subject: [PATCH 01/14] vdpa: use v->shadow_vqs_enabled in
5
+ vhost_vdpa_svqs_start & stop
6
+ MIME-Version: 1.0
7
+ Content-Type: text/plain; charset=UTF-8
8
+ Content-Transfer-Encoding: 8bit
9
+
10
+ RH-Author: Eugenio Pérez <eperezma@redhat.com>
11
+ RH-MergeRequest: 136: vDPA ASID support in Qemu
12
+ RH-Bugzilla: 2104412
13
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
14
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
16
+ RH-Commit: [1/13] f0db50a95f87dd011418617be7b80aa6813a1146 (eperezmartin/qemu-kvm)
17
+
18
+ This function used to trust in v->shadow_vqs != NULL to know if it must
19
+ start svq or not.
20
+
21
+ This is not going to be valid anymore, as qemu is going to allocate svq
22
+ array unconditionally (but it will only start them conditionally).
23
+
24
+ Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
25
+ Acked-by: Jason Wang <jasowang@redhat.com>
26
+ Message-Id: <20221215113144.322011-2-eperezma@redhat.com>
27
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
28
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
29
+ (cherry picked from commit 712c1a3171cf62d501dac5af58f77d5fea70350d)
30
+ ---
31
+ hw/virtio/vhost-vdpa.c | 4 ++--
32
+ 1 file changed, 2 insertions(+), 2 deletions(-)
33
+
34
+ diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
35
+ index c5be2645b0..44e6a9b7b3 100644
36
+ --- a/hw/virtio/vhost-vdpa.c
37
+ +++ b/hw/virtio/vhost-vdpa.c
38
+ @@ -1036,7 +1036,7 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *dev)
39
+ Error *err = NULL;
40
+ unsigned i;
41
+
42
+ - if (!v->shadow_vqs) {
43
+ + if (!v->shadow_vqs_enabled) {
44
+ return true;
45
+ }
46
+
47
+ @@ -1089,7 +1089,7 @@ static void vhost_vdpa_svqs_stop(struct vhost_dev *dev)
48
+ {
49
+ struct vhost_vdpa *v = dev->opaque;
50
+
51
+ - if (!v->shadow_vqs) {
52
+ + if (!v->shadow_vqs_enabled) {
53
+ return;
54
+ }
55
+
56
+ --
57
+ 2.31.1
58
+
SOURCES/kvm-vfio-common-remove-spurious-tpm-crb-cmd-misalignment.patch DELETED
@@ -1,114 +0,0 @@
1
- From b90a5878355bd549200ed1eff52ea084325bfc8a Mon Sep 17 00:00:00 2001
2
- From: Eric Auger <eric.auger@redhat.com>
3
- Date: Fri, 6 May 2022 15:25:10 +0200
4
- Subject: [PATCH 5/5] vfio/common: remove spurious tpm-crb-cmd misalignment
5
- warning
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Eric Auger <eric.auger@redhat.com>
11
- RH-MergeRequest: 84: vfio/common: Remove spurious tpm-crb-cmd misalignment warning
12
- RH-Commit: [2/2] 9b73a9aec59cb50d5e3468cc553464bf4a73d0a1 (eauger1/centos-qemu-kvm)
13
- RH-Bugzilla: 2037612
14
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
16
- RH-Acked-by: Andrew Jones <drjones@redhat.com>
17
-
18
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2037612
19
- Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=45166961
20
- Upstream Status: YES
21
- Tested: With TPM-CRB and VFIO
22
-
23
- The CRB command buffer currently is a RAM MemoryRegion and given
24
- its base address alignment, it causes an error report on
25
- vfio_listener_region_add(). This region could have been a RAM device
26
- region, easing the detection of such safe situation but this option
27
- was not well received. So let's add a helper function that uses the
28
- memory region owner type to detect the situation is safe wrt
29
- the assignment. Other device types can be checked here if such kind
30
- of problem occurs again.
31
-
32
- Conflicts in hw/vfio/common.c
33
- We don't have 8e3b0cbb721 ("Replace qemu_real_host_page variables with inlined functions")
34
-
35
- Signed-off-by: Eric Auger <eric.auger@redhat.com>
36
- Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
37
- Acked-by: Stefan Berger <stefanb@linux.ibm.com>
38
- Reviewed-by: Cornelia Huck <cohuck@redhat.com>
39
- Link: https://lore.kernel.org/r/20220506132510.1847942-3-eric.auger@redhat.com
40
- Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
41
- (cherry picked from commit 851d6d1a0ff29a87ec588205842edf6b86d99b5c)
42
- Signed-off-by: Eric Auger <eric.auger@redhat.com>
43
- ---
44
- hw/vfio/common.c | 27 ++++++++++++++++++++++++++-
45
- hw/vfio/trace-events | 1 +
46
- 2 files changed, 27 insertions(+), 1 deletion(-)
47
-
48
- diff --git a/hw/vfio/common.c b/hw/vfio/common.c
49
- index 080046e3f5..0fbe0d47af 100644
50
- --- a/hw/vfio/common.c
51
- +++ b/hw/vfio/common.c
52
- @@ -40,6 +40,7 @@
53
- #include "trace.h"
54
- #include "qapi/error.h"
55
- #include "migration/migration.h"
56
- +#include "sysemu/tpm.h"
57
-
58
- VFIOGroupList vfio_group_list =
59
- QLIST_HEAD_INITIALIZER(vfio_group_list);
60
- @@ -861,6 +862,22 @@ static void vfio_unregister_ram_discard_listener(VFIOContainer *container,
61
- g_free(vrdl);
62
- }
63
-
64
- +static bool vfio_known_safe_misalignment(MemoryRegionSection *section)
65
- +{
66
- + MemoryRegion *mr = section->mr;
67
- +
68
- + if (!TPM_IS_CRB(mr->owner)) {
69
- + return false;
70
- + }
71
- +
72
- + /* this is a known safe misaligned region, just trace for debug purpose */
73
- + trace_vfio_known_safe_misalignment(memory_region_name(mr),
74
- + section->offset_within_address_space,
75
- + section->offset_within_region,
76
- + qemu_real_host_page_size);
77
- + return true;
78
- +}
79
- +
80
- static void vfio_listener_region_add(MemoryListener *listener,
81
- MemoryRegionSection *section)
82
- {
83
- @@ -884,7 +901,15 @@ static void vfio_listener_region_add(MemoryListener *listener,
84
- if (unlikely((section->offset_within_address_space &
85
- ~qemu_real_host_page_mask) !=
86
- (section->offset_within_region & ~qemu_real_host_page_mask))) {
87
- - error_report("%s received unaligned region", __func__);
88
- + if (!vfio_known_safe_misalignment(section)) {
89
- + error_report("%s received unaligned region %s iova=0x%"PRIx64
90
- + " offset_within_region=0x%"PRIx64
91
- + " qemu_real_host_page_size=0x%"PRIxPTR,
92
- + __func__, memory_region_name(section->mr),
93
- + section->offset_within_address_space,
94
- + section->offset_within_region,
95
- + qemu_real_host_page_size);
96
- + }
97
- return;
98
- }
99
-
100
- diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
101
- index 0ef1b5f4a6..582882db91 100644
102
- --- a/hw/vfio/trace-events
103
- +++ b/hw/vfio/trace-events
104
- @@ -100,6 +100,7 @@ vfio_listener_region_add_skip(uint64_t start, uint64_t end) "SKIPPING region_add
105
- vfio_spapr_group_attach(int groupfd, int tablefd) "Attached groupfd %d to liobn fd %d"
106
- vfio_listener_region_add_iommu(uint64_t start, uint64_t end) "region_add [iommu] 0x%"PRIx64" - 0x%"PRIx64
107
- vfio_listener_region_add_ram(uint64_t iova_start, uint64_t iova_end, void *vaddr) "region_add [ram] 0x%"PRIx64" - 0x%"PRIx64" [%p]"
108
- +vfio_known_safe_misalignment(const char *name, uint64_t iova, uint64_t offset_within_region, uintptr_t page_size) "Region \"%s\" iova=0x%"PRIx64" offset_within_region=0x%"PRIx64" qemu_real_host_page_size=0x%"PRIxPTR ": cannot be mapped for DMA"
109
- vfio_listener_region_add_no_dma_map(const char *name, uint64_t iova, uint64_t size, uint64_t page_size) "Region \"%s\" 0x%"PRIx64" size=0x%"PRIx64" is not aligned to 0x%"PRIx64" and cannot be mapped for DMA"
110
- vfio_listener_region_del_skip(uint64_t start, uint64_t end) "SKIPPING region_del 0x%"PRIx64" - 0x%"PRIx64
111
- vfio_listener_region_del(uint64_t start, uint64_t end) "region_del 0x%"PRIx64" - 0x%"PRIx64
112
- --
113
- 2.31.1
114
-
SOURCES/kvm-vfio-common-remove-spurious-warning-on-vfio_listener.patch DELETED
@@ -1,78 +0,0 @@
1
- From 3de8fb9f3dba18d04efa10b70bcec641035effc5 Mon Sep 17 00:00:00 2001
2
- From: Eric Auger <eric.auger@redhat.com>
3
- Date: Tue, 24 May 2022 05:14:05 -0400
4
- Subject: [PATCH 16/16] vfio/common: remove spurious warning on
5
- vfio_listener_region_del
6
-
7
- RH-Author: Eric Auger <eric.auger@redhat.com>
8
- RH-MergeRequest: 101: vfio/common: remove spurious warning on vfio_listener_region_del
9
- RH-Commit: [1/1] dac688b8a981ebb964fea79ea198c329b9cdb551 (eauger1/centos-qemu-kvm)
10
- RH-Bugzilla: 2086262
11
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
13
- RH-Acked-by: Alex Williamson <None>
14
-
15
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2086262
16
- Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=45876133
17
- Upstream Status: YES
18
- Tested: With TPM-CRB and VFIO
19
-
20
- 851d6d1a0f ("vfio/common: remove spurious tpm-crb-cmd misalignment
21
- warning") removed the warning on vfio_listener_region_add() path.
22
-
23
- However the same warning also hits on region_del path. Let's remove
24
- it and reword the dynamic trace as this can be called on both
25
- map and unmap path.
26
-
27
- Contextual Conflict in hw/vfio/common.c
28
- We don't have 8e3b0cbb721 ("Replace qemu_real_host_page variables with inlined functions")
29
-
30
- Signed-off-by: Eric Auger <eric.auger@redhat.com>
31
- Reviewed-by: Cornelia Huck <cohuck@redhat.com>
32
- Link: https://lore.kernel.org/r/20220524091405.416256-1-eric.auger@redhat.com
33
- Fixes: 851d6d1a0ff2 ("vfio/common: remove spurious tpm-crb-cmd misalignment warning")
34
- Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
35
- (cherry picked from commit ec6600be0dc16982181c7ad80d94c143c0807dd2)
36
- Signed-off-by: Eric Auger <eric.auger@redhat.com>
37
- ---
38
- hw/vfio/common.c | 10 +++++++++-
39
- hw/vfio/trace-events | 2 +-
40
- 2 files changed, 10 insertions(+), 2 deletions(-)
41
-
42
- diff --git a/hw/vfio/common.c b/hw/vfio/common.c
43
- index 0fbe0d47af..637981f9a1 100644
44
- --- a/hw/vfio/common.c
45
- +++ b/hw/vfio/common.c
46
- @@ -1145,7 +1145,15 @@ static void vfio_listener_region_del(MemoryListener *listener,
47
- if (unlikely((section->offset_within_address_space &
48
- ~qemu_real_host_page_mask) !=
49
- (section->offset_within_region & ~qemu_real_host_page_mask))) {
50
- - error_report("%s received unaligned region", __func__);
51
- + if (!vfio_known_safe_misalignment(section)) {
52
- + error_report("%s received unaligned region %s iova=0x%"PRIx64
53
- + " offset_within_region=0x%"PRIx64
54
- + " qemu_real_host_page_size=0x%"PRIxPTR,
55
- + __func__, memory_region_name(section->mr),
56
- + section->offset_within_address_space,
57
- + section->offset_within_region,
58
- + qemu_real_host_page_size);
59
- + }
60
- return;
61
- }
62
-
63
- diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
64
- index 582882db91..73dffe9e00 100644
65
- --- a/hw/vfio/trace-events
66
- +++ b/hw/vfio/trace-events
67
- @@ -100,7 +100,7 @@ vfio_listener_region_add_skip(uint64_t start, uint64_t end) "SKIPPING region_add
68
- vfio_spapr_group_attach(int groupfd, int tablefd) "Attached groupfd %d to liobn fd %d"
69
- vfio_listener_region_add_iommu(uint64_t start, uint64_t end) "region_add [iommu] 0x%"PRIx64" - 0x%"PRIx64
70
- vfio_listener_region_add_ram(uint64_t iova_start, uint64_t iova_end, void *vaddr) "region_add [ram] 0x%"PRIx64" - 0x%"PRIx64" [%p]"
71
- -vfio_known_safe_misalignment(const char *name, uint64_t iova, uint64_t offset_within_region, uintptr_t page_size) "Region \"%s\" iova=0x%"PRIx64" offset_within_region=0x%"PRIx64" qemu_real_host_page_size=0x%"PRIxPTR ": cannot be mapped for DMA"
72
- +vfio_known_safe_misalignment(const char *name, uint64_t iova, uint64_t offset_within_region, uintptr_t page_size) "Region \"%s\" iova=0x%"PRIx64" offset_within_region=0x%"PRIx64" qemu_real_host_page_size=0x%"PRIxPTR
73
- vfio_listener_region_add_no_dma_map(const char *name, uint64_t iova, uint64_t size, uint64_t page_size) "Region \"%s\" 0x%"PRIx64" size=0x%"PRIx64" is not aligned to 0x%"PRIx64" and cannot be mapped for DMA"
74
- vfio_listener_region_del_skip(uint64_t start, uint64_t end) "SKIPPING region_del 0x%"PRIx64" - 0x%"PRIx64
75
- vfio_listener_region_del(uint64_t start, uint64_t end) "region_del 0x%"PRIx64" - 0x%"PRIx64
76
- --
77
- 2.31.1
78
-
SOURCES/kvm-vhost-Add-SVQDescState.patch DELETED
@@ -1,135 +0,0 @@
1
- From 14200f493243f73152ea4a4b97274f0ec4fb36fa Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:38:55 +0200
4
- Subject: [PATCH 15/32] vhost: Add SVQDescState
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [15/27] 2e2866f22e37cace8598ff44dfcdc07fcc915d6d (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit 9e87868fcaf5785c8e1490c290505fa32305ff91
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Wed Jul 20 08:59:34 2022 +0200
24
-
25
- vhost: Add SVQDescState
26
-
27
- This will allow SVQ to add context to the different queue elements.
28
-
29
- This patch only store the actual element, no functional change intended.
30
-
31
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
32
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
33
- Signed-off-by: Jason Wang <jasowang@redhat.com>
34
-
35
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
36
- ---
37
- hw/virtio/vhost-shadow-virtqueue.c | 16 ++++++++--------
38
- hw/virtio/vhost-shadow-virtqueue.h | 8 ++++++--
39
- 2 files changed, 14 insertions(+), 10 deletions(-)
40
-
41
- diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
42
- index 3cec03d709..a08e3d4025 100644
43
- --- a/hw/virtio/vhost-shadow-virtqueue.c
44
- +++ b/hw/virtio/vhost-shadow-virtqueue.c
45
- @@ -256,7 +256,7 @@ static int vhost_svq_add(VhostShadowVirtqueue *svq, const struct iovec *out_sg,
46
- return -EINVAL;
47
- }
48
-
49
- - svq->ring_id_maps[qemu_head] = elem;
50
- + svq->desc_state[qemu_head].elem = elem;
51
- vhost_svq_kick(svq);
52
- return 0;
53
- }
54
- @@ -411,21 +411,21 @@ static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
55
- return NULL;
56
- }
57
-
58
- - if (unlikely(!svq->ring_id_maps[used_elem.id])) {
59
- + if (unlikely(!svq->desc_state[used_elem.id].elem)) {
60
- qemu_log_mask(LOG_GUEST_ERROR,
61
- "Device %s says index %u is used, but it was not available",
62
- svq->vdev->name, used_elem.id);
63
- return NULL;
64
- }
65
-
66
- - num = svq->ring_id_maps[used_elem.id]->in_num +
67
- - svq->ring_id_maps[used_elem.id]->out_num;
68
- + num = svq->desc_state[used_elem.id].elem->in_num +
69
- + svq->desc_state[used_elem.id].elem->out_num;
70
- last_used_chain = vhost_svq_last_desc_of_chain(svq, num, used_elem.id);
71
- svq->desc_next[last_used_chain] = svq->free_head;
72
- svq->free_head = used_elem.id;
73
-
74
- *len = used_elem.len;
75
- - return g_steal_pointer(&svq->ring_id_maps[used_elem.id]);
76
- + return g_steal_pointer(&svq->desc_state[used_elem.id].elem);
77
- }
78
-
79
- static void vhost_svq_flush(VhostShadowVirtqueue *svq,
80
- @@ -595,7 +595,7 @@ void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev,
81
- memset(svq->vring.desc, 0, driver_size);
82
- svq->vring.used = qemu_memalign(qemu_real_host_page_size, device_size);
83
- memset(svq->vring.used, 0, device_size);
84
- - svq->ring_id_maps = g_new0(VirtQueueElement *, svq->vring.num);
85
- + svq->desc_state = g_new0(SVQDescState, svq->vring.num);
86
- svq->desc_next = g_new0(uint16_t, svq->vring.num);
87
- for (unsigned i = 0; i < svq->vring.num - 1; i++) {
88
- svq->desc_next[i] = cpu_to_le16(i + 1);
89
- @@ -620,7 +620,7 @@ void vhost_svq_stop(VhostShadowVirtqueue *svq)
90
-
91
- for (unsigned i = 0; i < svq->vring.num; ++i) {
92
- g_autofree VirtQueueElement *elem = NULL;
93
- - elem = g_steal_pointer(&svq->ring_id_maps[i]);
94
- + elem = g_steal_pointer(&svq->desc_state[i].elem);
95
- if (elem) {
96
- virtqueue_detach_element(svq->vq, elem, 0);
97
- }
98
- @@ -632,7 +632,7 @@ void vhost_svq_stop(VhostShadowVirtqueue *svq)
99
- }
100
- svq->vq = NULL;
101
- g_free(svq->desc_next);
102
- - g_free(svq->ring_id_maps);
103
- + g_free(svq->desc_state);
104
- qemu_vfree(svq->vring.desc);
105
- qemu_vfree(svq->vring.used);
106
- }
107
- diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-virtqueue.h
108
- index c132c994e9..d646c35054 100644
109
- --- a/hw/virtio/vhost-shadow-virtqueue.h
110
- +++ b/hw/virtio/vhost-shadow-virtqueue.h
111
- @@ -15,6 +15,10 @@
112
- #include "standard-headers/linux/vhost_types.h"
113
- #include "hw/virtio/vhost-iova-tree.h"
114
-
115
- +typedef struct SVQDescState {
116
- + VirtQueueElement *elem;
117
- +} SVQDescState;
118
- +
119
- /* Shadow virtqueue to relay notifications */
120
- typedef struct VhostShadowVirtqueue {
121
- /* Shadow vring */
122
- @@ -47,8 +51,8 @@ typedef struct VhostShadowVirtqueue {
123
- /* IOVA mapping */
124
- VhostIOVATree *iova_tree;
125
-
126
- - /* Map for use the guest's descriptors */
127
- - VirtQueueElement **ring_id_maps;
128
- + /* SVQ vring descriptors state */
129
- + SVQDescState *desc_state;
130
-
131
- /* Next VirtQueue element that guest made available */
132
- VirtQueueElement *next_guest_avail_elem;
133
- --
134
- 2.31.1
135
-
SOURCES/kvm-vhost-Add-svq-avail_handler-callback.patch DELETED
@@ -1,164 +0,0 @@
1
- From 433106c286a1961737300ebaece6f10b2747e7d8 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:38:55 +0200
4
- Subject: [PATCH 20/32] vhost: Add svq avail_handler callback
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [20/27] d228eb89d204f8be623bc870503bbf0078dfc9ae (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit e966c0b781aebabd2c0f5eef91678f08ce1d068c
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Wed Jul 20 08:59:39 2022 +0200
24
-
25
- vhost: Add svq avail_handler callback
26
-
27
- This allows external handlers to be aware of new buffers that the guest
28
- places in the virtqueue.
29
-
30
- When this callback is defined the ownership of the guest's virtqueue
31
- element is transferred to the callback. This means that if the user
32
- wants to forward the descriptor it needs to manually inject it. The
33
- callback is also free to process the command by itself and use the
34
- element with svq_push.
35
-
36
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
37
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
38
- Signed-off-by: Jason Wang <jasowang@redhat.com>
39
-
40
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
41
- ---
42
- hw/virtio/vhost-shadow-virtqueue.c | 14 ++++++++++++--
43
- hw/virtio/vhost-shadow-virtqueue.h | 31 +++++++++++++++++++++++++++++-
44
- hw/virtio/vhost-vdpa.c | 3 ++-
45
- 3 files changed, 44 insertions(+), 4 deletions(-)
46
-
47
- diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
48
- index 95d0d7a7ee..e53aac45f6 100644
49
- --- a/hw/virtio/vhost-shadow-virtqueue.c
50
- +++ b/hw/virtio/vhost-shadow-virtqueue.c
51
- @@ -306,7 +306,11 @@ static void vhost_handle_guest_kick(VhostShadowVirtqueue *svq)
52
- break;
53
- }
54
-
55
- - r = vhost_svq_add_element(svq, elem);
56
- + if (svq->ops) {
57
- + r = svq->ops->avail_handler(svq, elem, svq->ops_opaque);
58
- + } else {
59
- + r = vhost_svq_add_element(svq, elem);
60
- + }
61
- if (unlikely(r != 0)) {
62
- if (r == -ENOSPC) {
63
- /*
64
- @@ -685,12 +689,16 @@ void vhost_svq_stop(VhostShadowVirtqueue *svq)
65
- * shadow methods and file descriptors.
66
- *
67
- * @iova_tree: Tree to perform descriptors translations
68
- + * @ops: SVQ owner callbacks
69
- + * @ops_opaque: ops opaque pointer
70
- *
71
- * Returns the new virtqueue or NULL.
72
- *
73
- * In case of error, reason is reported through error_report.
74
- */
75
- -VhostShadowVirtqueue *vhost_svq_new(VhostIOVATree *iova_tree)
76
- +VhostShadowVirtqueue *vhost_svq_new(VhostIOVATree *iova_tree,
77
- + const VhostShadowVirtqueueOps *ops,
78
- + void *ops_opaque)
79
- {
80
- g_autofree VhostShadowVirtqueue *svq = g_new0(VhostShadowVirtqueue, 1);
81
- int r;
82
- @@ -712,6 +720,8 @@ VhostShadowVirtqueue *vhost_svq_new(VhostIOVATree *iova_tree)
83
- event_notifier_init_fd(&svq->svq_kick, VHOST_FILE_UNBIND);
84
- event_notifier_set_handler(&svq->hdev_call, vhost_svq_handle_call);
85
- svq->iova_tree = iova_tree;
86
- + svq->ops = ops;
87
- + svq->ops_opaque = ops_opaque;
88
- return g_steal_pointer(&svq);
89
-
90
- err_init_hdev_call:
91
- diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-virtqueue.h
92
- index cf442f7dea..d04c34a589 100644
93
- --- a/hw/virtio/vhost-shadow-virtqueue.h
94
- +++ b/hw/virtio/vhost-shadow-virtqueue.h
95
- @@ -25,6 +25,27 @@ typedef struct SVQDescState {
96
- unsigned int ndescs;
97
- } SVQDescState;
98
-
99
- +typedef struct VhostShadowVirtqueue VhostShadowVirtqueue;
100
- +
101
- +/**
102
- + * Callback to handle an avail buffer.
103
- + *
104
- + * @svq: Shadow virtqueue
105
- + * @elem: Element placed in the queue by the guest
106
- + * @vq_callback_opaque: Opaque
107
- + *
108
- + * Returns 0 if the vq is running as expected.
109
- + *
110
- + * Note that ownership of elem is transferred to the callback.
111
- + */
112
- +typedef int (*VirtQueueAvailCallback)(VhostShadowVirtqueue *svq,
113
- + VirtQueueElement *elem,
114
- + void *vq_callback_opaque);
115
- +
116
- +typedef struct VhostShadowVirtqueueOps {
117
- + VirtQueueAvailCallback avail_handler;
118
- +} VhostShadowVirtqueueOps;
119
- +
120
- /* Shadow virtqueue to relay notifications */
121
- typedef struct VhostShadowVirtqueue {
122
- /* Shadow vring */
123
- @@ -69,6 +90,12 @@ typedef struct VhostShadowVirtqueue {
124
- */
125
- uint16_t *desc_next;
126
-
127
- + /* Caller callbacks */
128
- + const VhostShadowVirtqueueOps *ops;
129
- +
130
- + /* Caller callbacks opaque */
131
- + void *ops_opaque;
132
- +
133
- /* Next head to expose to the device */
134
- uint16_t shadow_avail_idx;
135
-
136
- @@ -102,7 +129,9 @@ void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev,
137
- VirtQueue *vq);
138
- void vhost_svq_stop(VhostShadowVirtqueue *svq);
139
-
140
- -VhostShadowVirtqueue *vhost_svq_new(VhostIOVATree *iova_tree);
141
- +VhostShadowVirtqueue *vhost_svq_new(VhostIOVATree *iova_tree,
142
- + const VhostShadowVirtqueueOps *ops,
143
- + void *ops_opaque);
144
-
145
- void vhost_svq_free(gpointer vq);
146
- G_DEFINE_AUTOPTR_CLEANUP_FUNC(VhostShadowVirtqueue, vhost_svq_free);
147
- diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
148
- index 33dcaa135e..28df57b12e 100644
149
- --- a/hw/virtio/vhost-vdpa.c
150
- +++ b/hw/virtio/vhost-vdpa.c
151
- @@ -416,8 +416,9 @@ static int vhost_vdpa_init_svq(struct vhost_dev *hdev, struct vhost_vdpa *v,
152
-
153
- shadow_vqs = g_ptr_array_new_full(hdev->nvqs, vhost_svq_free);
154
- for (unsigned n = 0; n < hdev->nvqs; ++n) {
155
- - g_autoptr(VhostShadowVirtqueue) svq = vhost_svq_new(v->iova_tree);
156
- + g_autoptr(VhostShadowVirtqueue) svq;
157
-
158
- + svq = vhost_svq_new(v->iova_tree, NULL, NULL);
159
- if (unlikely(!svq)) {
160
- error_setg(errp, "Cannot create svq %u", n);
161
- return -1;
162
- --
163
- 2.31.1
164
-
SOURCES/kvm-vhost-Check-for-queue-full-at-vhost_svq_add.patch DELETED
@@ -1,134 +0,0 @@
1
- From 893dffb820973361bcef33612a6b924554a856c1 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:38:55 +0200
4
- Subject: [PATCH 13/32] vhost: Check for queue full at vhost_svq_add
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [13/27] d4bd8299fb7733a1e190618dfc92b4b53b7bbeb3 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit f20b70eb5a68cfd8fef74a13ccdd494ef1cb0221
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Wed Jul 20 08:59:32 2022 +0200
24
-
25
- vhost: Check for queue full at vhost_svq_add
26
-
27
- The series need to expose vhost_svq_add with full functionality,
28
- including checking for full queue.
29
-
30
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
31
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
32
- Signed-off-by: Jason Wang <jasowang@redhat.com>
33
-
34
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
35
- ---
36
- hw/virtio/vhost-shadow-virtqueue.c | 59 +++++++++++++++++-------------
37
- 1 file changed, 33 insertions(+), 26 deletions(-)
38
-
39
- diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
40
- index e3fc3c2658..1d2bab287b 100644
41
- --- a/hw/virtio/vhost-shadow-virtqueue.c
42
- +++ b/hw/virtio/vhost-shadow-virtqueue.c
43
- @@ -233,21 +233,29 @@ static void vhost_svq_kick(VhostShadowVirtqueue *svq)
44
- * Add an element to a SVQ.
45
- *
46
- * The caller must check that there is enough slots for the new element. It
47
- - * takes ownership of the element: In case of failure, it is free and the SVQ
48
- - * is considered broken.
49
- + * takes ownership of the element: In case of failure not ENOSPC, it is free.
50
- + *
51
- + * Return -EINVAL if element is invalid, -ENOSPC if dev queue is full
52
- */
53
- -static bool vhost_svq_add(VhostShadowVirtqueue *svq, VirtQueueElement *elem)
54
- +static int vhost_svq_add(VhostShadowVirtqueue *svq, VirtQueueElement *elem)
55
- {
56
- unsigned qemu_head;
57
- - bool ok = vhost_svq_add_split(svq, elem, &qemu_head);
58
- + unsigned ndescs = elem->in_num + elem->out_num;
59
- + bool ok;
60
- +
61
- + if (unlikely(ndescs > vhost_svq_available_slots(svq))) {
62
- + return -ENOSPC;
63
- + }
64
- +
65
- + ok = vhost_svq_add_split(svq, elem, &qemu_head);
66
- if (unlikely(!ok)) {
67
- g_free(elem);
68
- - return false;
69
- + return -EINVAL;
70
- }
71
-
72
- svq->ring_id_maps[qemu_head] = elem;
73
- vhost_svq_kick(svq);
74
- - return true;
75
- + return 0;
76
- }
77
-
78
- /**
79
- @@ -274,7 +282,7 @@ static void vhost_handle_guest_kick(VhostShadowVirtqueue *svq)
80
-
81
- while (true) {
82
- VirtQueueElement *elem;
83
- - bool ok;
84
- + int r;
85
-
86
- if (svq->next_guest_avail_elem) {
87
- elem = g_steal_pointer(&svq->next_guest_avail_elem);
88
- @@ -286,25 +294,24 @@ static void vhost_handle_guest_kick(VhostShadowVirtqueue *svq)
89
- break;
90
- }
91
-
92
- - if (elem->out_num + elem->in_num > vhost_svq_available_slots(svq)) {
93
- - /*
94
- - * This condition is possible since a contiguous buffer in GPA
95
- - * does not imply a contiguous buffer in qemu's VA
96
- - * scatter-gather segments. If that happens, the buffer exposed
97
- - * to the device needs to be a chain of descriptors at this
98
- - * moment.
99
- - *
100
- - * SVQ cannot hold more available buffers if we are here:
101
- - * queue the current guest descriptor and ignore further kicks
102
- - * until some elements are used.
103
- - */
104
- - svq->next_guest_avail_elem = elem;
105
- - return;
106
- - }
107
- -
108
- - ok = vhost_svq_add(svq, elem);
109
- - if (unlikely(!ok)) {
110
- - /* VQ is broken, just return and ignore any other kicks */
111
- + r = vhost_svq_add(svq, elem);
112
- + if (unlikely(r != 0)) {
113
- + if (r == -ENOSPC) {
114
- + /*
115
- + * This condition is possible since a contiguous buffer in
116
- + * GPA does not imply a contiguous buffer in qemu's VA
117
- + * scatter-gather segments. If that happens, the buffer
118
- + * exposed to the device needs to be a chain of descriptors
119
- + * at this moment.
120
- + *
121
- + * SVQ cannot hold more available buffers if we are here:
122
- + * queue the current guest descriptor and ignore kicks
123
- + * until some elements are used.
124
- + */
125
- + svq->next_guest_avail_elem = elem;
126
- + }
127
- +
128
- + /* VQ is full or broken, just return and ignore kicks */
129
- return;
130
- }
131
- }
132
- --
133
- 2.31.1
134
-
SOURCES/kvm-vhost-Decouple-vhost_svq_add-from-VirtQueueElement.patch DELETED
@@ -1,138 +0,0 @@
1
- From 5c8de23e185a1a1f0b19eac3c9fa03411c9f545c Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:38:55 +0200
4
- Subject: [PATCH 14/32] vhost: Decouple vhost_svq_add from VirtQueueElement
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [14/27] 463087dd316adc91b9c7a4e6634c6fc1745c1849 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit 1f46ae65d85f677b660bda46685dd3e94885a7cb
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Wed Jul 20 08:59:33 2022 +0200
24
-
25
- vhost: Decouple vhost_svq_add from VirtQueueElement
26
-
27
- VirtQueueElement comes from the guest, but we're heading SVQ to be able
28
- to modify the element presented to the device without the guest's
29
- knowledge.
30
-
31
- To do so, make SVQ accept sg buffers directly, instead of using
32
- VirtQueueElement.
33
-
34
- Add vhost_svq_add_element to maintain element convenience.
35
-
36
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
37
- Acked-by: Jason Wang <jasowang@redhat.com>
38
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
39
- Signed-off-by: Jason Wang <jasowang@redhat.com>
40
-
41
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
42
- ---
43
- hw/virtio/vhost-shadow-virtqueue.c | 33 ++++++++++++++++++++----------
44
- 1 file changed, 22 insertions(+), 11 deletions(-)
45
-
46
- diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
47
- index 1d2bab287b..3cec03d709 100644
48
- --- a/hw/virtio/vhost-shadow-virtqueue.c
49
- +++ b/hw/virtio/vhost-shadow-virtqueue.c
50
- @@ -172,30 +172,31 @@ static bool vhost_svq_vring_write_descs(VhostShadowVirtqueue *svq, hwaddr *sg,
51
- }
52
-
53
- static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,
54
- - VirtQueueElement *elem, unsigned *head)
55
- + const struct iovec *out_sg, size_t out_num,
56
- + const struct iovec *in_sg, size_t in_num,
57
- + unsigned *head)
58
- {
59
- unsigned avail_idx;
60
- vring_avail_t *avail = svq->vring.avail;
61
- bool ok;
62
- - g_autofree hwaddr *sgs = g_new(hwaddr, MAX(elem->out_num, elem->in_num));
63
- + g_autofree hwaddr *sgs = g_new(hwaddr, MAX(out_num, in_num));
64
-
65
- *head = svq->free_head;
66
-
67
- /* We need some descriptors here */
68
- - if (unlikely(!elem->out_num && !elem->in_num)) {
69
- + if (unlikely(!out_num && !in_num)) {
70
- qemu_log_mask(LOG_GUEST_ERROR,
71
- "Guest provided element with no descriptors");
72
- return false;
73
- }
74
-
75
- - ok = vhost_svq_vring_write_descs(svq, sgs, elem->out_sg, elem->out_num,
76
- - elem->in_num > 0, false);
77
- + ok = vhost_svq_vring_write_descs(svq, sgs, out_sg, out_num, in_num > 0,
78
- + false);
79
- if (unlikely(!ok)) {
80
- return false;
81
- }
82
-
83
- - ok = vhost_svq_vring_write_descs(svq, sgs, elem->in_sg, elem->in_num, false,
84
- - true);
85
- + ok = vhost_svq_vring_write_descs(svq, sgs, in_sg, in_num, false, true);
86
- if (unlikely(!ok)) {
87
- return false;
88
- }
89
- @@ -237,17 +238,19 @@ static void vhost_svq_kick(VhostShadowVirtqueue *svq)
90
- *
91
- * Return -EINVAL if element is invalid, -ENOSPC if dev queue is full
92
- */
93
- -static int vhost_svq_add(VhostShadowVirtqueue *svq, VirtQueueElement *elem)
94
- +static int vhost_svq_add(VhostShadowVirtqueue *svq, const struct iovec *out_sg,
95
- + size_t out_num, const struct iovec *in_sg,
96
- + size_t in_num, VirtQueueElement *elem)
97
- {
98
- unsigned qemu_head;
99
- - unsigned ndescs = elem->in_num + elem->out_num;
100
- + unsigned ndescs = in_num + out_num;
101
- bool ok;
102
-
103
- if (unlikely(ndescs > vhost_svq_available_slots(svq))) {
104
- return -ENOSPC;
105
- }
106
-
107
- - ok = vhost_svq_add_split(svq, elem, &qemu_head);
108
- + ok = vhost_svq_add_split(svq, out_sg, out_num, in_sg, in_num, &qemu_head);
109
- if (unlikely(!ok)) {
110
- g_free(elem);
111
- return -EINVAL;
112
- @@ -258,6 +261,14 @@ static int vhost_svq_add(VhostShadowVirtqueue *svq, VirtQueueElement *elem)
113
- return 0;
114
- }
115
-
116
- +/* Convenience wrapper to add a guest's element to SVQ */
117
- +static int vhost_svq_add_element(VhostShadowVirtqueue *svq,
118
- + VirtQueueElement *elem)
119
- +{
120
- + return vhost_svq_add(svq, elem->out_sg, elem->out_num, elem->in_sg,
121
- + elem->in_num, elem);
122
- +}
123
- +
124
- /**
125
- * Forward available buffers.
126
- *
127
- @@ -294,7 +305,7 @@ static void vhost_handle_guest_kick(VhostShadowVirtqueue *svq)
128
- break;
129
- }
130
-
131
- - r = vhost_svq_add(svq, elem);
132
- + r = vhost_svq_add_element(svq, elem);
133
- if (unlikely(r != 0)) {
134
- if (r == -ENOSPC) {
135
- /*
136
- --
137
- 2.31.1
138
-
SOURCES/kvm-vhost-Expose-vhost_svq_add.patch DELETED
@@ -1,73 +0,0 @@
1
- From cefd6583a8483c7a80f9cde8f7ad4705983af9e7 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:38:55 +0200
4
- Subject: [PATCH 18/32] vhost: Expose vhost_svq_add
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [18/27] bfb44f597d350336113783bcc9b3c9d9d32ff8c0 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit d0291f3f284d3bc220cdb13b0d8ac8a44eb5fd4c
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Wed Jul 20 08:59:37 2022 +0200
24
-
25
- vhost: Expose vhost_svq_add
26
-
27
- This allows external parts of SVQ to forward custom buffers to the
28
- device.
29
-
30
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
31
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
32
- Signed-off-by: Jason Wang <jasowang@redhat.com>
33
-
34
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
35
- ---
36
- hw/virtio/vhost-shadow-virtqueue.c | 6 +++---
37
- hw/virtio/vhost-shadow-virtqueue.h | 3 +++
38
- 2 files changed, 6 insertions(+), 3 deletions(-)
39
-
40
- diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
41
- index 1ce52d5b4a..cb879e7b88 100644
42
- --- a/hw/virtio/vhost-shadow-virtqueue.c
43
- +++ b/hw/virtio/vhost-shadow-virtqueue.c
44
- @@ -238,9 +238,9 @@ static void vhost_svq_kick(VhostShadowVirtqueue *svq)
45
- *
46
- * Return -EINVAL if element is invalid, -ENOSPC if dev queue is full
47
- */
48
- -static int vhost_svq_add(VhostShadowVirtqueue *svq, const struct iovec *out_sg,
49
- - size_t out_num, const struct iovec *in_sg,
50
- - size_t in_num, VirtQueueElement *elem)
51
- +int vhost_svq_add(VhostShadowVirtqueue *svq, const struct iovec *out_sg,
52
- + size_t out_num, const struct iovec *in_sg, size_t in_num,
53
- + VirtQueueElement *elem)
54
- {
55
- unsigned qemu_head;
56
- unsigned ndescs = in_num + out_num;
57
- diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-virtqueue.h
58
- index d9fc1f1799..dd78f4bec2 100644
59
- --- a/hw/virtio/vhost-shadow-virtqueue.h
60
- +++ b/hw/virtio/vhost-shadow-virtqueue.h
61
- @@ -86,6 +86,9 @@ bool vhost_svq_valid_features(uint64_t features, Error **errp);
62
-
63
- void vhost_svq_push_elem(VhostShadowVirtqueue *svq,
64
- const VirtQueueElement *elem, uint32_t len);
65
- +int vhost_svq_add(VhostShadowVirtqueue *svq, const struct iovec *out_sg,
66
- + size_t out_num, const struct iovec *in_sg, size_t in_num,
67
- + VirtQueueElement *elem);
68
-
69
- void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *svq, int svq_kick_fd);
70
- void vhost_svq_set_svq_call_fd(VhostShadowVirtqueue *svq, int call_fd);
71
- --
72
- 2.31.1
73
-
SOURCES/kvm-vhost-Fix-device-s-used-descriptor-dequeue.patch DELETED
@@ -1,83 +0,0 @@
1
- From 793d6d56190397624efdcaf6e0112bd12e39c05d Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:25:01 +0200
4
- Subject: [PATCH 02/32] vhost: Fix device's used descriptor dequeue
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [2/27] b92803a0681c94c65d243dd07424522387594760 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit 81abfa5724c9a6502d7a1d3a67c55f2a303a1170
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Thu May 12 19:57:43 2022 +0200
24
-
25
- vhost: Fix device's used descriptor dequeue
26
-
27
- Only the first one of them were properly enqueued back.
28
-
29
- Fixes: 100890f7ca ("vhost: Shadow virtqueue buffers forwarding")
30
-
31
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
32
- Message-Id: <20220512175747.142058-3-eperezma@redhat.com>
33
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
34
- Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
35
-
36
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
37
- ---
38
- hw/virtio/vhost-shadow-virtqueue.c | 17 +++++++++++++++--
39
- 1 file changed, 15 insertions(+), 2 deletions(-)
40
-
41
- diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
42
- index 3155801f50..31fc50907d 100644
43
- --- a/hw/virtio/vhost-shadow-virtqueue.c
44
- +++ b/hw/virtio/vhost-shadow-virtqueue.c
45
- @@ -334,12 +334,22 @@ static void vhost_svq_disable_notification(VhostShadowVirtqueue *svq)
46
- svq->vring.avail->flags |= cpu_to_le16(VRING_AVAIL_F_NO_INTERRUPT);
47
- }
48
-
49
- +static uint16_t vhost_svq_last_desc_of_chain(const VhostShadowVirtqueue *svq,
50
- + uint16_t num, uint16_t i)
51
- +{
52
- + for (uint16_t j = 0; j < (num - 1); ++j) {
53
- + i = le16_to_cpu(svq->desc_next[i]);
54
- + }
55
- +
56
- + return i;
57
- +}
58
- +
59
- static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
60
- uint32_t *len)
61
- {
62
- const vring_used_t *used = svq->vring.used;
63
- vring_used_elem_t used_elem;
64
- - uint16_t last_used;
65
- + uint16_t last_used, last_used_chain, num;
66
-
67
- if (!vhost_svq_more_used(svq)) {
68
- return NULL;
69
- @@ -365,7 +375,10 @@ static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
70
- return NULL;
71
- }
72
-
73
- - svq->desc_next[used_elem.id] = svq->free_head;
74
- + num = svq->ring_id_maps[used_elem.id]->in_num +
75
- + svq->ring_id_maps[used_elem.id]->out_num;
76
- + last_used_chain = vhost_svq_last_desc_of_chain(svq, num, used_elem.id);
77
- + svq->desc_next[last_used_chain] = svq->free_head;
78
- svq->free_head = used_elem.id;
79
-
80
- *len = used_elem.len;
81
- --
82
- 2.31.1
83
-
SOURCES/kvm-vhost-Fix-element-in-vhost_svq_add-failure.patch DELETED
@@ -1,68 +0,0 @@
1
- From aa99cf129923e0203c0caeb3b4e94a0eb973746f Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:36:38 +0200
4
- Subject: [PATCH 04/32] vhost: Fix element in vhost_svq_add failure
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [4/27] 96689c99a47dd49591c0d126cb1fbb975b2f79b4 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit 5181db132b587754dda3a520eec923b87a65bbb7
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Thu May 12 19:57:47 2022 +0200
24
-
25
- vhost: Fix element in vhost_svq_add failure
26
-
27
- Coverity rightly reports that is not free in that case.
28
-
29
- Fixes: Coverity CID 1487559
30
- Fixes: 100890f7ca ("vhost: Shadow virtqueue buffers forwarding")
31
-
32
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
33
- Message-Id: <20220512175747.142058-7-eperezma@redhat.com>
34
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
35
- Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
36
-
37
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
38
- ---
39
- hw/virtio/vhost-shadow-virtqueue.c | 8 ++++++++
40
- 1 file changed, 8 insertions(+)
41
-
42
- diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
43
- index 31fc50907d..06d0bb39d9 100644
44
- --- a/hw/virtio/vhost-shadow-virtqueue.c
45
- +++ b/hw/virtio/vhost-shadow-virtqueue.c
46
- @@ -199,11 +199,19 @@ static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,
47
- return true;
48
- }
49
-
50
- +/**
51
- + * Add an element to a SVQ.
52
- + *
53
- + * The caller must check that there is enough slots for the new element. It
54
- + * takes ownership of the element: In case of failure, it is free and the SVQ
55
- + * is considered broken.
56
- + */
57
- static bool vhost_svq_add(VhostShadowVirtqueue *svq, VirtQueueElement *elem)
58
- {
59
- unsigned qemu_head;
60
- bool ok = vhost_svq_add_split(svq, elem, &qemu_head);
61
- if (unlikely(!ok)) {
62
- + g_free(elem);
63
- return false;
64
- }
65
-
66
- --
67
- 2.31.1
68
-
SOURCES/kvm-vhost-Move-vhost_svq_kick-call-to-vhost_svq_add.patch DELETED
@@ -1,61 +0,0 @@
1
- From 3a944d8cd3d35b2398ff68d9ed8ea51d27dfab3c Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:38:55 +0200
4
- Subject: [PATCH 12/32] vhost: Move vhost_svq_kick call to vhost_svq_add
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [12/27] 29a7e1fb4992c4beca1e9a3379bb4c8a0f567459 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit 98b5adef8493a2bfad6655cfee84299e88bedbf7
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Wed Jul 20 08:59:31 2022 +0200
24
-
25
- vhost: Move vhost_svq_kick call to vhost_svq_add
26
-
27
- The series needs to expose vhost_svq_add with full functionality,
28
- including kick
29
-
30
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
31
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
32
- Signed-off-by: Jason Wang <jasowang@redhat.com>
33
-
34
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
35
- ---
36
- hw/virtio/vhost-shadow-virtqueue.c | 2 +-
37
- 1 file changed, 1 insertion(+), 1 deletion(-)
38
-
39
- diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
40
- index 05cd39d1eb..e3fc3c2658 100644
41
- --- a/hw/virtio/vhost-shadow-virtqueue.c
42
- +++ b/hw/virtio/vhost-shadow-virtqueue.c
43
- @@ -246,6 +246,7 @@ static bool vhost_svq_add(VhostShadowVirtqueue *svq, VirtQueueElement *elem)
44
- }
45
-
46
- svq->ring_id_maps[qemu_head] = elem;
47
- + vhost_svq_kick(svq);
48
- return true;
49
- }
50
-
51
- @@ -306,7 +307,6 @@ static void vhost_handle_guest_kick(VhostShadowVirtqueue *svq)
52
- /* VQ is broken, just return and ignore any other kicks */
53
- return;
54
- }
55
- - vhost_svq_kick(svq);
56
- }
57
-
58
- virtio_queue_set_notification(svq->vq, true);
59
- --
60
- 2.31.1
61
-
SOURCES/kvm-vhost-Reorder-vhost_svq_kick.patch DELETED
@@ -1,88 +0,0 @@
1
- From fdbf66e4c70de16ab36d70ea591322b1b24df591 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:38:55 +0200
4
- Subject: [PATCH 11/32] vhost: Reorder vhost_svq_kick
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [11/27] 1d08b97eb3960a0f85f2dd48c3331b803f7ea205 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit d93a2405ca6efa9dc1c420cee5a34bd8242818d0
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Wed Jul 20 08:59:30 2022 +0200
24
-
25
- vhost: Reorder vhost_svq_kick
26
-
27
- Future code needs to call it from vhost_svq_add.
28
-
29
- No functional change intended.
30
-
31
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
32
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
33
- Signed-off-by: Jason Wang <jasowang@redhat.com>
34
-
35
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
36
- ---
37
- hw/virtio/vhost-shadow-virtqueue.c | 28 ++++++++++++++--------------
38
- 1 file changed, 14 insertions(+), 14 deletions(-)
39
-
40
- diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
41
- index 9c46c3a8fa..05cd39d1eb 100644
42
- --- a/hw/virtio/vhost-shadow-virtqueue.c
43
- +++ b/hw/virtio/vhost-shadow-virtqueue.c
44
- @@ -215,6 +215,20 @@ static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,
45
- return true;
46
- }
47
-
48
- +static void vhost_svq_kick(VhostShadowVirtqueue *svq)
49
- +{
50
- + /*
51
- + * We need to expose the available array entries before checking the used
52
- + * flags
53
- + */
54
- + smp_mb();
55
- + if (svq->vring.used->flags & VRING_USED_F_NO_NOTIFY) {
56
- + return;
57
- + }
58
- +
59
- + event_notifier_set(&svq->hdev_kick);
60
- +}
61
- +
62
- /**
63
- * Add an element to a SVQ.
64
- *
65
- @@ -235,20 +249,6 @@ static bool vhost_svq_add(VhostShadowVirtqueue *svq, VirtQueueElement *elem)
66
- return true;
67
- }
68
-
69
- -static void vhost_svq_kick(VhostShadowVirtqueue *svq)
70
- -{
71
- - /*
72
- - * We need to expose the available array entries before checking the used
73
- - * flags
74
- - */
75
- - smp_mb();
76
- - if (svq->vring.used->flags & VRING_USED_F_NO_NOTIFY) {
77
- - return;
78
- - }
79
- -
80
- - event_notifier_set(&svq->hdev_kick);
81
- -}
82
- -
83
- /**
84
- * Forward available buffers.
85
- *
86
- --
87
- 2.31.1
88
-
SOURCES/kvm-vhost-Track-descriptor-chain-in-private-at-SVQ.patch DELETED
@@ -1,123 +0,0 @@
1
- From 486647551223cc01f4dba87197030bbf4e674f0f Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:24:48 +0200
4
- Subject: [PATCH 01/32] vhost: Track descriptor chain in private at SVQ
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [1/27] 26d16dc383e3064ac6e4288d5c52b39fee0ad204 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit 495fe3a78749c39c0e772c4e1a55d6cb8a7e5292
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Thu May 12 19:57:42 2022 +0200
24
-
25
- vhost: Track descriptor chain in private at SVQ
26
-
27
- The device could have access to modify them, and it definitely have
28
- access when we implement packed vq. Harden SVQ maintaining a private
29
- copy of the descriptor chain. Other fields like buffer addresses are
30
- already maintained sepparatedly.
31
-
32
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
33
- Message-Id: <20220512175747.142058-2-eperezma@redhat.com>
34
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
35
- Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
36
-
37
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
38
- ---
39
- hw/virtio/vhost-shadow-virtqueue.c | 12 +++++++-----
40
- hw/virtio/vhost-shadow-virtqueue.h | 6 ++++++
41
- 2 files changed, 13 insertions(+), 5 deletions(-)
42
-
43
- diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
44
- index b232803d1b..3155801f50 100644
45
- --- a/hw/virtio/vhost-shadow-virtqueue.c
46
- +++ b/hw/virtio/vhost-shadow-virtqueue.c
47
- @@ -138,6 +138,7 @@ static void vhost_vring_write_descs(VhostShadowVirtqueue *svq, hwaddr *sg,
48
- for (n = 0; n < num; n++) {
49
- if (more_descs || (n + 1 < num)) {
50
- descs[i].flags = flags | cpu_to_le16(VRING_DESC_F_NEXT);
51
- + descs[i].next = cpu_to_le16(svq->desc_next[i]);
52
- } else {
53
- descs[i].flags = flags;
54
- }
55
- @@ -145,10 +146,10 @@ static void vhost_vring_write_descs(VhostShadowVirtqueue *svq, hwaddr *sg,
56
- descs[i].len = cpu_to_le32(iovec[n].iov_len);
57
-
58
- last = i;
59
- - i = cpu_to_le16(descs[i].next);
60
- + i = cpu_to_le16(svq->desc_next[i]);
61
- }
62
-
63
- - svq->free_head = le16_to_cpu(descs[last].next);
64
- + svq->free_head = le16_to_cpu(svq->desc_next[last]);
65
- }
66
-
67
- static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,
68
- @@ -336,7 +337,6 @@ static void vhost_svq_disable_notification(VhostShadowVirtqueue *svq)
69
- static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
70
- uint32_t *len)
71
- {
72
- - vring_desc_t *descs = svq->vring.desc;
73
- const vring_used_t *used = svq->vring.used;
74
- vring_used_elem_t used_elem;
75
- uint16_t last_used;
76
- @@ -365,7 +365,7 @@ static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
77
- return NULL;
78
- }
79
-
80
- - descs[used_elem.id].next = svq->free_head;
81
- + svq->desc_next[used_elem.id] = svq->free_head;
82
- svq->free_head = used_elem.id;
83
-
84
- *len = used_elem.len;
85
- @@ -540,8 +540,9 @@ void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev,
86
- svq->vring.used = qemu_memalign(qemu_real_host_page_size, device_size);
87
- memset(svq->vring.used, 0, device_size);
88
- svq->ring_id_maps = g_new0(VirtQueueElement *, svq->vring.num);
89
- + svq->desc_next = g_new0(uint16_t, svq->vring.num);
90
- for (unsigned i = 0; i < svq->vring.num - 1; i++) {
91
- - svq->vring.desc[i].next = cpu_to_le16(i + 1);
92
- + svq->desc_next[i] = cpu_to_le16(i + 1);
93
- }
94
- }
95
-
96
- @@ -574,6 +575,7 @@ void vhost_svq_stop(VhostShadowVirtqueue *svq)
97
- virtqueue_detach_element(svq->vq, next_avail_elem, 0);
98
- }
99
- svq->vq = NULL;
100
- + g_free(svq->desc_next);
101
- g_free(svq->ring_id_maps);
102
- qemu_vfree(svq->vring.desc);
103
- qemu_vfree(svq->vring.used);
104
- diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-virtqueue.h
105
- index e5e24c536d..c132c994e9 100644
106
- --- a/hw/virtio/vhost-shadow-virtqueue.h
107
- +++ b/hw/virtio/vhost-shadow-virtqueue.h
108
- @@ -53,6 +53,12 @@ typedef struct VhostShadowVirtqueue {
109
- /* Next VirtQueue element that guest made available */
110
- VirtQueueElement *next_guest_avail_elem;
111
-
112
- + /*
113
- + * Backup next field for each descriptor so we can recover securely, not
114
- + * needing to trust the device access.
115
- + */
116
- + uint16_t *desc_next;
117
- +
118
- /* Next head to expose to the device */
119
- uint16_t shadow_avail_idx;
120
-
121
- --
122
- 2.31.1
123
-
SOURCES/kvm-vhost-Track-number-of-descs-in-SVQDescState.patch DELETED
@@ -1,81 +0,0 @@
1
- From 24b8cf88f53f9fc7cb393c9cad908f759980bfee Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:38:55 +0200
4
- Subject: [PATCH 16/32] vhost: Track number of descs in SVQDescState
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [16/27] 26f30cb6dd35c1eb1ddabe25113431bed3d744aa (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit ac4cfdc6f39c06732d27554523f9d5f8a53b4ffa
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Wed Jul 20 08:59:35 2022 +0200
24
-
25
- vhost: Track number of descs in SVQDescState
26
-
27
- A guest's buffer continuos on GPA may need multiple descriptors on
28
- qemu's VA, so SVQ should track its length sepparatedly.
29
-
30
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
31
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
32
- Signed-off-by: Jason Wang <jasowang@redhat.com>
33
-
34
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
35
- ---
36
- hw/virtio/vhost-shadow-virtqueue.c | 4 ++--
37
- hw/virtio/vhost-shadow-virtqueue.h | 6 ++++++
38
- 2 files changed, 8 insertions(+), 2 deletions(-)
39
-
40
- diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
41
- index a08e3d4025..4d99075e73 100644
42
- --- a/hw/virtio/vhost-shadow-virtqueue.c
43
- +++ b/hw/virtio/vhost-shadow-virtqueue.c
44
- @@ -257,6 +257,7 @@ static int vhost_svq_add(VhostShadowVirtqueue *svq, const struct iovec *out_sg,
45
- }
46
-
47
- svq->desc_state[qemu_head].elem = elem;
48
- + svq->desc_state[qemu_head].ndescs = ndescs;
49
- vhost_svq_kick(svq);
50
- return 0;
51
- }
52
- @@ -418,8 +419,7 @@ static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
53
- return NULL;
54
- }
55
-
56
- - num = svq->desc_state[used_elem.id].elem->in_num +
57
- - svq->desc_state[used_elem.id].elem->out_num;
58
- + num = svq->desc_state[used_elem.id].ndescs;
59
- last_used_chain = vhost_svq_last_desc_of_chain(svq, num, used_elem.id);
60
- svq->desc_next[last_used_chain] = svq->free_head;
61
- svq->free_head = used_elem.id;
62
- diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-virtqueue.h
63
- index d646c35054..5c7e7cbab6 100644
64
- --- a/hw/virtio/vhost-shadow-virtqueue.h
65
- +++ b/hw/virtio/vhost-shadow-virtqueue.h
66
- @@ -17,6 +17,12 @@
67
-
68
- typedef struct SVQDescState {
69
- VirtQueueElement *elem;
70
- +
71
- + /*
72
- + * Number of descriptors exposed to the device. May or may not match
73
- + * guest's
74
- + */
75
- + unsigned int ndescs;
76
- } SVQDescState;
77
-
78
- /* Shadow virtqueue to relay notifications */
79
- --
80
- 2.31.1
81
-
SOURCES/kvm-vhost-add-support-for-configure-interrupt.patch ADDED
@@ -0,0 +1,185 @@
1
+ From 42818e2bc6fa537fe52f7f0e6b094774a1eb00e1 Mon Sep 17 00:00:00 2001
2
+ From: Cindy Lu <lulu@redhat.com>
3
+ Date: Thu, 22 Dec 2022 15:04:48 +0800
4
+ Subject: [PATCH 07/31] vhost: add support for configure interrupt
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Cindy Lu <lulu@redhat.com>
10
+ RH-MergeRequest: 132: vhost-vdpa: support config interrupt in vhost-vdpa
11
+ RH-Bugzilla: 1905805
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [7/10] d58b439eb093f5dd3b7ca081af0ab75780e42917 (lulu6/qemu-kvm3)
16
+
17
+ https://bugzilla.redhat.com/show_bug.cgi?id=1905805
18
+ Add functions to support configure interrupt.
19
+ The configure interrupt process will start in vhost_dev_start
20
+ and stop in vhost_dev_stop.
21
+
22
+ Also add the functions to support vhost_config_pending and
23
+ vhost_config_mask.
24
+
25
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
26
+ Message-Id: <20221222070451.936503-8-lulu@redhat.com>
27
+ Acked-by: Jason Wang <jasowang@redhat.com>
28
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
29
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
30
+ (cherry picked from commit f9a09ca3ea69d108d828b7c82f1bd61b2df6fc96)
31
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
32
+ ---
33
+ hw/virtio/vhost.c | 78 ++++++++++++++++++++++++++++++++++++++-
34
+ include/hw/virtio/vhost.h | 4 ++
35
+ 2 files changed, 81 insertions(+), 1 deletion(-)
36
+
37
+ diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
38
+ index 7fb008bc9e..84dbb39e07 100644
39
+ --- a/hw/virtio/vhost.c
40
+ +++ b/hw/virtio/vhost.c
41
+ @@ -1596,7 +1596,68 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int n,
42
+ file.index = hdev->vhost_ops->vhost_get_vq_index(hdev, n);
43
+ r = hdev->vhost_ops->vhost_set_vring_call(hdev, &file);
44
+ if (r < 0) {
45
+ - VHOST_OPS_DEBUG(r, "vhost_set_vring_call failed");
46
+ + error_report("vhost_set_vring_call failed %d", -r);
47
+ + }
48
+ +}
49
+ +
50
+ +bool vhost_config_pending(struct vhost_dev *hdev)
51
+ +{
52
+ + assert(hdev->vhost_ops);
53
+ + if ((hdev->started == false) ||
54
+ + (hdev->vhost_ops->vhost_set_config_call == NULL)) {
55
+ + return false;
56
+ + }
57
+ +
58
+ + EventNotifier *notifier =
59
+ + &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier;
60
+ + return event_notifier_test_and_clear(notifier);
61
+ +}
62
+ +
63
+ +void vhost_config_mask(struct vhost_dev *hdev, VirtIODevice *vdev, bool mask)
64
+ +{
65
+ + int fd;
66
+ + int r;
67
+ + EventNotifier *notifier =
68
+ + &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier;
69
+ + EventNotifier *config_notifier = &vdev->config_notifier;
70
+ + assert(hdev->vhost_ops);
71
+ +
72
+ + if ((hdev->started == false) ||
73
+ + (hdev->vhost_ops->vhost_set_config_call == NULL)) {
74
+ + return;
75
+ + }
76
+ + if (mask) {
77
+ + assert(vdev->use_guest_notifier_mask);
78
+ + fd = event_notifier_get_fd(notifier);
79
+ + } else {
80
+ + fd = event_notifier_get_fd(config_notifier);
81
+ + }
82
+ + r = hdev->vhost_ops->vhost_set_config_call(hdev, fd);
83
+ + if (r < 0) {
84
+ + error_report("vhost_set_config_call failed %d", -r);
85
+ + }
86
+ +}
87
+ +
88
+ +static void vhost_stop_config_intr(struct vhost_dev *dev)
89
+ +{
90
+ + int fd = -1;
91
+ + assert(dev->vhost_ops);
92
+ + if (dev->vhost_ops->vhost_set_config_call) {
93
+ + dev->vhost_ops->vhost_set_config_call(dev, fd);
94
+ + }
95
+ +}
96
+ +
97
+ +static void vhost_start_config_intr(struct vhost_dev *dev)
98
+ +{
99
+ + int r;
100
+ +
101
+ + assert(dev->vhost_ops);
102
+ + int fd = event_notifier_get_fd(&dev->vdev->config_notifier);
103
+ + if (dev->vhost_ops->vhost_set_config_call) {
104
+ + r = dev->vhost_ops->vhost_set_config_call(dev, fd);
105
+ + if (!r) {
106
+ + event_notifier_set(&dev->vdev->config_notifier);
107
+ + }
108
+ }
109
+ }
110
+
111
+ @@ -1836,6 +1897,16 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
112
+ }
113
+ }
114
+
115
+ + r = event_notifier_init(
116
+ + &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier, 0);
117
+ + if (r < 0) {
118
+ + return r;
119
+ + }
120
+ + event_notifier_test_and_clear(
121
+ + &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier);
122
+ + if (!vdev->use_guest_notifier_mask) {
123
+ + vhost_config_mask(hdev, vdev, true);
124
+ + }
125
+ if (hdev->log_enabled) {
126
+ uint64_t log_base;
127
+
128
+ @@ -1874,6 +1945,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
129
+ vhost_device_iotlb_miss(hdev, vq->used_phys, true);
130
+ }
131
+ }
132
+ + vhost_start_config_intr(hdev);
133
+ return 0;
134
+ fail_start:
135
+ if (vrings) {
136
+ @@ -1903,6 +1975,9 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
137
+
138
+ /* should only be called after backend is connected */
139
+ assert(hdev->vhost_ops);
140
+ + event_notifier_test_and_clear(
141
+ + &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier);
142
+ + event_notifier_test_and_clear(&vdev->config_notifier);
143
+
144
+ trace_vhost_dev_stop(hdev, vdev->name, vrings);
145
+
146
+ @@ -1925,6 +2000,7 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
147
+ }
148
+ memory_listener_unregister(&hdev->iommu_listener);
149
+ }
150
+ + vhost_stop_config_intr(hdev);
151
+ vhost_log_put(hdev, true);
152
+ hdev->started = false;
153
+ vdev->vhost_started = false;
154
+ diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
155
+ index 67a6807fac..05bedb2416 100644
156
+ --- a/include/hw/virtio/vhost.h
157
+ +++ b/include/hw/virtio/vhost.h
158
+ @@ -33,6 +33,7 @@ struct vhost_virtqueue {
159
+ unsigned used_size;
160
+ EventNotifier masked_notifier;
161
+ EventNotifier error_notifier;
162
+ + EventNotifier masked_config_notifier;
163
+ struct vhost_dev *dev;
164
+ };
165
+
166
+ @@ -41,6 +42,7 @@ typedef unsigned long vhost_log_chunk_t;
167
+ #define VHOST_LOG_BITS (8 * sizeof(vhost_log_chunk_t))
168
+ #define VHOST_LOG_CHUNK (VHOST_LOG_PAGE * VHOST_LOG_BITS)
169
+ #define VHOST_INVALID_FEATURE_BIT (0xff)
170
+ +#define VHOST_QUEUE_NUM_CONFIG_INR 0
171
+
172
+ struct vhost_log {
173
+ unsigned long long size;
174
+ @@ -168,6 +170,8 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev);
175
+ * Disable direct notifications to vhost device.
176
+ */
177
+ void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev);
178
+ +bool vhost_config_pending(struct vhost_dev *hdev);
179
+ +void vhost_config_mask(struct vhost_dev *hdev, VirtIODevice *vdev, bool mask);
180
+
181
+ /**
182
+ * vhost_dev_is_started() - report status of vhost device
183
+ --
184
+ 2.31.1
185
+
SOURCES/kvm-vhost-add-vhost_svq_poll.patch DELETED
@@ -1,92 +0,0 @@
1
- From 0ab3da1092362470d256b433c546bd365d34f930 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:38:55 +0200
4
- Subject: [PATCH 19/32] vhost: add vhost_svq_poll
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [19/27] 6807bb0bb6e5183b46a03b12b4027c7d767e8555 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit 3f44d13dda83d390cc9563e56e7d337e4f6223f4
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Wed Jul 20 08:59:38 2022 +0200
24
-
25
- vhost: add vhost_svq_poll
26
-
27
- It allows the Shadow Control VirtQueue to wait for the device to use the
28
- available buffers.
29
-
30
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
31
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
32
- Signed-off-by: Jason Wang <jasowang@redhat.com>
33
-
34
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
35
- ---
36
- hw/virtio/vhost-shadow-virtqueue.c | 27 +++++++++++++++++++++++++++
37
- hw/virtio/vhost-shadow-virtqueue.h | 1 +
38
- 2 files changed, 28 insertions(+)
39
-
40
- diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
41
- index cb879e7b88..95d0d7a7ee 100644
42
- --- a/hw/virtio/vhost-shadow-virtqueue.c
43
- +++ b/hw/virtio/vhost-shadow-virtqueue.c
44
- @@ -485,6 +485,33 @@ static void vhost_svq_flush(VhostShadowVirtqueue *svq,
45
- } while (!vhost_svq_enable_notification(svq));
46
- }
47
-
48
- +/**
49
- + * Poll the SVQ for one device used buffer.
50
- + *
51
- + * This function race with main event loop SVQ polling, so extra
52
- + * synchronization is needed.
53
- + *
54
- + * Return the length written by the device.
55
- + */
56
- +size_t vhost_svq_poll(VhostShadowVirtqueue *svq)
57
- +{
58
- + int64_t start_us = g_get_monotonic_time();
59
- + do {
60
- + uint32_t len;
61
- + VirtQueueElement *elem = vhost_svq_get_buf(svq, &len);
62
- + if (elem) {
63
- + return len;
64
- + }
65
- +
66
- + if (unlikely(g_get_monotonic_time() - start_us > 10e6)) {
67
- + return 0;
68
- + }
69
- +
70
- + /* Make sure we read new used_idx */
71
- + smp_rmb();
72
- + } while (true);
73
- +}
74
- +
75
- /**
76
- * Forward used buffers.
77
- *
78
- diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-virtqueue.h
79
- index dd78f4bec2..cf442f7dea 100644
80
- --- a/hw/virtio/vhost-shadow-virtqueue.h
81
- +++ b/hw/virtio/vhost-shadow-virtqueue.h
82
- @@ -89,6 +89,7 @@ void vhost_svq_push_elem(VhostShadowVirtqueue *svq,
83
- int vhost_svq_add(VhostShadowVirtqueue *svq, const struct iovec *out_sg,
84
- size_t out_num, const struct iovec *in_sg, size_t in_num,
85
- VirtQueueElement *elem);
86
- +size_t vhost_svq_poll(VhostShadowVirtqueue *svq);
87
-
88
- void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *svq, int svq_kick_fd);
89
- void vhost_svq_set_svq_call_fd(VhostShadowVirtqueue *svq, int call_fd);
90
- --
91
- 2.31.1
92
-
SOURCES/kvm-vhost-add-vhost_svq_push_elem.patch DELETED
@@ -1,83 +0,0 @@
1
- From a26eb02b3a49c5d1163685ba5b83b67138c09047 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:38:55 +0200
4
- Subject: [PATCH 17/32] vhost: add vhost_svq_push_elem
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [17/27] d064b40a262f2dfdc9f648d250aa8c8020c40385 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit 432efd144e990b6e040862de25f8f0b6a6eeb03d
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Wed Jul 20 08:59:36 2022 +0200
24
-
25
- vhost: add vhost_svq_push_elem
26
-
27
- This function allows external SVQ users to return guest's available
28
- buffers.
29
-
30
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
31
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
32
- Signed-off-by: Jason Wang <jasowang@redhat.com>
33
-
34
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
35
- ---
36
- hw/virtio/vhost-shadow-virtqueue.c | 16 ++++++++++++++++
37
- hw/virtio/vhost-shadow-virtqueue.h | 3 +++
38
- 2 files changed, 19 insertions(+)
39
-
40
- diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
41
- index 4d99075e73..1ce52d5b4a 100644
42
- --- a/hw/virtio/vhost-shadow-virtqueue.c
43
- +++ b/hw/virtio/vhost-shadow-virtqueue.c
44
- @@ -428,6 +428,22 @@ static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
45
- return g_steal_pointer(&svq->desc_state[used_elem.id].elem);
46
- }
47
-
48
- +/**
49
- + * Push an element to SVQ, returning it to the guest.
50
- + */
51
- +void vhost_svq_push_elem(VhostShadowVirtqueue *svq,
52
- + const VirtQueueElement *elem, uint32_t len)
53
- +{
54
- + virtqueue_push(svq->vq, elem, len);
55
- + if (svq->next_guest_avail_elem) {
56
- + /*
57
- + * Avail ring was full when vhost_svq_flush was called, so it's a
58
- + * good moment to make more descriptors available if possible.
59
- + */
60
- + vhost_handle_guest_kick(svq);
61
- + }
62
- +}
63
- +
64
- static void vhost_svq_flush(VhostShadowVirtqueue *svq,
65
- bool check_for_avail_queue)
66
- {
67
- diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-virtqueue.h
68
- index 5c7e7cbab6..d9fc1f1799 100644
69
- --- a/hw/virtio/vhost-shadow-virtqueue.h
70
- +++ b/hw/virtio/vhost-shadow-virtqueue.h
71
- @@ -84,6 +84,9 @@ typedef struct VhostShadowVirtqueue {
72
-
73
- bool vhost_svq_valid_features(uint64_t features, Error **errp);
74
-
75
- +void vhost_svq_push_elem(VhostShadowVirtqueue *svq,
76
- + const VirtQueueElement *elem, uint32_t len);
77
- +
78
- void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *svq, int svq_kick_fd);
79
- void vhost_svq_set_svq_call_fd(VhostShadowVirtqueue *svq, int call_fd);
80
- void vhost_svq_get_vring_addr(const VhostShadowVirtqueue *svq,
81
- --
82
- 2.31.1
83
-
SOURCES/kvm-vhost-allocate-SVQ-device-file-descriptors-at-device.patch ADDED
@@ -0,0 +1,171 @@
1
+ From bffccbd59a2e2c641810cd7362c7b5ecf5989ed8 Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
+ Date: Thu, 15 Dec 2022 12:31:35 +0100
4
+ Subject: [PATCH 03/14] vhost: allocate SVQ device file descriptors at device
5
+ start
6
+ MIME-Version: 1.0
7
+ Content-Type: text/plain; charset=UTF-8
8
+ Content-Transfer-Encoding: 8bit
9
+
10
+ RH-Author: Eugenio Pérez <eperezma@redhat.com>
11
+ RH-MergeRequest: 136: vDPA ASID support in Qemu
12
+ RH-Bugzilla: 2104412
13
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
14
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
16
+ RH-Commit: [3/13] bab2d43f0fc0d13a4917e706244b37e1a431b082 (eperezmartin/qemu-kvm)
17
+
18
+ The next patches will start control SVQ if possible. However, we don't
19
+ know if that will be possible at qemu boot anymore.
20
+
21
+ Delay device file descriptors until we know it at device start. This
22
+ will avoid to create them if the device does not support SVQ.
23
+
24
+ Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
25
+ Acked-by: Jason Wang <jasowang@redhat.com>
26
+ Message-Id: <20221215113144.322011-4-eperezma@redhat.com>
27
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
28
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
29
+ (cherry picked from commit 3cfb4d069cd2977b707fb519c455d7d416e1f4b0)
30
+ ---
31
+ hw/virtio/vhost-shadow-virtqueue.c | 31 ++------------------------
32
+ hw/virtio/vhost-vdpa.c | 35 ++++++++++++++++++++++++------
33
+ 2 files changed, 30 insertions(+), 36 deletions(-)
34
+
35
+ diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
36
+ index 264ddc166d..3b05bab44d 100644
37
+ --- a/hw/virtio/vhost-shadow-virtqueue.c
38
+ +++ b/hw/virtio/vhost-shadow-virtqueue.c
39
+ @@ -715,43 +715,18 @@ void vhost_svq_stop(VhostShadowVirtqueue *svq)
40
+ * @iova_tree: Tree to perform descriptors translations
41
+ * @ops: SVQ owner callbacks
42
+ * @ops_opaque: ops opaque pointer
43
+ - *
44
+ - * Returns the new virtqueue or NULL.
45
+ - *
46
+ - * In case of error, reason is reported through error_report.
47
+ */
48
+ VhostShadowVirtqueue *vhost_svq_new(VhostIOVATree *iova_tree,
49
+ const VhostShadowVirtqueueOps *ops,
50
+ void *ops_opaque)
51
+ {
52
+ - g_autofree VhostShadowVirtqueue *svq = g_new0(VhostShadowVirtqueue, 1);
53
+ - int r;
54
+ -
55
+ - r = event_notifier_init(&svq->hdev_kick, 0);
56
+ - if (r != 0) {
57
+ - error_report("Couldn't create kick event notifier: %s (%d)",
58
+ - g_strerror(errno), errno);
59
+ - goto err_init_hdev_kick;
60
+ - }
61
+ -
62
+ - r = event_notifier_init(&svq->hdev_call, 0);
63
+ - if (r != 0) {
64
+ - error_report("Couldn't create call event notifier: %s (%d)",
65
+ - g_strerror(errno), errno);
66
+ - goto err_init_hdev_call;
67
+ - }
68
+ + VhostShadowVirtqueue *svq = g_new0(VhostShadowVirtqueue, 1);
69
+
70
+ event_notifier_init_fd(&svq->svq_kick, VHOST_FILE_UNBIND);
71
+ svq->iova_tree = iova_tree;
72
+ svq->ops = ops;
73
+ svq->ops_opaque = ops_opaque;
74
+ - return g_steal_pointer(&svq);
75
+ -
76
+ -err_init_hdev_call:
77
+ - event_notifier_cleanup(&svq->hdev_kick);
78
+ -
79
+ -err_init_hdev_kick:
80
+ - return NULL;
81
+ + return svq;
82
+ }
83
+
84
+ /**
85
+ @@ -763,7 +738,5 @@ void vhost_svq_free(gpointer pvq)
86
+ {
87
+ VhostShadowVirtqueue *vq = pvq;
88
+ vhost_svq_stop(vq);
89
+ - event_notifier_cleanup(&vq->hdev_kick);
90
+ - event_notifier_cleanup(&vq->hdev_call);
91
+ g_free(vq);
92
+ }
93
+ diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
94
+ index 44e6a9b7b3..530d2ca362 100644
95
+ --- a/hw/virtio/vhost-vdpa.c
96
+ +++ b/hw/virtio/vhost-vdpa.c
97
+ @@ -428,15 +428,11 @@ static int vhost_vdpa_init_svq(struct vhost_dev *hdev, struct vhost_vdpa *v,
98
+
99
+ shadow_vqs = g_ptr_array_new_full(hdev->nvqs, vhost_svq_free);
100
+ for (unsigned n = 0; n < hdev->nvqs; ++n) {
101
+ - g_autoptr(VhostShadowVirtqueue) svq;
102
+ + VhostShadowVirtqueue *svq;
103
+
104
+ svq = vhost_svq_new(v->iova_tree, v->shadow_vq_ops,
105
+ v->shadow_vq_ops_opaque);
106
+ - if (unlikely(!svq)) {
107
+ - error_setg(errp, "Cannot create svq %u", n);
108
+ - return -1;
109
+ - }
110
+ - g_ptr_array_add(shadow_vqs, g_steal_pointer(&svq));
111
+ + g_ptr_array_add(shadow_vqs, svq);
112
+ }
113
+
114
+ v->shadow_vqs = g_steal_pointer(&shadow_vqs);
115
+ @@ -871,11 +867,23 @@ static int vhost_vdpa_svq_set_fds(struct vhost_dev *dev,
116
+ const EventNotifier *event_notifier = &svq->hdev_kick;
117
+ int r;
118
+
119
+ + r = event_notifier_init(&svq->hdev_kick, 0);
120
+ + if (r != 0) {
121
+ + error_setg_errno(errp, -r, "Couldn't create kick event notifier");
122
+ + goto err_init_hdev_kick;
123
+ + }
124
+ +
125
+ + r = event_notifier_init(&svq->hdev_call, 0);
126
+ + if (r != 0) {
127
+ + error_setg_errno(errp, -r, "Couldn't create call event notifier");
128
+ + goto err_init_hdev_call;
129
+ + }
130
+ +
131
+ file.fd = event_notifier_get_fd(event_notifier);
132
+ r = vhost_vdpa_set_vring_dev_kick(dev, &file);
133
+ if (unlikely(r != 0)) {
134
+ error_setg_errno(errp, -r, "Can't set device kick fd");
135
+ - return r;
136
+ + goto err_init_set_dev_fd;
137
+ }
138
+
139
+ event_notifier = &svq->hdev_call;
140
+ @@ -883,8 +891,18 @@ static int vhost_vdpa_svq_set_fds(struct vhost_dev *dev,
141
+ r = vhost_vdpa_set_vring_dev_call(dev, &file);
142
+ if (unlikely(r != 0)) {
143
+ error_setg_errno(errp, -r, "Can't set device call fd");
144
+ + goto err_init_set_dev_fd;
145
+ }
146
+
147
+ + return 0;
148
+ +
149
+ +err_init_set_dev_fd:
150
+ + event_notifier_set_handler(&svq->hdev_call, NULL);
151
+ +
152
+ +err_init_hdev_call:
153
+ + event_notifier_cleanup(&svq->hdev_kick);
154
+ +
155
+ +err_init_hdev_kick:
156
+ return r;
157
+ }
158
+
159
+ @@ -1096,6 +1114,9 @@ static void vhost_vdpa_svqs_stop(struct vhost_dev *dev)
160
+ for (unsigned i = 0; i < v->shadow_vqs->len; ++i) {
161
+ VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
162
+ vhost_vdpa_svq_unmap_rings(dev, svq);
163
+ +
164
+ + event_notifier_cleanup(&svq->hdev_kick);
165
+ + event_notifier_cleanup(&svq->hdev_call);
166
+ }
167
+ }
168
+
169
+ --
170
+ 2.31.1
171
+
SOURCES/kvm-vhost-fix-vq-dirty-bitmap-syncing-when-vIOMMU-is-ena.patch ADDED
@@ -0,0 +1,157 @@
1
+ From 55aad90e347599e88747888ddbefcba33427f386 Mon Sep 17 00:00:00 2001
2
+ From: Jason Wang <jasowang@redhat.com>
3
+ Date: Fri, 16 Dec 2022 11:35:52 +0800
4
+ Subject: [PATCH 12/31] vhost: fix vq dirty bitmap syncing when vIOMMU is
5
+ enabled
6
+
7
+ RH-Author: Eric Auger <eric.auger@redhat.com>
8
+ RH-MergeRequest: 134: vhost: fix vq dirty bitmap syncing when vIOMMU is enabled
9
+ RH-Bugzilla: 2124856
10
+ RH-Acked-by: Peter Xu <peterx@redhat.com>
11
+ RH-Acked-by: Jason Wang <jasowang@redhat.com>
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Commit: [1/1] 57ef499b63dc2cca6e64ee84d1dc127635868ca2 (eauger1/centos-qemu-kvm)
14
+
15
+ Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2124856
16
+ Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=49989924
17
+ Upstream: yes
18
+
19
+ When vIOMMU is enabled, the vq->used_phys is actually the IOVA not
20
+ GPA. So we need to translate it to GPA before the syncing otherwise we
21
+ may hit the following crash since IOVA could be out of the scope of
22
+ the GPA log size. This could be noted when using virtio-IOMMU with
23
+ vhost using 1G memory.
24
+
25
+ Fixes: c471ad0e9bd46 ("vhost_net: device IOTLB support")
26
+ Cc: qemu-stable@nongnu.org
27
+ Tested-by: Lei Yang <leiyang@redhat.com>
28
+ Reported-by: Yalan Zhang <yalzhang@redhat.com>
29
+ Signed-off-by: Jason Wang <jasowang@redhat.com>
30
+ Message-Id: <20221216033552.77087-1-jasowang@redhat.com>
31
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
32
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
33
+ (cherry picked from commit 345cc1cbcbce2bab00abc2b88338d7d89c702d6b)
34
+ Signed-off-by: Eric Auger <eric.auger@redhat.com>
35
+ ---
36
+ hw/virtio/vhost.c | 84 ++++++++++++++++++++++++++++++++++++-----------
37
+ 1 file changed, 64 insertions(+), 20 deletions(-)
38
+
39
+ diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
40
+ index 84dbb39e07..2c566dc539 100644
41
+ --- a/hw/virtio/vhost.c
42
+ +++ b/hw/virtio/vhost.c
43
+ @@ -20,6 +20,7 @@
44
+ #include "qemu/range.h"
45
+ #include "qemu/error-report.h"
46
+ #include "qemu/memfd.h"
47
+ +#include "qemu/log.h"
48
+ #include "standard-headers/linux/vhost_types.h"
49
+ #include "hw/virtio/virtio-bus.h"
50
+ #include "hw/virtio/virtio-access.h"
51
+ @@ -106,6 +107,24 @@ static void vhost_dev_sync_region(struct vhost_dev *dev,
52
+ }
53
+ }
54
+
55
+ +static bool vhost_dev_has_iommu(struct vhost_dev *dev)
56
+ +{
57
+ + VirtIODevice *vdev = dev->vdev;
58
+ +
59
+ + /*
60
+ + * For vhost, VIRTIO_F_IOMMU_PLATFORM means the backend support
61
+ + * incremental memory mapping API via IOTLB API. For platform that
62
+ + * does not have IOMMU, there's no need to enable this feature
63
+ + * which may cause unnecessary IOTLB miss/update transactions.
64
+ + */
65
+ + if (vdev) {
66
+ + return virtio_bus_device_iommu_enabled(vdev) &&
67
+ + virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
68
+ + } else {
69
+ + return false;
70
+ + }
71
+ +}
72
+ +
73
+ static int vhost_sync_dirty_bitmap(struct vhost_dev *dev,
74
+ MemoryRegionSection *section,
75
+ hwaddr first,
76
+ @@ -137,8 +156,51 @@ static int vhost_sync_dirty_bitmap(struct vhost_dev *dev,
77
+ continue;
78
+ }
79
+
80
+ - vhost_dev_sync_region(dev, section, start_addr, end_addr, vq->used_phys,
81
+ - range_get_last(vq->used_phys, vq->used_size));
82
+ + if (vhost_dev_has_iommu(dev)) {
83
+ + IOMMUTLBEntry iotlb;
84
+ + hwaddr used_phys = vq->used_phys, used_size = vq->used_size;
85
+ + hwaddr phys, s, offset;
86
+ +
87
+ + while (used_size) {
88
+ + rcu_read_lock();
89
+ + iotlb = address_space_get_iotlb_entry(dev->vdev->dma_as,
90
+ + used_phys,
91
+ + true,
92
+ + MEMTXATTRS_UNSPECIFIED);
93
+ + rcu_read_unlock();
94
+ +
95
+ + if (!iotlb.target_as) {
96
+ + qemu_log_mask(LOG_GUEST_ERROR, "translation "
97
+ + "failure for used_iova %"PRIx64"\n",
98
+ + used_phys);
99
+ + return -EINVAL;
100
+ + }
101
+ +
102
+ + offset = used_phys & iotlb.addr_mask;
103
+ + phys = iotlb.translated_addr + offset;
104
+ +
105
+ + /*
106
+ + * Distance from start of used ring until last byte of
107
+ + * IOMMU page.
108
+ + */
109
+ + s = iotlb.addr_mask - offset;
110
+ + /*
111
+ + * Size of used ring, or of the part of it until end
112
+ + * of IOMMU page. To avoid zero result, do the adding
113
+ + * outside of MIN().
114
+ + */
115
+ + s = MIN(s, used_size - 1) + 1;
116
+ +
117
+ + vhost_dev_sync_region(dev, section, start_addr, end_addr, phys,
118
+ + range_get_last(phys, s));
119
+ + used_size -= s;
120
+ + used_phys += s;
121
+ + }
122
+ + } else {
123
+ + vhost_dev_sync_region(dev, section, start_addr,
124
+ + end_addr, vq->used_phys,
125
+ + range_get_last(vq->used_phys, vq->used_size));
126
+ + }
127
+ }
128
+ return 0;
129
+ }
130
+ @@ -306,24 +368,6 @@ static inline void vhost_dev_log_resize(struct vhost_dev *dev, uint64_t size)
131
+ dev->log_size = size;
132
+ }
133
+
134
+ -static bool vhost_dev_has_iommu(struct vhost_dev *dev)
135
+ -{
136
+ - VirtIODevice *vdev = dev->vdev;
137
+ -
138
+ - /*
139
+ - * For vhost, VIRTIO_F_IOMMU_PLATFORM means the backend support
140
+ - * incremental memory mapping API via IOTLB API. For platform that
141
+ - * does not have IOMMU, there's no need to enable this feature
142
+ - * which may cause unnecessary IOTLB miss/update transactions.
143
+ - */
144
+ - if (vdev) {
145
+ - return virtio_bus_device_iommu_enabled(vdev) &&
146
+ - virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
147
+ - } else {
148
+ - return false;
149
+ - }
150
+ -}
151
+ -
152
+ static void *vhost_memory_map(struct vhost_dev *dev, hwaddr addr,
153
+ hwaddr *plen, bool is_write)
154
+ {
155
+ --
156
+ 2.31.1
157
+
SOURCES/kvm-vhost-introduce-new-VhostOps-vhost_set_config_call.patch ADDED
@@ -0,0 +1,56 @@
1
+ From d135303da1187d9f214e520a977fe7c47e5ce1f0 Mon Sep 17 00:00:00 2001
2
+ From: Cindy Lu <lulu@redhat.com>
3
+ Date: Thu, 22 Dec 2022 15:04:45 +0800
4
+ Subject: [PATCH 04/31] vhost: introduce new VhostOps vhost_set_config_call
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Cindy Lu <lulu@redhat.com>
10
+ RH-MergeRequest: 132: vhost-vdpa: support config interrupt in vhost-vdpa
11
+ RH-Bugzilla: 1905805
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [4/10] c2492838d9c1415e42d2507f2956d640a30325f2 (lulu6/qemu-kvm3)
16
+
17
+ https://bugzilla.redhat.com/show_bug.cgi?id=1905805
18
+ This patch introduces new VhostOps vhost_set_config_call.
19
+ This function allows the qemu to set the config
20
+ event fd to kernel driver.
21
+
22
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
23
+ Message-Id: <20221222070451.936503-5-lulu@redhat.com>
24
+ Acked-by: Jason Wang <jasowang@redhat.com>
25
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
26
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
27
+ (cherry picked from commit 9b30cdf9bbf9524a4f4f8a6eb551eb13cbbd3893)
28
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
29
+ ---
30
+ include/hw/virtio/vhost-backend.h | 3 +++
31
+ 1 file changed, 3 insertions(+)
32
+
33
+ diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
34
+ index eab46d7f0b..c5ab49051e 100644
35
+ --- a/include/hw/virtio/vhost-backend.h
36
+ +++ b/include/hw/virtio/vhost-backend.h
37
+ @@ -128,6 +128,8 @@ typedef int (*vhost_get_device_id_op)(struct vhost_dev *dev, uint32_t *dev_id);
38
+
39
+ typedef bool (*vhost_force_iommu_op)(struct vhost_dev *dev);
40
+
41
+ +typedef int (*vhost_set_config_call_op)(struct vhost_dev *dev,
42
+ + int fd);
43
+ typedef struct VhostOps {
44
+ VhostBackendType backend_type;
45
+ vhost_backend_init vhost_backend_init;
46
+ @@ -174,6 +176,7 @@ typedef struct VhostOps {
47
+ vhost_vq_get_addr_op vhost_vq_get_addr;
48
+ vhost_get_device_id_op vhost_get_device_id;
49
+ vhost_force_iommu_op vhost_force_iommu;
50
+ + vhost_set_config_call_op vhost_set_config_call;
51
+ } VhostOps;
52
+
53
+ int vhost_backend_update_device_iotlb(struct vhost_dev *dev,
54
+ --
55
+ 2.31.1
56
+
SOURCES/kvm-vhost-move-descriptor-translation-to-vhost_svq_vring.patch DELETED
@@ -1,120 +0,0 @@
1
- From 2bdea90bfbce3b8d5bfa86178a942a470b85b835 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:38:55 +0200
4
- Subject: [PATCH 07/32] vhost: move descriptor translation to
5
- vhost_svq_vring_write_descs
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
11
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
12
- RH-Commit: [7/27] 5533c72065e4ebf8ea7db966c976a3b29bdafb82 (eperezmartin/qemu-kvm)
13
- RH-Bugzilla: 1939363
14
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
15
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
16
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
17
-
18
- Bugzilla: https://bugzilla.redhat.com/1939363
19
-
20
- Upstream Status: git://git.qemu.org/qemu.git
21
-
22
- commit 009c2549bb9dc7f7061009eb87f2a53d4b364983
23
- Author: Eugenio Pérez <eperezma@redhat.com>
24
- Date: Wed Jul 20 08:59:26 2022 +0200
25
-
26
- vhost: move descriptor translation to vhost_svq_vring_write_descs
27
-
28
- It's done for both in and out descriptors so it's better placed here.
29
-
30
- Acked-by: Jason Wang <jasowang@redhat.com>
31
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
32
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
33
- Signed-off-by: Jason Wang <jasowang@redhat.com>
34
-
35
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
36
- ---
37
- hw/virtio/vhost-shadow-virtqueue.c | 38 +++++++++++++++++++++---------
38
- 1 file changed, 27 insertions(+), 11 deletions(-)
39
-
40
- diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
41
- index 06d0bb39d9..3fbda1e3d4 100644
42
- --- a/hw/virtio/vhost-shadow-virtqueue.c
43
- +++ b/hw/virtio/vhost-shadow-virtqueue.c
44
- @@ -122,17 +122,35 @@ static bool vhost_svq_translate_addr(const VhostShadowVirtqueue *svq,
45
- return true;
46
- }
47
-
48
- -static void vhost_vring_write_descs(VhostShadowVirtqueue *svq, hwaddr *sg,
49
- - const struct iovec *iovec, size_t num,
50
- - bool more_descs, bool write)
51
- +/**
52
- + * Write descriptors to SVQ vring
53
- + *
54
- + * @svq: The shadow virtqueue
55
- + * @sg: Cache for hwaddr
56
- + * @iovec: The iovec from the guest
57
- + * @num: iovec length
58
- + * @more_descs: True if more descriptors come in the chain
59
- + * @write: True if they are writeable descriptors
60
- + *
61
- + * Return true if success, false otherwise and print error.
62
- + */
63
- +static bool vhost_svq_vring_write_descs(VhostShadowVirtqueue *svq, hwaddr *sg,
64
- + const struct iovec *iovec, size_t num,
65
- + bool more_descs, bool write)
66
- {
67
- uint16_t i = svq->free_head, last = svq->free_head;
68
- unsigned n;
69
- uint16_t flags = write ? cpu_to_le16(VRING_DESC_F_WRITE) : 0;
70
- vring_desc_t *descs = svq->vring.desc;
71
- + bool ok;
72
-
73
- if (num == 0) {
74
- - return;
75
- + return true;
76
- + }
77
- +
78
- + ok = vhost_svq_translate_addr(svq, sg, iovec, num);
79
- + if (unlikely(!ok)) {
80
- + return false;
81
- }
82
-
83
- for (n = 0; n < num; n++) {
84
- @@ -150,6 +168,7 @@ static void vhost_vring_write_descs(VhostShadowVirtqueue *svq, hwaddr *sg,
85
- }
86
-
87
- svq->free_head = le16_to_cpu(svq->desc_next[last]);
88
- + return true;
89
- }
90
-
91
- static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,
92
- @@ -169,21 +188,18 @@ static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,
93
- return false;
94
- }
95
-
96
- - ok = vhost_svq_translate_addr(svq, sgs, elem->out_sg, elem->out_num);
97
- + ok = vhost_svq_vring_write_descs(svq, sgs, elem->out_sg, elem->out_num,
98
- + elem->in_num > 0, false);
99
- if (unlikely(!ok)) {
100
- return false;
101
- }
102
- - vhost_vring_write_descs(svq, sgs, elem->out_sg, elem->out_num,
103
- - elem->in_num > 0, false);
104
- -
105
-
106
- - ok = vhost_svq_translate_addr(svq, sgs, elem->in_sg, elem->in_num);
107
- + ok = vhost_svq_vring_write_descs(svq, sgs, elem->in_sg, elem->in_num, false,
108
- + true);
109
- if (unlikely(!ok)) {
110
- return false;
111
- }
112
-
113
- - vhost_vring_write_descs(svq, sgs, elem->in_sg, elem->in_num, false, true);
114
- -
115
- /*
116
- * Put the entry in the available array (but don't update avail->idx until
117
- * they do sync).
118
- --
119
- 2.31.1
120
-
SOURCES/kvm-vhost-move-iova_tree-set-to-vhost_svq_start.patch ADDED
@@ -0,0 +1,122 @@
1
+ From 6584478deca49d0ea20add588e4fdb51cdc26f1d Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
+ Date: Thu, 15 Dec 2022 12:31:36 +0100
4
+ Subject: [PATCH 04/14] vhost: move iova_tree set to vhost_svq_start
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
+ RH-MergeRequest: 136: vDPA ASID support in Qemu
11
+ RH-Bugzilla: 2104412
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [4/13] 200d8e9b58e258a6e301430debc73ef7d962b732 (eperezmartin/qemu-kvm)
16
+
17
+ Since we don't know if we will use SVQ at qemu initialization, let's
18
+ allocate iova_tree only if needed. To do so, accept it at SVQ start, not
19
+ at initialization.
20
+
21
+ This will avoid to create it if the device does not support SVQ.
22
+
23
+ Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
24
+ Acked-by: Jason Wang <jasowang@redhat.com>
25
+ Message-Id: <20221215113144.322011-5-eperezma@redhat.com>
26
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
27
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
28
+ (cherry picked from commit 5fde952bbdd521c10fc018ee04f922a7dca5f663)
29
+ ---
30
+ hw/virtio/vhost-shadow-virtqueue.c | 9 ++++-----
31
+ hw/virtio/vhost-shadow-virtqueue.h | 5 ++---
32
+ hw/virtio/vhost-vdpa.c | 5 ++---
33
+ 3 files changed, 8 insertions(+), 11 deletions(-)
34
+
35
+ diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
36
+ index 3b05bab44d..4307296358 100644
37
+ --- a/hw/virtio/vhost-shadow-virtqueue.c
38
+ +++ b/hw/virtio/vhost-shadow-virtqueue.c
39
+ @@ -642,9 +642,10 @@ void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *svq, int svq_kick_fd)
40
+ * @svq: Shadow Virtqueue
41
+ * @vdev: VirtIO device
42
+ * @vq: Virtqueue to shadow
43
+ + * @iova_tree: Tree to perform descriptors translations
44
+ */
45
+ void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev,
46
+ - VirtQueue *vq)
47
+ + VirtQueue *vq, VhostIOVATree *iova_tree)
48
+ {
49
+ size_t desc_size, driver_size, device_size;
50
+
51
+ @@ -655,6 +656,7 @@ void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev,
52
+ svq->last_used_idx = 0;
53
+ svq->vdev = vdev;
54
+ svq->vq = vq;
55
+ + svq->iova_tree = iova_tree;
56
+
57
+ svq->vring.num = virtio_queue_get_num(vdev, virtio_get_queue_index(vq));
58
+ driver_size = vhost_svq_driver_area_size(svq);
59
+ @@ -712,18 +714,15 @@ void vhost_svq_stop(VhostShadowVirtqueue *svq)
60
+ * Creates vhost shadow virtqueue, and instructs the vhost device to use the
61
+ * shadow methods and file descriptors.
62
+ *
63
+ - * @iova_tree: Tree to perform descriptors translations
64
+ * @ops: SVQ owner callbacks
65
+ * @ops_opaque: ops opaque pointer
66
+ */
67
+ -VhostShadowVirtqueue *vhost_svq_new(VhostIOVATree *iova_tree,
68
+ - const VhostShadowVirtqueueOps *ops,
69
+ +VhostShadowVirtqueue *vhost_svq_new(const VhostShadowVirtqueueOps *ops,
70
+ void *ops_opaque)
71
+ {
72
+ VhostShadowVirtqueue *svq = g_new0(VhostShadowVirtqueue, 1);
73
+
74
+ event_notifier_init_fd(&svq->svq_kick, VHOST_FILE_UNBIND);
75
+ - svq->iova_tree = iova_tree;
76
+ svq->ops = ops;
77
+ svq->ops_opaque = ops_opaque;
78
+ return svq;
79
+ diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-virtqueue.h
80
+ index d04c34a589..926a4897b1 100644
81
+ --- a/hw/virtio/vhost-shadow-virtqueue.h
82
+ +++ b/hw/virtio/vhost-shadow-virtqueue.h
83
+ @@ -126,11 +126,10 @@ size_t vhost_svq_driver_area_size(const VhostShadowVirtqueue *svq);
84
+ size_t vhost_svq_device_area_size(const VhostShadowVirtqueue *svq);
85
+
86
+ void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev,
87
+ - VirtQueue *vq);
88
+ + VirtQueue *vq, VhostIOVATree *iova_tree);
89
+ void vhost_svq_stop(VhostShadowVirtqueue *svq);
90
+
91
+ -VhostShadowVirtqueue *vhost_svq_new(VhostIOVATree *iova_tree,
92
+ - const VhostShadowVirtqueueOps *ops,
93
+ +VhostShadowVirtqueue *vhost_svq_new(const VhostShadowVirtqueueOps *ops,
94
+ void *ops_opaque);
95
+
96
+ void vhost_svq_free(gpointer vq);
97
+ diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
98
+ index 530d2ca362..e65603022f 100644
99
+ --- a/hw/virtio/vhost-vdpa.c
100
+ +++ b/hw/virtio/vhost-vdpa.c
101
+ @@ -430,8 +430,7 @@ static int vhost_vdpa_init_svq(struct vhost_dev *hdev, struct vhost_vdpa *v,
102
+ for (unsigned n = 0; n < hdev->nvqs; ++n) {
103
+ VhostShadowVirtqueue *svq;
104
+
105
+ - svq = vhost_svq_new(v->iova_tree, v->shadow_vq_ops,
106
+ - v->shadow_vq_ops_opaque);
107
+ + svq = vhost_svq_new(v->shadow_vq_ops, v->shadow_vq_ops_opaque);
108
+ g_ptr_array_add(shadow_vqs, svq);
109
+ }
110
+
111
+ @@ -1070,7 +1069,7 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *dev)
112
+ goto err;
113
+ }
114
+
115
+ - vhost_svq_start(svq, dev->vdev, vq);
116
+ + vhost_svq_start(svq, dev->vdev, vq, v->iova_tree);
117
+ ok = vhost_vdpa_svq_map_rings(dev, svq, &addr, &err);
118
+ if (unlikely(!ok)) {
119
+ goto err_map;
120
+ --
121
+ 2.31.1
122
+
SOURCES/kvm-vhost-net-fix-improper-cleanup-in-vhost_net_start.patch DELETED
@@ -1,56 +0,0 @@
1
- From edb2bd99355f300b512c040e91f5870ea14a5d7e Mon Sep 17 00:00:00 2001
2
- From: Si-Wei Liu <si-wei.liu@oracle.com>
3
- Date: Fri, 6 May 2022 19:28:15 -0700
4
- Subject: [PATCH 11/16] vhost-net: fix improper cleanup in vhost_net_start
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Jason Wang <jasowang@redhat.com>
10
- RH-MergeRequest: 98: Multiqueue fixes for vhost-vDPA
11
- RH-Commit: [4/7] e88e482dd4b344f0cc887a358268beaed4d62917 (jasowang/qemu-kvm-cs)
12
- RH-Bugzilla: 2070804
13
- RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
14
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
15
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
16
-
17
- vhost_net_start() missed a corresponding stop_one() upon error from
18
- vhost_set_vring_enable(). While at it, make the error handling for
19
- err_start more robust. No real issue was found due to this though.
20
-
21
- Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
22
- Acked-by: Jason Wang <jasowang@redhat.com>
23
- Message-Id: <1651890498-24478-5-git-send-email-si-wei.liu@oracle.com>
24
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
25
- Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
26
- (cherry picked from commit 6f3910b5eee00b8cc959e94659c0d524c482a418)
27
- Signed-off-by: Jason Wang <jasowang@redhat.com>
28
- ---
29
- hw/net/vhost_net.c | 4 +++-
30
- 1 file changed, 3 insertions(+), 1 deletion(-)
31
-
32
- diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
33
- index 30379d2ca4..d6d7c51f62 100644
34
- --- a/hw/net/vhost_net.c
35
- +++ b/hw/net/vhost_net.c
36
- @@ -381,6 +381,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
37
- r = vhost_set_vring_enable(peer, peer->vring_enable);
38
-
39
- if (r < 0) {
40
- + vhost_net_stop_one(get_vhost_net(peer), dev);
41
- goto err_start;
42
- }
43
- }
44
- @@ -390,7 +391,8 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
45
-
46
- err_start:
47
- while (--i >= 0) {
48
- - peer = qemu_get_peer(ncs , i);
49
- + peer = qemu_get_peer(ncs, i < data_queue_pairs ?
50
- + i : n->max_queue_pairs);
51
- vhost_net_stop_one(get_vhost_net(peer), dev);
52
- }
53
- e = k->set_guest_notifiers(qbus->parent, total_notifiers, false);
54
- --
55
- 2.31.1
56
-
SOURCES/kvm-vhost-net-vdpa-add-stubs-for-when-no-virtio-net-devi.patch DELETED
@@ -1,87 +0,0 @@
1
- From a9095850da8dd4ea3fdb725cb7f79118144e22fa Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:39:27 +0200
4
- Subject: [PATCH 22/32] vhost-net-vdpa: add stubs for when no virtio-net device
5
- is present
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
11
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
12
- RH-Commit: [22/27] a2b25a805bb06094a5fab27ce8f82bee12a9fcb5 (eperezmartin/qemu-kvm)
13
- RH-Bugzilla: 1939363
14
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
15
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
16
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
17
-
18
- Bugzilla: https://bugzilla.redhat.com/1939363
19
-
20
- Upstream Status: git://git.qemu.org/qemu.git
21
-
22
- commit 94c643732dc110d04bbdf0eb43c41bce23b3593e
23
- Author: Eugenio Pérez <eperezma@redhat.com>
24
- Date: Wed Jul 20 08:59:41 2022 +0200
25
-
26
- vhost-net-vdpa: add stubs for when no virtio-net device is present
27
-
28
- net/vhost-vdpa.c will need functions that are declared in
29
- vhost-shadow-virtqueue.c, that needs functions of virtio-net.c.
30
-
31
- Copy the vhost-vdpa-stub.c code so
32
- only the constructor net_init_vhost_vdpa needs to be defined.
33
-
34
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
35
- Signed-off-by: Jason Wang <jasowang@redhat.com>
36
-
37
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
38
- ---
39
- net/meson.build | 3 ++-
40
- net/vhost-vdpa-stub.c | 21 +++++++++++++++++++++
41
- 2 files changed, 23 insertions(+), 1 deletion(-)
42
- create mode 100644 net/vhost-vdpa-stub.c
43
-
44
- diff --git a/net/meson.build b/net/meson.build
45
- index c965e83b26..116a9e7cbb 100644
46
- --- a/net/meson.build
47
- +++ b/net/meson.build
48
- @@ -41,7 +41,8 @@ endif
49
- softmmu_ss.add(when: 'CONFIG_POSIX', if_true: files(tap_posix))
50
- softmmu_ss.add(when: 'CONFIG_WIN32', if_true: files('tap-win32.c'))
51
- if have_vhost_net_vdpa
52
- - softmmu_ss.add(files('vhost-vdpa.c'))
53
- + softmmu_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('vhost-vdpa.c'), if_false: files('vhost-vdpa-stub.c'))
54
- + softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-vdpa-stub.c'))
55
- endif
56
-
57
- subdir('can')
58
- diff --git a/net/vhost-vdpa-stub.c b/net/vhost-vdpa-stub.c
59
- new file mode 100644
60
- index 0000000000..1732ed2443
61
- --- /dev/null
62
- +++ b/net/vhost-vdpa-stub.c
63
- @@ -0,0 +1,21 @@
64
- +/*
65
- + * vhost-vdpa-stub.c
66
- + *
67
- + * Copyright (c) 2022 Red Hat, Inc.
68
- + *
69
- + * This work is licensed under the terms of the GNU GPL, version 2 or later.
70
- + * See the COPYING file in the top-level directory.
71
- + *
72
- + */
73
- +
74
- +#include "qemu/osdep.h"
75
- +#include "clients.h"
76
- +#include "net/vhost-vdpa.h"
77
- +#include "qapi/error.h"
78
- +
79
- +int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
80
- + NetClientState *peer, Error **errp)
81
- +{
82
- + error_setg(errp, "vhost-vdpa requires frontend driver virtio-net-*");
83
- + return -1;
84
- +}
85
- --
86
- 2.31.1
87
-
SOURCES/kvm-vhost-set-SVQ-device-call-handler-at-SVQ-start.patch ADDED
@@ -0,0 +1,73 @@
1
+ From 2906f8df3c5e915a3dc05a705b87990211f114b5 Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
+ Date: Thu, 15 Dec 2022 12:31:34 +0100
4
+ Subject: [PATCH 02/14] vhost: set SVQ device call handler at SVQ start
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
+ RH-MergeRequest: 136: vDPA ASID support in Qemu
11
+ RH-Bugzilla: 2104412
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [2/13] ad90a6cc5c71b70d705904433d5a986e8fedb924 (eperezmartin/qemu-kvm)
16
+
17
+ By the end of this series CVQ is shadowed as long as the features
18
+ support it.
19
+
20
+ Since we don't know at the beginning of qemu running if this is
21
+ supported, move the event notifier handler setting to the start of the
22
+ SVQ, instead of the start of qemu run. This will avoid to create them if
23
+ the device does not support SVQ.
24
+
25
+ Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
26
+ Acked-by: Jason Wang <jasowang@redhat.com>
27
+ Message-Id: <20221215113144.322011-3-eperezma@redhat.com>
28
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
29
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
30
+ (cherry picked from commit 20e7412bfd63c68f1798fbdb799aedb7e05fee88)
31
+ ---
32
+ hw/virtio/vhost-shadow-virtqueue.c | 4 ++--
33
+ 1 file changed, 2 insertions(+), 2 deletions(-)
34
+
35
+ diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
36
+ index 5bd14cad96..264ddc166d 100644
37
+ --- a/hw/virtio/vhost-shadow-virtqueue.c
38
+ +++ b/hw/virtio/vhost-shadow-virtqueue.c
39
+ @@ -648,6 +648,7 @@ void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev,
40
+ {
41
+ size_t desc_size, driver_size, device_size;
42
+
43
+ + event_notifier_set_handler(&svq->hdev_call, vhost_svq_handle_call);
44
+ svq->next_guest_avail_elem = NULL;
45
+ svq->shadow_avail_idx = 0;
46
+ svq->shadow_used_idx = 0;
47
+ @@ -704,6 +705,7 @@ void vhost_svq_stop(VhostShadowVirtqueue *svq)
48
+ g_free(svq->desc_state);
49
+ qemu_vfree(svq->vring.desc);
50
+ qemu_vfree(svq->vring.used);
51
+ + event_notifier_set_handler(&svq->hdev_call, NULL);
52
+ }
53
+
54
+ /**
55
+ @@ -740,7 +742,6 @@ VhostShadowVirtqueue *vhost_svq_new(VhostIOVATree *iova_tree,
56
+ }
57
+
58
+ event_notifier_init_fd(&svq->svq_kick, VHOST_FILE_UNBIND);
59
+ - event_notifier_set_handler(&svq->hdev_call, vhost_svq_handle_call);
60
+ svq->iova_tree = iova_tree;
61
+ svq->ops = ops;
62
+ svq->ops_opaque = ops_opaque;
63
+ @@ -763,7 +764,6 @@ void vhost_svq_free(gpointer pvq)
64
+ VhostShadowVirtqueue *vq = pvq;
65
+ vhost_svq_stop(vq);
66
+ event_notifier_cleanup(&vq->hdev_kick);
67
+ - event_notifier_set_handler(&vq->hdev_call, NULL);
68
+ event_notifier_cleanup(&vq->hdev_call);
69
+ g_free(vq);
70
+ }
71
+ --
72
+ 2.31.1
73
+
SOURCES/kvm-vhost-vdpa-add-support-for-config-interrupt.patch ADDED
@@ -0,0 +1,73 @@
1
+ From e01563a8de9a45937ffd8d4c1d74a6890ffb6eb6 Mon Sep 17 00:00:00 2001
2
+ From: Cindy Lu <lulu@redhat.com>
3
+ Date: Thu, 22 Dec 2022 15:04:46 +0800
4
+ Subject: [PATCH 05/31] vhost-vdpa: add support for config interrupt
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Cindy Lu <lulu@redhat.com>
10
+ RH-MergeRequest: 132: vhost-vdpa: support config interrupt in vhost-vdpa
11
+ RH-Bugzilla: 1905805
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [5/10] 49bfd214a503f8e199ff93f4bbfcbd4c4f2405b5 (lulu6/qemu-kvm3)
16
+
17
+ https://bugzilla.redhat.com/show_bug.cgi?id=1905805
18
+ Add new call back function in vhost-vdpa, The function
19
+ vhost_set_config_call can set the event fd to kernel.
20
+ This function will be called in the vhost_dev_start
21
+ and vhost_dev_stop
22
+
23
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
24
+ Message-Id: <20221222070451.936503-6-lulu@redhat.com>
25
+ Acked-by: Jason Wang <jasowang@redhat.com>
26
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
27
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
28
+ (cherry picked from commit 259f3acc1c675dd77ebbdb28a483f5d0220bdbf6)
29
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
30
+ ---
31
+ hw/virtio/trace-events | 1 +
32
+ hw/virtio/vhost-vdpa.c | 8 ++++++++
33
+ 2 files changed, 9 insertions(+)
34
+
35
+ diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
36
+ index 14fc5b9bb2..46f2faf04e 100644
37
+ --- a/hw/virtio/trace-events
38
+ +++ b/hw/virtio/trace-events
39
+ @@ -62,6 +62,7 @@ vhost_vdpa_get_features(void *dev, uint64_t features) "dev: %p features: 0x%"PRI
40
+ vhost_vdpa_set_owner(void *dev) "dev: %p"
41
+ vhost_vdpa_vq_get_addr(void *dev, void *vq, uint64_t desc_user_addr, uint64_t avail_user_addr, uint64_t used_user_addr) "dev: %p vq: %p desc_user_addr: 0x%"PRIx64" avail_user_addr: 0x%"PRIx64" used_user_addr: 0x%"PRIx64
42
+ vhost_vdpa_get_iova_range(void *dev, uint64_t first, uint64_t last) "dev: %p first: 0x%"PRIx64" last: 0x%"PRIx64
43
+ +vhost_vdpa_set_config_call(void *dev, int fd)"dev: %p fd: %d"
44
+
45
+ # virtio.c
46
+ virtqueue_alloc_element(void *elem, size_t sz, unsigned in_num, unsigned out_num) "elem %p size %zd in_num %u out_num %u"
47
+ diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
48
+ index 7468e44b87..c5be2645b0 100644
49
+ --- a/hw/virtio/vhost-vdpa.c
50
+ +++ b/hw/virtio/vhost-vdpa.c
51
+ @@ -754,6 +754,13 @@ static int vhost_vdpa_set_vring_ready(struct vhost_dev *dev)
52
+ return 0;
53
+ }
54
+
55
+ +static int vhost_vdpa_set_config_call(struct vhost_dev *dev,
56
+ + int fd)
57
+ +{
58
+ + trace_vhost_vdpa_set_config_call(dev, fd);
59
+ + return vhost_vdpa_call(dev, VHOST_VDPA_SET_CONFIG_CALL, &fd);
60
+ +}
61
+ +
62
+ static void vhost_vdpa_dump_config(struct vhost_dev *dev, const uint8_t *config,
63
+ uint32_t config_len)
64
+ {
65
+ @@ -1310,4 +1317,5 @@ const VhostOps vdpa_ops = {
66
+ .vhost_get_device_id = vhost_vdpa_get_device_id,
67
+ .vhost_vq_get_addr = vhost_vdpa_vq_get_addr,
68
+ .vhost_force_iommu = vhost_vdpa_force_iommu,
69
+ + .vhost_set_config_call = vhost_vdpa_set_config_call,
70
+ };
71
+ --
72
+ 2.31.1
73
+
SOURCES/kvm-vhost-vdpa-backend-feature-should-set-only-once.patch DELETED
@@ -1,58 +0,0 @@
1
- From 46c5a35aa56cf0dd55376638dbf7d46e85f497e1 Mon Sep 17 00:00:00 2001
2
- From: Si-Wei Liu <si-wei.liu@oracle.com>
3
- Date: Fri, 6 May 2022 19:28:16 -0700
4
- Subject: [PATCH 12/16] vhost-vdpa: backend feature should set only once
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Jason Wang <jasowang@redhat.com>
10
- RH-MergeRequest: 98: Multiqueue fixes for vhost-vDPA
11
- RH-Commit: [5/7] 7531bb8da0c99b29997e8bfc6d1e811daf3cdd38 (jasowang/qemu-kvm-cs)
12
- RH-Bugzilla: 2070804
13
- RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
14
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
15
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
16
-
17
- The vhost_vdpa_one_time_request() branch in
18
- vhost_vdpa_set_backend_cap() incorrectly sends down
19
- ioctls on vhost_dev with non-zero index. This may
20
- end up with multiple VHOST_SET_BACKEND_FEATURES
21
- ioctl calls sent down on the vhost-vdpa fd that is
22
- shared between all these vhost_dev's.
23
-
24
- To fix it, send down ioctl only once via the first
25
- vhost_dev with index 0. Toggle the polarity of the
26
- vhost_vdpa_one_time_request() test should do the
27
- trick.
28
-
29
- Fixes: 4d191cfdc7de ("vhost-vdpa: classify one time request")
30
- Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
31
- Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
32
- Acked-by: Jason Wang <jasowang@redhat.com>
33
- Acked-by: Eugenio Pérez <eperezma@redhat.com>
34
- Message-Id: <1651890498-24478-6-git-send-email-si-wei.liu@oracle.com>
35
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
36
- Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
37
- (cherry picked from commit 6aee7e4233f6467f69531fcd352adff028f3f5ea)
38
- Signed-off-by: Jason Wang <jasowang@redhat.com>
39
- ---
40
- hw/virtio/vhost-vdpa.c | 2 +-
41
- 1 file changed, 1 insertion(+), 1 deletion(-)
42
-
43
- diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
44
- index 8adf7c0b92..6e3dbd9e89 100644
45
- --- a/hw/virtio/vhost-vdpa.c
46
- +++ b/hw/virtio/vhost-vdpa.c
47
- @@ -665,7 +665,7 @@ static int vhost_vdpa_set_backend_cap(struct vhost_dev *dev)
48
-
49
- features &= f;
50
-
51
- - if (vhost_vdpa_one_time_request(dev)) {
52
- + if (!vhost_vdpa_one_time_request(dev)) {
53
- r = vhost_vdpa_call(dev, VHOST_SET_BACKEND_FEATURES, &features);
54
- if (r) {
55
- return -EFAULT;
56
- --
57
- 2.31.1
58
-
SOURCES/kvm-vhost-vdpa-change-name-and-polarity-for-vhost_vdpa_o.patch DELETED
@@ -1,123 +0,0 @@
1
- From 58acdab17ec00ab76105ab92a51c5ba4dec3df5a Mon Sep 17 00:00:00 2001
2
- From: Si-Wei Liu <si-wei.liu@oracle.com>
3
- Date: Fri, 6 May 2022 19:28:17 -0700
4
- Subject: [PATCH 13/16] vhost-vdpa: change name and polarity for
5
- vhost_vdpa_one_time_request()
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Jason Wang <jasowang@redhat.com>
11
- RH-MergeRequest: 98: Multiqueue fixes for vhost-vDPA
12
- RH-Commit: [6/7] 7029778f463a136ff412c63b86b6953390e47bf8 (jasowang/qemu-kvm-cs)
13
- RH-Bugzilla: 2070804
14
- RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
17
-
18
- The name vhost_vdpa_one_time_request() was confusing. No
19
- matter whatever it returns, its typical occurrence had
20
- always been at requests that only need to be applied once.
21
- And the name didn't suggest what it actually checks for.
22
- Change it to vhost_vdpa_first_dev() with polarity flipped
23
- for better readibility of code. That way it is able to
24
- reflect what the check is really about.
25
-
26
- This call is applicable to request which performs operation
27
- only once, before queues are set up, and usually at the beginning
28
- of the caller function. Document the requirement for it in place.
29
-
30
- Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
31
- Message-Id: <1651890498-24478-7-git-send-email-si-wei.liu@oracle.com>
32
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
33
- Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
34
- Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
35
- Acked-by: Jason Wang <jasowang@redhat.com>
36
- (cherry picked from commit d71b0609fc04217e28d17009f04d74b08be6f466)
37
- Signed-off-by: Jason Wang <jasowang@redhat.com>
38
- ---
39
- hw/virtio/vhost-vdpa.c | 23 +++++++++++++++--------
40
- 1 file changed, 15 insertions(+), 8 deletions(-)
41
-
42
- diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
43
- index 6e3dbd9e89..33dcaa135e 100644
44
- --- a/hw/virtio/vhost-vdpa.c
45
- +++ b/hw/virtio/vhost-vdpa.c
46
- @@ -366,11 +366,18 @@ static void vhost_vdpa_get_iova_range(struct vhost_vdpa *v)
47
- v->iova_range.last);
48
- }
49
-
50
- -static bool vhost_vdpa_one_time_request(struct vhost_dev *dev)
51
- +/*
52
- + * The use of this function is for requests that only need to be
53
- + * applied once. Typically such request occurs at the beginning
54
- + * of operation, and before setting up queues. It should not be
55
- + * used for request that performs operation until all queues are
56
- + * set, which would need to check dev->vq_index_end instead.
57
- + */
58
- +static bool vhost_vdpa_first_dev(struct vhost_dev *dev)
59
- {
60
- struct vhost_vdpa *v = dev->opaque;
61
-
62
- - return v->index != 0;
63
- + return v->index == 0;
64
- }
65
-
66
- static int vhost_vdpa_get_dev_features(struct vhost_dev *dev,
67
- @@ -451,7 +458,7 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp)
68
-
69
- vhost_vdpa_get_iova_range(v);
70
-
71
- - if (vhost_vdpa_one_time_request(dev)) {
72
- + if (!vhost_vdpa_first_dev(dev)) {
73
- return 0;
74
- }
75
-
76
- @@ -594,7 +601,7 @@ static int vhost_vdpa_memslots_limit(struct vhost_dev *dev)
77
- static int vhost_vdpa_set_mem_table(struct vhost_dev *dev,
78
- struct vhost_memory *mem)
79
- {
80
- - if (vhost_vdpa_one_time_request(dev)) {
81
- + if (!vhost_vdpa_first_dev(dev)) {
82
- return 0;
83
- }
84
-
85
- @@ -623,7 +630,7 @@ static int vhost_vdpa_set_features(struct vhost_dev *dev,
86
- struct vhost_vdpa *v = dev->opaque;
87
- int ret;
88
-
89
- - if (vhost_vdpa_one_time_request(dev)) {
90
- + if (!vhost_vdpa_first_dev(dev)) {
91
- return 0;
92
- }
93
-
94
- @@ -665,7 +672,7 @@ static int vhost_vdpa_set_backend_cap(struct vhost_dev *dev)
95
-
96
- features &= f;
97
-
98
- - if (!vhost_vdpa_one_time_request(dev)) {
99
- + if (vhost_vdpa_first_dev(dev)) {
100
- r = vhost_vdpa_call(dev, VHOST_SET_BACKEND_FEATURES, &features);
101
- if (r) {
102
- return -EFAULT;
103
- @@ -1118,7 +1125,7 @@ static int vhost_vdpa_set_log_base(struct vhost_dev *dev, uint64_t base,
104
- struct vhost_log *log)
105
- {
106
- struct vhost_vdpa *v = dev->opaque;
107
- - if (v->shadow_vqs_enabled || vhost_vdpa_one_time_request(dev)) {
108
- + if (v->shadow_vqs_enabled || !vhost_vdpa_first_dev(dev)) {
109
- return 0;
110
- }
111
-
112
- @@ -1240,7 +1247,7 @@ static int vhost_vdpa_get_features(struct vhost_dev *dev,
113
-
114
- static int vhost_vdpa_set_owner(struct vhost_dev *dev)
115
- {
116
- - if (vhost_vdpa_one_time_request(dev)) {
117
- + if (!vhost_vdpa_first_dev(dev)) {
118
- return 0;
119
- }
120
-
121
- --
122
- 2.31.1
123
-
SOURCES/kvm-vhost-vdpa-fix-improper-cleanup-in-net_init_vhost_vd.patch DELETED
@@ -1,48 +0,0 @@
1
- From 3142102adb98f46518c0ac1773b0c48710c6bed6 Mon Sep 17 00:00:00 2001
2
- From: Si-Wei Liu <si-wei.liu@oracle.com>
3
- Date: Fri, 6 May 2022 19:28:14 -0700
4
- Subject: [PATCH 10/16] vhost-vdpa: fix improper cleanup in net_init_vhost_vdpa
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Jason Wang <jasowang@redhat.com>
10
- RH-MergeRequest: 98: Multiqueue fixes for vhost-vDPA
11
- RH-Commit: [3/7] c83ff6c97d34cfae3c3447edde934b42a9ace75f (jasowang/qemu-kvm-cs)
12
- RH-Bugzilla: 2070804
13
- RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
14
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
15
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
16
-
17
- ... such that no memory leaks on dangling net clients in case of
18
- error.
19
-
20
- Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
21
- Acked-by: Jason Wang <jasowang@redhat.com>
22
- Message-Id: <1651890498-24478-4-git-send-email-si-wei.liu@oracle.com>
23
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
24
- Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
25
- (cherry picked from commit 9bd055073e375c8a0d7ebce925e05d914d69fc7f)
26
- Signed-off-by: Jason Wang <jasowang@redhat.com>
27
- ---
28
- net/vhost-vdpa.c | 4 +++-
29
- 1 file changed, 3 insertions(+), 1 deletion(-)
30
-
31
- diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
32
- index 1e9fe47c03..df1e69ee72 100644
33
- --- a/net/vhost-vdpa.c
34
- +++ b/net/vhost-vdpa.c
35
- @@ -306,7 +306,9 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
36
-
37
- err:
38
- if (i) {
39
- - qemu_del_net_client(ncs[0]);
40
- + for (i--; i >= 0; i--) {
41
- + qemu_del_net_client(ncs[i]);
42
- + }
43
- }
44
- qemu_close(vdpa_device_fd);
45
-
46
- --
47
- 2.31.1
48
-
SOURCES/kvm-virtio-add-support-for-configure-interrupt.patch ADDED
@@ -0,0 +1,115 @@
1
+ From e04c76339580effae41617b690b58a6605e0f40b Mon Sep 17 00:00:00 2001
2
+ From: Cindy Lu <lulu@redhat.com>
3
+ Date: Thu, 22 Dec 2022 15:04:47 +0800
4
+ Subject: [PATCH 06/31] virtio: add support for configure interrupt
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Cindy Lu <lulu@redhat.com>
10
+ RH-MergeRequest: 132: vhost-vdpa: support config interrupt in vhost-vdpa
11
+ RH-Bugzilla: 1905805
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [6/10] 7048eb488b732578686d451684babaf17b582b05 (lulu6/qemu-kvm3)
16
+
17
+ https://bugzilla.redhat.com/show_bug.cgi?id=1905805
18
+ Add the functions to support the configure interrupt in virtio
19
+ The function virtio_config_guest_notifier_read will notify the
20
+ guest if there is an configure interrupt.
21
+ The function virtio_config_set_guest_notifier_fd_handler is
22
+ to set the fd hander for the notifier
23
+
24
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
25
+ Message-Id: <20221222070451.936503-7-lulu@redhat.com>
26
+ Acked-by: Jason Wang <jasowang@redhat.com>
27
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
28
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
29
+ (cherry picked from commit 7d847d0c9b93b91160f40d69a65c904d76f1edd8)
30
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
31
+ ---
32
+ hw/virtio/virtio.c | 29 +++++++++++++++++++++++++++++
33
+ include/hw/virtio/virtio.h | 4 ++++
34
+ 2 files changed, 33 insertions(+)
35
+
36
+ diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
37
+ index eb6347ab5d..34e9c5d141 100644
38
+ --- a/hw/virtio/virtio.c
39
+ +++ b/hw/virtio/virtio.c
40
+ @@ -4012,7 +4012,14 @@ static void virtio_queue_guest_notifier_read(EventNotifier *n)
41
+ virtio_irq(vq);
42
+ }
43
+ }
44
+ +static void virtio_config_guest_notifier_read(EventNotifier *n)
45
+ +{
46
+ + VirtIODevice *vdev = container_of(n, VirtIODevice, config_notifier);
47
+
48
+ + if (event_notifier_test_and_clear(n)) {
49
+ + virtio_notify_config(vdev);
50
+ + }
51
+ +}
52
+ void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
53
+ bool with_irqfd)
54
+ {
55
+ @@ -4029,6 +4036,23 @@ void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
56
+ }
57
+ }
58
+
59
+ +void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev,
60
+ + bool assign, bool with_irqfd)
61
+ +{
62
+ + EventNotifier *n;
63
+ + n = &vdev->config_notifier;
64
+ + if (assign && !with_irqfd) {
65
+ + event_notifier_set_handler(n, virtio_config_guest_notifier_read);
66
+ + } else {
67
+ + event_notifier_set_handler(n, NULL);
68
+ + }
69
+ + if (!assign) {
70
+ + /* Test and clear notifier before closing it,*/
71
+ + /* in case poll callback didn't have time to run. */
72
+ + virtio_config_guest_notifier_read(n);
73
+ + }
74
+ +}
75
+ +
76
+ EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq)
77
+ {
78
+ return &vq->guest_notifier;
79
+ @@ -4109,6 +4133,11 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq)
80
+ return &vq->host_notifier;
81
+ }
82
+
83
+ +EventNotifier *virtio_config_get_guest_notifier(VirtIODevice *vdev)
84
+ +{
85
+ + return &vdev->config_notifier;
86
+ +}
87
+ +
88
+ void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled)
89
+ {
90
+ vq->host_notifier_enabled = enabled;
91
+ diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
92
+ index 1f4a41b958..9c3a4642f2 100644
93
+ --- a/include/hw/virtio/virtio.h
94
+ +++ b/include/hw/virtio/virtio.h
95
+ @@ -138,6 +138,7 @@ struct VirtIODevice
96
+ AddressSpace *dma_as;
97
+ QLIST_HEAD(, VirtQueue) *vector_queues;
98
+ QTAILQ_ENTRY(VirtIODevice) next;
99
+ + EventNotifier config_notifier;
100
+ };
101
+
102
+ struct VirtioDeviceClass {
103
+ @@ -360,6 +361,9 @@ void virtio_queue_aio_attach_host_notifier_no_poll(VirtQueue *vq, AioContext *ct
104
+ void virtio_queue_aio_detach_host_notifier(VirtQueue *vq, AioContext *ctx);
105
+ VirtQueue *virtio_vector_first_queue(VirtIODevice *vdev, uint16_t vector);
106
+ VirtQueue *virtio_vector_next_queue(VirtQueue *vq);
107
+ +EventNotifier *virtio_config_get_guest_notifier(VirtIODevice *vdev);
108
+ +void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev,
109
+ + bool assign, bool with_irqfd);
110
+
111
+ static inline void virtio_add_feature(uint64_t *features, unsigned int fbit)
112
+ {
113
+ --
114
+ 2.31.1
115
+
SOURCES/kvm-virtio-introduce-macro-VIRTIO_CONFIG_IRQ_IDX.patch ADDED
@@ -0,0 +1,262 @@
1
+ From 34a267758cf016f34b327318500efdbf0f606033 Mon Sep 17 00:00:00 2001
2
+ From: Cindy Lu <lulu@redhat.com>
3
+ Date: Thu, 22 Dec 2022 15:04:42 +0800
4
+ Subject: [PATCH 01/31] virtio: introduce macro VIRTIO_CONFIG_IRQ_IDX
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Cindy Lu <lulu@redhat.com>
10
+ RH-MergeRequest: 132: vhost-vdpa: support config interrupt in vhost-vdpa
11
+ RH-Bugzilla: 1905805
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [1/10] f374aaae221bc5a4c2521a267d21350b812e11ba (lulu6/qemu-kvm3)
16
+
17
+ https://bugzilla.redhat.com/show_bug.cgi?id=1905805
18
+ To support configure interrupt for vhost-vdpa
19
+ Introduce VIRTIO_CONFIG_IRQ_IDX -1 as configure interrupt's queue index,
20
+ Then we can reuse the functions guest_notifier_mask and guest_notifier_pending.
21
+ Add the check of queue index in these drivers, if the driver does not support
22
+ configure interrupt, the function will just return
23
+
24
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
25
+ Message-Id: <20221222070451.936503-2-lulu@redhat.com>
26
+ Acked-by: Jason Wang <jasowang@redhat.com>
27
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
28
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
29
+ (cherry picked from commit 544f0278afcab2bebab61b14e4c2c58e65911f5b)
30
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
31
+ ---
32
+ hw/display/vhost-user-gpu.c | 18 ++++++++++++++++++
33
+ hw/net/virtio-net.c | 22 ++++++++++++++++++++--
34
+ hw/virtio/vhost-user-fs.c | 18 ++++++++++++++++++
35
+ hw/virtio/vhost-user-gpio.c | 10 ++++++++++
36
+ hw/virtio/vhost-vsock-common.c | 18 ++++++++++++++++++
37
+ hw/virtio/virtio-crypto.c | 18 ++++++++++++++++++
38
+ include/hw/virtio/virtio.h | 3 +++
39
+ 7 files changed, 105 insertions(+), 2 deletions(-)
40
+
41
+ diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c
42
+ index 19c0e20103..4380a5e672 100644
43
+ --- a/hw/display/vhost-user-gpu.c
44
+ +++ b/hw/display/vhost-user-gpu.c
45
+ @@ -486,6 +486,15 @@ vhost_user_gpu_guest_notifier_pending(VirtIODevice *vdev, int idx)
46
+ {
47
+ VhostUserGPU *g = VHOST_USER_GPU(vdev);
48
+
49
+ + /*
50
+ + * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
51
+ + * as the Marco of configure interrupt's IDX, If this driver does not
52
+ + * support, the function will return
53
+ + */
54
+ +
55
+ + if (idx == VIRTIO_CONFIG_IRQ_IDX) {
56
+ + return false;
57
+ + }
58
+ return vhost_virtqueue_pending(&g->vhost->dev, idx);
59
+ }
60
+
61
+ @@ -494,6 +503,15 @@ vhost_user_gpu_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask)
62
+ {
63
+ VhostUserGPU *g = VHOST_USER_GPU(vdev);
64
+
65
+ + /*
66
+ + * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
67
+ + * as the Marco of configure interrupt's IDX, If this driver does not
68
+ + * support, the function will return
69
+ + */
70
+ +
71
+ + if (idx == VIRTIO_CONFIG_IRQ_IDX) {
72
+ + return;
73
+ + }
74
+ vhost_virtqueue_mask(&g->vhost->dev, vdev, idx, mask);
75
+ }
76
+
77
+ diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
78
+ index aba12759d5..bee35d6f9f 100644
79
+ --- a/hw/net/virtio-net.c
80
+ +++ b/hw/net/virtio-net.c
81
+ @@ -3316,6 +3316,15 @@ static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx)
82
+ } else {
83
+ nc = qemu_get_subqueue(n->nic, vq2q(idx));
84
+ }
85
+ + /*
86
+ + * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
87
+ + * as the Marco of configure interrupt's IDX, If this driver does not
88
+ + * support, the function will return false
89
+ + */
90
+ +
91
+ + if (idx == VIRTIO_CONFIG_IRQ_IDX) {
92
+ + return false;
93
+ + }
94
+ return vhost_net_virtqueue_pending(get_vhost_net(nc->peer), idx);
95
+ }
96
+
97
+ @@ -3339,8 +3348,17 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx,
98
+ } else {
99
+ nc = qemu_get_subqueue(n->nic, vq2q(idx));
100
+ }
101
+ - vhost_net_virtqueue_mask(get_vhost_net(nc->peer),
102
+ - vdev, idx, mask);
103
+ + /*
104
+ + *Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
105
+ + * as the Marco of configure interrupt's IDX, If this driver does not
106
+ + * support, the function will return
107
+ + */
108
+ +
109
+ + if (idx == VIRTIO_CONFIG_IRQ_IDX) {
110
+ + return;
111
+ + }
112
+ +
113
+ + vhost_net_virtqueue_mask(get_vhost_net(nc->peer), vdev, idx, mask);
114
+ }
115
+
116
+ static void virtio_net_set_config_size(VirtIONet *n, uint64_t host_features)
117
+ diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c
118
+ index d97b179e6f..f5049735ac 100644
119
+ --- a/hw/virtio/vhost-user-fs.c
120
+ +++ b/hw/virtio/vhost-user-fs.c
121
+ @@ -159,6 +159,15 @@ static void vuf_guest_notifier_mask(VirtIODevice *vdev, int idx,
122
+ {
123
+ VHostUserFS *fs = VHOST_USER_FS(vdev);
124
+
125
+ + /*
126
+ + * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
127
+ + * as the Marco of configure interrupt's IDX, If this driver does not
128
+ + * support, the function will return
129
+ + */
130
+ +
131
+ + if (idx == VIRTIO_CONFIG_IRQ_IDX) {
132
+ + return;
133
+ + }
134
+ vhost_virtqueue_mask(&fs->vhost_dev, vdev, idx, mask);
135
+ }
136
+
137
+ @@ -166,6 +175,15 @@ static bool vuf_guest_notifier_pending(VirtIODevice *vdev, int idx)
138
+ {
139
+ VHostUserFS *fs = VHOST_USER_FS(vdev);
140
+
141
+ + /*
142
+ + * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
143
+ + * as the Marco of configure interrupt's IDX, If this driver does not
144
+ + * support, the function will return
145
+ + */
146
+ +
147
+ + if (idx == VIRTIO_CONFIG_IRQ_IDX) {
148
+ + return false;
149
+ + }
150
+ return vhost_virtqueue_pending(&fs->vhost_dev, idx);
151
+ }
152
+
153
+ diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c
154
+ index b7b82a1099..fe3da32c74 100644
155
+ --- a/hw/virtio/vhost-user-gpio.c
156
+ +++ b/hw/virtio/vhost-user-gpio.c
157
+ @@ -191,6 +191,16 @@ static void vu_gpio_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask)
158
+ {
159
+ VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev);
160
+
161
+ + /*
162
+ + * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
163
+ + * as the Marco of configure interrupt's IDX, If this driver does not
164
+ + * support, the function will return
165
+ + */
166
+ +
167
+ + if (idx == VIRTIO_CONFIG_IRQ_IDX) {
168
+ + return;
169
+ + }
170
+ +
171
+ vhost_virtqueue_mask(&gpio->vhost_dev, vdev, idx, mask);
172
+ }
173
+
174
+ diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c
175
+ index d21c72b401..d2b5519d5a 100644
176
+ --- a/hw/virtio/vhost-vsock-common.c
177
+ +++ b/hw/virtio/vhost-vsock-common.c
178
+ @@ -127,6 +127,15 @@ static void vhost_vsock_common_guest_notifier_mask(VirtIODevice *vdev, int idx,
179
+ {
180
+ VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev);
181
+
182
+ + /*
183
+ + * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
184
+ + * as the Marco of configure interrupt's IDX, If this driver does not
185
+ + * support, the function will return
186
+ + */
187
+ +
188
+ + if (idx == VIRTIO_CONFIG_IRQ_IDX) {
189
+ + return;
190
+ + }
191
+ vhost_virtqueue_mask(&vvc->vhost_dev, vdev, idx, mask);
192
+ }
193
+
194
+ @@ -135,6 +144,15 @@ static bool vhost_vsock_common_guest_notifier_pending(VirtIODevice *vdev,
195
+ {
196
+ VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev);
197
+
198
+ + /*
199
+ + * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
200
+ + * as the Marco of configure interrupt's IDX, If this driver does not
201
+ + * support, the function will return
202
+ + */
203
+ +
204
+ + if (idx == VIRTIO_CONFIG_IRQ_IDX) {
205
+ + return false;
206
+ + }
207
+ return vhost_virtqueue_pending(&vvc->vhost_dev, idx);
208
+ }
209
+
210
+ diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
211
+ index 97da74e719..516425e26a 100644
212
+ --- a/hw/virtio/virtio-crypto.c
213
+ +++ b/hw/virtio/virtio-crypto.c
214
+ @@ -1182,6 +1182,15 @@ static void virtio_crypto_guest_notifier_mask(VirtIODevice *vdev, int idx,
215
+
216
+ assert(vcrypto->vhost_started);
217
+
218
+ + /*
219
+ + * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
220
+ + * as the Marco of configure interrupt's IDX, If this driver does not
221
+ + * support, the function will return
222
+ + */
223
+ +
224
+ + if (idx == VIRTIO_CONFIG_IRQ_IDX) {
225
+ + return;
226
+ + }
227
+ cryptodev_vhost_virtqueue_mask(vdev, queue, idx, mask);
228
+ }
229
+
230
+ @@ -1192,6 +1201,15 @@ static bool virtio_crypto_guest_notifier_pending(VirtIODevice *vdev, int idx)
231
+
232
+ assert(vcrypto->vhost_started);
233
+
234
+ + /*
235
+ + * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
236
+ + * as the Marco of configure interrupt's IDX, If this driver does not
237
+ + * support, the function will return
238
+ + */
239
+ +
240
+ + if (idx == VIRTIO_CONFIG_IRQ_IDX) {
241
+ + return false;
242
+ + }
243
+ return cryptodev_vhost_virtqueue_pending(vdev, queue, idx);
244
+ }
245
+
246
+ diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
247
+ index acfd4df125..1f4a41b958 100644
248
+ --- a/include/hw/virtio/virtio.h
249
+ +++ b/include/hw/virtio/virtio.h
250
+ @@ -79,6 +79,9 @@ typedef struct VirtQueueElement
251
+
252
+ #define VIRTIO_NO_VECTOR 0xffff
253
+
254
+ +/* special index value used internally for config irqs */
255
+ +#define VIRTIO_CONFIG_IRQ_IDX -1
256
+ +
257
+ #define TYPE_VIRTIO_DEVICE "virtio-device"
258
+ OBJECT_DECLARE_TYPE(VirtIODevice, VirtioDeviceClass, VIRTIO_DEVICE)
259
+
260
+ --
261
+ 2.31.1
262
+
SOURCES/kvm-virtio-iommu-Add-an-assert-check-in-translate-routin.patch DELETED
@@ -1,46 +0,0 @@
1
- From 643d9c28ff8b15c333cc748c5e712659ad2a257c Mon Sep 17 00:00:00 2001
2
- From: Zhenzhong Duan <zhenzhong.duan@intel.com>
3
- Date: Mon, 13 Jun 2022 14:10:10 +0800
4
- Subject: [PATCH 03/17] virtio-iommu: Add an assert check in translate routine
5
-
6
- RH-Author: Eric Auger <eric.auger@redhat.com>
7
- RH-MergeRequest: 105: virtio-iommu: Fix bypass mode for assigned devices
8
- RH-Commit: [3/5] 19f309fd0beda40d65f51c454e37936658ac9f38 (eauger1/centos-qemu-kvm)
9
- RH-Bugzilla: 2100106
10
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
- RH-Acked-by: Peter Xu <peterx@redhat.com>
12
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
13
-
14
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2100106
15
-
16
- With address space switch supported, dma access translation only
17
- happen after endpoint is attached to a non-bypass domain.
18
-
19
- Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
20
- Message-Id: <20220613061010.2674054-4-zhenzhong.duan@intel.com>
21
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
22
- Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
23
- (cherry picked from commit 23b5f0ff6d923d3bca11cf44eed3daf7a0a836a8)
24
- Signed-off-by: Eric Auger <eric.auger@redhat.com>
25
- ---
26
- hw/virtio/virtio-iommu.c | 4 ++++
27
- 1 file changed, 4 insertions(+)
28
-
29
- diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
30
- index 440a1c28a7..e970d4d5a6 100644
31
- --- a/hw/virtio/virtio-iommu.c
32
- +++ b/hw/virtio/virtio-iommu.c
33
- @@ -866,6 +866,10 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr,
34
- qemu_rec_mutex_lock(&s->mutex);
35
-
36
- ep = g_tree_lookup(s->endpoints, GUINT_TO_POINTER(sid));
37
- +
38
- + if (bypass_allowed)
39
- + assert(ep && ep->domain && !ep->domain->bypass);
40
- +
41
- if (!ep) {
42
- if (!bypass_allowed) {
43
- error_report_once("%s sid=%d is not known!!", __func__, sid);
44
- --
45
- 2.31.1
46
-
SOURCES/kvm-virtio-iommu-Add-bypass-mode-support-to-assigned-dev.patch DELETED
@@ -1,250 +0,0 @@
1
- From d60774ee3168eefb21a4120a38107cd36ae17e07 Mon Sep 17 00:00:00 2001
2
- From: Zhenzhong Duan <zhenzhong.duan@intel.com>
3
- Date: Mon, 13 Jun 2022 14:10:08 +0800
4
- Subject: [PATCH 01/17] virtio-iommu: Add bypass mode support to assigned
5
- device
6
-
7
- RH-Author: Eric Auger <eric.auger@redhat.com>
8
- RH-MergeRequest: 105: virtio-iommu: Fix bypass mode for assigned devices
9
- RH-Commit: [1/5] 4777815533b31c7f4f09af8902e378fd3fc1186a (eauger1/centos-qemu-kvm)
10
- RH-Bugzilla: 2100106
11
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
- RH-Acked-by: Peter Xu <peterx@redhat.com>
13
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
14
-
15
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2100106
16
-
17
- Currently assigned devices can not work in virtio-iommu bypass mode.
18
- Guest driver fails to probe the device due to DMA failure. And the
19
- reason is because of lacking GPA -> HPA mappings when VM is created.
20
-
21
- Add a root container memory region to hold both bypass memory region
22
- and iommu memory region, so the switch between them is supported
23
- just like the implementation in virtual VT-d.
24
-
25
- Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
26
- Message-Id: <20220613061010.2674054-2-zhenzhong.duan@intel.com>
27
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
28
- Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
29
- (cherry picked from commit 90519b90539b16258d1d52b908b199f44877dc18)
30
- Signed-off-by: Eric Auger <eric.auger@redhat.com>
31
- ---
32
- hw/virtio/trace-events | 1 +
33
- hw/virtio/virtio-iommu.c | 115 ++++++++++++++++++++++++++++++-
34
- include/hw/virtio/virtio-iommu.h | 2 +
35
- 3 files changed, 116 insertions(+), 2 deletions(-)
36
-
37
- diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
38
- index a5102eac9e..2ab5881b88 100644
39
- --- a/hw/virtio/trace-events
40
- +++ b/hw/virtio/trace-events
41
- @@ -114,6 +114,7 @@ virtio_iommu_remap(const char *name, uint64_t virt_start, uint64_t virt_end, uin
42
- virtio_iommu_set_page_size_mask(const char *name, uint64_t old, uint64_t new) "mr=%s old_mask=0x%"PRIx64" new_mask=0x%"PRIx64
43
- virtio_iommu_notify_flag_add(const char *name) "add notifier to mr %s"
44
- virtio_iommu_notify_flag_del(const char *name) "del notifier from mr %s"
45
- +virtio_iommu_switch_address_space(uint8_t bus, uint8_t slot, uint8_t fn, bool on) "Device %02x:%02x.%x switching address space (iommu enabled=%d)"
46
-
47
- # virtio-mem.c
48
- virtio_mem_send_response(uint16_t type) "type=%" PRIu16
49
- diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
50
- index 6d5ea0bdf1..5e99e6c62b 100644
51
- --- a/hw/virtio/virtio-iommu.c
52
- +++ b/hw/virtio/virtio-iommu.c
53
- @@ -70,6 +70,77 @@ static inline uint16_t virtio_iommu_get_bdf(IOMMUDevice *dev)
54
- return PCI_BUILD_BDF(pci_bus_num(dev->bus), dev->devfn);
55
- }
56
-
57
- +static bool virtio_iommu_device_bypassed(IOMMUDevice *sdev)
58
- +{
59
- + uint32_t sid;
60
- + bool bypassed;
61
- + VirtIOIOMMU *s = sdev->viommu;
62
- + VirtIOIOMMUEndpoint *ep;
63
- +
64
- + sid = virtio_iommu_get_bdf(sdev);
65
- +
66
- + qemu_mutex_lock(&s->mutex);
67
- + /* need to check bypass before system reset */
68
- + if (!s->endpoints) {
69
- + bypassed = s->config.bypass;
70
- + goto unlock;
71
- + }
72
- +
73
- + ep = g_tree_lookup(s->endpoints, GUINT_TO_POINTER(sid));
74
- + if (!ep || !ep->domain) {
75
- + bypassed = s->config.bypass;
76
- + } else {
77
- + bypassed = ep->domain->bypass;
78
- + }
79
- +
80
- +unlock:
81
- + qemu_mutex_unlock(&s->mutex);
82
- + return bypassed;
83
- +}
84
- +
85
- +/* Return whether the device is using IOMMU translation. */
86
- +static bool virtio_iommu_switch_address_space(IOMMUDevice *sdev)
87
- +{
88
- + bool use_remapping;
89
- +
90
- + assert(sdev);
91
- +
92
- + use_remapping = !virtio_iommu_device_bypassed(sdev);
93
- +
94
- + trace_virtio_iommu_switch_address_space(pci_bus_num(sdev->bus),
95
- + PCI_SLOT(sdev->devfn),
96
- + PCI_FUNC(sdev->devfn),
97
- + use_remapping);
98
- +
99
- + /* Turn off first then on the other */
100
- + if (use_remapping) {
101
- + memory_region_set_enabled(&sdev->bypass_mr, false);
102
- + memory_region_set_enabled(MEMORY_REGION(&sdev->iommu_mr), true);
103
- + } else {
104
- + memory_region_set_enabled(MEMORY_REGION(&sdev->iommu_mr), false);
105
- + memory_region_set_enabled(&sdev->bypass_mr, true);
106
- + }
107
- +
108
- + return use_remapping;
109
- +}
110
- +
111
- +static void virtio_iommu_switch_address_space_all(VirtIOIOMMU *s)
112
- +{
113
- + GHashTableIter iter;
114
- + IOMMUPciBus *iommu_pci_bus;
115
- + int i;
116
- +
117
- + g_hash_table_iter_init(&iter, s->as_by_busptr);
118
- + while (g_hash_table_iter_next(&iter, NULL, (void **)&iommu_pci_bus)) {
119
- + for (i = 0; i < PCI_DEVFN_MAX; i++) {
120
- + if (!iommu_pci_bus->pbdev[i]) {
121
- + continue;
122
- + }
123
- + virtio_iommu_switch_address_space(iommu_pci_bus->pbdev[i]);
124
- + }
125
- + }
126
- +}
127
- +
128
- /**
129
- * The bus number is used for lookup when SID based operations occur.
130
- * In that case we lazily populate the IOMMUPciBus array from the bus hash
131
- @@ -214,6 +285,7 @@ static gboolean virtio_iommu_notify_map_cb(gpointer key, gpointer value,
132
- static void virtio_iommu_detach_endpoint_from_domain(VirtIOIOMMUEndpoint *ep)
133
- {
134
- VirtIOIOMMUDomain *domain = ep->domain;
135
- + IOMMUDevice *sdev = container_of(ep->iommu_mr, IOMMUDevice, iommu_mr);
136
-
137
- if (!ep->domain) {
138
- return;
139
- @@ -222,6 +294,7 @@ static void virtio_iommu_detach_endpoint_from_domain(VirtIOIOMMUEndpoint *ep)
140
- ep->iommu_mr);
141
- QLIST_REMOVE(ep, next);
142
- ep->domain = NULL;
143
- + virtio_iommu_switch_address_space(sdev);
144
- }
145
-
146
- static VirtIOIOMMUEndpoint *virtio_iommu_get_endpoint(VirtIOIOMMU *s,
147
- @@ -324,12 +397,39 @@ static AddressSpace *virtio_iommu_find_add_as(PCIBus *bus, void *opaque,
148
-
149
- trace_virtio_iommu_init_iommu_mr(name);
150
-
151
- + memory_region_init(&sdev->root, OBJECT(s), name, UINT64_MAX);
152
- + address_space_init(&sdev->as, &sdev->root, TYPE_VIRTIO_IOMMU);
153
- +
154
- + /*
155
- + * Build the IOMMU disabled container with aliases to the
156
- + * shared MRs. Note that aliasing to a shared memory region
157
- + * could help the memory API to detect same FlatViews so we
158
- + * can have devices to share the same FlatView when in bypass
159
- + * mode. (either by not configuring virtio-iommu driver or with
160
- + * "iommu=pt"). It will greatly reduce the total number of
161
- + * FlatViews of the system hence VM runs faster.
162
- + */
163
- + memory_region_init_alias(&sdev->bypass_mr, OBJECT(s),
164
- + "system", get_system_memory(), 0,
165
- + memory_region_size(get_system_memory()));
166
- +
167
- memory_region_init_iommu(&sdev->iommu_mr, sizeof(sdev->iommu_mr),
168
- TYPE_VIRTIO_IOMMU_MEMORY_REGION,
169
- OBJECT(s), name,
170
- UINT64_MAX);
171
- - address_space_init(&sdev->as,
172
- - MEMORY_REGION(&sdev->iommu_mr), TYPE_VIRTIO_IOMMU);
173
- +
174
- + /*
175
- + * Hook both the containers under the root container, we
176
- + * switch between iommu & bypass MRs by enable/disable
177
- + * corresponding sub-containers
178
- + */
179
- + memory_region_add_subregion_overlap(&sdev->root, 0,
180
- + MEMORY_REGION(&sdev->iommu_mr),
181
- + 0);
182
- + memory_region_add_subregion_overlap(&sdev->root, 0,
183
- + &sdev->bypass_mr, 0);
184
- +
185
- + virtio_iommu_switch_address_space(sdev);
186
- g_free(name);
187
- }
188
- return &sdev->as;
189
- @@ -343,6 +443,7 @@ static int virtio_iommu_attach(VirtIOIOMMU *s,
190
- uint32_t flags = le32_to_cpu(req->flags);
191
- VirtIOIOMMUDomain *domain;
192
- VirtIOIOMMUEndpoint *ep;
193
- + IOMMUDevice *sdev;
194
-
195
- trace_virtio_iommu_attach(domain_id, ep_id);
196
-
197
- @@ -376,6 +477,8 @@ static int virtio_iommu_attach(VirtIOIOMMU *s,
198
- QLIST_INSERT_HEAD(&domain->endpoint_list, ep, next);
199
-
200
- ep->domain = domain;
201
- + sdev = container_of(ep->iommu_mr, IOMMUDevice, iommu_mr);
202
- + virtio_iommu_switch_address_space(sdev);
203
-
204
- /* Replay domain mappings on the associated memory region */
205
- g_tree_foreach(domain->mappings, virtio_iommu_notify_map_cb,
206
- @@ -888,6 +991,7 @@ static void virtio_iommu_set_config(VirtIODevice *vdev,
207
- return;
208
- }
209
- dev_config->bypass = in_config->bypass;
210
- + virtio_iommu_switch_address_space_all(dev);
211
- }
212
-
213
- trace_virtio_iommu_set_config(in_config->bypass);
214
- @@ -1027,6 +1131,8 @@ static void virtio_iommu_system_reset(void *opaque)
215
- * system reset
216
- */
217
- s->config.bypass = s->boot_bypass;
218
- + virtio_iommu_switch_address_space_all(s);
219
- +
220
- }
221
-
222
- static void virtio_iommu_device_realize(DeviceState *dev, Error **errp)
223
- @@ -1043,6 +1149,11 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp)
224
- virtio_iommu_handle_command);
225
- s->event_vq = virtio_add_queue(vdev, VIOMMU_DEFAULT_QUEUE_SIZE, NULL);
226
-
227
- + /*
228
- + * config.bypass is needed to get initial address space early, such as
229
- + * in vfio realize
230
- + */
231
- + s->config.bypass = s->boot_bypass;
232
- s->config.page_size_mask = TARGET_PAGE_MASK;
233
- s->config.input_range.end = UINT64_MAX;
234
- s->config.domain_range.end = UINT32_MAX;
235
- diff --git a/include/hw/virtio/virtio-iommu.h b/include/hw/virtio/virtio-iommu.h
236
- index 84391f8448..102eeefa73 100644
237
- --- a/include/hw/virtio/virtio-iommu.h
238
- +++ b/include/hw/virtio/virtio-iommu.h
239
- @@ -37,6 +37,8 @@ typedef struct IOMMUDevice {
240
- int devfn;
241
- IOMMUMemoryRegion iommu_mr;
242
- AddressSpace as;
243
- + MemoryRegion root; /* The root container of the device */
244
- + MemoryRegion bypass_mr; /* The alias of shared memory MR */
245
- } IOMMUDevice;
246
-
247
- typedef struct IOMMUPciBus {
248
- --
249
- 2.31.1
250
-
SOURCES/kvm-virtio-iommu-Fix-migration-regression.patch DELETED
@@ -1,54 +0,0 @@
1
- From 8d45902b4884315ec090e607e9f03606b21001cf Mon Sep 17 00:00:00 2001
2
- From: Zhenzhong Duan <zhenzhong.duan@intel.com>
3
- Date: Fri, 24 Jun 2022 17:37:40 +0800
4
- Subject: [PATCH 05/17] virtio-iommu: Fix migration regression
5
-
6
- RH-Author: Eric Auger <eric.auger@redhat.com>
7
- RH-MergeRequest: 105: virtio-iommu: Fix bypass mode for assigned devices
8
- RH-Commit: [5/5] 9652c4aaaf88e24083fab1fbc3d1423260c93ca6 (eauger1/centos-qemu-kvm)
9
- RH-Bugzilla: 2100106
10
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
- RH-Acked-by: Peter Xu <peterx@redhat.com>
12
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
13
-
14
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2100106
15
-
16
- We also need to switch to the right address space on dest side
17
- after loading the device status. DMA to wrong address space is
18
- destructive.
19
-
20
- Fixes: 3facd774962fd ("virtio-iommu: Add bypass mode support to assigned device")
21
- Suggested-by: Eric Auger <eric.auger@redhat.com>
22
- Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
23
- Message-Id: <20220624093740.3525267-1-zhenzhong.duan@intel.com>
24
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
25
- Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
26
- Reviewed-by: Eric Auger <eric.auger@redhat.com>
27
- (cherry picked from commit d355566bd958e24e7e384da6ea89a9fc88d7bfed)
28
- Signed-off-by: Eric Auger <eric.auger@redhat.com>
29
- ---
30
- hw/virtio/virtio-iommu.c | 8 ++++++++
31
- 1 file changed, 8 insertions(+)
32
-
33
- diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
34
- index 44a041dec9..2012835554 100644
35
- --- a/hw/virtio/virtio-iommu.c
36
- +++ b/hw/virtio/virtio-iommu.c
37
- @@ -1324,6 +1324,14 @@ static int iommu_post_load(void *opaque, int version_id)
38
- VirtIOIOMMU *s = opaque;
39
-
40
- g_tree_foreach(s->domains, reconstruct_endpoints, s);
41
- +
42
- + /*
43
- + * Memory regions are dynamically turned on/off depending on
44
- + * 'config.bypass' and attached domain type if there is. After
45
- + * migration, we need to make sure the memory regions are
46
- + * still correct.
47
- + */
48
- + virtio_iommu_switch_address_space_all(s);
49
- return 0;
50
- }
51
-
52
- --
53
- 2.31.1
54
-
SOURCES/kvm-virtio-iommu-Fix-the-partial-copy-of-probe-request.patch DELETED
@@ -1,67 +0,0 @@
1
- From b681247c29b59af40c86f8f0ae5709138ae9bf1a Mon Sep 17 00:00:00 2001
2
- From: Zhenzhong Duan <zhenzhong.duan@intel.com>
3
- Date: Thu, 23 Jun 2022 10:31:52 +0800
4
- Subject: [PATCH 04/17] virtio-iommu: Fix the partial copy of probe request
5
-
6
- RH-Author: Eric Auger <eric.auger@redhat.com>
7
- RH-MergeRequest: 105: virtio-iommu: Fix bypass mode for assigned devices
8
- RH-Commit: [4/5] c402164414a8e69bbb6df20af3c2b6d2589d6f3e (eauger1/centos-qemu-kvm)
9
- RH-Bugzilla: 2100106
10
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
- RH-Acked-by: Peter Xu <peterx@redhat.com>
12
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
13
-
14
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2100106
15
-
16
- The structure of probe request doesn't include the tail, this leads
17
- to a few field missed to be copied. Currently this isn't an issue as
18
- those missed field belong to reserved field, just in case reserved
19
- field will be used in the future.
20
-
21
- Changed 4th parameter of virtio_iommu_iov_to_req() to receive size
22
- of device-readable part.
23
-
24
- Fixes: 1733eebb9e75b ("virtio-iommu: Implement RESV_MEM probe request")
25
- Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
26
- Message-Id: <20220623023152.3473231-1-zhenzhong.duan@intel.com>
27
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
28
- Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
29
- Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
30
- Reviewed-by: Eric Auger <eric.auger@redhat.com>
31
- (cherry picked from commit 45461aace83d961e933b27519b81d17b4c690514)
32
- Signed-off-by: Eric Auger <eric.auger@redhat.com>
33
- ---
34
- hw/virtio/virtio-iommu.c | 8 ++++----
35
- 1 file changed, 4 insertions(+), 4 deletions(-)
36
-
37
- diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
38
- index e970d4d5a6..44a041dec9 100644
39
- --- a/hw/virtio/virtio-iommu.c
40
- +++ b/hw/virtio/virtio-iommu.c
41
- @@ -676,11 +676,10 @@ static int virtio_iommu_probe(VirtIOIOMMU *s,
42
-
43
- static int virtio_iommu_iov_to_req(struct iovec *iov,
44
- unsigned int iov_cnt,
45
- - void *req, size_t req_sz)
46
- + void *req, size_t payload_sz)
47
- {
48
- - size_t sz, payload_sz = req_sz - sizeof(struct virtio_iommu_req_tail);
49
- + size_t sz = iov_to_buf(iov, iov_cnt, 0, req, payload_sz);
50
-
51
- - sz = iov_to_buf(iov, iov_cnt, 0, req, payload_sz);
52
- if (unlikely(sz != payload_sz)) {
53
- return VIRTIO_IOMMU_S_INVAL;
54
- }
55
- @@ -693,7 +692,8 @@ static int virtio_iommu_handle_ ## __req(VirtIOIOMMU *s, \
56
- unsigned int iov_cnt) \
57
- { \
58
- struct virtio_iommu_req_ ## __req req; \
59
- - int ret = virtio_iommu_iov_to_req(iov, iov_cnt, &req, sizeof(req)); \
60
- + int ret = virtio_iommu_iov_to_req(iov, iov_cnt, &req, \
61
- + sizeof(req) - sizeof(struct virtio_iommu_req_tail));\
62
- \
63
- return ret ? ret : virtio_iommu_ ## __req(s, &req); \
64
- }
65
- --
66
- 2.31.1
67
-
SOURCES/kvm-virtio-iommu-Use-recursive-lock-to-avoid-deadlock.patch DELETED
@@ -1,141 +0,0 @@
1
- From 881c999e302e7ee1212b47c523a2cf442c549417 Mon Sep 17 00:00:00 2001
2
- From: Zhenzhong Duan <zhenzhong.duan@intel.com>
3
- Date: Mon, 13 Jun 2022 14:10:09 +0800
4
- Subject: [PATCH 02/17] virtio-iommu: Use recursive lock to avoid deadlock
5
-
6
- RH-Author: Eric Auger <eric.auger@redhat.com>
7
- RH-MergeRequest: 105: virtio-iommu: Fix bypass mode for assigned devices
8
- RH-Commit: [2/5] 67dce1eecb49555f728f119f8efac00417ff65bf (eauger1/centos-qemu-kvm)
9
- RH-Bugzilla: 2100106
10
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
- RH-Acked-by: Peter Xu <peterx@redhat.com>
12
- RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
13
-
14
- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2100106
15
-
16
- When switching address space with mutex lock hold, mapping will be
17
- replayed for assigned device. This will trigger relock deadlock.
18
-
19
- Also release the mutex resource in unrealize routine.
20
-
21
- Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
22
- Message-Id: <20220613061010.2674054-3-zhenzhong.duan@intel.com>
23
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
24
- Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
25
- (cherry picked from commit 08f2030a2e46f1e93d186b3a683e5caef1df562b)
26
- Signed-off-by: Eric Auger <eric.auger@redhat.com>
27
- ---
28
- hw/virtio/virtio-iommu.c | 20 +++++++++++---------
29
- include/hw/virtio/virtio-iommu.h | 2 +-
30
- 2 files changed, 12 insertions(+), 10 deletions(-)
31
-
32
- diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
33
- index 5e99e6c62b..440a1c28a7 100644
34
- --- a/hw/virtio/virtio-iommu.c
35
- +++ b/hw/virtio/virtio-iommu.c
36
- @@ -79,7 +79,7 @@ static bool virtio_iommu_device_bypassed(IOMMUDevice *sdev)
37
-
38
- sid = virtio_iommu_get_bdf(sdev);
39
-
40
- - qemu_mutex_lock(&s->mutex);
41
- + qemu_rec_mutex_lock(&s->mutex);
42
- /* need to check bypass before system reset */
43
- if (!s->endpoints) {
44
- bypassed = s->config.bypass;
45
- @@ -94,7 +94,7 @@ static bool virtio_iommu_device_bypassed(IOMMUDevice *sdev)
46
- }
47
-
48
- unlock:
49
- - qemu_mutex_unlock(&s->mutex);
50
- + qemu_rec_mutex_unlock(&s->mutex);
51
- return bypassed;
52
- }
53
-
54
- @@ -746,7 +746,7 @@ static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue *vq)
55
- tail.status = VIRTIO_IOMMU_S_DEVERR;
56
- goto out;
57
- }
58
- - qemu_mutex_lock(&s->mutex);
59
- + qemu_rec_mutex_lock(&s->mutex);
60
- switch (head.type) {
61
- case VIRTIO_IOMMU_T_ATTACH:
62
- tail.status = virtio_iommu_handle_attach(s, iov, iov_cnt);
63
- @@ -775,7 +775,7 @@ static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue *vq)
64
- default:
65
- tail.status = VIRTIO_IOMMU_S_UNSUPP;
66
- }
67
- - qemu_mutex_unlock(&s->mutex);
68
- + qemu_rec_mutex_unlock(&s->mutex);
69
-
70
- out:
71
- sz = iov_from_buf(elem->in_sg, elem->in_num, 0,
72
- @@ -863,7 +863,7 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr,
73
- sid = virtio_iommu_get_bdf(sdev);
74
-
75
- trace_virtio_iommu_translate(mr->parent_obj.name, sid, addr, flag);
76
- - qemu_mutex_lock(&s->mutex);
77
- + qemu_rec_mutex_lock(&s->mutex);
78
-
79
- ep = g_tree_lookup(s->endpoints, GUINT_TO_POINTER(sid));
80
- if (!ep) {
81
- @@ -947,7 +947,7 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr,
82
- trace_virtio_iommu_translate_out(addr, entry.translated_addr, sid);
83
-
84
- unlock:
85
- - qemu_mutex_unlock(&s->mutex);
86
- + qemu_rec_mutex_unlock(&s->mutex);
87
- return entry;
88
- }
89
-
90
- @@ -1036,7 +1036,7 @@ static void virtio_iommu_replay(IOMMUMemoryRegion *mr, IOMMUNotifier *n)
91
-
92
- sid = virtio_iommu_get_bdf(sdev);
93
-
94
- - qemu_mutex_lock(&s->mutex);
95
- + qemu_rec_mutex_lock(&s->mutex);
96
-
97
- if (!s->endpoints) {
98
- goto unlock;
99
- @@ -1050,7 +1050,7 @@ static void virtio_iommu_replay(IOMMUMemoryRegion *mr, IOMMUNotifier *n)
100
- g_tree_foreach(ep->domain->mappings, virtio_iommu_remap, mr);
101
-
102
- unlock:
103
- - qemu_mutex_unlock(&s->mutex);
104
- + qemu_rec_mutex_unlock(&s->mutex);
105
- }
106
-
107
- static int virtio_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu_mr,
108
- @@ -1169,7 +1169,7 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp)
109
- virtio_add_feature(&s->features, VIRTIO_IOMMU_F_PROBE);
110
- virtio_add_feature(&s->features, VIRTIO_IOMMU_F_BYPASS_CONFIG);
111
-
112
- - qemu_mutex_init(&s->mutex);
113
- + qemu_rec_mutex_init(&s->mutex);
114
-
115
- s->as_by_busptr = g_hash_table_new_full(NULL, NULL, NULL, g_free);
116
-
117
- @@ -1197,6 +1197,8 @@ static void virtio_iommu_device_unrealize(DeviceState *dev)
118
- g_tree_destroy(s->endpoints);
119
- }
120
-
121
- + qemu_rec_mutex_destroy(&s->mutex);
122
- +
123
- virtio_delete_queue(s->req_vq);
124
- virtio_delete_queue(s->event_vq);
125
- virtio_cleanup(vdev);
126
- diff --git a/include/hw/virtio/virtio-iommu.h b/include/hw/virtio/virtio-iommu.h
127
- index 102eeefa73..2ad5ee320b 100644
128
- --- a/include/hw/virtio/virtio-iommu.h
129
- +++ b/include/hw/virtio/virtio-iommu.h
130
- @@ -58,7 +58,7 @@ struct VirtIOIOMMU {
131
- ReservedRegion *reserved_regions;
132
- uint32_t nb_reserved_regions;
133
- GTree *domains;
134
- - QemuMutex mutex;
135
- + QemuRecMutex mutex;
136
- GTree *endpoints;
137
- bool boot_bypass;
138
- };
139
- --
140
- 2.31.1
141
-
SOURCES/kvm-virtio-mmio-add-support-for-configure-interrupt.patch ADDED
@@ -0,0 +1,80 @@
1
+ From 181705090c9963c2da97811838ace5bb058737c6 Mon Sep 17 00:00:00 2001
2
+ From: Cindy Lu <lulu@redhat.com>
3
+ Date: Thu, 22 Dec 2022 15:04:50 +0800
4
+ Subject: [PATCH 09/31] virtio-mmio: add support for configure interrupt
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Cindy Lu <lulu@redhat.com>
10
+ RH-MergeRequest: 132: vhost-vdpa: support config interrupt in vhost-vdpa
11
+ RH-Bugzilla: 1905805
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [9/10] 742cc2b425ffd7bbd393772526e7481446ee131c (lulu6/qemu-kvm3)
16
+
17
+ https://bugzilla.redhat.com/show_bug.cgi?id=1905805
18
+ Add configure interrupt support in virtio-mmio bus.
19
+ add function to set configure guest notifier.
20
+
21
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
22
+ Message-Id: <20221222070451.936503-10-lulu@redhat.com>
23
+ Acked-by: Jason Wang <jasowang@redhat.com>
24
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
25
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
26
+ (cherry picked from commit cd336e834620ea78edef049c3567f312974e475b)
27
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
28
+ ---
29
+ hw/virtio/virtio-mmio.c | 27 +++++++++++++++++++++++++++
30
+ 1 file changed, 27 insertions(+)
31
+
32
+ diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c
33
+ index d240efef97..103260ec15 100644
34
+ --- a/hw/virtio/virtio-mmio.c
35
+ +++ b/hw/virtio/virtio-mmio.c
36
+ @@ -670,7 +670,30 @@ static int virtio_mmio_set_guest_notifier(DeviceState *d, int n, bool assign,
37
+
38
+ return 0;
39
+ }
40
+ +static int virtio_mmio_set_config_guest_notifier(DeviceState *d, bool assign,
41
+ + bool with_irqfd)
42
+ +{
43
+ + VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d);
44
+ + VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
45
+ + VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
46
+ + EventNotifier *notifier = virtio_config_get_guest_notifier(vdev);
47
+ + int r = 0;
48
+
49
+ + if (assign) {
50
+ + r = event_notifier_init(notifier, 0);
51
+ + if (r < 0) {
52
+ + return r;
53
+ + }
54
+ + virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irqfd);
55
+ + } else {
56
+ + virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irqfd);
57
+ + event_notifier_cleanup(notifier);
58
+ + }
59
+ + if (vdc->guest_notifier_mask && vdev->use_guest_notifier_mask) {
60
+ + vdc->guest_notifier_mask(vdev, VIRTIO_CONFIG_IRQ_IDX, !assign);
61
+ + }
62
+ + return r;
63
+ +}
64
+ static int virtio_mmio_set_guest_notifiers(DeviceState *d, int nvqs,
65
+ bool assign)
66
+ {
67
+ @@ -692,6 +715,10 @@ static int virtio_mmio_set_guest_notifiers(DeviceState *d, int nvqs,
68
+ goto assign_error;
69
+ }
70
+ }
71
+ + r = virtio_mmio_set_config_guest_notifier(d, assign, with_irqfd);
72
+ + if (r < 0) {
73
+ + goto assign_error;
74
+ + }
75
+
76
+ return 0;
77
+
78
+ --
79
+ 2.31.1
80
+
SOURCES/kvm-virtio-net-Expose-MAC_TABLE_ENTRIES.patch DELETED
@@ -1,69 +0,0 @@
1
- From dffe24d5c1f5a4676e9d2a5bc032effd420b008f Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:38:55 +0200
4
- Subject: [PATCH 08/32] virtio-net: Expose MAC_TABLE_ENTRIES
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [8/27] 5c3b96215ddf853cafc594da47f57d7e157db4ee (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit 6758c01f054c2a842d41d927d628b09f649d3254
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Wed Jul 20 08:59:27 2022 +0200
24
-
25
- virtio-net: Expose MAC_TABLE_ENTRIES
26
-
27
- vhost-vdpa control virtqueue needs to know the maximum entries supported
28
- by the virtio-net device, so we know if it is possible to apply the
29
- filter.
30
-
31
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
32
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
33
- Signed-off-by: Jason Wang <jasowang@redhat.com>
34
-
35
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
36
- ---
37
- hw/net/virtio-net.c | 1 -
38
- include/hw/virtio/virtio-net.h | 3 +++
39
- 2 files changed, 3 insertions(+), 1 deletion(-)
40
-
41
- diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
42
- index 633de61513..2a127f0a3b 100644
43
- --- a/hw/net/virtio-net.c
44
- +++ b/hw/net/virtio-net.c
45
- @@ -49,7 +49,6 @@
46
-
47
- #define VIRTIO_NET_VM_VERSION 11
48
-
49
- -#define MAC_TABLE_ENTRIES 64
50
- #define MAX_VLAN (1 << 12) /* Per 802.1Q definition */
51
-
52
- /* previously fixed value */
53
- diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
54
- index eb87032627..cce1c554f7 100644
55
- --- a/include/hw/virtio/virtio-net.h
56
- +++ b/include/hw/virtio/virtio-net.h
57
- @@ -35,6 +35,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(VirtIONet, VIRTIO_NET)
58
- * and latency. */
59
- #define TX_BURST 256
60
-
61
- +/* Maximum VIRTIO_NET_CTRL_MAC_TABLE_SET unicast + multicast entries. */
62
- +#define MAC_TABLE_ENTRIES 64
63
- +
64
- typedef struct virtio_net_conf
65
- {
66
- uint32_t txtimer;
67
- --
68
- 2.31.1
69
-
SOURCES/kvm-virtio-net-Expose-ctrl-virtqueue-logic.patch DELETED
@@ -1,169 +0,0 @@
1
- From 49e91b34b62f5da147fa2fb80d203dd675c48f64 Mon Sep 17 00:00:00 2001
2
- From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
- Date: Thu, 21 Jul 2022 15:38:55 +0200
4
- Subject: [PATCH 09/32] virtio-net: Expose ctrl virtqueue logic
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
- RH-MergeRequest: 108: Net Control Virtqueue shadow Support
11
- RH-Commit: [9/27] c4ab1e35f4ca728df82a687763c662369282c513 (eperezmartin/qemu-kvm)
12
- RH-Bugzilla: 1939363
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
-
17
- Bugzilla: https://bugzilla.redhat.com/1939363
18
-
19
- Upstream Status: git://git.qemu.org/qemu.git
20
-
21
- commit 640b8a1c588b56349b3307d88459ea1cd86181fb
22
- Author: Eugenio Pérez <eperezma@redhat.com>
23
- Date: Wed Jul 20 08:59:28 2022 +0200
24
-
25
- virtio-net: Expose ctrl virtqueue logic
26
-
27
- This allows external vhost-net devices to modify the state of the
28
- VirtIO device model once the vhost-vdpa device has acknowledged the
29
- control commands.
30
-
31
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
32
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
33
- Signed-off-by: Jason Wang <jasowang@redhat.com>
34
-
35
- Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
36
- ---
37
- hw/net/virtio-net.c | 84 ++++++++++++++++++++--------------
38
- include/hw/virtio/virtio-net.h | 4 ++
39
- 2 files changed, 53 insertions(+), 35 deletions(-)
40
-
41
- diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
42
- index 2a127f0a3b..59bedba681 100644
43
- --- a/hw/net/virtio-net.c
44
- +++ b/hw/net/virtio-net.c
45
- @@ -1433,57 +1433,71 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd,
46
- return VIRTIO_NET_OK;
47
- }
48
-
49
- -static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
50
- +size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev,
51
- + const struct iovec *in_sg, unsigned in_num,
52
- + const struct iovec *out_sg,
53
- + unsigned out_num)
54
- {
55
- VirtIONet *n = VIRTIO_NET(vdev);
56
- struct virtio_net_ctrl_hdr ctrl;
57
- virtio_net_ctrl_ack status = VIRTIO_NET_ERR;
58
- - VirtQueueElement *elem;
59
- size_t s;
60
- struct iovec *iov, *iov2;
61
- - unsigned int iov_cnt;
62
- +
63
- + if (iov_size(in_sg, in_num) < sizeof(status) ||
64
- + iov_size(out_sg, out_num) < sizeof(ctrl)) {
65
- + virtio_error(vdev, "virtio-net ctrl missing headers");
66
- + return 0;
67
- + }
68
- +
69
- + iov2 = iov = g_memdup2(out_sg, sizeof(struct iovec) * out_num);
70
- + s = iov_to_buf(iov, out_num, 0, &ctrl, sizeof(ctrl));
71
- + iov_discard_front(&iov, &out_num, sizeof(ctrl));
72
- + if (s != sizeof(ctrl)) {
73
- + status = VIRTIO_NET_ERR;
74
- + } else if (ctrl.class == VIRTIO_NET_CTRL_RX) {
75
- + status = virtio_net_handle_rx_mode(n, ctrl.cmd, iov, out_num);
76
- + } else if (ctrl.class == VIRTIO_NET_CTRL_MAC) {
77
- + status = virtio_net_handle_mac(n, ctrl.cmd, iov, out_num);
78
- + } else if (ctrl.class == VIRTIO_NET_CTRL_VLAN) {
79
- + status = virtio_net_handle_vlan_table(n, ctrl.cmd, iov, out_num);
80
- + } else if (ctrl.class == VIRTIO_NET_CTRL_ANNOUNCE) {
81
- + status = virtio_net_handle_announce(n, ctrl.cmd, iov, out_num);
82
- + } else if (ctrl.class == VIRTIO_NET_CTRL_MQ) {
83
- + status = virtio_net_handle_mq(n, ctrl.cmd, iov, out_num);
84
- + } else if (ctrl.class == VIRTIO_NET_CTRL_GUEST_OFFLOADS) {
85
- + status = virtio_net_handle_offloads(n, ctrl.cmd, iov, out_num);
86
- + }
87
- +
88
- + s = iov_from_buf(in_sg, in_num, 0, &status, sizeof(status));
89
- + assert(s == sizeof(status));
90
- +
91
- + g_free(iov2);
92
- + return sizeof(status);
93
- +}
94
- +
95
- +static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
96
- +{
97
- + VirtQueueElement *elem;
98
-
99
- for (;;) {
100
- + size_t written;
101
- elem = virtqueue_pop(vq, sizeof(VirtQueueElement));
102
- if (!elem) {
103
- break;
104
- }
105
- - if (iov_size(elem->in_sg, elem->in_num) < sizeof(status) ||
106
- - iov_size(elem->out_sg, elem->out_num) < sizeof(ctrl)) {
107
- - virtio_error(vdev, "virtio-net ctrl missing headers");
108
- +
109
- + written = virtio_net_handle_ctrl_iov(vdev, elem->in_sg, elem->in_num,
110
- + elem->out_sg, elem->out_num);
111
- + if (written > 0) {
112
- + virtqueue_push(vq, elem, written);
113
- + virtio_notify(vdev, vq);
114
- + g_free(elem);
115
- + } else {
116
- virtqueue_detach_element(vq, elem, 0);
117
- g_free(elem);
118
- break;
119
- }
120
- -
121
- - iov_cnt = elem->out_num;
122
- - iov2 = iov = g_memdup2(elem->out_sg,
123
- - sizeof(struct iovec) * elem->out_num);
124
- - s = iov_to_buf(iov, iov_cnt, 0, &ctrl, sizeof(ctrl));
125
- - iov_discard_front(&iov, &iov_cnt, sizeof(ctrl));
126
- - if (s != sizeof(ctrl)) {
127
- - status = VIRTIO_NET_ERR;
128
- - } else if (ctrl.class == VIRTIO_NET_CTRL_RX) {
129
- - status = virtio_net_handle_rx_mode(n, ctrl.cmd, iov, iov_cnt);
130
- - } else if (ctrl.class == VIRTIO_NET_CTRL_MAC) {
131
- - status = virtio_net_handle_mac(n, ctrl.cmd, iov, iov_cnt);
132
- - } else if (ctrl.class == VIRTIO_NET_CTRL_VLAN) {
133
- - status = virtio_net_handle_vlan_table(n, ctrl.cmd, iov, iov_cnt);
134
- - } else if (ctrl.class == VIRTIO_NET_CTRL_ANNOUNCE) {
135
- - status = virtio_net_handle_announce(n, ctrl.cmd, iov, iov_cnt);
136
- - } else if (ctrl.class == VIRTIO_NET_CTRL_MQ) {
137
- - status = virtio_net_handle_mq(n, ctrl.cmd, iov, iov_cnt);
138
- - } else if (ctrl.class == VIRTIO_NET_CTRL_GUEST_OFFLOADS) {
139
- - status = virtio_net_handle_offloads(n, ctrl.cmd, iov, iov_cnt);
140
- - }
141
- -
142
- - s = iov_from_buf(elem->in_sg, elem->in_num, 0, &status, sizeof(status));
143
- - assert(s == sizeof(status));
144
- -
145
- - virtqueue_push(vq, elem, sizeof(status));
146
- - virtio_notify(vdev, vq);
147
- - g_free(iov2);
148
- - g_free(elem);
149
- }
150
- }
151
-
152
- diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
153
- index cce1c554f7..ef234ffe7e 100644
154
- --- a/include/hw/virtio/virtio-net.h
155
- +++ b/include/hw/virtio/virtio-net.h
156
- @@ -221,6 +221,10 @@ struct VirtIONet {
157
- struct EBPFRSSContext ebpf_rss;
158
- };
159
-
160
- +size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev,
161
- + const struct iovec *in_sg, unsigned in_num,
162
- + const struct iovec *out_sg,
163
- + unsigned out_num);
164
- void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
165
- const char *type);
166
-
167
- --
168
- 2.31.1
169
-
SOURCES/kvm-virtio-net-add-support-for-configure-interrupt.patch ADDED
@@ -0,0 +1,115 @@
1
+ From 2b8e3409edb8a17d89c3829cfa3d92bdfdd43c53 Mon Sep 17 00:00:00 2001
2
+ From: Cindy Lu <lulu@redhat.com>
3
+ Date: Thu, 22 Dec 2022 15:04:49 +0800
4
+ Subject: [PATCH 08/31] virtio-net: add support for configure interrupt
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Cindy Lu <lulu@redhat.com>
10
+ RH-MergeRequest: 132: vhost-vdpa: support config interrupt in vhost-vdpa
11
+ RH-Bugzilla: 1905805
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [8/10] 1b125169bea6c81c508b154fa1bae68af153b312 (lulu6/qemu-kvm3)
16
+
17
+ https://bugzilla.redhat.com/show_bug.cgi?id=1905805
18
+ Add functions to support configure interrupt in virtio_net
19
+ Add the functions to support vhost_net_config_pending
20
+ and vhost_net_config_mask.
21
+
22
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
23
+ Message-Id: <20221222070451.936503-9-lulu@redhat.com>
24
+ Acked-by: Jason Wang <jasowang@redhat.com>
25
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
26
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
27
+ (cherry picked from commit 8aab0d1dbe90c7b5ac6672a1a09b0578178f5f4c)
28
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
29
+ ---
30
+ hw/net/vhost_net-stub.c | 9 +++++++++
31
+ hw/net/vhost_net.c | 9 +++++++++
32
+ hw/net/virtio-net.c | 4 ++--
33
+ include/net/vhost_net.h | 2 ++
34
+ 4 files changed, 22 insertions(+), 2 deletions(-)
35
+
36
+ diff --git a/hw/net/vhost_net-stub.c b/hw/net/vhost_net-stub.c
37
+ index 9f7daae99c..c36f258201 100644
38
+ --- a/hw/net/vhost_net-stub.c
39
+ +++ b/hw/net/vhost_net-stub.c
40
+ @@ -82,6 +82,15 @@ void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev,
41
+ {
42
+ }
43
+
44
+ +bool vhost_net_config_pending(VHostNetState *net)
45
+ +{
46
+ + return false;
47
+ +}
48
+ +
49
+ +void vhost_net_config_mask(VHostNetState *net, VirtIODevice *dev, bool mask)
50
+ +{
51
+ +}
52
+ +
53
+ int vhost_net_notify_migration_done(struct vhost_net *net, char* mac_addr)
54
+ {
55
+ return -1;
56
+ diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
57
+ index 043058ff43..6a55f5a473 100644
58
+ --- a/hw/net/vhost_net.c
59
+ +++ b/hw/net/vhost_net.c
60
+ @@ -478,6 +478,15 @@ void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev,
61
+ vhost_virtqueue_mask(&net->dev, dev, idx, mask);
62
+ }
63
+
64
+ +bool vhost_net_config_pending(VHostNetState *net)
65
+ +{
66
+ + return vhost_config_pending(&net->dev);
67
+ +}
68
+ +
69
+ +void vhost_net_config_mask(VHostNetState *net, VirtIODevice *dev, bool mask)
70
+ +{
71
+ + vhost_config_mask(&net->dev, dev, mask);
72
+ +}
73
+ VHostNetState *get_vhost_net(NetClientState *nc)
74
+ {
75
+ VHostNetState *vhost_net = 0;
76
+ diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
77
+ index bee35d6f9f..ec974f7a76 100644
78
+ --- a/hw/net/virtio-net.c
79
+ +++ b/hw/net/virtio-net.c
80
+ @@ -3323,7 +3323,7 @@ static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx)
81
+ */
82
+
83
+ if (idx == VIRTIO_CONFIG_IRQ_IDX) {
84
+ - return false;
85
+ + return vhost_net_config_pending(get_vhost_net(nc->peer));
86
+ }
87
+ return vhost_net_virtqueue_pending(get_vhost_net(nc->peer), idx);
88
+ }
89
+ @@ -3355,9 +3355,9 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx,
90
+ */
91
+
92
+ if (idx == VIRTIO_CONFIG_IRQ_IDX) {
93
+ + vhost_net_config_mask(get_vhost_net(nc->peer), vdev, mask);
94
+ return;
95
+ }
96
+ -
97
+ vhost_net_virtqueue_mask(get_vhost_net(nc->peer), vdev, idx, mask);
98
+ }
99
+
100
+ diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
101
+ index 40b9a40074..dbbd0dc04e 100644
102
+ --- a/include/net/vhost_net.h
103
+ +++ b/include/net/vhost_net.h
104
+ @@ -39,6 +39,8 @@ int vhost_net_set_config(struct vhost_net *net, const uint8_t *data,
105
+ bool vhost_net_virtqueue_pending(VHostNetState *net, int n);
106
+ void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev,
107
+ int idx, bool mask);
108
+ +bool vhost_net_config_pending(VHostNetState *net);
109
+ +void vhost_net_config_mask(VHostNetState *net, VirtIODevice *dev, bool mask);
110
+ int vhost_net_notify_migration_done(VHostNetState *net, char* mac_addr);
111
+ VHostNetState *get_vhost_net(NetClientState *nc);
112
+
113
+ --
114
+ 2.31.1
115
+
SOURCES/kvm-virtio-net-align-ctrl_vq-index-for-non-mq-guest-for-.patch DELETED
@@ -1,143 +0,0 @@
1
- From 316b73277de233c7a9b6917077c00d7012060944 Mon Sep 17 00:00:00 2001
2
- From: Si-Wei Liu <si-wei.liu@oracle.com>
3
- Date: Fri, 6 May 2022 19:28:13 -0700
4
- Subject: [PATCH 09/16] virtio-net: align ctrl_vq index for non-mq guest for
5
- vhost_vdpa
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Jason Wang <jasowang@redhat.com>
11
- RH-MergeRequest: 98: Multiqueue fixes for vhost-vDPA
12
- RH-Commit: [2/7] 7f764bbb579c7b473ad67fc25b46e698d277e781 (jasowang/qemu-kvm-cs)
13
- RH-Bugzilla: 2070804
14
- RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
17
-
18
- With MQ enabled vdpa device and non-MQ supporting guest e.g.
19
- booting vdpa with mq=on over OVMF of single vqp, below assert
20
- failure is seen:
21
-
22
- ../hw/virtio/vhost-vdpa.c:560: vhost_vdpa_get_vq_index: Assertion `idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs' failed.
23
-
24
- 0 0x00007f8ce3ff3387 in raise () at /lib64/libc.so.6
25
- 1 0x00007f8ce3ff4a78 in abort () at /lib64/libc.so.6
26
- 2 0x00007f8ce3fec1a6 in __assert_fail_base () at /lib64/libc.so.6
27
- 3 0x00007f8ce3fec252 in () at /lib64/libc.so.6
28
- 4 0x0000558f52d79421 in vhost_vdpa_get_vq_index (dev=<optimized out>, idx=<optimized out>) at ../hw/virtio/vhost-vdpa.c:563
29
- 5 0x0000558f52d79421 in vhost_vdpa_get_vq_index (dev=<optimized out>, idx=<optimized out>) at ../hw/virtio/vhost-vdpa.c:558
30
- 6 0x0000558f52d7329a in vhost_virtqueue_mask (hdev=0x558f55c01800, vdev=0x558f568f91f0, n=2, mask=<optimized out>) at ../hw/virtio/vhost.c:1557
31
- 7 0x0000558f52c6b89a in virtio_pci_set_guest_notifier (d=d@entry=0x558f568f0f60, n=n@entry=2, assign=assign@entry=true, with_irqfd=with_irqfd@entry=false)
32
- at ../hw/virtio/virtio-pci.c:974
33
- 8 0x0000558f52c6c0d8 in virtio_pci_set_guest_notifiers (d=0x558f568f0f60, nvqs=3, assign=true) at ../hw/virtio/virtio-pci.c:1019
34
- 9 0x0000558f52bf091d in vhost_net_start (dev=dev@entry=0x558f568f91f0, ncs=0x558f56937cd0, data_queue_pairs=data_queue_pairs@entry=1, cvq=cvq@entry=1)
35
- at ../hw/net/vhost_net.c:361
36
- 10 0x0000558f52d4e5e7 in virtio_net_set_status (status=<optimized out>, n=0x558f568f91f0) at ../hw/net/virtio-net.c:289
37
- 11 0x0000558f52d4e5e7 in virtio_net_set_status (vdev=0x558f568f91f0, status=15 '\017') at ../hw/net/virtio-net.c:370
38
- 12 0x0000558f52d6c4b2 in virtio_set_status (vdev=vdev@entry=0x558f568f91f0, val=val@entry=15 '\017') at ../hw/virtio/virtio.c:1945
39
- 13 0x0000558f52c69eff in virtio_pci_common_write (opaque=0x558f568f0f60, addr=<optimized out>, val=<optimized out>, size=<optimized out>) at ../hw/virtio/virtio-pci.c:1292
40
- 14 0x0000558f52d15d6e in memory_region_write_accessor (mr=0x558f568f19d0, addr=20, value=<optimized out>, size=1, shift=<optimized out>, mask=<optimized out>, attrs=...)
41
- at ../softmmu/memory.c:492
42
- 15 0x0000558f52d127de in access_with_adjusted_size (addr=addr@entry=20, value=value@entry=0x7f8cdbffe748, size=size@entry=1, access_size_min=<optimized out>, access_size_max=<optimized out>, access_fn=0x558f52d15cf0 <memory_region_write_accessor>, mr=0x558f568f19d0, attrs=...) at ../softmmu/memory.c:554
43
- 16 0x0000558f52d157ef in memory_region_dispatch_write (mr=mr@entry=0x558f568f19d0, addr=20, data=<optimized out>, op=<optimized out>, attrs=attrs@entry=...)
44
- at ../softmmu/memory.c:1504
45
- 17 0x0000558f52d078e7 in flatview_write_continue (fv=fv@entry=0x7f8accbc3b90, addr=addr@entry=103079215124, attrs=..., ptr=ptr@entry=0x7f8ce6300028, len=len@entry=1, addr1=<optimized out>, l=<optimized out>, mr=0x558f568f19d0) at /home/opc/qemu-upstream/include/qemu/host-utils.h:165
46
- 18 0x0000558f52d07b06 in flatview_write (fv=0x7f8accbc3b90, addr=103079215124, attrs=..., buf=0x7f8ce6300028, len=1) at ../softmmu/physmem.c:2822
47
- 19 0x0000558f52d0b36b in address_space_write (as=<optimized out>, addr=<optimized out>, attrs=..., buf=buf@entry=0x7f8ce6300028, len=<optimized out>)
48
- at ../softmmu/physmem.c:2914
49
- 20 0x0000558f52d0b3da in address_space_rw (as=<optimized out>, addr=<optimized out>, attrs=...,
50
- attrs@entry=..., buf=buf@entry=0x7f8ce6300028, len=<optimized out>, is_write=<optimized out>) at ../softmmu/physmem.c:2924
51
- 21 0x0000558f52dced09 in kvm_cpu_exec (cpu=cpu@entry=0x558f55c2da60) at ../accel/kvm/kvm-all.c:2903
52
- 22 0x0000558f52dcfabd in kvm_vcpu_thread_fn (arg=arg@entry=0x558f55c2da60) at ../accel/kvm/kvm-accel-ops.c:49
53
- 23 0x0000558f52f9f04a in qemu_thread_start (args=<optimized out>) at ../util/qemu-thread-posix.c:556
54
- 24 0x00007f8ce4392ea5 in start_thread () at /lib64/libpthread.so.0
55
- 25 0x00007f8ce40bb9fd in clone () at /lib64/libc.so.6
56
-
57
- The cause for the assert failure is due to that the vhost_dev index
58
- for the ctrl vq was not aligned with actual one in use by the guest.
59
- Upon multiqueue feature negotiation in virtio_net_set_multiqueue(),
60
- if guest doesn't support multiqueue, the guest vq layout would shrink
61
- to a single queue pair, consisting of 3 vqs in total (rx, tx and ctrl).
62
- This results in ctrl_vq taking a different vhost_dev group index than
63
- the default. We can map vq to the correct vhost_dev group by checking
64
- if MQ is supported by guest and successfully negotiated. Since the
65
- MQ feature is only present along with CTRL_VQ, we ensure the index
66
- 2 is only meant for the control vq while MQ is not supported by guest.
67
-
68
- Fixes: 22288fe ("virtio-net: vhost control virtqueue support")
69
- Suggested-by: Jason Wang <jasowang@redhat.com>
70
- Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
71
- Acked-by: Jason Wang <jasowang@redhat.com>
72
- Message-Id: <1651890498-24478-3-git-send-email-si-wei.liu@oracle.com>
73
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
74
- Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
75
- (cherry picked from commit 68b0a6395f36a8f48f56f46d05f30be2067598b0)
76
- Signed-off-by: Jason Wang <jasowang@redhat.com>
77
- ---
78
- hw/net/virtio-net.c | 33 +++++++++++++++++++++++++++++++--
79
- 1 file changed, 31 insertions(+), 2 deletions(-)
80
-
81
- diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
82
- index ffb3475201..f0bb29c741 100644
83
- --- a/hw/net/virtio-net.c
84
- +++ b/hw/net/virtio-net.c
85
- @@ -14,6 +14,7 @@
86
- #include "qemu/osdep.h"
87
- #include "qemu/atomic.h"
88
- #include "qemu/iov.h"
89
- +#include "qemu/log.h"
90
- #include "qemu/main-loop.h"
91
- #include "qemu/module.h"
92
- #include "hw/virtio/virtio.h"
93
- @@ -3171,8 +3172,22 @@ static NetClientInfo net_virtio_info = {
94
- static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx)
95
- {
96
- VirtIONet *n = VIRTIO_NET(vdev);
97
- - NetClientState *nc = qemu_get_subqueue(n->nic, vq2q(idx));
98
- + NetClientState *nc;
99
- assert(n->vhost_started);
100
- + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_MQ) && idx == 2) {
101
- + /* Must guard against invalid features and bogus queue index
102
- + * from being set by malicious guest, or penetrated through
103
- + * buggy migration stream.
104
- + */
105
- + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) {
106
- + qemu_log_mask(LOG_GUEST_ERROR,
107
- + "%s: bogus vq index ignored\n", __func__);
108
- + return false;
109
- + }
110
- + nc = qemu_get_subqueue(n->nic, n->max_queue_pairs);
111
- + } else {
112
- + nc = qemu_get_subqueue(n->nic, vq2q(idx));
113
- + }
114
- return vhost_net_virtqueue_pending(get_vhost_net(nc->peer), idx);
115
- }
116
-
117
- @@ -3180,8 +3195,22 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx,
118
- bool mask)
119
- {
120
- VirtIONet *n = VIRTIO_NET(vdev);
121
- - NetClientState *nc = qemu_get_subqueue(n->nic, vq2q(idx));
122
- + NetClientState *nc;
123
- assert(n->vhost_started);
124
- + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_MQ) && idx == 2) {
125
- + /* Must guard against invalid features and bogus queue index
126
- + * from being set by malicious guest, or penetrated through
127
- + * buggy migration stream.
128
- + */
129
- + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) {
130
- + qemu_log_mask(LOG_GUEST_ERROR,
131
- + "%s: bogus vq index ignored\n", __func__);
132
- + return;
133
- + }
134
- + nc = qemu_get_subqueue(n->nic, n->max_queue_pairs);
135
- + } else {
136
- + nc = qemu_get_subqueue(n->nic, vq2q(idx));
137
- + }
138
- vhost_net_virtqueue_mask(get_vhost_net(nc->peer),
139
- vdev, idx, mask);
140
- }
141
- --
142
- 2.31.1
143
-
SOURCES/kvm-virtio-net-don-t-handle-mq-request-in-userspace-hand.patch DELETED
@@ -1,109 +0,0 @@
1
- From 521a1953bc11ab6823dcbbee773bcf86e926a9e7 Mon Sep 17 00:00:00 2001
2
- From: Si-Wei Liu <si-wei.liu@oracle.com>
3
- Date: Fri, 6 May 2022 19:28:18 -0700
4
- Subject: [PATCH 14/16] virtio-net: don't handle mq request in userspace
5
- handler for vhost-vdpa
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Jason Wang <jasowang@redhat.com>
11
- RH-MergeRequest: 98: Multiqueue fixes for vhost-vDPA
12
- RH-Commit: [7/7] 9781cab45448ae16a00fbf10cf7995df6b984a0a (jasowang/qemu-kvm-cs)
13
- RH-Bugzilla: 2070804
14
- RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
17
-
18
- virtio_queue_host_notifier_read() tends to read pending event
19
- left behind on ioeventfd in the vhost_net_stop() path, and
20
- attempts to handle outstanding kicks from userspace vq handler.
21
- However, in the ctrl_vq handler, virtio_net_handle_mq() has a
22
- recursive call into virtio_net_set_status(), which may lead to
23
- segmentation fault as shown in below stack trace:
24
-
25
- 0 0x000055f800df1780 in qdev_get_parent_bus (dev=0x0) at ../hw/core/qdev.c:376
26
- 1 0x000055f800c68ad8 in virtio_bus_device_iommu_enabled (vdev=vdev@entry=0x0) at ../hw/virtio/virtio-bus.c:331
27
- 2 0x000055f800d70d7f in vhost_memory_unmap (dev=<optimized out>) at ../hw/virtio/vhost.c:318
28
- 3 0x000055f800d70d7f in vhost_memory_unmap (dev=<optimized out>, buffer=0x7fc19bec5240, len=2052, is_write=1, access_len=2052) at ../hw/virtio/vhost.c:336
29
- 4 0x000055f800d71867 in vhost_virtqueue_stop (dev=dev@entry=0x55f8037ccc30, vdev=vdev@entry=0x55f8044ec590, vq=0x55f8037cceb0, idx=0) at ../hw/virtio/vhost.c:1241
30
- 5 0x000055f800d7406c in vhost_dev_stop (hdev=hdev@entry=0x55f8037ccc30, vdev=vdev@entry=0x55f8044ec590) at ../hw/virtio/vhost.c:1839
31
- 6 0x000055f800bf00a7 in vhost_net_stop_one (net=0x55f8037ccc30, dev=0x55f8044ec590) at ../hw/net/vhost_net.c:315
32
- 7 0x000055f800bf0678 in vhost_net_stop (dev=dev@entry=0x55f8044ec590, ncs=0x55f80452bae0, data_queue_pairs=data_queue_pairs@entry=7, cvq=cvq@entry=1)
33
- at ../hw/net/vhost_net.c:423
34
- 8 0x000055f800d4e628 in virtio_net_set_status (status=<optimized out>, n=0x55f8044ec590) at ../hw/net/virtio-net.c:296
35
- 9 0x000055f800d4e628 in virtio_net_set_status (vdev=vdev@entry=0x55f8044ec590, status=15 '\017') at ../hw/net/virtio-net.c:370
36
- 10 0x000055f800d534d8 in virtio_net_handle_ctrl (iov_cnt=<optimized out>, iov=<optimized out>, cmd=0 '\000', n=0x55f8044ec590) at ../hw/net/virtio-net.c:1408
37
- 11 0x000055f800d534d8 in virtio_net_handle_ctrl (vdev=0x55f8044ec590, vq=0x7fc1a7e888d0) at ../hw/net/virtio-net.c:1452
38
- 12 0x000055f800d69f37 in virtio_queue_host_notifier_read (vq=0x7fc1a7e888d0) at ../hw/virtio/virtio.c:2331
39
- 13 0x000055f800d69f37 in virtio_queue_host_notifier_read (n=n@entry=0x7fc1a7e8894c) at ../hw/virtio/virtio.c:3575
40
- 14 0x000055f800c688e6 in virtio_bus_cleanup_host_notifier (bus=<optimized out>, n=n@entry=14) at ../hw/virtio/virtio-bus.c:312
41
- 15 0x000055f800d73106 in vhost_dev_disable_notifiers (hdev=hdev@entry=0x55f8035b51b0, vdev=vdev@entry=0x55f8044ec590)
42
- at ../../../include/hw/virtio/virtio-bus.h:35
43
- 16 0x000055f800bf00b2 in vhost_net_stop_one (net=0x55f8035b51b0, dev=0x55f8044ec590) at ../hw/net/vhost_net.c:316
44
- 17 0x000055f800bf0678 in vhost_net_stop (dev=dev@entry=0x55f8044ec590, ncs=0x55f80452bae0, data_queue_pairs=data_queue_pairs@entry=7, cvq=cvq@entry=1)
45
- at ../hw/net/vhost_net.c:423
46
- 18 0x000055f800d4e628 in virtio_net_set_status (status=<optimized out>, n=0x55f8044ec590) at ../hw/net/virtio-net.c:296
47
- 19 0x000055f800d4e628 in virtio_net_set_status (vdev=0x55f8044ec590, status=15 '\017') at ../hw/net/virtio-net.c:370
48
- 20 0x000055f800d6c4b2 in virtio_set_status (vdev=0x55f8044ec590, val=<optimized out>) at ../hw/virtio/virtio.c:1945
49
- 21 0x000055f800d11d9d in vm_state_notify (running=running@entry=false, state=state@entry=RUN_STATE_SHUTDOWN) at ../softmmu/runstate.c:333
50
- 22 0x000055f800d04e7a in do_vm_stop (state=state@entry=RUN_STATE_SHUTDOWN, send_stop=send_stop@entry=false) at ../softmmu/cpus.c:262
51
- 23 0x000055f800d04e99 in vm_shutdown () at ../softmmu/cpus.c:280
52
- 24 0x000055f800d126af in qemu_cleanup () at ../softmmu/runstate.c:812
53
- 25 0x000055f800ad5b13 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at ../softmmu/main.c:51
54
-
55
- For now, temporarily disable handling MQ request from the ctrl_vq
56
- userspace hanlder to avoid the recursive virtio_net_set_status()
57
- call. Some rework is needed to allow changing the number of
58
- queues without going through a full virtio_net_set_status cycle,
59
- particularly for vhost-vdpa backend.
60
-
61
- This patch will need to be reverted as soon as future patches of
62
- having the change of #queues handled in userspace is merged.
63
-
64
- Fixes: 402378407db ("vhost-vdpa: multiqueue support")
65
- Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
66
- Acked-by: Jason Wang <jasowang@redhat.com>
67
- Message-Id: <1651890498-24478-8-git-send-email-si-wei.liu@oracle.com>
68
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
69
- Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
70
- (cherry picked from commit 2a7888cc3aa31faee839fa5dddad354ff8941f4c)
71
- Signed-off-by: Jason Wang <jasowang@redhat.com>
72
- ---
73
- hw/net/virtio-net.c | 13 +++++++++++++
74
- 1 file changed, 13 insertions(+)
75
-
76
- diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
77
- index f0bb29c741..099e65036d 100644
78
- --- a/hw/net/virtio-net.c
79
- +++ b/hw/net/virtio-net.c
80
- @@ -1381,6 +1381,7 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd,
81
- {
82
- VirtIODevice *vdev = VIRTIO_DEVICE(n);
83
- uint16_t queue_pairs;
84
- + NetClientState *nc = qemu_get_queue(n->nic);
85
-
86
- virtio_net_disable_rss(n);
87
- if (cmd == VIRTIO_NET_CTRL_MQ_HASH_CONFIG) {
88
- @@ -1412,6 +1413,18 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd,
89
- return VIRTIO_NET_ERR;
90
- }
91
-
92
- + /* Avoid changing the number of queue_pairs for vdpa device in
93
- + * userspace handler. A future fix is needed to handle the mq
94
- + * change in userspace handler with vhost-vdpa. Let's disable
95
- + * the mq handling from userspace for now and only allow get
96
- + * done through the kernel. Ripples may be seen when falling
97
- + * back to userspace, but without doing it qemu process would
98
- + * crash on a recursive entry to virtio_net_set_status().
99
- + */
100
- + if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
101
- + return VIRTIO_NET_ERR;
102
- + }
103
- +
104
- n->curr_queue_pairs = queue_pairs;
105
- /* stop the backend before changing the number of queue_pairs to avoid handling a
106
- * disabled queue */
107
- --
108
- 2.31.1
109
-
SOURCES/kvm-virtio-net-setup-vhost_dev-and-notifiers-for-cvq-onl.patch DELETED
@@ -1,52 +0,0 @@
1
- From 9e737aba614e94da4458f02d4ff97e95ffffd19f Mon Sep 17 00:00:00 2001
2
- From: Si-Wei Liu <si-wei.liu@oracle.com>
3
- Date: Fri, 6 May 2022 19:28:12 -0700
4
- Subject: [PATCH 08/16] virtio-net: setup vhost_dev and notifiers for cvq only
5
- when feature is negotiated
6
- MIME-Version: 1.0
7
- Content-Type: text/plain; charset=UTF-8
8
- Content-Transfer-Encoding: 8bit
9
-
10
- RH-Author: Jason Wang <jasowang@redhat.com>
11
- RH-MergeRequest: 98: Multiqueue fixes for vhost-vDPA
12
- RH-Commit: [1/7] a5c5a2862b2e4d15ef7c09da3e4234fdef37cc66 (jasowang/qemu-kvm-cs)
13
- RH-Bugzilla: 2070804
14
- RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
15
- RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
16
- RH-Acked-by: Cindy Lu <lulu@redhat.com>
17
-
18
- When the control virtqueue feature is absent or not negotiated,
19
- vhost_net_start() still tries to set up vhost_dev and install
20
- vhost notifiers for the control virtqueue, which results in
21
- erroneous ioctl calls with incorrect queue index sending down
22
- to driver. Do that only when needed.
23
-
24
- Fixes: 22288fe ("virtio-net: vhost control virtqueue support")
25
- Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
26
- Acked-by: Jason Wang <jasowang@redhat.com>
27
- Message-Id: <1651890498-24478-2-git-send-email-si-wei.liu@oracle.com>
28
- Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
29
- Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
30
- (cherry picked from commit aa8581945a13712ff3eed0ad3ba7a9664fc1604b)
31
- Signed-off-by: Jason Wang <jasowang@redhat.com>
32
- ---
33
- hw/net/virtio-net.c | 3 ++-
34
- 1 file changed, 2 insertions(+), 1 deletion(-)
35
-
36
- diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
37
- index 1067e72b39..ffb3475201 100644
38
- --- a/hw/net/virtio-net.c
39
- +++ b/hw/net/virtio-net.c
40
- @@ -245,7 +245,8 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
41
- VirtIODevice *vdev = VIRTIO_DEVICE(n);
42
- NetClientState *nc = qemu_get_queue(n->nic);
43
- int queue_pairs = n->multiqueue ? n->max_queue_pairs : 1;
44
- - int cvq = n->max_ncs - n->max_queue_pairs;
45
- + int cvq = virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ) ?
46
- + n->max_ncs - n->max_queue_pairs : 0;
47
-
48
- if (!get_vhost_net(nc->peer)) {
49
- return;
50
- --
51
- 2.31.1
52
-
SOURCES/kvm-virtio-pci-add-support-for-configure-interrupt.patch ADDED
@@ -0,0 +1,274 @@
1
+ From 61ac1476d3820c97e1cc103af422b17bc94c6ca5 Mon Sep 17 00:00:00 2001
2
+ From: Cindy Lu <lulu@redhat.com>
3
+ Date: Thu, 22 Dec 2022 15:04:51 +0800
4
+ Subject: [PATCH 10/31] virtio-pci: add support for configure interrupt
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Cindy Lu <lulu@redhat.com>
10
+ RH-MergeRequest: 132: vhost-vdpa: support config interrupt in vhost-vdpa
11
+ RH-Bugzilla: 1905805
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [10/10] ebd6a11d7699660d8ac5a4e44a790f823daea57c (lulu6/qemu-kvm3)
16
+
17
+ https://bugzilla.redhat.com/show_bug.cgi?id=1905805
18
+ Add process to handle the configure interrupt, The function's
19
+ logic is the same with vq interrupt.Add extra process to check
20
+ the configure interrupt
21
+
22
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
23
+ Message-Id: <20221222070451.936503-11-lulu@redhat.com>
24
+ Acked-by: Jason Wang <jasowang@redhat.com>
25
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
26
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
27
+ (cherry picked from commit 1680542862edd963e6380dd4121a5e85df55581f)
28
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
29
+ ---
30
+ hw/virtio/virtio-pci.c | 118 +++++++++++++++++++++++++++------
31
+ include/hw/virtio/virtio-pci.h | 4 +-
32
+ 2 files changed, 102 insertions(+), 20 deletions(-)
33
+
34
+ diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
35
+ index ec816ea367..3f00e91718 100644
36
+ --- a/hw/virtio/virtio-pci.c
37
+ +++ b/hw/virtio/virtio-pci.c
38
+ @@ -751,7 +751,8 @@ static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no,
39
+ VirtQueue *vq;
40
+
41
+ if (queue_no == VIRTIO_CONFIG_IRQ_IDX) {
42
+ - return -1;
43
+ + *n = virtio_config_get_guest_notifier(vdev);
44
+ + *vector = vdev->config_vector;
45
+ } else {
46
+ if (!virtio_queue_get_num(vdev, queue_no)) {
47
+ return -1;
48
+ @@ -811,7 +812,7 @@ undo:
49
+ }
50
+ return ret;
51
+ }
52
+ -static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs)
53
+ +static int kvm_virtio_pci_vector_vq_use(VirtIOPCIProxy *proxy, int nvqs)
54
+ {
55
+ int queue_no;
56
+ int ret = 0;
57
+ @@ -826,6 +827,10 @@ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs)
58
+ return ret;
59
+ }
60
+
61
+ +static int kvm_virtio_pci_vector_config_use(VirtIOPCIProxy *proxy)
62
+ +{
63
+ + return kvm_virtio_pci_vector_use_one(proxy, VIRTIO_CONFIG_IRQ_IDX);
64
+ +}
65
+
66
+ static void kvm_virtio_pci_vector_release_one(VirtIOPCIProxy *proxy,
67
+ int queue_no)
68
+ @@ -850,7 +855,7 @@ static void kvm_virtio_pci_vector_release_one(VirtIOPCIProxy *proxy,
69
+ kvm_virtio_pci_vq_vector_release(proxy, vector);
70
+ }
71
+
72
+ -static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs)
73
+ +static void kvm_virtio_pci_vector_vq_release(VirtIOPCIProxy *proxy, int nvqs)
74
+ {
75
+ int queue_no;
76
+ VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
77
+ @@ -863,6 +868,11 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs)
78
+ }
79
+ }
80
+
81
+ +static void kvm_virtio_pci_vector_config_release(VirtIOPCIProxy *proxy)
82
+ +{
83
+ + kvm_virtio_pci_vector_release_one(proxy, VIRTIO_CONFIG_IRQ_IDX);
84
+ +}
85
+ +
86
+ static int virtio_pci_one_vector_unmask(VirtIOPCIProxy *proxy,
87
+ unsigned int queue_no,
88
+ unsigned int vector,
89
+ @@ -944,9 +954,19 @@ static int virtio_pci_vector_unmask(PCIDevice *dev, unsigned vector,
90
+ }
91
+ vq = virtio_vector_next_queue(vq);
92
+ }
93
+ -
94
+ + /* unmask config intr */
95
+ + if (vector == vdev->config_vector) {
96
+ + n = virtio_config_get_guest_notifier(vdev);
97
+ + ret = virtio_pci_one_vector_unmask(proxy, VIRTIO_CONFIG_IRQ_IDX, vector,
98
+ + msg, n);
99
+ + if (ret < 0) {
100
+ + goto undo_config;
101
+ + }
102
+ + }
103
+ return 0;
104
+ -
105
+ +undo_config:
106
+ + n = virtio_config_get_guest_notifier(vdev);
107
+ + virtio_pci_one_vector_mask(proxy, VIRTIO_CONFIG_IRQ_IDX, vector, n);
108
+ undo:
109
+ vq = virtio_vector_first_queue(vdev, vector);
110
+ while (vq && unmasked >= 0) {
111
+ @@ -980,6 +1000,11 @@ static void virtio_pci_vector_mask(PCIDevice *dev, unsigned vector)
112
+ }
113
+ vq = virtio_vector_next_queue(vq);
114
+ }
115
+ +
116
+ + if (vector == vdev->config_vector) {
117
+ + n = virtio_config_get_guest_notifier(vdev);
118
+ + virtio_pci_one_vector_mask(proxy, VIRTIO_CONFIG_IRQ_IDX, vector, n);
119
+ + }
120
+ }
121
+
122
+ static void virtio_pci_vector_poll(PCIDevice *dev,
123
+ @@ -1011,6 +1036,34 @@ static void virtio_pci_vector_poll(PCIDevice *dev,
124
+ msix_set_pending(dev, vector);
125
+ }
126
+ }
127
+ + /* poll the config intr */
128
+ + ret = virtio_pci_get_notifier(proxy, VIRTIO_CONFIG_IRQ_IDX, &notifier,
129
+ + &vector);
130
+ + if (ret < 0) {
131
+ + return;
132
+ + }
133
+ + if (vector < vector_start || vector >= vector_end ||
134
+ + !msix_is_masked(dev, vector)) {
135
+ + return;
136
+ + }
137
+ + if (k->guest_notifier_pending) {
138
+ + if (k->guest_notifier_pending(vdev, VIRTIO_CONFIG_IRQ_IDX)) {
139
+ + msix_set_pending(dev, vector);
140
+ + }
141
+ + } else if (event_notifier_test_and_clear(notifier)) {
142
+ + msix_set_pending(dev, vector);
143
+ + }
144
+ +}
145
+ +
146
+ +void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueue *vq,
147
+ + int n, bool assign,
148
+ + bool with_irqfd)
149
+ +{
150
+ + if (n == VIRTIO_CONFIG_IRQ_IDX) {
151
+ + virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irqfd);
152
+ + } else {
153
+ + virtio_queue_set_guest_notifier_fd_handler(vq, assign, with_irqfd);
154
+ + }
155
+ }
156
+
157
+ static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assign,
158
+ @@ -1019,17 +1072,25 @@ static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assign,
159
+ VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
160
+ VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
161
+ VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
162
+ - VirtQueue *vq = virtio_get_queue(vdev, n);
163
+ - EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);
164
+ + VirtQueue *vq = NULL;
165
+ + EventNotifier *notifier = NULL;
166
+ +
167
+ + if (n == VIRTIO_CONFIG_IRQ_IDX) {
168
+ + notifier = virtio_config_get_guest_notifier(vdev);
169
+ + } else {
170
+ + vq = virtio_get_queue(vdev, n);
171
+ + notifier = virtio_queue_get_guest_notifier(vq);
172
+ + }
173
+
174
+ if (assign) {
175
+ int r = event_notifier_init(notifier, 0);
176
+ if (r < 0) {
177
+ return r;
178
+ }
179
+ - virtio_queue_set_guest_notifier_fd_handler(vq, true, with_irqfd);
180
+ + virtio_pci_set_guest_notifier_fd_handler(vdev, vq, n, true, with_irqfd);
181
+ } else {
182
+ - virtio_queue_set_guest_notifier_fd_handler(vq, false, with_irqfd);
183
+ + virtio_pci_set_guest_notifier_fd_handler(vdev, vq, n, false,
184
+ + with_irqfd);
185
+ event_notifier_cleanup(notifier);
186
+ }
187
+
188
+ @@ -1072,10 +1133,13 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign)
189
+ proxy->nvqs_with_notifiers = nvqs;
190
+
191
+ /* Must unset vector notifier while guest notifier is still assigned */
192
+ - if ((proxy->vector_irqfd || k->guest_notifier_mask) && !assign) {
193
+ + if ((proxy->vector_irqfd ||
194
+ + (vdev->use_guest_notifier_mask && k->guest_notifier_mask)) &&
195
+ + !assign) {
196
+ msix_unset_vector_notifiers(&proxy->pci_dev);
197
+ if (proxy->vector_irqfd) {
198
+ - kvm_virtio_pci_vector_release(proxy, nvqs);
199
+ + kvm_virtio_pci_vector_vq_release(proxy, nvqs);
200
+ + kvm_virtio_pci_vector_config_release(proxy);
201
+ g_free(proxy->vector_irqfd);
202
+ proxy->vector_irqfd = NULL;
203
+ }
204
+ @@ -1091,20 +1155,30 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign)
205
+ goto assign_error;
206
+ }
207
+ }
208
+ -
209
+ + r = virtio_pci_set_guest_notifier(d, VIRTIO_CONFIG_IRQ_IDX, assign,
210
+ + with_irqfd);
211
+ + if (r < 0) {
212
+ + goto config_assign_error;
213
+ + }
214
+ /* Must set vector notifier after guest notifier has been assigned */
215
+ - if ((with_irqfd || k->guest_notifier_mask) && assign) {
216
+ + if ((with_irqfd ||
217
+ + (vdev->use_guest_notifier_mask && k->guest_notifier_mask)) &&
218
+ + assign) {
219
+ if (with_irqfd) {
220
+ proxy->vector_irqfd =
221
+ g_malloc0(sizeof(*proxy->vector_irqfd) *
222
+ msix_nr_vectors_allocated(&proxy->pci_dev));
223
+ - r = kvm_virtio_pci_vector_use(proxy, nvqs);
224
+ + r = kvm_virtio_pci_vector_vq_use(proxy, nvqs);
225
+ + if (r < 0) {
226
+ + goto config_assign_error;
227
+ + }
228
+ + r = kvm_virtio_pci_vector_config_use(proxy);
229
+ if (r < 0) {
230
+ - goto assign_error;
231
+ + goto config_error;
232
+ }
233
+ }
234
+ - r = msix_set_vector_notifiers(&proxy->pci_dev,
235
+ - virtio_pci_vector_unmask,
236
+ +
237
+ + r = msix_set_vector_notifiers(&proxy->pci_dev, virtio_pci_vector_unmask,
238
+ virtio_pci_vector_mask,
239
+ virtio_pci_vector_poll);
240
+ if (r < 0) {
241
+ @@ -1117,9 +1191,15 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign)
242
+ notifiers_error:
243
+ if (with_irqfd) {
244
+ assert(assign);
245
+ - kvm_virtio_pci_vector_release(proxy, nvqs);
246
+ + kvm_virtio_pci_vector_vq_release(proxy, nvqs);
247
+ }
248
+ -
249
+ +config_error:
250
+ + if (with_irqfd) {
251
+ + kvm_virtio_pci_vector_config_release(proxy);
252
+ + }
253
+ +config_assign_error:
254
+ + virtio_pci_set_guest_notifier(d, VIRTIO_CONFIG_IRQ_IDX, !assign,
255
+ + with_irqfd);
256
+ assign_error:
257
+ /* We get here on assignment failure. Recover by undoing for VQs 0 .. n. */
258
+ assert(assign);
259
+ diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h
260
+ index 938799e8f6..c02e278f46 100644
261
+ --- a/include/hw/virtio/virtio-pci.h
262
+ +++ b/include/hw/virtio/virtio-pci.h
263
+ @@ -256,5 +256,7 @@ void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t);
264
+ * @fixed_queues.
265
+ */
266
+ unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues);
267
+ -
268
+ +void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueue *vq,
269
+ + int n, bool assign,
270
+ + bool with_irqfd);
271
+ #endif
272
+ --
273
+ 2.31.1
274
+
SOURCES/kvm-virtio-pci-decouple-notifier-from-interrupt-process.patch ADDED
@@ -0,0 +1,272 @@
1
+ From 9a234f849273d3480e4a88042cb1ea06a37a626b Mon Sep 17 00:00:00 2001
2
+ From: Cindy Lu <lulu@redhat.com>
3
+ Date: Thu, 22 Dec 2022 15:04:43 +0800
4
+ Subject: [PATCH 02/31] virtio-pci: decouple notifier from interrupt process
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Cindy Lu <lulu@redhat.com>
10
+ RH-MergeRequest: 132: vhost-vdpa: support config interrupt in vhost-vdpa
11
+ RH-Bugzilla: 1905805
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
14
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
15
+ RH-Commit: [2/10] a20f4c9ff38b239531d12cbcc7deaa649c86abc3 (lulu6/qemu-kvm3)
16
+
17
+ https://bugzilla.redhat.com/show_bug.cgi?id=1905805
18
+ To reuse the notifier process. We add the virtio_pci_get_notifier
19
+ to get the notifier and vector. The INPUT for this function is IDX,
20
+ The OUTPUT is the notifier and the vector
21
+
22
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
23
+ Message-Id: <20221222070451.936503-3-lulu@redhat.com>
24
+ Acked-by: Jason Wang <jasowang@redhat.com>
25
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
26
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
27
+ (cherry picked from commit 2e07f69d0c828e21515b63dc22884d548540b382)
28
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
29
+ ---
30
+ hw/virtio/virtio-pci.c | 88 +++++++++++++++++++++++++++---------------
31
+ 1 file changed, 57 insertions(+), 31 deletions(-)
32
+
33
+ diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
34
+ index a1c9dfa7bb..52c7692fff 100644
35
+ --- a/hw/virtio/virtio-pci.c
36
+ +++ b/hw/virtio/virtio-pci.c
37
+ @@ -728,29 +728,41 @@ static void kvm_virtio_pci_vq_vector_release(VirtIOPCIProxy *proxy,
38
+ }
39
+
40
+ static int kvm_virtio_pci_irqfd_use(VirtIOPCIProxy *proxy,
41
+ - unsigned int queue_no,
42
+ + EventNotifier *n,
43
+ unsigned int vector)
44
+ {
45
+ VirtIOIRQFD *irqfd = &proxy->vector_irqfd[vector];
46
+ - VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
47
+ - VirtQueue *vq = virtio_get_queue(vdev, queue_no);
48
+ - EventNotifier *n = virtio_queue_get_guest_notifier(vq);
49
+ return kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, n, NULL, irqfd->virq);
50
+ }
51
+
52
+ static void kvm_virtio_pci_irqfd_release(VirtIOPCIProxy *proxy,
53
+ - unsigned int queue_no,
54
+ + EventNotifier *n ,
55
+ unsigned int vector)
56
+ {
57
+ - VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
58
+ - VirtQueue *vq = virtio_get_queue(vdev, queue_no);
59
+ - EventNotifier *n = virtio_queue_get_guest_notifier(vq);
60
+ VirtIOIRQFD *irqfd = &proxy->vector_irqfd[vector];
61
+ int ret;
62
+
63
+ ret = kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, n, irqfd->virq);
64
+ assert(ret == 0);
65
+ }
66
+ +static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no,
67
+ + EventNotifier **n, unsigned int *vector)
68
+ +{
69
+ + VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
70
+ + VirtQueue *vq;
71
+ +
72
+ + if (queue_no == VIRTIO_CONFIG_IRQ_IDX) {
73
+ + return -1;
74
+ + } else {
75
+ + if (!virtio_queue_get_num(vdev, queue_no)) {
76
+ + return -1;
77
+ + }
78
+ + *vector = virtio_queue_vector(vdev, queue_no);
79
+ + vq = virtio_get_queue(vdev, queue_no);
80
+ + *n = virtio_queue_get_guest_notifier(vq);
81
+ + }
82
+ + return 0;
83
+ +}
84
+
85
+ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs)
86
+ {
87
+ @@ -759,12 +771,15 @@ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs)
88
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
89
+ unsigned int vector;
90
+ int ret, queue_no;
91
+ -
92
+ + EventNotifier *n;
93
+ for (queue_no = 0; queue_no < nvqs; queue_no++) {
94
+ if (!virtio_queue_get_num(vdev, queue_no)) {
95
+ break;
96
+ }
97
+ - vector = virtio_queue_vector(vdev, queue_no);
98
+ + ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
99
+ + if (ret < 0) {
100
+ + break;
101
+ + }
102
+ if (vector >= msix_nr_vectors_allocated(dev)) {
103
+ continue;
104
+ }
105
+ @@ -776,7 +791,7 @@ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs)
106
+ * Otherwise, delay until unmasked in the frontend.
107
+ */
108
+ if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
109
+ - ret = kvm_virtio_pci_irqfd_use(proxy, queue_no, vector);
110
+ + ret = kvm_virtio_pci_irqfd_use(proxy, n, vector);
111
+ if (ret < 0) {
112
+ kvm_virtio_pci_vq_vector_release(proxy, vector);
113
+ goto undo;
114
+ @@ -792,7 +807,11 @@ undo:
115
+ continue;
116
+ }
117
+ if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
118
+ - kvm_virtio_pci_irqfd_release(proxy, queue_no, vector);
119
+ + ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
120
+ + if (ret < 0) {
121
+ + break;
122
+ + }
123
+ + kvm_virtio_pci_irqfd_release(proxy, n, vector);
124
+ }
125
+ kvm_virtio_pci_vq_vector_release(proxy, vector);
126
+ }
127
+ @@ -806,12 +825,16 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs)
128
+ unsigned int vector;
129
+ int queue_no;
130
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
131
+ -
132
+ + EventNotifier *n;
133
+ + int ret ;
134
+ for (queue_no = 0; queue_no < nvqs; queue_no++) {
135
+ if (!virtio_queue_get_num(vdev, queue_no)) {
136
+ break;
137
+ }
138
+ - vector = virtio_queue_vector(vdev, queue_no);
139
+ + ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
140
+ + if (ret < 0) {
141
+ + break;
142
+ + }
143
+ if (vector >= msix_nr_vectors_allocated(dev)) {
144
+ continue;
145
+ }
146
+ @@ -819,21 +842,20 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs)
147
+ * Otherwise, it was cleaned when masked in the frontend.
148
+ */
149
+ if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
150
+ - kvm_virtio_pci_irqfd_release(proxy, queue_no, vector);
151
+ + kvm_virtio_pci_irqfd_release(proxy, n, vector);
152
+ }
153
+ kvm_virtio_pci_vq_vector_release(proxy, vector);
154
+ }
155
+ }
156
+
157
+ -static int virtio_pci_vq_vector_unmask(VirtIOPCIProxy *proxy,
158
+ +static int virtio_pci_one_vector_unmask(VirtIOPCIProxy *proxy,
159
+ unsigned int queue_no,
160
+ unsigned int vector,
161
+ - MSIMessage msg)
162
+ + MSIMessage msg,
163
+ + EventNotifier *n)
164
+ {
165
+ VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
166
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
167
+ - VirtQueue *vq = virtio_get_queue(vdev, queue_no);
168
+ - EventNotifier *n = virtio_queue_get_guest_notifier(vq);
169
+ VirtIOIRQFD *irqfd;
170
+ int ret = 0;
171
+
172
+ @@ -860,14 +882,15 @@ static int virtio_pci_vq_vector_unmask(VirtIOPCIProxy *proxy,
173
+ event_notifier_set(n);
174
+ }
175
+ } else {
176
+ - ret = kvm_virtio_pci_irqfd_use(proxy, queue_no, vector);
177
+ + ret = kvm_virtio_pci_irqfd_use(proxy, n, vector);
178
+ }
179
+ return ret;
180
+ }
181
+
182
+ -static void virtio_pci_vq_vector_mask(VirtIOPCIProxy *proxy,
183
+ +static void virtio_pci_one_vector_mask(VirtIOPCIProxy *proxy,
184
+ unsigned int queue_no,
185
+ - unsigned int vector)
186
+ + unsigned int vector,
187
+ + EventNotifier *n)
188
+ {
189
+ VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
190
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
191
+ @@ -878,7 +901,7 @@ static void virtio_pci_vq_vector_mask(VirtIOPCIProxy *proxy,
192
+ if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
193
+ k->guest_notifier_mask(vdev, queue_no, true);
194
+ } else {
195
+ - kvm_virtio_pci_irqfd_release(proxy, queue_no, vector);
196
+ + kvm_virtio_pci_irqfd_release(proxy, n, vector);
197
+ }
198
+ }
199
+
200
+ @@ -888,6 +911,7 @@ static int virtio_pci_vector_unmask(PCIDevice *dev, unsigned vector,
201
+ VirtIOPCIProxy *proxy = container_of(dev, VirtIOPCIProxy, pci_dev);
202
+ VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
203
+ VirtQueue *vq = virtio_vector_first_queue(vdev, vector);
204
+ + EventNotifier *n;
205
+ int ret, index, unmasked = 0;
206
+
207
+ while (vq) {
208
+ @@ -896,7 +920,8 @@ static int virtio_pci_vector_unmask(PCIDevice *dev, unsigned vector,
209
+ break;
210
+ }
211
+ if (index < proxy->nvqs_with_notifiers) {
212
+ - ret = virtio_pci_vq_vector_unmask(proxy, index, vector, msg);
213
+ + n = virtio_queue_get_guest_notifier(vq);
214
+ + ret = virtio_pci_one_vector_unmask(proxy, index, vector, msg, n);
215
+ if (ret < 0) {
216
+ goto undo;
217
+ }
218
+ @@ -912,7 +937,8 @@ undo:
219
+ while (vq && unmasked >= 0) {
220
+ index = virtio_get_queue_index(vq);
221
+ if (index < proxy->nvqs_with_notifiers) {
222
+ - virtio_pci_vq_vector_mask(proxy, index, vector);
223
+ + n = virtio_queue_get_guest_notifier(vq);
224
+ + virtio_pci_one_vector_mask(proxy, index, vector, n);
225
+ --unmasked;
226
+ }
227
+ vq = virtio_vector_next_queue(vq);
228
+ @@ -925,15 +951,17 @@ static void virtio_pci_vector_mask(PCIDevice *dev, unsigned vector)
229
+ VirtIOPCIProxy *proxy = container_of(dev, VirtIOPCIProxy, pci_dev);
230
+ VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
231
+ VirtQueue *vq = virtio_vector_first_queue(vdev, vector);
232
+ + EventNotifier *n;
233
+ int index;
234
+
235
+ while (vq) {
236
+ index = virtio_get_queue_index(vq);
237
+ + n = virtio_queue_get_guest_notifier(vq);
238
+ if (!virtio_queue_get_num(vdev, index)) {
239
+ break;
240
+ }
241
+ if (index < proxy->nvqs_with_notifiers) {
242
+ - virtio_pci_vq_vector_mask(proxy, index, vector);
243
+ + virtio_pci_one_vector_mask(proxy, index, vector, n);
244
+ }
245
+ vq = virtio_vector_next_queue(vq);
246
+ }
247
+ @@ -949,19 +977,17 @@ static void virtio_pci_vector_poll(PCIDevice *dev,
248
+ int queue_no;
249
+ unsigned int vector;
250
+ EventNotifier *notifier;
251
+ - VirtQueue *vq;
252
+ + int ret;
253
+
254
+ for (queue_no = 0; queue_no < proxy->nvqs_with_notifiers; queue_no++) {
255
+ - if (!virtio_queue_get_num(vdev, queue_no)) {
256
+ + ret = virtio_pci_get_notifier(proxy, queue_no, &notifier, &vector);
257
+ + if (ret < 0) {
258
+ break;
259
+ }
260
+ - vector = virtio_queue_vector(vdev, queue_no);
261
+ if (vector < vector_start || vector >= vector_end ||
262
+ !msix_is_masked(dev, vector)) {
263
+ continue;
264
+ }
265
+ - vq = virtio_get_queue(vdev, queue_no);
266
+ - notifier = virtio_queue_get_guest_notifier(vq);
267
+ if (k->guest_notifier_pending) {
268
+ if (k->guest_notifier_pending(vdev, queue_no)) {
269
+ msix_set_pending(dev, vector);
270
+ --
271
+ 2.31.1
272
+
SOURCES/kvm-virtio-pci-decouple-the-single-vector-from-the-inter.patch ADDED
@@ -0,0 +1,212 @@
1
+ From 58cd577ff157cfaf7506bba135db58e75c330ff0 Mon Sep 17 00:00:00 2001
2
+ From: Cindy Lu <lulu@redhat.com>
3
+ Date: Thu, 22 Dec 2022 15:04:44 +0800
4
+ Subject: [PATCH 03/31] virtio-pci: decouple the single vector from the
5
+ interrupt process
6
+ MIME-Version: 1.0
7
+ Content-Type: text/plain; charset=UTF-8
8
+ Content-Transfer-Encoding: 8bit
9
+
10
+ RH-Author: Cindy Lu <lulu@redhat.com>
11
+ RH-MergeRequest: 132: vhost-vdpa: support config interrupt in vhost-vdpa
12
+ RH-Bugzilla: 1905805
13
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
14
+ RH-Acked-by: Eugenio Pérez <eperezma@redhat.com>
15
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
16
+ RH-Commit: [3/10] 2c79cb678f005fb2f53b2db0f237347634ab3422 (lulu6/qemu-kvm3)
17
+
18
+ https://bugzilla.redhat.com/show_bug.cgi?id=1905805
19
+
20
+ To reuse the interrupt process in configure interrupt
21
+ Need to decouple the single vector from the interrupt process.
22
+ We add new function kvm_virtio_pci_vector_use_one and _release_one.
23
+ These functions are used for the single vector, the whole process will
24
+ finish in the loop with vq number.
25
+
26
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
27
+ Message-Id: <20221222070451.936503-4-lulu@redhat.com>
28
+ Acked-by: Jason Wang <jasowang@redhat.com>
29
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
30
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
31
+ (cherry picked from commit ee3b8dc6cc496ba7f4e27aed4493275c706a7942)
32
+ Signed-off-by: Cindy Lu <lulu@redhat.com>
33
+ ---
34
+ hw/virtio/virtio-pci.c | 131 +++++++++++++++++++++++------------------
35
+ 1 file changed, 73 insertions(+), 58 deletions(-)
36
+
37
+ diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
38
+ index 52c7692fff..ec816ea367 100644
39
+ --- a/hw/virtio/virtio-pci.c
40
+ +++ b/hw/virtio/virtio-pci.c
41
+ @@ -699,7 +699,6 @@ static uint32_t virtio_read_config(PCIDevice *pci_dev,
42
+ }
43
+
44
+ static int kvm_virtio_pci_vq_vector_use(VirtIOPCIProxy *proxy,
45
+ - unsigned int queue_no,
46
+ unsigned int vector)
47
+ {
48
+ VirtIOIRQFD *irqfd = &proxy->vector_irqfd[vector];
49
+ @@ -764,87 +763,103 @@ static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no,
50
+ return 0;
51
+ }
52
+
53
+ -static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs)
54
+ +static int kvm_virtio_pci_vector_use_one(VirtIOPCIProxy *proxy, int queue_no)
55
+ {
56
+ + unsigned int vector;
57
+ + int ret;
58
+ + EventNotifier *n;
59
+ PCIDevice *dev = &proxy->pci_dev;
60
+ VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
61
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
62
+ - unsigned int vector;
63
+ - int ret, queue_no;
64
+ - EventNotifier *n;
65
+ - for (queue_no = 0; queue_no < nvqs; queue_no++) {
66
+ - if (!virtio_queue_get_num(vdev, queue_no)) {
67
+ - break;
68
+ - }
69
+ - ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
70
+ - if (ret < 0) {
71
+ - break;
72
+ - }
73
+ - if (vector >= msix_nr_vectors_allocated(dev)) {
74
+ - continue;
75
+ - }
76
+ - ret = kvm_virtio_pci_vq_vector_use(proxy, queue_no, vector);
77
+ +
78
+ + ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
79
+ + if (ret < 0) {
80
+ + return ret;
81
+ + }
82
+ + if (vector >= msix_nr_vectors_allocated(dev)) {
83
+ + return 0;
84
+ + }
85
+ + ret = kvm_virtio_pci_vq_vector_use(proxy, vector);
86
+ + if (ret < 0) {
87
+ + goto undo;
88
+ + }
89
+ + /*
90
+ + * If guest supports masking, set up irqfd now.
91
+ + * Otherwise, delay until unmasked in the frontend.
92
+ + */
93
+ + if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
94
+ + ret = kvm_virtio_pci_irqfd_use(proxy, n, vector);
95
+ if (ret < 0) {
96
+ + kvm_virtio_pci_vq_vector_release(proxy, vector);
97
+ goto undo;
98
+ }
99
+ - /* If guest supports masking, set up irqfd now.
100
+ - * Otherwise, delay until unmasked in the frontend.
101
+ - */
102
+ - if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
103
+ - ret = kvm_virtio_pci_irqfd_use(proxy, n, vector);
104
+ - if (ret < 0) {
105
+ - kvm_virtio_pci_vq_vector_release(proxy, vector);
106
+ - goto undo;
107
+ - }
108
+ - }
109
+ }
110
+ - return 0;
111
+
112
+ + return 0;
113
+ undo:
114
+ - while (--queue_no >= 0) {
115
+ - vector = virtio_queue_vector(vdev, queue_no);
116
+ - if (vector >= msix_nr_vectors_allocated(dev)) {
117
+ - continue;
118
+ +
119
+ + vector = virtio_queue_vector(vdev, queue_no);
120
+ + if (vector >= msix_nr_vectors_allocated(dev)) {
121
+ + return ret;
122
+ + }
123
+ + if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
124
+ + ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
125
+ + if (ret < 0) {
126
+ + return ret;
127
+ }
128
+ - if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
129
+ - ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
130
+ - if (ret < 0) {
131
+ - break;
132
+ - }
133
+ - kvm_virtio_pci_irqfd_release(proxy, n, vector);
134
+ + kvm_virtio_pci_irqfd_release(proxy, n, vector);
135
+ + }
136
+ + return ret;
137
+ +}
138
+ +static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs)
139
+ +{
140
+ + int queue_no;
141
+ + int ret = 0;
142
+ + VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
143
+ +
144
+ + for (queue_no = 0; queue_no < nvqs; queue_no++) {
145
+ + if (!virtio_queue_get_num(vdev, queue_no)) {
146
+ + return -1;
147
+ }
148
+ - kvm_virtio_pci_vq_vector_release(proxy, vector);
149
+ + ret = kvm_virtio_pci_vector_use_one(proxy, queue_no);
150
+ }
151
+ return ret;
152
+ }
153
+
154
+ -static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs)
155
+ +
156
+ +static void kvm_virtio_pci_vector_release_one(VirtIOPCIProxy *proxy,
157
+ + int queue_no)
158
+ {
159
+ - PCIDevice *dev = &proxy->pci_dev;
160
+ VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
161
+ unsigned int vector;
162
+ - int queue_no;
163
+ - VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
164
+ EventNotifier *n;
165
+ - int ret ;
166
+ + int ret;
167
+ + VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
168
+ + PCIDevice *dev = &proxy->pci_dev;
169
+ +
170
+ + ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
171
+ + if (ret < 0) {
172
+ + return;
173
+ + }
174
+ + if (vector >= msix_nr_vectors_allocated(dev)) {
175
+ + return;
176
+ + }
177
+ + if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
178
+ + kvm_virtio_pci_irqfd_release(proxy, n, vector);
179
+ + }
180
+ + kvm_virtio_pci_vq_vector_release(proxy, vector);
181
+ +}
182
+ +
183
+ +static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs)
184
+ +{
185
+ + int queue_no;
186
+ + VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
187
+ +
188
+ for (queue_no = 0; queue_no < nvqs; queue_no++) {
189
+ if (!virtio_queue_get_num(vdev, queue_no)) {
190
+ break;
191
+ }
192
+ - ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector);
193
+ - if (ret < 0) {
194
+ - break;
195
+ - }
196
+ - if (vector >= msix_nr_vectors_allocated(dev)) {
197
+ - continue;
198
+ - }
199
+ - /* If guest supports masking, clean up irqfd now.
200
+ - * Otherwise, it was cleaned when masked in the frontend.
201
+ - */
202
+ - if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) {
203
+ - kvm_virtio_pci_irqfd_release(proxy, n, vector);
204
+ - }
205
+ - kvm_virtio_pci_vq_vector_release(proxy, vector);
206
+ + kvm_virtio_pci_vector_release_one(proxy, queue_no);
207
+ }
208
+ }
209
+
210
+ --
211
+ 2.31.1
212
+
SOURCES/kvm-virtio-rng-pci-fix-migration-compat-for-vectors.patch ADDED
@@ -0,0 +1,53 @@
1
+ From 35ffe28a91a2ef08dd181d1a22695050ccbb6995 Mon Sep 17 00:00:00 2001
2
+ From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
3
+ Date: Mon, 9 Jan 2023 16:04:43 +0000
4
+ Subject: [PATCH 1/2] virtio-rng-pci: fix migration compat for vectors
5
+
6
+ RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
7
+ RH-MergeRequest: 131: virtio-rng-pci: fix migration compat for vectors
8
+ RH-Bugzilla: 2155749
9
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
10
+ RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
11
+ RH-Acked-by: Thomas Huth <thuth@redhat.com>
12
+ RH-Commit: [1/1] 1a866491dd191b073d71ae1aa5f4d76ee885de6d (dagrh/c-9-s-qemu-kvm)
13
+
14
+ Fixup the migration compatibility for existing machine types
15
+ so that they do not enable msi-x.
16
+
17
+ Symptom:
18
+
19
+ (qemu) qemu: get_pci_config_device: Bad config data: i=0x34 read: 84 device: 98 cmask: ff wmask: 0 w1cmask:0
20
+ qemu: Failed to load PCIDevice:config
21
+ qemu: Failed to load virtio-rng:virtio
22
+ qemu: error while loading state for instance 0x0 of device '0000:00:03.0/virtio-rng'
23
+ qemu: load of migration failed: Invalid argument
24
+
25
+ Note: This fix will break migration from 7.2->7.2-fixed with this patch
26
+
27
+ bz: https://bugzilla.redhat.com/show_bug.cgi?id=2155749
28
+ Fixes: 9ea02e8f1 ("virtio-rng-pci: Allow setting nvectors, so we can use MSI-X")
29
+
30
+ This downstream fix is the equivalent of an upstream fix I've posted to
31
+ the 7.2 machine type compatibility.
32
+
33
+ Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
34
+ ---
35
+ hw/core/machine.c | 2 ++
36
+ 1 file changed, 2 insertions(+)
37
+
38
+ diff --git a/hw/core/machine.c b/hw/core/machine.c
39
+ index 3d851d34da..7adbac6f87 100644
40
+ --- a/hw/core/machine.c
41
+ +++ b/hw/core/machine.c
42
+ @@ -56,6 +56,8 @@ GlobalProperty hw_compat_rhel_9_1[] = {
43
+ { "nvme-ns", "eui64-default", "on"},
44
+ /* hw_compat_rhel_9_1 from hw_compat_7_1 */
45
+ { "virtio-device", "queue_reset", "false" },
46
+ + /* hw_compat_rhel_9_1 bz 2155749 */
47
+ + { "virtio-rng-pci", "vectors", "0" },
48
+ };
49
+ const size_t hw_compat_rhel_9_1_len = G_N_ELEMENTS(hw_compat_rhel_9_1);
50
+
51
+ --
52
+ 2.31.1
53
+
SOURCES/kvm-virtio-rng-pci-fix-transitional-migration-compat-for.patch ADDED
@@ -0,0 +1,47 @@
1
+ From 5413b8825db6eecc6f245854a6bce58e4dee3294 Mon Sep 17 00:00:00 2001
2
+ From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
3
+ Date: Tue, 7 Feb 2023 17:57:39 +0000
4
+ Subject: [PATCH 20/20] virtio-rng-pci: fix transitional migration compat for
5
+ vectors
6
+
7
+ RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
8
+ RH-MergeRequest: 147: virtio-rng-pci: fix transitional migration compat for vectors
9
+ RH-Bugzilla: 2162569
10
+ RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
+ RH-Acked-by: Thomas Huth <thuth@redhat.com>
12
+ RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
13
+ RH-Commit: [1/1] 6e2bd111cd56808fccf2c0464a40f7784fd893a2 (dagrh/c-9-s-qemu-kvm)
14
+
15
+ In upstream bad9c5a5166/downstream 46e08bafe9ed I fixed the virito-rng-pci
16
+ migration compatibility, but it was discovered that we also need to fix
17
+ the other aliases of the device for the transitional cases.
18
+
19
+ I've sent upstream:
20
+ https://lists.gnu.org/archive/html/qemu-devel/2023-02/msg01926.html
21
+ but downstream we need to change the downstream machine type anyway,
22
+ so it's not quite identical.
23
+
24
+ Fixes: 9ea02e8f1 ('virtio-rng-pci: Allow setting nvectors, so we can use MSI-X')
25
+
26
+ Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
27
+ ---
28
+ hw/core/machine.c | 3 +++
29
+ 1 file changed, 3 insertions(+)
30
+
31
+ diff --git a/hw/core/machine.c b/hw/core/machine.c
32
+ index 7adbac6f87..3ee638394b 100644
33
+ --- a/hw/core/machine.c
34
+ +++ b/hw/core/machine.c
35
+ @@ -58,6 +58,9 @@ GlobalProperty hw_compat_rhel_9_1[] = {
36
+ { "virtio-device", "queue_reset", "false" },
37
+ /* hw_compat_rhel_9_1 bz 2155749 */
38
+ { "virtio-rng-pci", "vectors", "0" },
39
+ + /* hw_compat_rhel_9_1 bz 2162569 */
40
+ + { "virtio-rng-pci-transitional", "vectors", "0" },
41
+ + { "virtio-rng-pci-non-transitional", "vectors", "0" },
42
+ };
43
+ const size_t hw_compat_rhel_9_1_len = G_N_ELEMENTS(hw_compat_rhel_9_1);
44
+
45
+ --
46
+ 2.31.1
47
+
SOURCES/kvm-virtio-scsi-clean-up-virtio_scsi_handle_cmd_vq.patch DELETED
@@ -1,77 +0,0 @@
1
- From 975af1b9f1811e113e1babd928ae70f8e4ebefb5 Mon Sep 17 00:00:00 2001
2
- From: Stefan Hajnoczi <stefanha@redhat.com>
3
- Date: Tue, 17 May 2022 09:28:19 +0100
4
- Subject: [PATCH 13/16] virtio-scsi: clean up virtio_scsi_handle_cmd_vq()
5
-
6
- RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
7
- RH-MergeRequest: 88: virtio-scsi: fix 100% CPU consumption with IOThreads
8
- RH-Commit: [5/6] 27b0225783fa9bbb8fe5ee692bd3f0a888d49d07 (stefanha/centos-stream-qemu-kvm)
9
- RH-Bugzilla: 2079347
10
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
- RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
12
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
13
-
14
- virtio_scsi_handle_cmd_vq() is only called from hw/scsi/virtio-scsi.c
15
- now and its return value is no longer used. Remove the function
16
- prototype from virtio-scsi.h and drop the return value.
17
-
18
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
19
- Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
20
- Message-id: 20220427143541.119567-6-stefanha@redhat.com
21
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
22
- (cherry picked from commit ad482b57ef841b2d4883c5079d20ba44ff5e4b3e)
23
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
24
- ---
25
- hw/scsi/virtio-scsi.c | 5 +----
26
- include/hw/virtio/virtio-scsi.h | 1 -
27
- 2 files changed, 1 insertion(+), 5 deletions(-)
28
-
29
- diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
30
- index a47033d91d..df5ff8bab7 100644
31
- --- a/hw/scsi/virtio-scsi.c
32
- +++ b/hw/scsi/virtio-scsi.c
33
- @@ -685,12 +685,11 @@ static void virtio_scsi_handle_cmd_req_submit(VirtIOSCSI *s, VirtIOSCSIReq *req)
34
- scsi_req_unref(sreq);
35
- }
36
-
37
- -bool virtio_scsi_handle_cmd_vq(VirtIOSCSI *s, VirtQueue *vq)
38
- +static void virtio_scsi_handle_cmd_vq(VirtIOSCSI *s, VirtQueue *vq)
39
- {
40
- VirtIOSCSIReq *req, *next;
41
- int ret = 0;
42
- bool suppress_notifications = virtio_queue_get_notification(vq);
43
- - bool progress = false;
44
-
45
- QTAILQ_HEAD(, VirtIOSCSIReq) reqs = QTAILQ_HEAD_INITIALIZER(reqs);
46
-
47
- @@ -700,7 +699,6 @@ bool virtio_scsi_handle_cmd_vq(VirtIOSCSI *s, VirtQueue *vq)
48
- }
49
-
50
- while ((req = virtio_scsi_pop_req(s, vq))) {
51
- - progress = true;
52
- ret = virtio_scsi_handle_cmd_req_prepare(s, req);
53
- if (!ret) {
54
- QTAILQ_INSERT_TAIL(&reqs, req, next);
55
- @@ -725,7 +723,6 @@ bool virtio_scsi_handle_cmd_vq(VirtIOSCSI *s, VirtQueue *vq)
56
- QTAILQ_FOREACH_SAFE(req, &reqs, next, next) {
57
- virtio_scsi_handle_cmd_req_submit(s, req);
58
- }
59
- - return progress;
60
- }
61
-
62
- static void virtio_scsi_handle_cmd(VirtIODevice *vdev, VirtQueue *vq)
63
- diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h
64
- index 44dc3b81ec..2497530064 100644
65
- --- a/include/hw/virtio/virtio-scsi.h
66
- +++ b/include/hw/virtio/virtio-scsi.h
67
- @@ -151,7 +151,6 @@ void virtio_scsi_common_realize(DeviceState *dev,
68
- Error **errp);
69
-
70
- void virtio_scsi_common_unrealize(DeviceState *dev);
71
- -bool virtio_scsi_handle_cmd_vq(VirtIOSCSI *s, VirtQueue *vq);
72
- void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req);
73
- void virtio_scsi_free_req(VirtIOSCSIReq *req);
74
- void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
75
- --
76
- 2.31.1
77
-
SOURCES/kvm-virtio-scsi-clean-up-virtio_scsi_handle_ctrl_vq.patch DELETED
@@ -1,65 +0,0 @@
1
- From c6e16a7a5a18ec2bc4f8a6f5cc1c887e18b16cdf Mon Sep 17 00:00:00 2001
2
- From: Stefan Hajnoczi <stefanha@redhat.com>
3
- Date: Tue, 17 May 2022 09:28:12 +0100
4
- Subject: [PATCH 12/16] virtio-scsi: clean up virtio_scsi_handle_ctrl_vq()
5
-
6
- RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
7
- RH-MergeRequest: 88: virtio-scsi: fix 100% CPU consumption with IOThreads
8
- RH-Commit: [4/6] ca3751b7bfad5163c5b1c81b8525936a848d42ea (stefanha/centos-stream-qemu-kvm)
9
- RH-Bugzilla: 2079347
10
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
- RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
12
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
13
-
14
- virtio_scsi_handle_ctrl_vq() is only called from hw/scsi/virtio-scsi.c
15
- now and its return value is no longer used. Remove the function
16
- prototype from virtio-scsi.h and drop the return value.
17
-
18
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
19
- Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
20
- Message-id: 20220427143541.119567-5-stefanha@redhat.com
21
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
22
- (cherry picked from commit 73b3b49f1880f236b4d0ffd7efb00280c05a5fab)
23
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
24
- ---
25
- hw/scsi/virtio-scsi.c | 5 +----
26
- include/hw/virtio/virtio-scsi.h | 1 -
27
- 2 files changed, 1 insertion(+), 5 deletions(-)
28
-
29
- diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
30
- index dd2185b943..a47033d91d 100644
31
- --- a/hw/scsi/virtio-scsi.c
32
- +++ b/hw/scsi/virtio-scsi.c
33
- @@ -460,16 +460,13 @@ static void virtio_scsi_handle_ctrl_req(VirtIOSCSI *s, VirtIOSCSIReq *req)
34
- }
35
- }
36
-
37
- -bool virtio_scsi_handle_ctrl_vq(VirtIOSCSI *s, VirtQueue *vq)
38
- +static void virtio_scsi_handle_ctrl_vq(VirtIOSCSI *s, VirtQueue *vq)
39
- {
40
- VirtIOSCSIReq *req;
41
- - bool progress = false;
42
-
43
- while ((req = virtio_scsi_pop_req(s, vq))) {
44
- - progress = true;
45
- virtio_scsi_handle_ctrl_req(s, req);
46
- }
47
- - return progress;
48
- }
49
-
50
- /*
51
- diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h
52
- index 5957597825..44dc3b81ec 100644
53
- --- a/include/hw/virtio/virtio-scsi.h
54
- +++ b/include/hw/virtio/virtio-scsi.h
55
- @@ -152,7 +152,6 @@ void virtio_scsi_common_realize(DeviceState *dev,
56
-
57
- void virtio_scsi_common_unrealize(DeviceState *dev);
58
- bool virtio_scsi_handle_cmd_vq(VirtIOSCSI *s, VirtQueue *vq);
59
- -bool virtio_scsi_handle_ctrl_vq(VirtIOSCSI *s, VirtQueue *vq);
60
- void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req);
61
- void virtio_scsi_free_req(VirtIOSCSIReq *req);
62
- void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
63
- --
64
- 2.31.1
65
-
SOURCES/kvm-virtio-scsi-clean-up-virtio_scsi_handle_event_vq.patch DELETED
@@ -1,62 +0,0 @@
1
- From 019d5a0ca5d13f837a59b9e2815e2fd7ac120807 Mon Sep 17 00:00:00 2001
2
- From: Stefan Hajnoczi <stefanha@redhat.com>
3
- Date: Tue, 17 May 2022 09:28:06 +0100
4
- Subject: [PATCH 11/16] virtio-scsi: clean up virtio_scsi_handle_event_vq()
5
-
6
- RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
7
- RH-MergeRequest: 88: virtio-scsi: fix 100% CPU consumption with IOThreads
8
- RH-Commit: [3/6] f8dbc4c1991c61e4cf8dea50942c3cd509c9c4bd (stefanha/centos-stream-qemu-kvm)
9
- RH-Bugzilla: 2079347
10
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
- RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
12
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
13
-
14
- virtio_scsi_handle_event_vq() is only called from hw/scsi/virtio-scsi.c
15
- now and its return value is no longer used. Remove the function
16
- prototype from virtio-scsi.h and drop the return value.
17
-
18
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
19
- Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
20
- Message-id: 20220427143541.119567-4-stefanha@redhat.com
21
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
22
- (cherry picked from commit 37ce2de95169dacab3fb53d11bd4509b9c2e3a4c)
23
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
24
- ---
25
- hw/scsi/virtio-scsi.c | 4 +---
26
- include/hw/virtio/virtio-scsi.h | 1 -
27
- 2 files changed, 1 insertion(+), 4 deletions(-)
28
-
29
- diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
30
- index 7b69eeed64..dd2185b943 100644
31
- --- a/hw/scsi/virtio-scsi.c
32
- +++ b/hw/scsi/virtio-scsi.c
33
- @@ -856,13 +856,11 @@ void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
34
- virtio_scsi_complete_req(req);
35
- }
36
-
37
- -bool virtio_scsi_handle_event_vq(VirtIOSCSI *s, VirtQueue *vq)
38
- +static void virtio_scsi_handle_event_vq(VirtIOSCSI *s, VirtQueue *vq)
39
- {
40
- if (s->events_dropped) {
41
- virtio_scsi_push_event(s, NULL, VIRTIO_SCSI_T_NO_EVENT, 0);
42
- - return true;
43
- }
44
- - return false;
45
- }
46
-
47
- static void virtio_scsi_handle_event(VirtIODevice *vdev, VirtQueue *vq)
48
- diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h
49
- index 543681bc18..5957597825 100644
50
- --- a/include/hw/virtio/virtio-scsi.h
51
- +++ b/include/hw/virtio/virtio-scsi.h
52
- @@ -151,7 +151,6 @@ void virtio_scsi_common_realize(DeviceState *dev,
53
- Error **errp);
54
-
55
- void virtio_scsi_common_unrealize(DeviceState *dev);
56
- -bool virtio_scsi_handle_event_vq(VirtIOSCSI *s, VirtQueue *vq);
57
- bool virtio_scsi_handle_cmd_vq(VirtIOSCSI *s, VirtQueue *vq);
58
- bool virtio_scsi_handle_ctrl_vq(VirtIOSCSI *s, VirtQueue *vq);
59
- void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req);
60
- --
61
- 2.31.1
62
-
SOURCES/kvm-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch DELETED
@@ -1,103 +0,0 @@
1
- From 1b609b2af303fb6498b2ef94ac4f2e900dc8c1b2 Mon Sep 17 00:00:00 2001
2
- From: Stefan Hajnoczi <stefanha@redhat.com>
3
- Date: Tue, 17 May 2022 09:27:45 +0100
4
- Subject: [PATCH 10/16] virtio-scsi: don't waste CPU polling the event
5
- virtqueue
6
-
7
- RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
8
- RH-MergeRequest: 88: virtio-scsi: fix 100% CPU consumption with IOThreads
9
- RH-Commit: [2/6] 7e613d9b9fa8ceb668c78cb3ce7ebe1d73a004b5 (stefanha/centos-stream-qemu-kvm)
10
- RH-Bugzilla: 2079347
11
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
- RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
-
15
- The virtio-scsi event virtqueue is not emptied by its handler function.
16
- This is typical for rx virtqueues where the device uses buffers when
17
- some event occurs (e.g. a packet is received, an error condition
18
- happens, etc).
19
-
20
- Polling non-empty virtqueues wastes CPU cycles. We are not waiting for
21
- new buffers to become available, we are waiting for an event to occur,
22
- so it's a misuse of CPU resources to poll for buffers.
23
-
24
- Introduce the new virtio_queue_aio_attach_host_notifier_no_poll() API,
25
- which is identical to virtio_queue_aio_attach_host_notifier() except
26
- that it does not poll the virtqueue.
27
-
28
- Before this patch the following command-line consumed 100% CPU in the
29
- IOThread polling and calling virtio_scsi_handle_event():
30
-
31
- $ qemu-system-x86_64 -M accel=kvm -m 1G -cpu host \
32
- --object iothread,id=iothread0 \
33
- --device virtio-scsi-pci,iothread=iothread0 \
34
- --blockdev file,filename=test.img,aio=native,cache.direct=on,node-name=drive0 \
35
- --device scsi-hd,drive=drive0
36
-
37
- After this patch CPU is no longer wasted.
38
-
39
- Reported-by: Nir Soffer <nsoffer@redhat.com>
40
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
41
- Tested-by: Nir Soffer <nsoffer@redhat.com>
42
- Message-id: 20220427143541.119567-3-stefanha@redhat.com
43
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
44
- (cherry picked from commit 38738f7dbbda90fbc161757b7f4be35b52205552)
45
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
46
- ---
47
- hw/scsi/virtio-scsi-dataplane.c | 2 +-
48
- hw/virtio/virtio.c | 13 +++++++++++++
49
- include/hw/virtio/virtio.h | 1 +
50
- 3 files changed, 15 insertions(+), 1 deletion(-)
51
-
52
- diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
53
- index 29575cbaf6..8bb6e6acfc 100644
54
- --- a/hw/scsi/virtio-scsi-dataplane.c
55
- +++ b/hw/scsi/virtio-scsi-dataplane.c
56
- @@ -138,7 +138,7 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev)
57
-
58
- aio_context_acquire(s->ctx);
59
- virtio_queue_aio_attach_host_notifier(vs->ctrl_vq, s->ctx);
60
- - virtio_queue_aio_attach_host_notifier(vs->event_vq, s->ctx);
61
- + virtio_queue_aio_attach_host_notifier_no_poll(vs->event_vq, s->ctx);
62
-
63
- for (i = 0; i < vs->conf.num_queues; i++) {
64
- virtio_queue_aio_attach_host_notifier(vs->cmd_vqs[i], s->ctx);
65
- diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
66
- index 9d637e043e..67a873f54a 100644
67
- --- a/hw/virtio/virtio.c
68
- +++ b/hw/virtio/virtio.c
69
- @@ -3534,6 +3534,19 @@ void virtio_queue_aio_attach_host_notifier(VirtQueue *vq, AioContext *ctx)
70
- virtio_queue_host_notifier_aio_poll_end);
71
- }
72
-
73
- +/*
74
- + * Same as virtio_queue_aio_attach_host_notifier() but without polling. Use
75
- + * this for rx virtqueues and similar cases where the virtqueue handler
76
- + * function does not pop all elements. When the virtqueue is left non-empty
77
- + * polling consumes CPU cycles and should not be used.
78
- + */
79
- +void virtio_queue_aio_attach_host_notifier_no_poll(VirtQueue *vq, AioContext *ctx)
80
- +{
81
- + aio_set_event_notifier(ctx, &vq->host_notifier, true,
82
- + virtio_queue_host_notifier_read,
83
- + NULL, NULL);
84
- +}
85
- +
86
- void virtio_queue_aio_detach_host_notifier(VirtQueue *vq, AioContext *ctx)
87
- {
88
- aio_set_event_notifier(ctx, &vq->host_notifier, true, NULL, NULL, NULL);
89
- diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
90
- index b31c4507f5..b62a35fdca 100644
91
- --- a/include/hw/virtio/virtio.h
92
- +++ b/include/hw/virtio/virtio.h
93
- @@ -317,6 +317,7 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);
94
- void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled);
95
- void virtio_queue_host_notifier_read(EventNotifier *n);
96
- void virtio_queue_aio_attach_host_notifier(VirtQueue *vq, AioContext *ctx);
97
- +void virtio_queue_aio_attach_host_notifier_no_poll(VirtQueue *vq, AioContext *ctx);
98
- void virtio_queue_aio_detach_host_notifier(VirtQueue *vq, AioContext *ctx);
99
- VirtQueue *virtio_vector_first_queue(VirtIODevice *vdev, uint16_t vector);
100
- VirtQueue *virtio_vector_next_queue(VirtQueue *vq);
101
- --
102
- 2.31.1
103
-
SOURCES/kvm-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch DELETED
@@ -1,119 +0,0 @@
1
- From 5aaf33dbbbc89d58a52337985641723b9ee13541 Mon Sep 17 00:00:00 2001
2
- From: Stefan Hajnoczi <stefanha@redhat.com>
3
- Date: Wed, 27 Apr 2022 15:35:36 +0100
4
- Subject: [PATCH 09/16] virtio-scsi: fix ctrl and event handler functions in
5
- dataplane mode
6
-
7
- RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
8
- RH-MergeRequest: 88: virtio-scsi: fix 100% CPU consumption with IOThreads
9
- RH-Commit: [1/6] 3087889041b960f14a6b3893243f78523a78f637 (stefanha/centos-stream-qemu-kvm)
10
- RH-Bugzilla: 2079347
11
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12
- RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
13
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
14
-
15
- Commit f34e8d8b8d48d73f36a67b6d5e492ef9784b5012 ("virtio-scsi: prepare
16
- virtio_scsi_handle_cmd for dataplane") prepared the virtio-scsi cmd
17
- virtqueue handler function to be used in both the dataplane and
18
- non-datpalane code paths.
19
-
20
- It failed to convert the ctrl and event virtqueue handler functions,
21
- which are not designed to be called from the dataplane code path but
22
- will be since the ioeventfd is set up for those virtqueues when
23
- dataplane starts.
24
-
25
- Convert the ctrl and event virtqueue handler functions now so they
26
- operate correctly when called from the dataplane code path. Avoid code
27
- duplication by extracting this code into a helper function.
28
-
29
- Fixes: f34e8d8b8d48d73f36a67b6d5e492ef9784b5012 ("virtio-scsi: prepare virtio_scsi_handle_cmd for dataplane")
30
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
31
- Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
32
- Message-id: 20220427143541.119567-2-stefanha@redhat.com
33
- [Fixed s/by used/be used/ typo pointed out by Michael Tokarev
34
- <mjt@tls.msk.ru>.
35
- --Stefan]
36
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
37
- (cherry picked from commit 2f743ef6366c2df4ef51ef3ae318138cdc0125ab)
38
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
39
- ---
40
- hw/scsi/virtio-scsi.c | 42 +++++++++++++++++++++++++++---------------
41
- 1 file changed, 27 insertions(+), 15 deletions(-)
42
-
43
- diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
44
- index 7f6da33a8a..7b69eeed64 100644
45
- --- a/hw/scsi/virtio-scsi.c
46
- +++ b/hw/scsi/virtio-scsi.c
47
- @@ -472,16 +472,32 @@ bool virtio_scsi_handle_ctrl_vq(VirtIOSCSI *s, VirtQueue *vq)
48
- return progress;
49
- }
50
-
51
- +/*
52
- + * If dataplane is configured but not yet started, do so now and return true on
53
- + * success.
54
- + *
55
- + * Dataplane is started by the core virtio code but virtqueue handler functions
56
- + * can also be invoked when a guest kicks before DRIVER_OK, so this helper
57
- + * function helps us deal with manually starting ioeventfd in that case.
58
- + */
59
- +static bool virtio_scsi_defer_to_dataplane(VirtIOSCSI *s)
60
- +{
61
- + if (!s->ctx || s->dataplane_started) {
62
- + return false;
63
- + }
64
- +
65
- + virtio_device_start_ioeventfd(&s->parent_obj.parent_obj);
66
- + return !s->dataplane_fenced;
67
- +}
68
- +
69
- static void virtio_scsi_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
70
- {
71
- VirtIOSCSI *s = (VirtIOSCSI *)vdev;
72
-
73
- - if (s->ctx) {
74
- - virtio_device_start_ioeventfd(vdev);
75
- - if (!s->dataplane_fenced) {
76
- - return;
77
- - }
78
- + if (virtio_scsi_defer_to_dataplane(s)) {
79
- + return;
80
- }
81
- +
82
- virtio_scsi_acquire(s);
83
- virtio_scsi_handle_ctrl_vq(s, vq);
84
- virtio_scsi_release(s);
85
- @@ -720,12 +736,10 @@ static void virtio_scsi_handle_cmd(VirtIODevice *vdev, VirtQueue *vq)
86
- /* use non-QOM casts in the data path */
87
- VirtIOSCSI *s = (VirtIOSCSI *)vdev;
88
-
89
- - if (s->ctx && !s->dataplane_started) {
90
- - virtio_device_start_ioeventfd(vdev);
91
- - if (!s->dataplane_fenced) {
92
- - return;
93
- - }
94
- + if (virtio_scsi_defer_to_dataplane(s)) {
95
- + return;
96
- }
97
- +
98
- virtio_scsi_acquire(s);
99
- virtio_scsi_handle_cmd_vq(s, vq);
100
- virtio_scsi_release(s);
101
- @@ -855,12 +869,10 @@ static void virtio_scsi_handle_event(VirtIODevice *vdev, VirtQueue *vq)
102
- {
103
- VirtIOSCSI *s = VIRTIO_SCSI(vdev);
104
-
105
- - if (s->ctx) {
106
- - virtio_device_start_ioeventfd(vdev);
107
- - if (!s->dataplane_fenced) {
108
- - return;
109
- - }
110
- + if (virtio_scsi_defer_to_dataplane(s)) {
111
- + return;
112
- }
113
- +
114
- virtio_scsi_acquire(s);
115
- virtio_scsi_handle_event_vq(s, vq);
116
- virtio_scsi_release(s);
117
- --
118
- 2.31.1
119
-
SOURCES/kvm-virtio-scsi-move-request-related-items-from-.h-to-.c.patch DELETED
@@ -1,168 +0,0 @@
1
- From 6603f216dbc07a1d221b1665409cfec6cc9960e2 Mon Sep 17 00:00:00 2001
2
- From: Stefan Hajnoczi <stefanha@redhat.com>
3
- Date: Tue, 17 May 2022 09:28:26 +0100
4
- Subject: [PATCH 14/16] virtio-scsi: move request-related items from .h to .c
5
-
6
- RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
7
- RH-MergeRequest: 88: virtio-scsi: fix 100% CPU consumption with IOThreads
8
- RH-Commit: [6/6] ecdf5289abd04062c85c5ed8e577a5249684a3b0 (stefanha/centos-stream-qemu-kvm)
9
- RH-Bugzilla: 2079347
10
- RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
11
- RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
12
- RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
13
-
14
- There is no longer a need to expose the request and related APIs in
15
- virtio-scsi.h since there are no callers outside virtio-scsi.c.
16
-
17
- Note the block comment in VirtIOSCSIReq has been adjusted to meet the
18
- coding style.
19
-
20
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
21
- Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
22
- Message-id: 20220427143541.119567-7-stefanha@redhat.com
23
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
24
- (cherry picked from commit 3dc584abeef0e1277c2de8c1c1974cb49444eb0a)
25
- Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
26
- ---
27
- hw/scsi/virtio-scsi.c | 45 ++++++++++++++++++++++++++++++---
28
- include/hw/virtio/virtio-scsi.h | 40 -----------------------------
29
- 2 files changed, 41 insertions(+), 44 deletions(-)
30
-
31
- diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
32
- index df5ff8bab7..2450c9438c 100644
33
- --- a/hw/scsi/virtio-scsi.c
34
- +++ b/hw/scsi/virtio-scsi.c
35
- @@ -29,6 +29,43 @@
36
- #include "hw/virtio/virtio-access.h"
37
- #include "trace.h"
38
-
39
- +typedef struct VirtIOSCSIReq {
40
- + /*
41
- + * Note:
42
- + * - fields up to resp_iov are initialized by virtio_scsi_init_req;
43
- + * - fields starting at vring are zeroed by virtio_scsi_init_req.
44
- + */
45
- + VirtQueueElement elem;
46
- +
47
- + VirtIOSCSI *dev;
48
- + VirtQueue *vq;
49
- + QEMUSGList qsgl;
50
- + QEMUIOVector resp_iov;
51
- +
52
- + union {
53
- + /* Used for two-stage request submission */
54
- + QTAILQ_ENTRY(VirtIOSCSIReq) next;
55
- +
56
- + /* Used for cancellation of request during TMFs */
57
- + int remaining;
58
- + };
59
- +
60
- + SCSIRequest *sreq;
61
- + size_t resp_size;
62
- + enum SCSIXferMode mode;
63
- + union {
64
- + VirtIOSCSICmdResp cmd;
65
- + VirtIOSCSICtrlTMFResp tmf;
66
- + VirtIOSCSICtrlANResp an;
67
- + VirtIOSCSIEvent event;
68
- + } resp;
69
- + union {
70
- + VirtIOSCSICmdReq cmd;
71
- + VirtIOSCSICtrlTMFReq tmf;
72
- + VirtIOSCSICtrlANReq an;
73
- + } req;
74
- +} VirtIOSCSIReq;
75
- +
76
- static inline int virtio_scsi_get_lun(uint8_t *lun)
77
- {
78
- return ((lun[2] << 8) | lun[3]) & 0x3FFF;
79
- @@ -45,7 +82,7 @@ static inline SCSIDevice *virtio_scsi_device_get(VirtIOSCSI *s, uint8_t *lun)
80
- return scsi_device_get(&s->bus, 0, lun[1], virtio_scsi_get_lun(lun));
81
- }
82
-
83
- -void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req)
84
- +static void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req)
85
- {
86
- VirtIODevice *vdev = VIRTIO_DEVICE(s);
87
- const size_t zero_skip =
88
- @@ -58,7 +95,7 @@ void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req)
89
- memset((uint8_t *)req + zero_skip, 0, sizeof(*req) - zero_skip);
90
- }
91
-
92
- -void virtio_scsi_free_req(VirtIOSCSIReq *req)
93
- +static void virtio_scsi_free_req(VirtIOSCSIReq *req)
94
- {
95
- qemu_iovec_destroy(&req->resp_iov);
96
- qemu_sglist_destroy(&req->qsgl);
97
- @@ -801,8 +838,8 @@ static void virtio_scsi_reset(VirtIODevice *vdev)
98
- s->events_dropped = false;
99
- }
100
-
101
- -void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
102
- - uint32_t event, uint32_t reason)
103
- +static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
104
- + uint32_t event, uint32_t reason)
105
- {
106
- VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
107
- VirtIOSCSIReq *req;
108
- diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h
109
- index 2497530064..abdda2cbd0 100644
110
- --- a/include/hw/virtio/virtio-scsi.h
111
- +++ b/include/hw/virtio/virtio-scsi.h
112
- @@ -94,42 +94,6 @@ struct VirtIOSCSI {
113
- uint32_t host_features;
114
- };
115
-
116
- -typedef struct VirtIOSCSIReq {
117
- - /* Note:
118
- - * - fields up to resp_iov are initialized by virtio_scsi_init_req;
119
- - * - fields starting at vring are zeroed by virtio_scsi_init_req.
120
- - * */
121
- - VirtQueueElement elem;
122
- -
123
- - VirtIOSCSI *dev;
124
- - VirtQueue *vq;
125
- - QEMUSGList qsgl;
126
- - QEMUIOVector resp_iov;
127
- -
128
- - union {
129
- - /* Used for two-stage request submission */
130
- - QTAILQ_ENTRY(VirtIOSCSIReq) next;
131
- -
132
- - /* Used for cancellation of request during TMFs */
133
- - int remaining;
134
- - };
135
- -
136
- - SCSIRequest *sreq;
137
- - size_t resp_size;
138
- - enum SCSIXferMode mode;
139
- - union {
140
- - VirtIOSCSICmdResp cmd;
141
- - VirtIOSCSICtrlTMFResp tmf;
142
- - VirtIOSCSICtrlANResp an;
143
- - VirtIOSCSIEvent event;
144
- - } resp;
145
- - union {
146
- - VirtIOSCSICmdReq cmd;
147
- - VirtIOSCSICtrlTMFReq tmf;
148
- - VirtIOSCSICtrlANReq an;
149
- - } req;
150
- -} VirtIOSCSIReq;
151
- -
152
- static inline void virtio_scsi_acquire(VirtIOSCSI *s)
153
- {
154
- if (s->ctx) {
155
- @@ -151,10 +115,6 @@ void virtio_scsi_common_realize(DeviceState *dev,
156
- Error **errp);
157
-
158
- void virtio_scsi_common_unrealize(DeviceState *dev);
159
- -void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req);
160
- -void virtio_scsi_free_req(VirtIOSCSIReq *req);
161
- -void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
162
- - uint32_t event, uint32_t reason);
163
-
164
- void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **errp);
165
- int virtio_scsi_dataplane_start(VirtIODevice *s);
166
- --
167
- 2.31.1
168
-
SOURCES/kvm-virtio_net-Modify-virtio_net_get_config-to-early-ret.patch ADDED
@@ -0,0 +1,74 @@
1
+ From 3f55d12df35552ae948587a62d6f9015664adc13 Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
+ Date: Wed, 21 Dec 2022 12:50:12 +0100
4
+ Subject: [PATCH 1/9] virtio_net: Modify virtio_net_get_config to early return
5
+ MIME-Version: 1.0
6
+ Content-Type: text/plain; charset=UTF-8
7
+ Content-Transfer-Encoding: 8bit
8
+
9
+ RH-Author: Eugenio Pérez <eperezma@redhat.com>
10
+ RH-MergeRequest: 137: vDPA net SVQ guest announce support
11
+ RH-Bugzilla: 2141088
12
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
13
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
14
+ RH-Acked-by: Jason Wang <jasowang@redhat.com>
15
+ RH-Commit: [1/4] 4f5e79afd54e157f32e6fff56ae33e2b71492525 (eperezmartin/qemu-kvm)
16
+
17
+ Next patches introduce more code on vhost-vdpa branch, with already have
18
+ too much indentation.
19
+
20
+ Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
21
+ Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
22
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
23
+ Acked-by: Jason Wang <jasowang@redhat.com>
24
+ Message-Id: <20221221115015.1400889-2-eperezma@redhat.com>
25
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
26
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
27
+ (cherry picked from commit ebc141a62508dc91901373c1a19fe7e2cf560dfb)
28
+ ---
29
+ hw/net/virtio-net.c | 28 +++++++++++++++-------------
30
+ 1 file changed, 15 insertions(+), 13 deletions(-)
31
+
32
+ diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
33
+ index ec974f7a76..5935e55653 100644
34
+ --- a/hw/net/virtio-net.c
35
+ +++ b/hw/net/virtio-net.c
36
+ @@ -168,20 +168,22 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
37
+ if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
38
+ ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg,
39
+ n->config_size);
40
+ - if (ret != -1) {
41
+ - /*
42
+ - * Some NIC/kernel combinations present 0 as the mac address. As
43
+ - * that is not a legal address, try to proceed with the
44
+ - * address from the QEMU command line in the hope that the
45
+ - * address has been configured correctly elsewhere - just not
46
+ - * reported by the device.
47
+ - */
48
+ - if (memcmp(&netcfg.mac, &zero, sizeof(zero)) == 0) {
49
+ - info_report("Zero hardware mac address detected. Ignoring.");
50
+ - memcpy(netcfg.mac, n->mac, ETH_ALEN);
51
+ - }
52
+ - memcpy(config, &netcfg, n->config_size);
53
+ + if (ret == -1) {
54
+ + return;
55
+ }
56
+ +
57
+ + /*
58
+ + * Some NIC/kernel combinations present 0 as the mac address. As that
59
+ + * is not a legal address, try to proceed with the address from the
60
+ + * QEMU command line in the hope that the address has been configured
61
+ + * correctly elsewhere - just not reported by the device.
62
+ + */
63
+ + if (memcmp(&netcfg.mac, &zero, sizeof(zero)) == 0) {
64
+ + info_report("Zero hardware mac address detected. Ignoring.");
65
+ + memcpy(netcfg.mac, n->mac, ETH_ALEN);
66
+ + }
67
+ +
68
+ + memcpy(config, &netcfg, n->config_size);
69
+ }
70
+ }
71
+
72
+ --
73
+ 2.31.1
74
+
SOURCES/kvm-virtio_net-copy-VIRTIO_NET_S_ANNOUNCE-if-device-mode.patch ADDED
@@ -0,0 +1,46 @@
1
+ From b3d728b53abaae0c9884dfb5e9c216b1088196e3 Mon Sep 17 00:00:00 2001
2
+ From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
3
+ Date: Wed, 21 Dec 2022 12:50:13 +0100
4
+ Subject: [PATCH 2/9] virtio_net: copy VIRTIO_NET_S_ANNOUNCE if device model
5
+ has it
6
+ MIME-Version: 1.0
7
+ Content-Type: text/plain; charset=UTF-8
8
+ Content-Transfer-Encoding: 8bit
9
+
10
+ RH-Author: Eugenio Pérez <eperezma@redhat.com>
11
+ RH-MergeRequest: 137: vDPA net SVQ guest announce support
12
+ RH-Bugzilla: 2141088
13
+ RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
14
+ RH-Acked-by: Cindy Lu <lulu@redhat.com>
15
+ RH-Acked-by: Jason Wang <jasowang@redhat.com>
16
+ RH-Commit: [2/4] fb04186829eb93bab3c9ececf90fa5b035ffa2ec (eperezmartin/qemu-kvm)
17
+
18
+ Status part of the emulated feature. It will follow device model, so we
19
+ must copy it as long as NIC device model has it set.
20
+
21
+ Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
22
+ Message-Id: <20221221115015.1400889-3-eperezma@redhat.com>
23
+ Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
24
+ Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
25
+ Acked-by: Jason Wang <jasowang@redhat.com>
26
+ (cherry picked from commit 4f93aafc8f9d731c6588f5dc5594c6a1dd1fbe66)
27
+ ---
28
+ hw/net/virtio-net.c | 2 ++
29
+ 1 file changed, 2 insertions(+)
30
+
31
+ diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
32
+ index 5935e55653..948bcf33cf 100644
33
+ --- a/hw/net/virtio-net.c
34
+ +++ b/hw/net/virtio-net.c
35
+ @@ -183,6 +183,8 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
36
+ memcpy(netcfg.mac, n->mac, ETH_ALEN);
37
+ }
38
+
39
+ + netcfg.status |= virtio_tswap16(vdev,
40
+ + n->status & VIRTIO_NET_S_ANNOUNCE);
41
+ memcpy(config, &netcfg, n->config_size);
42
+ }
43
+ }
44
+ --
45
+ 2.31.1
46
+
file modified
+4 -4
SOURCES/qemu-ga.sysconfig CHANGED
@@ -1,11 +1,11 @@
1
1
# This is a systemd environment file, not a shell script.
2
2
# It provides settings for "/lib/systemd/system/qemu-guest-agent.service".
3
3
4
- # Comma-separated blacklist of RPCs to disable, or empty list to enable all.
4
+ # Comma-separated blocked RPCs to disable, or empty list to enable all.
5
5
#
6
- # You can get the list of RPC commands using "qemu-ga --blacklist='?'".
7
- # There should be no spaces between commas and commands in the blacklist.
8
- BLACKLIST_RPC=guest-file-open,guest-file-close,guest-file-read,guest-file-write,guest-file-seek,guest-file-flush,guest-exec,guest-exec-status
6
+ # You can get the list of RPC commands using "qemu-ga --block-rpcs='?'".
7
+ # There should be no spaces between commas and commands in the block list.
8
+ BLOCK_RPCS=guest-file-open,guest-file-close,guest-file-read,guest-file-write,guest-file-seek,guest-file-flush,guest-exec,guest-exec-status
9
9
10
10
# Fsfreeze hook script specification.
11
11
#
SOURCES/qemu-guest-agent.service CHANGED
@@ -10,7 +10,7 @@ EnvironmentFile=/etc/sysconfig/qemu-ga
10
10
ExecStart=/usr/bin/qemu-ga \
11
11
--method=virtio-serial \
12
12
--path=/dev/virtio-ports/org.qemu.guest_agent.0 \
13
- --blacklist=${BLACKLIST_RPC} \
13
+ --block-rpcs=${BLOCK_RPCS} \
14
14
-F${FSFREEZE_HOOK_PATHNAME}
15
15
Restart=always
16
16
RestartSec=0
file modified
+463 -300
SPECS/qemu-kvm.spec CHANGED
@@ -1,7 +1,7 @@
1
1
%global libfdt_version 1.6.0
2
2
%global libseccomp_version 2.4.0
3
3
%global libusbx_version 1.0.23
4
- %global meson_version 0.58.2
4
+ %global meson_version 0.61.3
5
5
%global usbredir_version 0.7.1
6
6
%global ipxe_version 20200823-5.git4bd064de
7
7
@@ -113,16 +113,13 @@ Requires: %{name}-ui-opengl = %{epoch}:%{version}-%{release} \
113
113
Requires: %{name}-ui-egl-headless = %{epoch}:%{version}-%{release} \
114
114
%endif \
115
115
Requires: %{name}-device-display-virtio-gpu = %{epoch}:%{version}-%{release} \
116
- Requires: %{name}-device-display-virtio-gpu-gl = %{epoch}:%{version}-%{release} \
117
116
%ifarch s390x \
118
117
Requires: %{name}-device-display-virtio-gpu-ccw = %{epoch}:%{version}-%{release} \
119
118
%else \
120
119
Requires: %{name}-device-display-virtio-gpu-pci = %{epoch}:%{version}-%{release} \
121
- Requires: %{name}-device-display-virtio-gpu-pci-gl = %{epoch}:%{version}-%{release} \
122
120
%endif \
123
121
%ifarch x86_64 %{power64} \
124
122
Requires: %{name}-device-display-virtio-vga = %{epoch}:%{version}-%{release} \
125
- Requires: %{name}-device-display-virtio-vga-gl = %{epoch}:%{version}-%{release} \
126
123
%endif \
127
124
Requires: %{name}-device-usb-host = %{epoch}:%{version}-%{release} \
128
125
%if %{have_usbredir} \
@@ -150,8 +147,8 @@ Obsoletes: %{name}-block-ssh <= %{epoch}:%{version} \
150
147
151
148
Summary: QEMU is a machine emulator and virtualizer
152
149
Name: qemu-kvm
153
- Version: 7.0.0
154
- Release: 11%{?rcrel}%{?dist}%{?cc_suffix}
150
+ Version: 7.2.0
151
+ Release: 10%{?rcrel}%{?dist}%{?cc_suffix}
155
152
# Epoch because we pushed a qemu-1.0 package. AIUI this can't ever be dropped
156
153
# Epoch 15 used for RHEL 8
157
154
# Epoch 17 used for RHEL 9 (due to release versioning offset in RHEL 8.5)
@@ -186,266 +183,197 @@ Patch0010: 0010-Add-x86_64-machine-types.patch
186
183
Patch0011: 0011-Enable-make-check.patch
187
184
Patch0012: 0012-vfio-cap-number-of-devices-that-can-be-assigned.patch
188
185
Patch0013: 0013-Add-support-statement-to-help-output.patch
189
- Patch0014: 0014-globally-limit-the-maximum-number-of-CPUs.patch
190
- Patch0015: 0015-Use-qemu-kvm-in-documentation-instead-of-qemu-system.patch
191
- Patch0016: 0016-virtio-scsi-Reject-scsi-cd-if-data-plane-enabled-RHE.patch
192
- Patch0017: 0017-BZ1653590-Require-at-least-64kiB-pages-for-downstrea.patch
193
- Patch0018: 0018-qcow2-Deprecation-warning-when-opening-v2-images-rw.patch
194
- Patch0019: 0019-WRB-Introduce-RHEL-9.0.0-hw-compat-structure.patch
195
- Patch0020: 0020-redhat-Update-s390x-machine-type-compatibility-for-r.patch
196
- Patch0021: 0021-pc-Move-s3-s4-suspend-disabling-to-compat.patch
197
- # For bz#2044162 - [RHEL9.1] Enable virtio-mem as tech-preview on ARM64 QEMU
198
- Patch22: kvm-configs-devices-aarch64-softmmu-Enable-CONFIG_VIRTIO.patch
199
- # For bz#2081022 - Build regression on ppc64le with c9s qemu-kvm 7.0.0-1 changes
200
- Patch23: kvm-target-ppc-cpu-models-Fix-ppc_cpu_aliases-list-for-R.patch
201
- # For bz#2046029 - [WRB] New machine type property - dtb-kaslr-seed
202
- Patch24: kvm-hw-arm-virt-Remove-the-dtb-kaslr-seed-machine-option.patch
203
- # For bz#2046029 - [WRB] New machine type property - dtb-kaslr-seed
204
- Patch25: kvm-hw-arm-virt-Fix-missing-initialization-in-instance-c.patch
205
- # For bz#1477099 - virtio-iommu (including ACPI, VHOST/VFIO integration, migration support)
206
- Patch26: kvm-Enable-virtio-iommu-pci-on-aarch64.patch
207
- # For bz#2037612 - [Win11][tpm][QL41112 PF] vfio_listener_region_add received unaligned region
208
- Patch27: kvm-sysemu-tpm-Add-a-stub-function-for-TPM_IS_CRB.patch
209
- # For bz#2037612 - [Win11][tpm][QL41112 PF] vfio_listener_region_add received unaligned region
210
- Patch28: kvm-vfio-common-remove-spurious-tpm-crb-cmd-misalignment.patch
211
- # For bz#2041823 - [aarch64][numa] When there are at least 6 Numa nodes serial log shows 'arch topology borken'
212
- Patch29: kvm-qapi-machine.json-Add-cluster-id.patch
213
- # For bz#2041823 - [aarch64][numa] When there are at least 6 Numa nodes serial log shows 'arch topology borken'
214
- Patch30: kvm-qtest-numa-test-Specify-CPU-topology-in-aarch64_numa.patch
215
- # For bz#2041823 - [aarch64][numa] When there are at least 6 Numa nodes serial log shows 'arch topology borken'
216
- Patch31: kvm-hw-arm-virt-Consider-SMP-configuration-in-CPU-topolo.patch
217
- # For bz#2041823 - [aarch64][numa] When there are at least 6 Numa nodes serial log shows 'arch topology borken'
218
- Patch32: kvm-qtest-numa-test-Correct-CPU-and-NUMA-association-in-.patch
219
- # For bz#2041823 - [aarch64][numa] When there are at least 6 Numa nodes serial log shows 'arch topology borken'
220
- Patch33: kvm-hw-arm-virt-Fix-CPU-s-default-NUMA-node-ID.patch
221
- # For bz#2041823 - [aarch64][numa] When there are at least 6 Numa nodes serial log shows 'arch topology borken'
222
- Patch34: kvm-hw-acpi-aml-build-Use-existing-CPU-topology-to-build.patch
223
- # For bz#2079938 - qemu coredump when boot with multi disks (qemu) failed to set up stack guard page: Cannot allocate memory
224
- Patch35: kvm-coroutine-Rename-qemu_coroutine_inc-dec_pool_size.patch
225
- # For bz#2079938 - qemu coredump when boot with multi disks (qemu) failed to set up stack guard page: Cannot allocate memory
226
- Patch36: kvm-coroutine-Revert-to-constant-batch-size.patch
227
- # For bz#2079347 - Guest boot blocked when scsi disks using same iothread and 100% CPU consumption
228
- Patch37: kvm-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch
229
- # For bz#2079347 - Guest boot blocked when scsi disks using same iothread and 100% CPU consumption
230
- Patch38: kvm-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch
231
- # For bz#2079347 - Guest boot blocked when scsi disks using same iothread and 100% CPU consumption
232
- Patch39: kvm-virtio-scsi-clean-up-virtio_scsi_handle_event_vq.patch
233
- # For bz#2079347 - Guest boot blocked when scsi disks using same iothread and 100% CPU consumption
234
- Patch40: kvm-virtio-scsi-clean-up-virtio_scsi_handle_ctrl_vq.patch
235
- # For bz#2079347 - Guest boot blocked when scsi disks using same iothread and 100% CPU consumption
236
- Patch41: kvm-virtio-scsi-clean-up-virtio_scsi_handle_cmd_vq.patch
237
- # For bz#2079347 - Guest boot blocked when scsi disks using same iothread and 100% CPU consumption
238
- Patch42: kvm-virtio-scsi-move-request-related-items-from-.h-to-.c.patch
239
- # For bz#1995710 - RFE: Allow virtio-scsi CD-ROM media change with IOThreads
240
- Patch43: kvm-Revert-virtio-scsi-Reject-scsi-cd-if-data-plane-enab.patch
241
- # For bz#2064530 - Rebuild qemu-kvm with clang-14
242
- Patch44: kvm-migration-Fix-operator-type.patch
243
- # For bz#1708300 - RFE: qemu-nbd vs NBD_FLAG_CAN_MULTI_CONN
244
- Patch45: kvm-qemu-nbd-Pass-max-connections-to-blockdev-layer.patch
245
- # For bz#1708300 - RFE: qemu-nbd vs NBD_FLAG_CAN_MULTI_CONN
246
- Patch46: kvm-nbd-server-Allow-MULTI_CONN-for-shared-writable-expo.patch
247
- # For bz#2031024 - Add support for fixing thread pool size [QEMU]
248
- Patch47: kvm-Introduce-event-loop-base-abstract-class.patch
249
- # For bz#2031024 - Add support for fixing thread pool size [QEMU]
250
- Patch48: kvm-util-main-loop-Introduce-the-main-loop-into-QOM.patch
251
- # For bz#2031024 - Add support for fixing thread pool size [QEMU]
252
- Patch49: kvm-util-event-loop-base-Introduce-options-to-set-the-th.patch
253
- # For bz#2072379 - Fail to rebuild the reference count tables of qcow2 image on host block devices (e.g. LVs)
254
- Patch50: kvm-qcow2-Improve-refcount-structure-rebuilding.patch
255
- # For bz#2072379 - Fail to rebuild the reference count tables of qcow2 image on host block devices (e.g. LVs)
256
- Patch51: kvm-iotests-108-Test-new-refcount-rebuild-algorithm.patch
257
- # For bz#2072379 - Fail to rebuild the reference count tables of qcow2 image on host block devices (e.g. LVs)
258
- Patch52: kvm-qcow2-Add-errp-to-rebuild_refcount_structure.patch
259
- # For bz#2072379 - Fail to rebuild the reference count tables of qcow2 image on host block devices (e.g. LVs)
260
- Patch53: kvm-iotests-108-Fix-when-missing-user_allow_other.patch
261
- # For bz#2070804 - PXE boot crash qemu when using multiqueue vDPA
262
- Patch54: kvm-virtio-net-setup-vhost_dev-and-notifiers-for-cvq-onl.patch
263
- # For bz#2070804 - PXE boot crash qemu when using multiqueue vDPA
264
- Patch55: kvm-virtio-net-align-ctrl_vq-index-for-non-mq-guest-for-.patch
265
- # For bz#2070804 - PXE boot crash qemu when using multiqueue vDPA
266
- Patch56: kvm-vhost-vdpa-fix-improper-cleanup-in-net_init_vhost_vd.patch
267
- # For bz#2070804 - PXE boot crash qemu when using multiqueue vDPA
268
- Patch57: kvm-vhost-net-fix-improper-cleanup-in-vhost_net_start.patch
269
- # For bz#2070804 - PXE boot crash qemu when using multiqueue vDPA
270
- Patch58: kvm-vhost-vdpa-backend-feature-should-set-only-once.patch
271
- # For bz#2070804 - PXE boot crash qemu when using multiqueue vDPA
272
- Patch59: kvm-vhost-vdpa-change-name-and-polarity-for-vhost_vdpa_o.patch
273
- # For bz#2070804 - PXE boot crash qemu when using multiqueue vDPA
274
- Patch60: kvm-virtio-net-don-t-handle-mq-request-in-userspace-hand.patch
275
- # For bz#2094270 - Do not set the hard vCPU limit to the soft vCPU limit in downstream qemu-kvm anymore
276
- Patch61: kvm-Revert-globally-limit-the-maximum-number-of-CPUs.patch
277
- # For bz#2086262 - [Win11][tpm]vfio_listener_region_del received unaligned region
278
- Patch62: kvm-vfio-common-remove-spurious-warning-on-vfio_listener.patch
279
- # For bz#1952483 - RFE: QEMU's coroutines fail with CFLAGS=-flto on non-x86_64 architectures
280
- Patch63: kvm-coroutine-ucontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch
281
- # For bz#1952483 - RFE: QEMU's coroutines fail with CFLAGS=-flto on non-x86_64 architectures
282
- Patch64: kvm-coroutine-use-QEMU_DEFINE_STATIC_CO_TLS.patch
283
- # For bz#1952483 - RFE: QEMU's coroutines fail with CFLAGS=-flto on non-x86_64 architectures
284
- Patch65: kvm-coroutine-win32-use-QEMU_DEFINE_STATIC_CO_TLS.patch
285
- # For bz#2094252 - Compile the virtio-iommu device on x86_64
286
- Patch66: kvm-Enable-virtio-iommu-pci-on-x86_64.patch
287
- # For bz#2092788 - Stalled IO Operations in VM
288
- Patch67: kvm-linux-aio-fix-unbalanced-plugged-counter-in-laio_io_.patch
289
- # For bz#2092788 - Stalled IO Operations in VM
290
- Patch68: kvm-linux-aio-explain-why-max-batch-is-checked-in-laio_i.patch
291
- # For bz#2060839 - Consider deprecating CPU models like "kvm64" / "qemu64" on RHEL 9
292
- Patch69: kvm-tests-avocado-update-aarch64_virt-test-to-exercise-c.patch
293
- # For bz#2060839 - Consider deprecating CPU models like "kvm64" / "qemu64" on RHEL 9
294
- Patch70: kvm-RHEL-only-tests-avocado-Switch-aarch64-tests-from-a5.patch
295
- # For bz#2060839 - Consider deprecating CPU models like "kvm64" / "qemu64" on RHEL 9
296
- Patch71: kvm-RHEL-only-AArch64-Drop-unsupported-CPU-types.patch
297
- # For bz#2060839 - Consider deprecating CPU models like "kvm64" / "qemu64" on RHEL 9
298
- Patch72: kvm-target-i386-deprecate-CPUs-older-than-x86_64-v2-ABI.patch
299
- # For bz#2060839 - Consider deprecating CPU models like "kvm64" / "qemu64" on RHEL 9
300
- Patch73: kvm-target-s390x-deprecate-CPUs-older-than-z14.patch
301
- # For bz#2060839 - Consider deprecating CPU models like "kvm64" / "qemu64" on RHEL 9
302
- Patch74: kvm-target-arm-deprecate-named-CPU-models.patch
303
- # For bz#1968509 - Use MSG_ZEROCOPY on QEMU Live Migration
304
- Patch75: kvm-meson.build-Fix-docker-test-build-alpine-when-includ.patch
305
- # For bz#1968509 - Use MSG_ZEROCOPY on QEMU Live Migration
306
- Patch76: kvm-QIOChannel-Add-flags-on-io_writev-and-introduce-io_f.patch
307
- # For bz#1968509 - Use MSG_ZEROCOPY on QEMU Live Migration
308
- Patch77: kvm-QIOChannelSocket-Implement-io_writev-zero-copy-flag-.patch
309
- # For bz#1968509 - Use MSG_ZEROCOPY on QEMU Live Migration
310
- Patch78: kvm-migration-Add-zero-copy-send-parameter-for-QMP-HMP-f.patch
311
- # For bz#1968509 - Use MSG_ZEROCOPY on QEMU Live Migration
312
- Patch79: kvm-migration-Add-migrate_use_tls-helper.patch
313
- # For bz#1968509 - Use MSG_ZEROCOPY on QEMU Live Migration
314
- Patch80: kvm-multifd-multifd_send_sync_main-now-returns-negative-.patch
315
- # For bz#1968509 - Use MSG_ZEROCOPY on QEMU Live Migration
316
- Patch81: kvm-multifd-Send-header-packet-without-flags-if-zero-cop.patch
317
- # For bz#1968509 - Use MSG_ZEROCOPY on QEMU Live Migration
318
- Patch82: kvm-multifd-Implement-zero-copy-write-in-multifd-migrati.patch
319
- # For bz#1968509 - Use MSG_ZEROCOPY on QEMU Live Migration
320
- Patch83: kvm-QIOChannelSocket-Introduce-assert-and-reduce-ifdefs-.patch
321
- # For bz#1968509 - Use MSG_ZEROCOPY on QEMU Live Migration
322
- Patch84: kvm-QIOChannelSocket-Fix-zero-copy-send-so-socket-flush-.patch
323
- # For bz#1968509 - Use MSG_ZEROCOPY on QEMU Live Migration
324
- Patch85: kvm-migration-Change-zero_copy_send-from-migration-param.patch
325
- # For bz#2096143 - The migration port is not released if use it again for recovering postcopy migration
326
- Patch86: kvm-migration-Allow-migrate-recover-to-run-multiple-time.patch
327
- # For bz#2100106 - Fix virtio-iommu/vfio bypass
328
- Patch87: kvm-virtio-iommu-Add-bypass-mode-support-to-assigned-dev.patch
329
- # For bz#2100106 - Fix virtio-iommu/vfio bypass
330
- Patch88: kvm-virtio-iommu-Use-recursive-lock-to-avoid-deadlock.patch
331
- # For bz#2100106 - Fix virtio-iommu/vfio bypass
332
- Patch89: kvm-virtio-iommu-Add-an-assert-check-in-translate-routin.patch
333
- # For bz#2100106 - Fix virtio-iommu/vfio bypass
334
- Patch90: kvm-virtio-iommu-Fix-the-partial-copy-of-probe-request.patch
335
- # For bz#2100106 - Fix virtio-iommu/vfio bypass
336
- Patch91: kvm-virtio-iommu-Fix-migration-regression.patch
337
- # For bz#2098077 - virtio-blk: Can't boot fresh installation from used virtio-blk dasd disk under certain conditions
338
- Patch92: kvm-pc-bios-s390-ccw-virtio-Introduce-a-macro-for-the-DA.patch
339
- # For bz#2098077 - virtio-blk: Can't boot fresh installation from used virtio-blk dasd disk under certain conditions
340
- Patch93: kvm-pc-bios-s390-ccw-bootmap-Improve-the-guessing-logic-.patch
341
- # For bz#2098077 - virtio-blk: Can't boot fresh installation from used virtio-blk dasd disk under certain conditions
342
- Patch94: kvm-pc-bios-s390-ccw-virtio-blkdev-Simplify-fix-virtio_i.patch
343
- # For bz#2098077 - virtio-blk: Can't boot fresh installation from used virtio-blk dasd disk under certain conditions
344
- Patch95: kvm-pc-bios-s390-ccw-virtio-blkdev-Remove-virtio_assume_.patch
345
- # For bz#2098077 - virtio-blk: Can't boot fresh installation from used virtio-blk dasd disk under certain conditions
346
- Patch96: kvm-pc-bios-s390-ccw-virtio-Set-missing-status-bits-whil.patch
347
- # For bz#2098077 - virtio-blk: Can't boot fresh installation from used virtio-blk dasd disk under certain conditions
348
- Patch97: kvm-pc-bios-s390-ccw-virtio-Read-device-config-after-fea.patch
349
- # For bz#2098077 - virtio-blk: Can't boot fresh installation from used virtio-blk dasd disk under certain conditions
350
- Patch98: kvm-pc-bios-s390-ccw-virtio-Beautify-the-code-for-readin.patch
351
- # For bz#2098077 - virtio-blk: Can't boot fresh installation from used virtio-blk dasd disk under certain conditions
352
- Patch99: kvm-pc-bios-s390-ccw-Split-virtio-scsi-code-from-virtio_.patch
353
- # For bz#2098077 - virtio-blk: Can't boot fresh installation from used virtio-blk dasd disk under certain conditions
354
- Patch100: kvm-pc-bios-s390-ccw-virtio-blkdev-Request-the-right-fea.patch
355
- # For bz#2098077 - virtio-blk: Can't boot fresh installation from used virtio-blk dasd disk under certain conditions
356
- Patch101: kvm-pc-bios-s390-ccw-netboot.mak-Ignore-Clang-s-warnings.patch
357
- # For bz#1951522 - CVE-2021-3507 qemu-kvm: QEMU: fdc: heap buffer overflow in DMA read data transfers [rhel-9.0]
358
- Patch102: kvm-hw-block-fdc-Prevent-end-of-track-overrun-CVE-2021-3.patch
359
- # For bz#1951522 - CVE-2021-3507 qemu-kvm: QEMU: fdc: heap buffer overflow in DMA read data transfers [rhel-9.0]
360
- Patch103: kvm-tests-qtest-fdc-test-Add-a-regression-test-for-CVE-2.patch
361
- # For bz#1939363 - vDPA control virtqueue support in Qemu
362
- Patch104: kvm-vhost-Track-descriptor-chain-in-private-at-SVQ.patch
363
- # For bz#1939363 - vDPA control virtqueue support in Qemu
364
- Patch105: kvm-vhost-Fix-device-s-used-descriptor-dequeue.patch
365
- # For bz#1939363 - vDPA control virtqueue support in Qemu
366
- Patch106: kvm-hw-virtio-Replace-g_memdup-by-g_memdup2.patch
367
- # For bz#1939363 - vDPA control virtqueue support in Qemu
368
- Patch107: kvm-vhost-Fix-element-in-vhost_svq_add-failure.patch
369
- # For bz#1939363 - vDPA control virtqueue support in Qemu
370
- Patch108: kvm-meson-create-have_vhost_-variables.patch
371
- # For bz#1939363 - vDPA control virtqueue support in Qemu
372
- Patch109: kvm-meson-use-have_vhost_-variables-to-pick-sources.patch
373
- # For bz#1939363 - vDPA control virtqueue support in Qemu
374
- Patch110: kvm-vhost-move-descriptor-translation-to-vhost_svq_vring.patch
375
- # For bz#1939363 - vDPA control virtqueue support in Qemu
376
- Patch111: kvm-virtio-net-Expose-MAC_TABLE_ENTRIES.patch
377
- # For bz#1939363 - vDPA control virtqueue support in Qemu
378
- Patch112: kvm-virtio-net-Expose-ctrl-virtqueue-logic.patch
379
- # For bz#1939363 - vDPA control virtqueue support in Qemu
186
+ Patch0014: 0014-Use-qemu-kvm-in-documentation-instead-of-qemu-system.patch
187
+ Patch0015: 0015-BZ1653590-Require-at-least-64kiB-pages-for-downstrea.patch
188
+ Patch0016: 0016-qcow2-Deprecation-warning-when-opening-v2-images-rw.patch
189
+ Patch0018: 0018-Addd-7.2-compat-bits-for-RHEL-9.1-machine-type.patch
190
+ Patch0019: 0019-redhat-Update-s390x-machine-type-compatibility-for-Q.patch
191
+ Patch0020: 0020-redhat-aarch64-add-rhel9.2.0-virt-machine-type.patch
192
+ Patch0021: 0021-redhat-Add-new-rhel-9.2.0-s390x-machine-type.patch
193
+ Patch0022: 0022-x86-rhel-9.2.0-machine-type.patch
194
+ Patch23: kvm-redhat-fix-virt-rhel9.2.0-compat-props.patch
195
+ # For bz#2113840 - [RHEL9.2] Memory mapping optimization for virt machine
196
+ Patch24: kvm-hw-arm-virt-Introduce-virt_set_high_memmap-helper.patch
197
+ # For bz#2113840 - [RHEL9.2] Memory mapping optimization for virt machine
198
+ Patch25: kvm-hw-arm-virt-Rename-variable-size-to-region_size-in-v.patch
199
+ # For bz#2113840 - [RHEL9.2] Memory mapping optimization for virt machine
200
+ Patch26: kvm-hw-arm-virt-Introduce-variable-region_base-in-virt_s.patch
201
+ # For bz#2113840 - [RHEL9.2] Memory mapping optimization for virt machine
202
+ Patch27: kvm-hw-arm-virt-Introduce-virt_get_high_memmap_enabled-h.patch
203
+ # For bz#2113840 - [RHEL9.2] Memory mapping optimization for virt machine
204
+ Patch28: kvm-hw-arm-virt-Improve-high-memory-region-address-assig.patch
205
+ # For bz#2113840 - [RHEL9.2] Memory mapping optimization for virt machine
206
+ Patch29: kvm-hw-arm-virt-Add-compact-highmem-property.patch
207
+ # For bz#2113840 - [RHEL9.2] Memory mapping optimization for virt machine
208
+ Patch30: kvm-hw-arm-virt-Add-properties-to-disable-high-memory-re.patch
209
+ # For bz#2113840 - [RHEL9.2] Memory mapping optimization for virt machine
210
+ Patch31: kvm-hw-arm-virt-Enable-compat-high-memory-region-address.patch
211
+ # For bz#2155749 - [regression][stable guest abi][qemu-kvm7.2]Migration failed due to virtio-rng device between RHEL8.8 and RHEL9.2/MSI-X
212
+ Patch32: kvm-virtio-rng-pci-fix-migration-compat-for-vectors.patch
213
+ # For bz#1905805 - support config interrupt in vhost-vdpa qemu
214
+ Patch33: kvm-virtio-introduce-macro-VIRTIO_CONFIG_IRQ_IDX.patch
215
+ # For bz#1905805 - support config interrupt in vhost-vdpa qemu
216
+ Patch34: kvm-virtio-pci-decouple-notifier-from-interrupt-process.patch
217
+ # For bz#1905805 - support config interrupt in vhost-vdpa qemu
218
+ Patch35: kvm-virtio-pci-decouple-the-single-vector-from-the-inter.patch
219
+ # For bz#1905805 - support config interrupt in vhost-vdpa qemu
220
+ Patch36: kvm-vhost-introduce-new-VhostOps-vhost_set_config_call.patch
221
+ # For bz#1905805 - support config interrupt in vhost-vdpa qemu
222
+ Patch37: kvm-vhost-vdpa-add-support-for-config-interrupt.patch
223
+ # For bz#1905805 - support config interrupt in vhost-vdpa qemu
224
+ Patch38: kvm-virtio-add-support-for-configure-interrupt.patch
225
+ # For bz#1905805 - support config interrupt in vhost-vdpa qemu
226
+ Patch39: kvm-vhost-add-support-for-configure-interrupt.patch
227
+ # For bz#1905805 - support config interrupt in vhost-vdpa qemu
228
+ Patch40: kvm-virtio-net-add-support-for-configure-interrupt.patch
229
+ # For bz#1905805 - support config interrupt in vhost-vdpa qemu
230
+ Patch41: kvm-virtio-mmio-add-support-for-configure-interrupt.patch
231
+ # For bz#1905805 - support config interrupt in vhost-vdpa qemu
232
+ Patch42: kvm-virtio-pci-add-support-for-configure-interrupt.patch
233
+ # For bz#2159408 - [s390x] VMs with ISM passthrough don't autostart after leapp upgrade from RHEL 8
234
+ Patch43: kvm-s390x-s390-virtio-ccw-Activate-zPCI-features-on-s390.patch
235
+ # For bz#2124856 - VM with virtio interface and iommu=on will crash when try to migrate
236
+ Patch44: kvm-vhost-fix-vq-dirty-bitmap-syncing-when-vIOMMU-is-ena.patch
237
+ # For bz#2155112 - Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled)
238
+ Patch45: kvm-block-drop-bdrv_remove_filter_or_cow_child.patch
239
+ # For bz#2155112 - Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled)
240
+ Patch46: kvm-qed-Don-t-yield-in-bdrv_qed_co_drain_begin.patch
241
+ # For bz#2155112 - Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled)
242
+ Patch47: kvm-test-bdrv-drain-Don-t-yield-in-.bdrv_co_drained_begi.patch
243
+ # For bz#2155112 - Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled)
244
+ Patch48: kvm-block-Revert-.bdrv_drained_begin-end-to-non-coroutin.patch
245
+ # For bz#2155112 - Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled)
246
+ Patch49: kvm-block-Remove-drained_end_counter.patch
247
+ # For bz#2155112 - Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled)
248
+ Patch50: kvm-block-Inline-bdrv_drain_invoke.patch
249
+ # For bz#2155112 - Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled)
250
+ Patch51: kvm-block-Fix-locking-for-bdrv_reopen_queue_child.patch
251
+ # For bz#2155112 - Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled)
252
+ Patch52: kvm-block-Drain-individual-nodes-during-reopen.patch
253
+ # For bz#2155112 - Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled)
254
+ Patch53: kvm-block-Don-t-use-subtree-drains-in-bdrv_drop_intermed.patch
255
+ # For bz#2155112 - Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled)
256
+ Patch54: kvm-stream-Replace-subtree-drain-with-a-single-node-drai.patch
257
+ # For bz#2155112 - Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled)
258
+ Patch55: kvm-block-Remove-subtree-drains.patch
259
+ # For bz#2155112 - Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled)
260
+ Patch56: kvm-block-Call-drain-callbacks-only-once.patch
261
+ # For bz#2155112 - Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled)
262
+ Patch57: kvm-block-Remove-ignore_bds_parents-parameter-from-drain.patch
263
+ # For bz#2155112 - Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled)
264
+ Patch58: kvm-block-Drop-out-of-coroutine-in-bdrv_do_drained_begin.patch
265
+ # For bz#2155112 - Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled)
266
+ Patch59: kvm-block-Don-t-poll-in-bdrv_replace_child_noperm.patch
267
+ # For bz#2155112 - Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled)
268
+ Patch60: kvm-block-Remove-poll-parameter-from-bdrv_parent_drained.patch
269
+ # For bz#1979276 - SVM: non atomic memslot updates cause boot failure with seabios and cpu-pm=on
270
+ Patch61: kvm-accel-introduce-accelerator-blocker-API.patch
271
+ # For bz#1979276 - SVM: non atomic memslot updates cause boot failure with seabios and cpu-pm=on
272
+ Patch62: kvm-KVM-keep-track-of-running-ioctls.patch
273
+ # For bz#1979276 - SVM: non atomic memslot updates cause boot failure with seabios and cpu-pm=on
274
+ Patch63: kvm-kvm-Atomic-memslot-updates.patch
275
+ # For bz#2141088 - vDPA SVQ guest announce support
276
+ Patch64: kvm-virtio_net-Modify-virtio_net_get_config-to-early-ret.patch
277
+ # For bz#2141088 - vDPA SVQ guest announce support
278
+ Patch65: kvm-virtio_net-copy-VIRTIO_NET_S_ANNOUNCE-if-device-mode.patch
279
+ # For bz#2141088 - vDPA SVQ guest announce support
280
+ Patch66: kvm-vdpa-handle-VIRTIO_NET_CTRL_ANNOUNCE-in-vhost_vdpa_n.patch
281
+ # For bz#2141088 - vDPA SVQ guest announce support
282
+ Patch67: kvm-vdpa-do-not-handle-VIRTIO_NET_F_GUEST_ANNOUNCE-in-vh.patch
283
+ # For bz#2122523 - Secure guest can't boot with maximal number of vcpus (248)
284
+ Patch68: kvm-s390x-pv-Implement-a-CGS-check-helper.patch
285
+ # For bz#2163701 - [s390x] VM fails to start with ISM passed through
286
+ Patch69: kvm-s390x-pci-coalesce-unmap-operations.patch
287
+ # For bz#2163701 - [s390x] VM fails to start with ISM passed through
288
+ Patch70: kvm-s390x-pci-shrink-DMA-aperture-to-be-bound-by-vfio-DM.patch
289
+ # For bz#2163701 - [s390x] VM fails to start with ISM passed through
290
+ Patch71: kvm-s390x-pci-reset-ISM-passthrough-devices-on-shutdown-.patch
291
+ # For bz#2149191 - [RFE][guest-agent] - USB bus type support
292
+ Patch72: kvm-qga-linux-add-usb-support-to-guest-get-fsinfo.patch
293
+ # For bz#2104412 - vDPA ASID support in Qemu
294
+ Patch73: kvm-vdpa-use-v-shadow_vqs_enabled-in-vhost_vdpa_svqs_sta.patch
295
+ # For bz#2104412 - vDPA ASID support in Qemu
296
+ Patch74: kvm-vhost-set-SVQ-device-call-handler-at-SVQ-start.patch
297
+ # For bz#2104412 - vDPA ASID support in Qemu
298
+ Patch75: kvm-vhost-allocate-SVQ-device-file-descriptors-at-device.patch
299
+ # For bz#2104412 - vDPA ASID support in Qemu
300
+ Patch76: kvm-vhost-move-iova_tree-set-to-vhost_svq_start.patch
301
+ # For bz#2104412 - vDPA ASID support in Qemu
302
+ Patch77: kvm-vdpa-add-vhost_vdpa_net_valid_svq_features.patch
303
+ # For bz#2104412 - vDPA ASID support in Qemu
304
+ Patch78: kvm-vdpa-request-iova_range-only-once.patch
305
+ # For bz#2104412 - vDPA ASID support in Qemu
306
+ Patch79: kvm-vdpa-move-SVQ-vring-features-check-to-net.patch
307
+ # For bz#2104412 - vDPA ASID support in Qemu
308
+ Patch80: kvm-vdpa-allocate-SVQ-array-unconditionally.patch
309
+ # For bz#2104412 - vDPA ASID support in Qemu
310
+ Patch81: kvm-vdpa-add-asid-parameter-to-vhost_vdpa_dma_map-unmap.patch
311
+ # For bz#2104412 - vDPA ASID support in Qemu
312
+ Patch82: kvm-vdpa-store-x-svq-parameter-in-VhostVDPAState.patch
313
+ # For bz#2104412 - vDPA ASID support in Qemu
314
+ Patch83: kvm-vdpa-add-shadow_data-to-vhost_vdpa.patch
315
+ # For bz#2104412 - vDPA ASID support in Qemu
316
+ Patch84: kvm-vdpa-always-start-CVQ-in-SVQ-mode-if-possible.patch
317
+ # For bz#2104412 - vDPA ASID support in Qemu
318
+ Patch85: kvm-vdpa-fix-VHOST_BACKEND_F_IOTLB_ASID-flag-check.patch
319
+ # For bz#2150180 - qemu-img finishes successfully while having errors in commit or bitmaps operations
320
+ Patch86: kvm-qcow2-Fix-theoretical-corruption-in-store_bitmap-err.patch
321
+ # For bz#2150180 - qemu-img finishes successfully while having errors in commit or bitmaps operations
322
+ Patch87: kvm-qemu-img-commit-Report-errors-while-closing-the-imag.patch
323
+ # For bz#2150180 - qemu-img finishes successfully while having errors in commit or bitmaps operations
324
+ Patch88: kvm-qemu-img-bitmap-Report-errors-while-closing-the-imag.patch
325
+ # For bz#2150180 - qemu-img finishes successfully while having errors in commit or bitmaps operations
326
+ Patch89: kvm-qemu-iotests-Test-qemu-img-bitmap-commit-exit-code-o.patch
327
+ # For bz#2165280 - [kvm-unit-tests] debug-wp-migration fails
328
+ Patch90: kvm-accel-tcg-Test-CPUJumpCache-in-tb_jmp_cache_clear_pa.patch
329
+ # For bz#1860292 - RFE: add extent_size_hint information to qemu-img info
330
+ Patch91: kvm-block-Improve-empty-format-specific-info-dump.patch
331
+ # For bz#1860292 - RFE: add extent_size_hint information to qemu-img info
332
+ Patch92: kvm-block-file-Add-file-specific-image-info.patch
333
+ # For bz#1860292 - RFE: add extent_size_hint information to qemu-img info
334
+ Patch93: kvm-block-vmdk-Change-extent-info-type.patch
335
+ # For bz#1860292 - RFE: add extent_size_hint information to qemu-img info
336
+ Patch94: kvm-block-Split-BlockNodeInfo-off-of-ImageInfo.patch
337
+ # For bz#1860292 - RFE: add extent_size_hint information to qemu-img info
338
+ Patch95: kvm-qemu-img-Use-BlockNodeInfo.patch
339
+ # For bz#1860292 - RFE: add extent_size_hint information to qemu-img info
340
+ Patch96: kvm-block-qapi-Let-bdrv_query_image_info-recurse.patch
341
+ # For bz#1860292 - RFE: add extent_size_hint information to qemu-img info
342
+ Patch97: kvm-block-qapi-Introduce-BlockGraphInfo.patch
343
+ # For bz#1860292 - RFE: add extent_size_hint information to qemu-img info
344
+ Patch98: kvm-block-qapi-Add-indentation-to-bdrv_node_info_dump.patch
345
+ # For bz#1860292 - RFE: add extent_size_hint information to qemu-img info
346
+ Patch99: kvm-iotests-Filter-child-node-information.patch
347
+ # For bz#1860292 - RFE: add extent_size_hint information to qemu-img info
348
+ Patch100: kvm-iotests-106-214-308-Read-only-one-size-line.patch
349
+ # For bz#1860292 - RFE: add extent_size_hint information to qemu-img info
350
+ Patch101: kvm-qemu-img-Let-info-print-block-graph.patch
351
+ # For bz#1860292 - RFE: add extent_size_hint information to qemu-img info
352
+ Patch102: kvm-qemu-img-Change-info-key-names-for-protocol-nodes.patch
353
+ # For bz#2155173 - [vhost-user] unable to start vhost net: 71: falling back on userspace
354
+ Patch103: kvm-Revert-vhost-user-Monitor-slave-channel-in-vhost_use.patch
355
+ # For bz#2155173 - [vhost-user] unable to start vhost net: 71: falling back on userspace
356
+ Patch104: kvm-Revert-vhost-user-Introduce-nested-event-loop-in-vho.patch
357
+ # For bz#2162569 - [transitional device][virtio-rng-pci-transitional]Stable Guest ABI failed between RHEL 8.6 to RHEL 9.2
358
+ Patch105: kvm-virtio-rng-pci-fix-transitional-migration-compat-for.patch
359
+ # For bz#2169232 - RFE: reconnect option for stream socket back-end
360
+ Patch106: kvm-tests-qtest-netdev-test-stream-and-dgram-backends.patch
361
+ # For bz#2169232 - RFE: reconnect option for stream socket back-end
362
+ Patch107: kvm-net-stream-add-a-new-option-to-automatically-reconne.patch
363
+ # For bz#2158704 - RFE: Prefer /dev/userfaultfd over userfaultfd(2) syscall
364
+ Patch108: kvm-linux-headers-Update-to-v6.1.patch
365
+ # For bz#2158704 - RFE: Prefer /dev/userfaultfd over userfaultfd(2) syscall
366
+ Patch109: kvm-util-userfaultfd-Add-uffd_open.patch
367
+ # For bz#2158704 - RFE: Prefer /dev/userfaultfd over userfaultfd(2) syscall
368
+ Patch110: kvm-util-userfaultfd-Support-dev-userfaultfd.patch
369
+ # For bz#2169732 - Multifd migration fails under a weak network/socket ordering race
370
+ Patch111: kvm-io-Add-support-for-MSG_PEEK-for-socket-channel.patch
371
+ # For bz#2169732 - Multifd migration fails under a weak network/socket ordering race
372
+ Patch112: kvm-migration-check-magic-value-for-deciding-the-mapping.patch
373
+ # For bz#2168172 - [s390x] qemu-kvm coredumps when SE crashes
374
+ Patch113: kvm-target-s390x-arch_dump-Fix-memory-corruption-in-s390.patch
375
+ # For bz#2168209 - Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled)
376
+ Patch114: kvm-block-temporarily-hold-the-new-AioContext-of-bs_top-.patch
380
- Patch113: kvm-vdpa-Avoid-compiler-to-squash-reads-to-used-idx.patch
381
- # For bz#1939363 - vDPA control virtqueue support in Qemu
382
- Patch114: kvm-vhost-Reorder-vhost_svq_kick.patch
383
- # For bz#1939363 - vDPA control virtqueue support in Qemu
384
- Patch115: kvm-vhost-Move-vhost_svq_kick-call-to-vhost_svq_add.patch
385
- # For bz#1939363 - vDPA control virtqueue support in Qemu
386
- Patch116: kvm-vhost-Check-for-queue-full-at-vhost_svq_add.patch
387
- # For bz#1939363 - vDPA control virtqueue support in Qemu
388
- Patch117: kvm-vhost-Decouple-vhost_svq_add-from-VirtQueueElement.patch
389
- # For bz#1939363 - vDPA control virtqueue support in Qemu
390
- Patch118: kvm-vhost-Add-SVQDescState.patch
391
- # For bz#1939363 - vDPA control virtqueue support in Qemu
392
- Patch119: kvm-vhost-Track-number-of-descs-in-SVQDescState.patch
393
- # For bz#1939363 - vDPA control virtqueue support in Qemu
394
- Patch120: kvm-vhost-add-vhost_svq_push_elem.patch
395
- # For bz#1939363 - vDPA control virtqueue support in Qemu
396
- Patch121: kvm-vhost-Expose-vhost_svq_add.patch
397
- # For bz#1939363 - vDPA control virtqueue support in Qemu
398
- Patch122: kvm-vhost-add-vhost_svq_poll.patch
399
- # For bz#1939363 - vDPA control virtqueue support in Qemu
400
- Patch123: kvm-vhost-Add-svq-avail_handler-callback.patch
401
- # For bz#1939363 - vDPA control virtqueue support in Qemu
402
- Patch124: kvm-vdpa-Export-vhost_vdpa_dma_map-and-unmap-calls.patch
403
- # For bz#1939363 - vDPA control virtqueue support in Qemu
404
- Patch125: kvm-vhost-net-vdpa-add-stubs-for-when-no-virtio-net-devi.patch
405
- # For bz#1939363 - vDPA control virtqueue support in Qemu
406
- Patch126: kvm-vdpa-manual-forward-CVQ-buffers.patch
407
- # For bz#1939363 - vDPA control virtqueue support in Qemu
408
- Patch127: kvm-vdpa-Buffer-CVQ-support-on-shadow-virtqueue.patch
409
- # For bz#1939363 - vDPA control virtqueue support in Qemu
410
- Patch128: kvm-vdpa-Extract-get-features-part-from-vhost_vdpa_get_m.patch
411
- # For bz#1939363 - vDPA control virtqueue support in Qemu
412
- Patch129: kvm-vdpa-Add-device-migration-blocker.patch
413
- # For bz#1939363 - vDPA control virtqueue support in Qemu
414
- Patch130: kvm-vdpa-Add-x-svq-to-NetdevVhostVDPAOptions.patch
415
- # For bz#2111994 - RHEL9: skey test in kvm_unit_test got failed
416
- Patch131: kvm-redhat-Update-linux-headers-linux-kvm.h-to-v5.18-rc6.patch
417
- # For bz#2111994 - RHEL9: skey test in kvm_unit_test got failed
418
- Patch132: kvm-target-s390x-kvm-Honor-storage-keys-during-emulation.patch
419
- # For bz#2095608 - Please correct the error message when try to start qemu with "-M kernel-irqchip=split"
420
- Patch133: kvm-kvm-don-t-use-perror-without-useful-errno.patch
421
- # For bz#2099934 - Guest reboot on destination host after postcopy migration completed
422
- Patch134: kvm-multifd-Copy-pages-before-compressing-them-with-zlib.patch
423
- # For bz#2099934 - Guest reboot on destination host after postcopy migration completed
424
- Patch135: kvm-Revert-migration-Simplify-unqueue_page.patch
425
- # For bz#2107466 - zerocopy capability can be enabled when set migrate capabilities with multifd and compress/xbzrle together
426
- Patch136: kvm-QIOChannelSocket-Fix-zero-copy-flush-returning-code-.patch
427
- # For bz#2107466 - zerocopy capability can be enabled when set migrate capabilities with multifd and compress/xbzrle together
428
- Patch137: kvm-Add-dirty-sync-missed-zero-copy-migration-stat.patch
429
- # For bz#2107466 - zerocopy capability can be enabled when set migrate capabilities with multifd and compress/xbzrle together
430
- Patch138: kvm-migration-multifd-Report-to-user-when-zerocopy-not-w.patch
431
- # For bz#2107466 - zerocopy capability can be enabled when set migrate capabilities with multifd and compress/xbzrle together
432
- Patch139: kvm-migration-Avoid-false-positive-on-non-supported-scen.patch
433
- # For bz#2107466 - zerocopy capability can be enabled when set migrate capabilities with multifd and compress/xbzrle together
434
- Patch140: kvm-migration-add-remaining-params-has_-true-in-migratio.patch
435
- # For bz#2107466 - zerocopy capability can be enabled when set migrate capabilities with multifd and compress/xbzrle together
436
- Patch141: kvm-QIOChannelSocket-Add-support-for-MSG_ZEROCOPY-IPV6.patch
437
- # For bz#2112303 - virtio-blk: Can't boot fresh installation from used 512 cluster_size image under certain conditions
438
- Patch142: kvm-pc-bios-s390-ccw-Fix-booting-with-logical-block-size.patch
439
- # For bz#2116876 - Fixes for vDPA control virtqueue support in Qemu
440
- Patch143: kvm-vdpa-Fix-bad-index-calculus-at-vhost_vdpa_get_vring_.patch
441
- # For bz#2116876 - Fixes for vDPA control virtqueue support in Qemu
442
- Patch144: kvm-vdpa-Fix-index-calculus-at-vhost_vdpa_svqs_start.patch
443
- # For bz#2116876 - Fixes for vDPA control virtqueue support in Qemu
444
- Patch145: kvm-vdpa-Fix-memory-listener-deletions-of-iova-tree.patch
445
- # For bz#2116876 - Fixes for vDPA control virtqueue support in Qemu
446
- Patch146: kvm-vdpa-Fix-file-descriptor-leak-on-get-features-error.patch
447
-
448
- # Source-git patches
449
377
450
378
%if %{have_clang}
451
379
BuildRequires: clang
@@ -516,6 +444,7 @@ BuildRequires: perl-Test-Harness
516
444
BuildRequires: libslirp-devel
517
445
BuildRequires: pulseaudio-libs-devel
518
446
BuildRequires: spice-protocol
447
+ BuildRequires: capstone-devel
519
448
520
449
# Requires for qemu-kvm package
521
450
Requires: %{name}-core = %{epoch}:%{version}-%{release}
@@ -546,6 +475,7 @@ Requires: edk2-aarch64
546
475
547
476
Requires: libseccomp >= %{libseccomp_version}
548
477
Requires: libusbx >= %{libusbx_version}
478
+ Requires: capstone
549
479
%if %{have_fdt}
550
480
Requires: libfdt >= %{libfdt_version}
551
481
%endif
@@ -580,6 +510,10 @@ Requires: seabios-bin >= 1.10.2-1
580
510
Requires: seavgabios-bin >= 1.12.0-3
581
511
Requires: ipxe-roms-qemu >= %{ipxe_version}
582
512
%endif
513
+ # Removal -gl modules as they do not provide any functionality - see bz#2149022
514
+ Obsoletes: %{name}-device-display-virtio-gpu-gl <= %{epoch}:%{version}
515
+ Obsoletes: %{name}-device-display-virtio-gpu-pci-gl <= %{epoch}:%{version}
516
+ Obsoletes: %{name}-device-display-virtio-vga-gl <= %{epoch}:%{version}
583
517
584
518
%description common
585
519
%{name} is an open source virtualizer that provides hardware emulation for
@@ -696,30 +630,20 @@ Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release}
696
630
%description device-display-virtio-gpu
697
631
This package provides the virtio-gpu display device for QEMU.
698
632
699
- %package device-display-virtio-gpu-gl
700
- Summary: QEMU virtio-gpu-gl display device
701
- Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release}
702
- %description device-display-virtio-gpu-gl
703
- This package provides the virtio-gpu-gl display device for QEMU.
704
-
705
633
%ifarch s390x
706
634
%package device-display-virtio-gpu-ccw
707
635
Summary: QEMU virtio-gpu-ccw display device
708
636
Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release}
637
+ Requires: %{name}-device-display-virtio-gpu = %{epoch}:%{version}-%{release}
709
638
%description device-display-virtio-gpu-ccw
710
639
This package provides the virtio-gpu-ccw display device for QEMU.
711
640
%else
712
641
%package device-display-virtio-gpu-pci
713
642
Summary: QEMU virtio-gpu-pci display device
714
643
Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release}
644
+ Requires: %{name}-device-display-virtio-gpu = %{epoch}:%{version}-%{release}
715
645
%description device-display-virtio-gpu-pci
716
646
This package provides the virtio-gpu-pci display device for QEMU.
717
-
718
- %package device-display-virtio-gpu-pci-gl
719
- Summary: QEMU virtio-gpu-pci-gl display device
720
- Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release}
721
- %description device-display-virtio-gpu-pci-gl
722
- This package provides the virtio-gpu-pci-gl display device for QEMU.
723
647
%endif
724
648
725
649
%ifarch x86_64 %{power64}
@@ -728,12 +652,6 @@ Summary: QEMU virtio-vga display device
728
652
Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release}
729
653
%description device-display-virtio-vga
730
654
This package provides the virtio-vga display device for QEMU.
731
-
732
- %package device-display-virtio-vga-gl
733
- Summary: QEMU virtio-vga-gl display device
734
- Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release}
735
- %description device-display-virtio-vga-gl
736
- This package provides the virtio-vga-gl display device for QEMU.
737
655
%endif
738
656
739
657
%package device-usb-host
@@ -763,6 +681,10 @@ mkdir -p %{qemu_kvm_build}
763
681
764
682
765
683
%build
684
+
685
+ # Necessary hack for ZUUL CI
686
+ ulimit -n 10240
687
+
766
688
%define disable_everything \\\
767
689
--audio-drv-list= \\\
768
690
--disable-alsa \\\
@@ -770,6 +692,7 @@ mkdir -p %{qemu_kvm_build}
770
692
--disable-auth-pam \\\
771
693
--disable-avx2 \\\
772
694
--disable-avx512f \\\
695
+ --disable-blkio \\\
773
696
--disable-block-drv-whitelist-in-tools \\\
774
697
--disable-bochs \\\
775
698
--disable-bpf \\\
@@ -818,6 +741,7 @@ mkdir -p %{qemu_kvm_build}
818
741
--disable-libssh \\\
819
742
--disable-libudev \\\
820
743
--disable-libusb \\\
744
+ --disable-libvduse \\\
821
745
--disable-linux-aio \\\
822
746
--disable-linux-io-uring \\\
823
747
--disable-linux-user \\\
@@ -859,6 +783,7 @@ mkdir -p %{qemu_kvm_build}
859
783
--disable-slirp-smbd \\\
860
784
--disable-smartcard \\\
861
785
--disable-snappy \\\
786
+ --disable-sndio \\\
862
787
--disable-sparse \\\
863
788
--disable-spice \\\
864
789
--disable-spice-protocol \\\
@@ -872,20 +797,19 @@ mkdir -p %{qemu_kvm_build}
872
797
--disable-user \\\
873
798
--disable-vde \\\
874
799
--disable-vdi \\\
800
+ --disable-vduse-blk-export \\\
875
801
--disable-vhost-crypto \\\
876
802
--disable-vhost-kernel \\\
877
803
--disable-vhost-net \\\
878
- --disable-vhost-scsi \\\
879
804
--disable-vhost-user \\\
880
805
--disable-vhost-user-blk-server \\\
881
806
--disable-vhost-vdpa \\\
882
- --disable-vhost-vsock \\\
883
807
--disable-virglrenderer \\\
884
808
--disable-virtfs \\\
885
809
--disable-virtiofsd \\\
886
810
--disable-vnc \\\
887
811
--disable-vnc-jpeg \\\
888
- --disable-vnc-png \\\
812
+ --disable-png \\\
889
813
--disable-vnc-sasl \\\
890
814
--disable-vte \\\
891
815
--disable-vvfat \\\
@@ -916,7 +840,7 @@ run_configure() {
916
840
--with-pkgversion="%{name}-%{version}-%{release}" \
917
841
--with-suffix="%{name}" \
918
842
--firmwarepath=%{firmwaredirs} \
919
- --meson="internal" \
843
+ --meson="%{__meson}" \
920
844
--enable-trace-backend=dtrace \
921
845
--with-coroutine=ucontext \
922
846
--with-git=git \
@@ -945,7 +869,7 @@ run_configure \
945
869
%endif
946
870
--enable-attr \
947
871
--enable-cap-ng \
948
- --enable-capstone=internal \
872
+ --enable-capstone \
949
873
--enable-coroutine-pool \
950
874
--enable-curl \
951
875
--enable-debug-info \
@@ -983,7 +907,7 @@ run_configure \
983
907
%endif
984
908
--enable-seccomp \
985
909
--enable-selinux \
986
- --enable-slirp=system \
910
+ --enable-slirp \
987
911
--enable-snappy \
988
912
--enable-spice-protocol \
989
913
--enable-system \
@@ -1000,9 +924,8 @@ run_configure \
1000
924
--enable-vhost-user \
1001
925
--enable-vhost-user-blk-server \
1002
926
--enable-vhost-vdpa \
1003
- --enable-vhost-vsock \
1004
927
--enable-vnc \
1005
- --enable-vnc-png \
928
+ --enable-png \
1006
929
--enable-vnc-sasl \
1007
930
%if %{enable_werror}
1008
931
--enable-werror \
@@ -1269,6 +1192,16 @@ install -D -m 0644 %{_sourcedir}/bridge.conf %{buildroot}%{_sysconfdir}/%{name}/
1269
1192
install -m 0644 contrib/systemd/qemu-pr-helper.service %{buildroot}%{_unitdir}
1270
1193
install -m 0644 contrib/systemd/qemu-pr-helper.socket %{buildroot}%{_unitdir}
1271
1194
1195
+ # We do not support gl display devices so we can remove their modules as they
1196
+ # do not have expected functionality included.
1197
+ #
1198
+ # https://gitlab.com/qemu-project/qemu/-/issues/1352 was filed to stop building these
1199
+ # modules in case all dependencies are not satisfied.
1200
+
1201
+ rm -rf %{buildroot}%{_libdir}/%{name}/hw-display-virtio-gpu-gl.so
1202
+ rm -rf %{buildroot}%{_libdir}/%{name}/hw-display-virtio-gpu-pci-gl.so
1203
+ rm -rf %{buildroot}%{_libdir}/%{name}/hw-display-virtio-vga-gl.so
1204
+
1272
1205
# We need to make the block device modules and other qemu SO files executable
1273
1206
# otherwise RPM won't pick up their dependencies.
1274
1207
chmod +x %{buildroot}%{_libdir}/%{name}/*.so
@@ -1426,25 +1359,17 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \
1426
1359
%files device-display-virtio-gpu
1427
1360
%{_libdir}/%{name}/hw-display-virtio-gpu.so
1428
1361
1429
- %files device-display-virtio-gpu-gl
1430
- %{_libdir}/%{name}/hw-display-virtio-gpu-gl.so
1431
-
1432
1362
%ifarch s390x
1433
1363
%files device-display-virtio-gpu-ccw
1434
1364
%{_libdir}/%{name}/hw-s390x-virtio-gpu-ccw.so
1435
1365
%else
1436
1366
%files device-display-virtio-gpu-pci
1437
1367
%{_libdir}/%{name}/hw-display-virtio-gpu-pci.so
1438
-
1439
- %files device-display-virtio-gpu-pci-gl
1440
- %{_libdir}/%{name}/hw-display-virtio-gpu-pci-gl.so
1441
1368
%endif
1442
1369
1443
1370
%ifarch x86_64 %{power64}
1444
1371
%files device-display-virtio-vga
1445
1372
%{_libdir}/%{name}/hw-display-virtio-vga.so
1446
- %files device-display-virtio-vga-gl
1447
- %{_libdir}/%{name}/hw-display-virtio-vga-gl.so
1448
1373
%endif
1449
1374
1450
1375
%files tests
@@ -1479,6 +1404,244 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \
1479
1404
%endif
1480
1405
1481
1406
%changelog
1407
+ * Tue Feb 21 2023 Miroslav Rezanina <mrezanin@redhat.com> - 7.2.0-10
1408
+ - kvm-block-temporarily-hold-the-new-AioContext-of-bs_top-.patch [bz#2168209]
1409
+ - Resolves: bz#2168209
1410
+ (Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled))
1411
+
1412
+ * Fri Feb 17 2023 Miroslav Rezanina <mrezanin@redhat.com> - 7.2.0-9
1413
+ - kvm-tests-qtest-netdev-test-stream-and-dgram-backends.patch [bz#2169232]
1414
+ - kvm-net-stream-add-a-new-option-to-automatically-reconne.patch [bz#2169232]
1415
+ - kvm-linux-headers-Update-to-v6.1.patch [bz#2158704]
1416
+ - kvm-util-userfaultfd-Add-uffd_open.patch [bz#2158704]
1417
+ - kvm-util-userfaultfd-Support-dev-userfaultfd.patch [bz#2158704]
1418
+ - kvm-io-Add-support-for-MSG_PEEK-for-socket-channel.patch [bz#2169732]
1419
+ - kvm-migration-check-magic-value-for-deciding-the-mapping.patch [bz#2169732]
1420
+ - kvm-target-s390x-arch_dump-Fix-memory-corruption-in-s390.patch [bz#2168172]
1421
+ - Resolves: bz#2169232
1422
+ (RFE: reconnect option for stream socket back-end)
1423
+ - Resolves: bz#2158704
1424
+ (RFE: Prefer /dev/userfaultfd over userfaultfd(2) syscall)
1425
+ - Resolves: bz#2169732
1426
+ (Multifd migration fails under a weak network/socket ordering race)
1427
+ - Resolves: bz#2168172
1428
+ ([s390x] qemu-kvm coredumps when SE crashes)
1429
+
1430
+ * Thu Feb 09 2023 Miroslav Rezanina <mrezanin@redhat.com> - 7.2.0-8
1431
+ - kvm-qcow2-Fix-theoretical-corruption-in-store_bitmap-err.patch [bz#2150180]
1432
+ - kvm-qemu-img-commit-Report-errors-while-closing-the-imag.patch [bz#2150180]
1433
+ - kvm-qemu-img-bitmap-Report-errors-while-closing-the-imag.patch [bz#2150180]
1434
+ - kvm-qemu-iotests-Test-qemu-img-bitmap-commit-exit-code-o.patch [bz#2150180]
1435
+ - kvm-accel-tcg-Test-CPUJumpCache-in-tb_jmp_cache_clear_pa.patch [bz#2165280]
1436
+ - kvm-block-Improve-empty-format-specific-info-dump.patch [bz#1860292]
1437
+ - kvm-block-file-Add-file-specific-image-info.patch [bz#1860292]
1438
+ - kvm-block-vmdk-Change-extent-info-type.patch [bz#1860292]
1439
+ - kvm-block-Split-BlockNodeInfo-off-of-ImageInfo.patch [bz#1860292]
1440
+ - kvm-qemu-img-Use-BlockNodeInfo.patch [bz#1860292]
1441
+ - kvm-block-qapi-Let-bdrv_query_image_info-recurse.patch [bz#1860292]
1442
+ - kvm-block-qapi-Introduce-BlockGraphInfo.patch [bz#1860292]
1443
+ - kvm-block-qapi-Add-indentation-to-bdrv_node_info_dump.patch [bz#1860292]
1444
+ - kvm-iotests-Filter-child-node-information.patch [bz#1860292]
1445
+ - kvm-iotests-106-214-308-Read-only-one-size-line.patch [bz#1860292]
1446
+ - kvm-qemu-img-Let-info-print-block-graph.patch [bz#1860292]
1447
+ - kvm-qemu-img-Change-info-key-names-for-protocol-nodes.patch [bz#1860292]
1448
+ - kvm-Revert-vhost-user-Monitor-slave-channel-in-vhost_use.patch [bz#2155173]
1449
+ - kvm-Revert-vhost-user-Introduce-nested-event-loop-in-vho.patch [bz#2155173]
1450
+ - kvm-virtio-rng-pci-fix-transitional-migration-compat-for.patch [bz#2162569]
1451
+ - Resolves: bz#2150180
1452
+ (qemu-img finishes successfully while having errors in commit or bitmaps operations)
1453
+ - Resolves: bz#2165280
1454
+ ([kvm-unit-tests] debug-wp-migration fails)
1455
+ - Resolves: bz#1860292
1456
+ (RFE: add extent_size_hint information to qemu-img info)
1457
+ - Resolves: bz#2155173
1458
+ ([vhost-user] unable to start vhost net: 71: falling back on userspace)
1459
+ - Resolves: bz#2162569
1460
+ ([transitional device][virtio-rng-pci-transitional]Stable Guest ABI failed between RHEL 8.6 to RHEL 9.2)
1461
+
1462
+ * Mon Feb 06 2023 Miroslav Rezanina <mrezanin@redhat.com> - 7.2.0-7
1463
+ - kvm-vdpa-use-v-shadow_vqs_enabled-in-vhost_vdpa_svqs_sta.patch [bz#2104412]
1464
+ - kvm-vhost-set-SVQ-device-call-handler-at-SVQ-start.patch [bz#2104412]
1465
+ - kvm-vhost-allocate-SVQ-device-file-descriptors-at-device.patch [bz#2104412]
1466
+ - kvm-vhost-move-iova_tree-set-to-vhost_svq_start.patch [bz#2104412]
1467
+ - kvm-vdpa-add-vhost_vdpa_net_valid_svq_features.patch [bz#2104412]
1468
+ - kvm-vdpa-request-iova_range-only-once.patch [bz#2104412]
1469
+ - kvm-vdpa-move-SVQ-vring-features-check-to-net.patch [bz#2104412]
1470
+ - kvm-vdpa-allocate-SVQ-array-unconditionally.patch [bz#2104412]
1471
+ - kvm-vdpa-add-asid-parameter-to-vhost_vdpa_dma_map-unmap.patch [bz#2104412]
1472
+ - kvm-vdpa-store-x-svq-parameter-in-VhostVDPAState.patch [bz#2104412]
1473
+ - kvm-vdpa-add-shadow_data-to-vhost_vdpa.patch [bz#2104412]
1474
+ - kvm-vdpa-always-start-CVQ-in-SVQ-mode-if-possible.patch [bz#2104412]
1475
+ - kvm-vdpa-fix-VHOST_BACKEND_F_IOTLB_ASID-flag-check.patch [bz#2104412]
1476
+ - kvm-spec-Disable-VDUSE.patch [bz#2128222]
1477
+ - Resolves: bz#2104412
1478
+ (vDPA ASID support in Qemu)
1479
+ - Resolves: bz#2128222
1480
+ (VDUSE block export should be disabled in builds for now)
1481
+
1482
+ * Mon Jan 30 2023 Miroslav Rezanina <mrezanin@redhat.com> - 7.2.0-6
1483
+ - kvm-virtio_net-Modify-virtio_net_get_config-to-early-ret.patch [bz#2141088]
1484
+ - kvm-virtio_net-copy-VIRTIO_NET_S_ANNOUNCE-if-device-mode.patch [bz#2141088]
1485
+ - kvm-vdpa-handle-VIRTIO_NET_CTRL_ANNOUNCE-in-vhost_vdpa_n.patch [bz#2141088]
1486
+ - kvm-vdpa-do-not-handle-VIRTIO_NET_F_GUEST_ANNOUNCE-in-vh.patch [bz#2141088]
1487
+ - kvm-s390x-pv-Implement-a-CGS-check-helper.patch [bz#2122523]
1488
+ - kvm-s390x-pci-coalesce-unmap-operations.patch [bz#2163701]
1489
+ - kvm-s390x-pci-shrink-DMA-aperture-to-be-bound-by-vfio-DM.patch [bz#2163701]
1490
+ - kvm-s390x-pci-reset-ISM-passthrough-devices-on-shutdown-.patch [bz#2163701]
1491
+ - kvm-qga-linux-add-usb-support-to-guest-get-fsinfo.patch [bz#2149191]
1492
+ - Resolves: bz#2141088
1493
+ (vDPA SVQ guest announce support)
1494
+ - Resolves: bz#2122523
1495
+ (Secure guest can't boot with maximal number of vcpus (248))
1496
+ - Resolves: bz#2163701
1497
+ ([s390x] VM fails to start with ISM passed through)
1498
+ - Resolves: bz#2149191
1499
+ ([RFE][guest-agent] - USB bus type support)
1500
+
1501
+ * Tue Jan 17 2023 Miroslav Rezanina <mrezanin@redhat.com> - 7.2.0-5
1502
+ - kvm-virtio-introduce-macro-VIRTIO_CONFIG_IRQ_IDX.patch [bz#1905805]
1503
+ - kvm-virtio-pci-decouple-notifier-from-interrupt-process.patch [bz#1905805]
1504
+ - kvm-virtio-pci-decouple-the-single-vector-from-the-inter.patch [bz#1905805]
1505
+ - kvm-vhost-introduce-new-VhostOps-vhost_set_config_call.patch [bz#1905805]
1506
+ - kvm-vhost-vdpa-add-support-for-config-interrupt.patch [bz#1905805]
1507
+ - kvm-virtio-add-support-for-configure-interrupt.patch [bz#1905805]
1508
+ - kvm-vhost-add-support-for-configure-interrupt.patch [bz#1905805]
1509
+ - kvm-virtio-net-add-support-for-configure-interrupt.patch [bz#1905805]
1510
+ - kvm-virtio-mmio-add-support-for-configure-interrupt.patch [bz#1905805]
1511
+ - kvm-virtio-pci-add-support-for-configure-interrupt.patch [bz#1905805]
1512
+ - kvm-s390x-s390-virtio-ccw-Activate-zPCI-features-on-s390.patch [bz#2159408]
1513
+ - kvm-vhost-fix-vq-dirty-bitmap-syncing-when-vIOMMU-is-ena.patch [bz#2124856]
1514
+ - kvm-block-drop-bdrv_remove_filter_or_cow_child.patch [bz#2155112]
1515
+ - kvm-qed-Don-t-yield-in-bdrv_qed_co_drain_begin.patch [bz#2155112]
1516
+ - kvm-test-bdrv-drain-Don-t-yield-in-.bdrv_co_drained_begi.patch [bz#2155112]
1517
+ - kvm-block-Revert-.bdrv_drained_begin-end-to-non-coroutin.patch [bz#2155112]
1518
+ - kvm-block-Remove-drained_end_counter.patch [bz#2155112]
1519
+ - kvm-block-Inline-bdrv_drain_invoke.patch [bz#2155112]
1520
+ - kvm-block-Fix-locking-for-bdrv_reopen_queue_child.patch [bz#2155112]
1521
+ - kvm-block-Drain-individual-nodes-during-reopen.patch [bz#2155112]
1522
+ - kvm-block-Don-t-use-subtree-drains-in-bdrv_drop_intermed.patch [bz#2155112]
1523
+ - kvm-stream-Replace-subtree-drain-with-a-single-node-drai.patch [bz#2155112]
1524
+ - kvm-block-Remove-subtree-drains.patch [bz#2155112]
1525
+ - kvm-block-Call-drain-callbacks-only-once.patch [bz#2155112]
1526
+ - kvm-block-Remove-ignore_bds_parents-parameter-from-drain.patch [bz#2155112]
1527
+ - kvm-block-Drop-out-of-coroutine-in-bdrv_do_drained_begin.patch [bz#2155112]
1528
+ - kvm-block-Don-t-poll-in-bdrv_replace_child_noperm.patch [bz#2155112]
1529
+ - kvm-block-Remove-poll-parameter-from-bdrv_parent_drained.patch [bz#2155112]
1530
+ - kvm-accel-introduce-accelerator-blocker-API.patch [bz#1979276]
1531
+ - kvm-KVM-keep-track-of-running-ioctls.patch [bz#1979276]
1532
+ - kvm-kvm-Atomic-memslot-updates.patch [bz#1979276]
1533
+ - Resolves: bz#1905805
1534
+ (support config interrupt in vhost-vdpa qemu)
1535
+ - Resolves: bz#2159408
1536
+ ([s390x] VMs with ISM passthrough don't autostart after leapp upgrade from RHEL 8)
1537
+ - Resolves: bz#2124856
1538
+ (VM with virtio interface and iommu=on will crash when try to migrate)
1539
+ - Resolves: bz#2155112
1540
+ (Qemu coredump after do snapshot of mirrored top image and its converted base image(iothread enabled))
1541
+ - Resolves: bz#1979276
1542
+ (SVM: non atomic memslot updates cause boot failure with seabios and cpu-pm=on)
1543
+
1544
+ * Thu Jan 12 2023 Miroslav Rezanina <mrezanin@redhat.com> - 7.2.0-4
1545
+ - kvm-virtio-rng-pci-fix-migration-compat-for-vectors.patch [bz#2155749]
1546
+ - kvm-Update-QGA-service-for-new-command-line.patch [bz#2156515]
1547
+ - Resolves: bz#2155749
1548
+ ([regression][stable guest abi][qemu-kvm7.2]Migration failed due to virtio-rng device between RHEL8.8 and RHEL9.2/MSI-X)
1549
+ - Resolves: bz#2156515
1550
+ ([guest-agent] Replace '-blacklist' to '-block-rpcs' in qemu-ga config file)
1551
+
1552
+ * Wed Jan 04 2023 Miroslav Rezanina <mrezanin@redhat.com> - 7.2.0-3
1553
+ - kvm-hw-arm-virt-Introduce-virt_set_high_memmap-helper.patch [bz#2113840]
1554
+ - kvm-hw-arm-virt-Rename-variable-size-to-region_size-in-v.patch [bz#2113840]
1555
+ - kvm-hw-arm-virt-Introduce-variable-region_base-in-virt_s.patch [bz#2113840]
1556
+ - kvm-hw-arm-virt-Introduce-virt_get_high_memmap_enabled-h.patch [bz#2113840]
1557
+ - kvm-hw-arm-virt-Improve-high-memory-region-address-assig.patch [bz#2113840]
1558
+ - kvm-hw-arm-virt-Add-compact-highmem-property.patch [bz#2113840]
1559
+ - kvm-hw-arm-virt-Add-properties-to-disable-high-memory-re.patch [bz#2113840]
1560
+ - kvm-hw-arm-virt-Enable-compat-high-memory-region-address.patch [bz#2113840]
1561
+ - Resolves: bz#2113840
1562
+ ([RHEL9.2] Memory mapping optimization for virt machine)
1563
+
1564
+ * Tue Dec 20 2022 Miroslav Rezanina <mrezanin@redhat.com> - 7.2.0-2
1565
+ - Fix updating from 7.1.0
1566
+ - kvm-redhat-fix-virt-rhel9.2.0-compat-props.patch[bz#2154640]
1567
+ - Resolves: bz#2154640
1568
+ ([aarch64] qemu fails to load "efi-virtio.rom" romfile when creating virtio-net-pci)
1569
+
1570
+ * Thu Dec 15 2022 Miroslav Rezanina <mrezanin@redhat.com> - 7.2.0-1
1571
+ - Rebase to QEMU 7.2.0 [bz#2135806]
1572
+ - Resolves: bz#2135806
1573
+ (Rebase to QEMU 7.2 for RHEL 9.2.0)
1574
+
1575
+ * Wed Dec 14 2022 Jon Maloy <jmaloy@redhat.com> - 7.1.0-7
1576
+ - kvm-hw-acpi-erst.c-Fix-memory-handling-issues.patch [bz#2149108]
1577
+ - Resolves: bz#2149108
1578
+ (CVE-2022-4172 qemu-kvm: QEMU: ACPI ERST: memory corruption issues in read_erst_record and write_erst_record [rhel-9])
1579
+
1580
+ * Fri Dec 02 2022 Miroslav Rezanina <mrezanin@redhat.com> - 7.1.0-6
1581
+ - kvm-block-move-bdrv_qiov_is_aligned-to-file-posix.patch [bz#2143170]
1582
+ - kvm-block-use-the-request-length-for-iov-alignment.patch [bz#2143170]
1583
+ - Resolves: bz#2143170
1584
+ (The installation can not start when install files (iso) locate on a 4k disk)
1585
+
1586
+ * Mon Nov 14 2022 Miroslav Rezanina <mrezanin@redhat.com> - 7.1.0-5
1587
+ - kvm-rtl8139-Remove-unused-variable.patch [bz#2141218]
1588
+ - kvm-qemu-img-remove-unused-variable.patch [bz#2141218]
1589
+ - kvm-host-libusb-Remove-unused-variable.patch [bz#2141218]
1590
+ - Resolves: bz#2141218
1591
+ (qemu-kvm build fails with clang 15.0.1 due to false unused variable error)
1592
+
1593
+ * Tue Nov 01 2022 Miroslav Rezanina <mrezanin@redhat.com> - 7.1.0-4
1594
+ - kvm-Revert-intel_iommu-Fix-irqchip-X2APIC-configuration-.patch [bz#2126095]
1595
+ - Resolves: bz#2126095
1596
+ ([rhel9.2][intel_iommu]Booting guest with "-device intel-iommu,intremap=on,device-iotlb=on,caching-mode=on" causes kernel call trace)
1597
+
1598
+ * Thu Oct 13 2022 Jon Maloy <jmaloy@redhat.com> - 7.1.0-3
1599
+ - kvm-target-i386-kvm-fix-kvmclock_current_nsec-Assertion-.patch [bz#2108531]
1600
+ - Resolves: bz#2108531
1601
+ (Windows guest reboot after migration with wsl2 installed inside)
1602
+
1603
+ * Thu Sep 29 2022 Miroslav Rezanina <mrezanin@redhat.com> - 7.1.0-2
1604
+ - kvm-vdpa-Skip-the-maps-not-in-the-iova-tree.patch [RHELX-57]
1605
+ - kvm-vdpa-do-not-save-failed-dma-maps-in-SVQ-iova-tree.patch [RHELX-57]
1606
+ - kvm-util-accept-iova_tree_remove_parameter-by-value.patch [RHELX-57]
1607
+ - kvm-vdpa-Remove-SVQ-vring-from-iova_tree-at-shutdown.patch [RHELX-57]
1608
+ - kvm-vdpa-Make-SVQ-vring-unmapping-return-void.patch [RHELX-57]
1609
+ - kvm-vhost-Always-store-new-kick-fd-on-vhost_svq_set_svq_.patch [RHELX-57]
1610
+ - kvm-vdpa-Use-ring-hwaddr-at-vhost_vdpa_svq_unmap_ring.patch [RHELX-57]
1611
+ - kvm-vhost-stop-transfer-elem-ownership-in-vhost_handle_g.patch [RHELX-57]
1612
+ - kvm-vhost-use-SVQ-element-ndescs-instead-of-opaque-data-.patch [RHELX-57]
1613
+ - kvm-vhost-Delete-useless-read-memory-barrier.patch [RHELX-57]
1614
+ - kvm-vhost-Do-not-depend-on-NULL-VirtQueueElement-on-vhos.patch [RHELX-57]
1615
+ - kvm-vhost_net-Add-NetClientInfo-start-callback.patch [RHELX-57]
1616
+ - kvm-vhost_net-Add-NetClientInfo-stop-callback.patch [RHELX-57]
1617
+ - kvm-vdpa-add-net_vhost_vdpa_cvq_info-NetClientInfo.patch [RHELX-57]
1618
+ - kvm-vdpa-Move-command-buffers-map-to-start-of-net-device.patch [RHELX-57]
1619
+ - kvm-vdpa-extract-vhost_vdpa_net_cvq_add-from-vhost_vdpa_.patch [RHELX-57]
1620
+ - kvm-vhost_net-add-NetClientState-load-callback.patch [RHELX-57]
1621
+ - kvm-vdpa-Add-virtio-net-mac-address-via-CVQ-at-start.patch [RHELX-57]
1622
+ - kvm-vdpa-Delete-CVQ-migration-blocker.patch [RHELX-57]
1623
+ - kvm-vdpa-Make-VhostVDPAState-cvq_cmd_in_buffer-control-a.patch [RHELX-57]
1624
+ - kvm-vdpa-extract-vhost_vdpa_net_load_mac-from-vhost_vdpa.patch [RHELX-57]
1625
+ - kvm-vdpa-Add-vhost_vdpa_net_load_mq.patch [RHELX-57]
1626
+ - kvm-vdpa-validate-MQ-CVQ-commands.patch [RHELX-57]
1627
+ - kvm-virtio-net-Update-virtio-net-curr_queue_pairs-in-vdp.patch [RHELX-57]
1628
+ - kvm-vdpa-Allow-MQ-feature-in-SVQ.patch [RHELX-57]
1629
+ - kvm-i386-reset-KVM-nested-state-upon-CPU-reset.patch [bz#2125281]
1630
+ - kvm-i386-do-kvm_put_msr_feature_control-first-thing-when.patch [bz#2125281]
1631
+ - kvm-Revert-Re-enable-capstone-internal-build.patch [bz#2127825]
1632
+ - kvm-spec-Use-capstone-package.patch [bz#2127825]
1633
+ - Resolves: RHELX-57
1634
+ (vDPA SVQ Multiqueue support )
1635
+ - Resolves: bz#2125281
1636
+ ([RHEL9.1] Guests in VMX root operation fail to reboot with QEMU's 'system_reset' command [rhel-9.2.0])
1637
+ - Resolves: bz#2127825
1638
+ (Use capstone for qemu-kvm build)
1639
+
1640
+ * Mon Sep 05 2022 Miroslav Rezanina <mrezanin@redhat.com> - 7.1.0-1
1641
+ - Rebase to QEMU 7.1.0 [bz#2111769]
1642
+ - Resolves: bz#2111769
1643
+ (Rebase to QEMU 7.1.0)
1644
+
1482
1645
* Mon Aug 15 2022 Miroslav Rezanina <mrezanin@redhat.com> - 7.0.0-11
1483
1646
- kvm-QIOChannelSocket-Fix-zero-copy-flush-returning-code-.patch [bz#2107466]
1484
1647
- kvm-Add-dirty-sync-missed-zero-copy-migration-stat.patch [bz#2107466]