diff --git a/Revert-vdpa-add-vhost_vdpa-suspended-parameter.patch b/Revert-vdpa-add-vhost_vdpa-suspended-parameter.patch new file mode 100644 index 0000000000000000000000000000000000000000..1957962e5e92f677d286ff7a74a207ddcc319095 --- /dev/null +++ b/Revert-vdpa-add-vhost_vdpa-suspended-parameter.patch @@ -0,0 +1,46 @@ +From bbdf53d3f62d9e96ef4c5593a7704cdaf0ad7790 Mon Sep 17 00:00:00 2001 +From: jiangdongxu +Date: Tue, 29 Oct 2024 19:53:27 +0800 +Subject: [PATCH 5/7] Revert "vdpa: add vhost_vdpa->suspended parameter" + +This reverts commit b6662cb7e5376659c7abb56efe27dcf3898d4fe6. +--- + hw/virtio/vhost-vdpa.c | 8 -------- + include/hw/virtio/vhost-vdpa.h | 2 -- + 2 files changed, 10 deletions(-) + +diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c +index 130afb06dc..bb3320946d 100644 +--- a/hw/virtio/vhost-vdpa.c ++++ b/hw/virtio/vhost-vdpa.c +@@ -1406,14 +1406,6 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev, + return 0; + } + +- if (!v->suspended) { +- /* +- * Cannot trust in value returned by device, let vhost recover used +- * idx from guest. +- */ +- return -1; +- } +- + ret = vhost_vdpa_call(dev, VHOST_GET_VRING_BASE, ring); + trace_vhost_vdpa_get_vring_base(dev, ring->index, ring->num); + return ret; +diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h +index 5407d54fd7..ee255bc1bd 100644 +--- a/include/hw/virtio/vhost-vdpa.h ++++ b/include/hw/virtio/vhost-vdpa.h +@@ -42,8 +42,6 @@ typedef struct vhost_vdpa { + bool shadow_vqs_enabled; + /* Vdpa must send shadow addresses as IOTLB key for data queues, not GPA */ + bool shadow_data; +- /* Device suspended successfully */ +- bool suspended; + /* IOVA mapping used by the Shadow Virtqueue */ + VhostIOVATree *iova_tree; + GPtrArray *shadow_vqs; +-- +2.27.0 + diff --git a/Revert-vdpa-add-vhost_vdpa_suspend.patch b/Revert-vdpa-add-vhost_vdpa_suspend.patch new file mode 100644 index 0000000000000000000000000000000000000000..e878ce3fee2dbe480d8519898e0522e3d33f23ab --- /dev/null +++ b/Revert-vdpa-add-vhost_vdpa_suspend.patch @@ -0,0 +1,82 @@ +From d522e06fb680cd322f32b061c240c2b8ca8d393f Mon Sep 17 00:00:00 2001 +From: jiangdongxu +Date: Tue, 29 Oct 2024 19:51:41 +0800 +Subject: [PATCH 4/7] Revert "vdpa: add vhost_vdpa_suspend" + +This reverts commit 0bb302a9960a186fc488068d268dc373e6b70876. +--- + hw/virtio/trace-events | 1 - + hw/virtio/vhost-vdpa.c | 26 -------------------------- + 2 files changed, 27 deletions(-) + +diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events +index 637cac4edf..de02bdc1d0 100644 +--- a/hw/virtio/trace-events ++++ b/hw/virtio/trace-events +@@ -52,7 +52,6 @@ vhost_vdpa_set_vring_ready(void *dev, unsigned i, int r) "dev: %p, idx: %u, r: % + vhost_vdpa_dump_config(void *dev, const char *line) "dev: %p %s" + vhost_vdpa_set_config(void *dev, uint32_t offset, uint32_t size, uint32_t flags) "dev: %p offset: %"PRIu32" size: %"PRIu32" flags: 0x%"PRIx32 + vhost_vdpa_get_config(void *dev, void *config, uint32_t config_len) "dev: %p config: %p config_len: %"PRIu32 +-vhost_vdpa_suspend(void *dev) "dev: %p" + vhost_vdpa_dev_start(void *dev, bool started) "dev: %p started: %d" + vhost_vdpa_set_log_base(void *dev, uint64_t base, unsigned long long size, int refcnt, int fd, void *log) "dev: %p base: 0x%"PRIx64" size: %llu refcnt: %d fd: %d log: %p" + vhost_vdpa_set_vring_addr(void *dev, unsigned int index, unsigned int flags, uint64_t desc_user_addr, uint64_t used_user_addr, uint64_t avail_user_addr, uint64_t log_guest_addr) "dev: %p index: %u flags: 0x%x desc_user_addr: 0x%"PRIx64" used_user_addr: 0x%"PRIx64" avail_user_addr: 0x%"PRIx64" log_guest_addr: 0x%"PRIx64 +diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c +index d49826845f..130afb06dc 100644 +--- a/hw/virtio/vhost-vdpa.c ++++ b/hw/virtio/vhost-vdpa.c +@@ -865,13 +865,11 @@ static int vhost_vdpa_get_device_id(struct vhost_dev *dev, + + static int vhost_vdpa_reset_device(struct vhost_dev *dev) + { +- struct vhost_vdpa *v = dev->opaque; + int ret; + uint8_t status = 0; + + ret = vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &status); + trace_vhost_vdpa_reset_device(dev); +- v->suspended = false; + return ret; + } + +@@ -1274,29 +1272,6 @@ static void vhost_vdpa_svqs_stop(struct vhost_dev *dev) + } + } + +-static void vhost_vdpa_suspend(struct vhost_dev *dev) +-{ +- struct vhost_vdpa *v = dev->opaque; +- int r; +- +- if (!vhost_vdpa_first_dev(dev)) { +- return; +- } +- +- if (dev->backend_cap & BIT_ULL(VHOST_BACKEND_F_SUSPEND)) { +- trace_vhost_vdpa_suspend(dev); +- r = ioctl(v->device_fd, VHOST_VDPA_SUSPEND); +- if (unlikely(r)) { +- error_report("Cannot suspend: %s(%d)", g_strerror(errno), errno); +- } else { +- v->suspended = true; +- return; +- } +- } +- +- vhost_vdpa_reset_device(dev); +-} +- + static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started) + { + struct vhost_vdpa *v = dev->opaque; +@@ -1310,7 +1285,6 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started) + return -1; + } + } else { +- vhost_vdpa_suspend(dev); + vhost_vdpa_svqs_stop(dev); + vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs); + } +-- +2.27.0 + diff --git a/Revert-vdpa-block-migration-if-SVQ-does-not-admit-a-.patch b/Revert-vdpa-block-migration-if-SVQ-does-not-admit-a-.patch new file mode 100644 index 0000000000000000000000000000000000000000..0655f746181c60085c03a4d5da583e00436a40aa --- /dev/null +++ b/Revert-vdpa-block-migration-if-SVQ-does-not-admit-a-.patch @@ -0,0 +1,40 @@ +From 39ba28dca533fc1ca3fdef29764f52eeebc2a548 Mon Sep 17 00:00:00 2001 +From: jiangdongxu +Date: Tue, 29 Oct 2024 19:58:14 +0800 +Subject: [PATCH 6/7] Revert "vdpa: block migration if SVQ does not admit a + feature" + +This reverts commit 57ac831865e370012496fb581a38d261cb72c5d0. +--- + hw/virtio/vhost-vdpa.c | 15 --------------- + 1 file changed, 15 deletions(-) + +diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c +index bb3320946d..69cf3b76e9 100644 +--- a/hw/virtio/vhost-vdpa.c ++++ b/hw/virtio/vhost-vdpa.c +@@ -596,21 +596,6 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp) + return 0; + } + +- /* +- * If dev->shadow_vqs_enabled at initialization that means the device has +- * been started with x-svq=on, so don't block migration +- */ +- if (dev->migration_blocker == NULL && !v->shadow_vqs_enabled) { +- /* We don't have dev->features yet */ +- uint64_t features; +- ret = vhost_vdpa_get_dev_features(dev, &features); +- if (unlikely(ret)) { +- error_setg_errno(errp, -ret, "Could not get device features"); +- return ret; +- } +- vhost_svq_valid_features(features, &dev->migration_blocker); +- } +- + /* + * Similar to VFIO, we end up pinning all guest memory and have to + * disable discarding of RAM. +-- +2.27.0 + diff --git a/enable-virtio-device-mmio-access-and-wait-util-virti.patch b/enable-virtio-device-mmio-access-and-wait-util-virti.patch new file mode 100644 index 0000000000000000000000000000000000000000..e3309ebaf32a7206156b51a583ba3d99756ebf05 --- /dev/null +++ b/enable-virtio-device-mmio-access-and-wait-util-virti.patch @@ -0,0 +1,86 @@ +From 0a179313fde1f71a8a7520c3d3149aa2dc4e66b2 Mon Sep 17 00:00:00 2001 +From: jiangdongxu +Date: Sat, 26 Oct 2024 15:32:02 +0800 +Subject: [PATCH] enable virtio device mmio access and wait util virtio device + reset done + +--- + roms/seabios/src/hw/blockcmd.h | 2 +- + roms/seabiossrc/hw/virtio-pci.c | 32 +++++++++++++++++++++++++++----- + 2 files changed, 28 insertions(+), 6 deletions(-) + +diff --git a/roms/seabios/src/hw/blockcmd.h b/roms/seabios/src/hw/blockcmd.h +index f18543ed..1063e6ab 100644 +--- a/roms/seabios/src/hw/blockcmd.h ++++ b/roms/seabios/src/hw/blockcmd.h +@@ -30,7 +30,7 @@ struct cdb_read_capacity { + struct cdbres_read_capacity { + u32 sectors; + u32 blksize; +-} PACKED; ++} __attribute__((aligned(4))); + + #define CDB_CMD_TEST_UNIT_READY 0x00 + #define CDB_CMD_INQUIRY 0x12 +diff --git a/roms/seabios/src/hw/virtio-pci.c b/roms/seabios/src/hw/virtio-pci.c +index 89a4f505..5d7b8428 100644 +--- a/roms/seabios/src/hw/virtio-pci.c ++++ b/roms/seabios/src/hw/virtio-pci.c +@@ -15,6 +15,7 @@ + * See the COPYING file in the top-level directory. + */ + ++#include "util.h" // msleep + #include "config.h" // CONFIG_DEBUG_LEVEL + #include "malloc.h" // free + #include "output.h" // dprintf +@@ -271,6 +272,10 @@ void vp_reset(struct vp_device *vp) + vp_read(&vp->common, virtio_mmio_cfg, irq_status); + } else if (vp->use_modern) { + vp_write(&vp->common, virtio_pci_common_cfg, device_status, 0); ++ dprintf(1, "vp start reset\n"); ++ while (vp_get_status(vp) != 0) ++ msleep(2); ++ dprintf(1, "vp reset finished\n"); + vp_read(&vp->isr, virtio_pci_isr, isr); + } else { + vp_write(&vp->legacy, virtio_pci_legacy, status, 0); +@@ -535,14 +540,31 @@ void vp_init_simple(struct vp_device *vp, struct pci_device *pci) + } else { + dprintf(1, "pci dev %pP using legacy (0.9.5) virtio mode\n", pci); + vp->legacy.bar = 0; +- vp->legacy.ioaddr = pci_enable_iobar(pci, PCI_BASE_ADDRESS_0); +- if (!vp->legacy.ioaddr) +- return; +- vp->legacy.mode = VP_ACCESS_IO; ++ ++ /* ++ * Extend the legacy virtio interface to support MMIO bar which ++ * is required by SR-IOV. ++ */ ++ addr = pci_config_readl(pci->bdf, PCI_BASE_ADDRESS_0); ++ if (addr & PCI_BASE_ADDRESS_SPACE_IO) { ++ dprintf(1, "legacy virtio: I/O BAR used\n"); ++ vp->legacy.ioaddr = pci_enable_iobar(pci, PCI_BASE_ADDRESS_0); ++ if (!vp->legacy.ioaddr) ++ return; ++ vp->legacy.mode = VP_ACCESS_IO; ++ } else { ++ dprintf(1, "legacy virtio: MMIO BAR used\n"); ++ vp->legacy.memaddr = pci_enable_membar(pci, PCI_BASE_ADDRESS_0); ++ if (!vp->legacy.memaddr) ++ return; ++ vp->legacy.mode = VP_ACCESS_MMIO; ++ } + } + +- vp_reset(vp); + pci_enable_busmaster(pci); ++ dprintf(1, "pci dev %pP start reset\n", pci); ++ vp_reset(vp); ++ dprintf(1, "pci dev %pP finish reset\n", pci); + vp_set_status(vp, VIRTIO_CONFIG_S_ACKNOWLEDGE | + VIRTIO_CONFIG_S_DRIVER ); + } +-- +2.43.0 diff --git a/qemu.spec b/qemu.spec index 145f44f3582aa83fc71994a20fbab286c9e25d15..a56f5b1a84e58369d583419c32e193e168231f38 100644 --- a/qemu.spec +++ b/qemu.spec @@ -3,7 +3,7 @@ Name: qemu Version: 8.2.0 -Release: 20 +Release: 21 Epoch: 11 Summary: QEMU is a generic and open source machine emulator and virtualizer License: GPLv2 and BSD and MIT and CC-BY-SA-4.0 @@ -363,6 +363,14 @@ Patch0346: crypto-avoid-leak-of-ctx-when-bad-cipher-mode-is-giv.patch Patch0347: hw-ufs-add-basic-info-of-query-response-upiu.patch Patch0348: hw-block-fix-uint32-overflow.patch Patch0349: Added-CoDA-feature-support-in-the-context-of-CVM.-Wh.patch +Patch0350: vdpa-fix-vdpa-device-migrate-rollback-wrong-when-sus.patch +Patch0351: vdpa-Fix-bug-where-vdpa-appliance-migration-does-not.patch +Patch0352: vdpa-block-device-capacity-expansion-online-support-.patch +Patch0353: Revert-vdpa-add-vhost_vdpa_suspend.patch +Patch0354: Revert-vdpa-add-vhost_vdpa-suspended-parameter.patch +Patch0355: Revert-vdpa-block-migration-if-SVQ-does-not-admit-a-.patch +Patch0356: vdpa-remove-memory-listener-unregister-in-vhost_vdpa.patch +Patch0357: enable-virtio-device-mmio-access-and-wait-util-virti.patch BuildRequires: flex BuildRequires: gcc diff --git a/vdpa-Fix-bug-where-vdpa-appliance-migration-does-not.patch b/vdpa-Fix-bug-where-vdpa-appliance-migration-does-not.patch new file mode 100644 index 0000000000000000000000000000000000000000..406a7ffd7e2d04cbbf510da2e09a4a566315aee4 --- /dev/null +++ b/vdpa-Fix-bug-where-vdpa-appliance-migration-does-not.patch @@ -0,0 +1,38 @@ +From 395d82b3b792dc4a980393f47cb8580e4acb7155 Mon Sep 17 00:00:00 2001 +From: Adttil <2429917001@qq.com> +Date: Mon, 8 Jul 2024 14:45:18 +0800 +Subject: [PATCH 2/7] vdpa: Fix bug where vdpa appliance migration does not + resume after rollback + +using vdpa->started to judge device started instead of vdev->vhost_started + +Signed-off-by: Adttil <2429917001@qq.com> +--- + hw/virtio/vdpa-dev-mig.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/hw/virtio/vdpa-dev-mig.c b/hw/virtio/vdpa-dev-mig.c +index 737d31cbeb..7de996c835 100644 +--- a/hw/virtio/vdpa-dev-mig.c ++++ b/hw/virtio/vdpa-dev-mig.c +@@ -131,7 +131,7 @@ static int vhost_vdpa_device_suspend(VhostVdpaDevice *vdpa) + { + VirtIODevice *vdev = VIRTIO_DEVICE(vdpa); + +- if (!vdev->vhost_started || vdpa->suspended) { ++ if (!vdpa->started || vdpa->suspended) { + return 0; + } + +@@ -146,7 +146,7 @@ static int vhost_vdpa_device_resume(VhostVdpaDevice *vdpa) + MigrationIncomingState *mis = migration_incoming_get_current(); + int ret; + +- if (!vdev->vhost_started || ++ if (!vdpa->started || + (!vdpa->suspended && mis->state != RUN_STATE_RESTORE_VM)) { + return 0; + } +-- +2.27.0 + diff --git a/vdpa-block-device-capacity-expansion-online-support-.patch b/vdpa-block-device-capacity-expansion-online-support-.patch new file mode 100644 index 0000000000000000000000000000000000000000..097630f74e25748d48c7bcc4c03c544afb9baa27 --- /dev/null +++ b/vdpa-block-device-capacity-expansion-online-support-.patch @@ -0,0 +1,50 @@ +From 242eced7ad699cf9405b47d5e26ad641e62335ca Mon Sep 17 00:00:00 2001 +From: jiangdongxu +Date: Sat, 7 Sep 2024 07:11:07 +0000 +Subject: [PATCH 3/7] vdpa:block device capacity expansion online support vdpa + block device update capacity. + +Signed-off-by: jiangdongxu +--- + hw/virtio/vdpa-dev.c | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c +index 91e71847b0..bf4b3ec3fd 100644 +--- a/hw/virtio/vdpa-dev.c ++++ b/hw/virtio/vdpa-dev.c +@@ -31,6 +31,7 @@ + #include "hw/virtio/vdpa-dev-mig.h" + #include "migration/migration.h" + #include "exec/address-spaces.h" ++#include "standard-headers/linux/virtio_ids.h" + + static void + vhost_vdpa_device_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq) +@@ -201,7 +202,23 @@ static void + vhost_vdpa_device_get_config(VirtIODevice *vdev, uint8_t *config) + { + VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev); ++ uint8_t *new_config; ++ int ret; ++ ++ if (s->vdev_id != VIRTIO_ID_BLOCK) { ++ goto out; ++ } + ++ new_config = g_malloc0(s->config_size); ++ ret = vhost_dev_get_config(&s->dev, new_config, s->config_size, NULL); ++ if (ret < 0) { ++ error_report("vhost-vdpa-device: get config failed(%d)\n", ret); ++ goto free; ++ } ++ memcpy(s->config, new_config, s->config_size); ++free: ++ g_free(new_config); ++out: + memcpy(config, s->config, s->config_size); + } + +-- +2.27.0 + diff --git a/vdpa-fix-vdpa-device-migrate-rollback-wrong-when-sus.patch b/vdpa-fix-vdpa-device-migrate-rollback-wrong-when-sus.patch new file mode 100644 index 0000000000000000000000000000000000000000..798610f2ab2f10709cbb6dd29f7c1abc687bf378 --- /dev/null +++ b/vdpa-fix-vdpa-device-migrate-rollback-wrong-when-sus.patch @@ -0,0 +1,142 @@ +From 11f1c7ca522dc98d792d5b05c27c30b57df99b8e Mon Sep 17 00:00:00 2001 +From: jiangdongxu +Date: Sat, 22 Jun 2024 07:02:48 +0000 +Subject: [PATCH 1/7] vdpa: fix vdpa device migrate rollback wrong when suspend + device failed. + + 1. set vdpa->suspended before call vhost_dev_suspend to make sure vdpa device + will resume when suspend failed. + 2. using vdpa->vhost_started to judge device started instead of vdev->started + 3. using state == RUN_STATE_FINISH_MIGRATE instead of ms->state == MIGRATION_STATUS_ACTIVE + to judge vm in migration. As migrate_fd_cancel will change ms->state, + which will result in some vdpa devices not being suspended. + +Signed-off-by: jiangdongxu +--- + hw/virtio/vdpa-dev-mig.c | 83 ++++------------------------------------ + 1 file changed, 8 insertions(+), 75 deletions(-) + +diff --git a/hw/virtio/vdpa-dev-mig.c b/hw/virtio/vdpa-dev-mig.c +index 887c96a201..737d31cbeb 100644 +--- a/hw/virtio/vdpa-dev-mig.c ++++ b/hw/virtio/vdpa-dev-mig.c +@@ -130,100 +130,33 @@ free: + static int vhost_vdpa_device_suspend(VhostVdpaDevice *vdpa) + { + VirtIODevice *vdev = VIRTIO_DEVICE(vdpa); +- BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); +- VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); +- int ret; + +- if (!vdpa->started || vdpa->suspended) { ++ if (!vdev->vhost_started || vdpa->suspended) { + return 0; + } + +- if (!k->set_guest_notifiers) { +- return -EFAULT; +- } +- +- vdpa->started = false; + vdpa->suspended = true; + +- ret = vhost_dev_suspend(&vdpa->dev, vdev, false); +- if (ret) { +- goto suspend_fail; +- } +- +- ret = k->set_guest_notifiers(qbus->parent, vdpa->dev.nvqs, false); +- if (ret < 0) { +- error_report("vhost guest notifier cleanup failed: %d\n", ret); +- goto set_guest_notifiers_fail; +- } +- +- vhost_dev_disable_notifiers(&vdpa->dev, vdev); +- return ret; +- +-set_guest_notifiers_fail: +- ret = k->set_guest_notifiers(qbus->parent, vdpa->dev.nvqs, true); +- if (ret) { +- error_report("vhost guest notifier restore failed: %d\n", ret); +- } +- +-suspend_fail: +- vdpa->suspended = false; +- vdpa->started = true; +- return ret; ++ return vhost_dev_suspend(&vdpa->dev, vdev, false); + } + + static int vhost_vdpa_device_resume(VhostVdpaDevice *vdpa) + { + VirtIODevice *vdev = VIRTIO_DEVICE(vdpa); +- BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); +- VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); +- int i, ret; ++ MigrationIncomingState *mis = migration_incoming_get_current(); ++ int ret; + +- if (vdpa->started || !vdpa->suspended) { ++ if (!vdev->vhost_started || ++ (!vdpa->suspended && mis->state != RUN_STATE_RESTORE_VM)) { + return 0; + } + +- if (!k->set_guest_notifiers) { +- error_report("binding does not support guest notifiers\n"); +- return -ENOSYS; +- } +- +- ret = vhost_dev_enable_notifiers(&vdpa->dev, vdev); ++ ret = vhost_dev_resume(&vdpa->dev, vdev, false); + if (ret < 0) { +- error_report("Error enabling host notifiers: %d\n", ret); + return ret; + } + +- ret = k->set_guest_notifiers(qbus->parent, vdpa->dev.nvqs, true); +- if (ret < 0) { +- error_report("Error binding guest notifier: %d\n", ret); +- goto err_host_notifiers; +- } +- +- vdpa->dev.acked_features = vdev->guest_features; +- +- ret = vhost_dev_resume(&vdpa->dev, vdev, false); +- if (ret < 0) { +- error_report("Error starting vhost: %d\n", ret); +- goto err_guest_notifiers; +- } +- vdpa->started = true; + vdpa->suspended = false; +- +- /* +- * guest_notifier_mask/pending not used yet, so just unmask +- * everything here. virtio-pci will do the right thing by +- * enabling/disabling irqfd. +- */ +- for (i = 0; i < vdpa->dev.nvqs; i++) { +- vhost_virtqueue_mask(&vdpa->dev, vdev, i, false); +- } +- +- return ret; +- +-err_guest_notifiers: +- k->set_guest_notifiers(qbus->parent, vdpa->dev.nvqs, false); +-err_host_notifiers: +- vhost_dev_disable_notifiers(&vdpa->dev, vdev); + return ret; + } + +@@ -248,7 +181,7 @@ static void vdpa_dev_vmstate_change(void *opaque, bool running, RunState state) + MigrationIncomingState *mis = migration_incoming_get_current(); + + if (!running) { +- if (ms->state == MIGRATION_STATUS_ACTIVE || state == RUN_STATE_PAUSED) { ++ if (state == RUN_STATE_FINISH_MIGRATE || state == RUN_STATE_PAUSED) { + ret = vhost_vdpa_device_suspend(vdpa); + if (ret) { + error_report("suspend vdpa device failed: %d\n", ret); +-- +2.27.0 + diff --git a/vdpa-remove-memory-listener-unregister-in-vhost_vdpa.patch b/vdpa-remove-memory-listener-unregister-in-vhost_vdpa.patch new file mode 100644 index 0000000000000000000000000000000000000000..b575e265d85349f3df6bcccd62c870b41690d1db --- /dev/null +++ b/vdpa-remove-memory-listener-unregister-in-vhost_vdpa.patch @@ -0,0 +1,37 @@ +From c5bcdb1fe285f538fd726ace11a9b3916c2fa934 Mon Sep 17 00:00:00 2001 +From: jiangdongxu +Date: Tue, 29 Oct 2024 20:02:10 +0800 +Subject: [PATCH] vdpa: remove memory listener unregister in + vhost_vdpa_reset_status + +Remove memory listener unregister in vhost_vdpa_reset_status as we +move the memory listener registration of vdpa from the start stage +to the realize stage before. +--- + hw/virtio/vhost-vdpa.c | 3 --- + 1 files changed, 0 insertion(+), 3 deletions(-) + +diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c +index 69cf3b76e9..dcf1ef2c15 100644 +--- a/hw/virtio/vhost-vdpa.c ++++ b/hw/virtio/vhost-vdpa.c +@@ -1292,8 +1292,6 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started) + + static void vhost_vdpa_reset_status(struct vhost_dev *dev) + { +- struct vhost_vdpa *v = dev->opaque; +- + if (dev->vq_index + dev->nvqs != dev->vq_index_end) { + return; + } +@@ -1301,7 +1299,6 @@ static void vhost_vdpa_reset_status(struct vhost_dev *dev) + vhost_vdpa_reset_device(dev); + vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE | + VIRTIO_CONFIG_S_DRIVER); +- memory_listener_unregister(&v->listener); + } + + static int vhost_vdpa_set_log_base(struct vhost_dev *dev, uint64_t base, +-- +2.27.0 +