backends/hostmem-memfd.c | 5 +- backends/hostmem-shm.c | 5 +- backends/iommufd.c | 4 +- hw/vfio/container-legacy.c | 17 ++-- hw/vfio/cpr-legacy.c | 10 +- hw/vfio/cpr.c | 6 +- hw/vfio/pci.c | 5 +- hw/virtio/vhost-kernel.c | 6 ++ hw/virtio/vhost-vsock.c | 193 +++++++++++++++++++++++++++++++++++--- hw/virtio/vhost.c | 57 ++++++++--- include/hw/vfio/vfio-cpr.h | 6 +- include/hw/virtio/vhost-backend.h | 2 + include/hw/virtio/vhost-vsock.h | 1 + include/hw/virtio/vhost.h | 61 ++++++++++++ include/migration/cpr.h | 2 +- migration/cpr.c | 55 +++++++---- migration/options.c | 7 ++ system/physmem.c | 5 +- tests/qtest/migration/cpr-tests.c | 36 ++++++- tests/unit/meson.build | 1 + tests/unit/test-cpr.c | 98 +++++++++++++++++++ 21 files changed, 512 insertions(+), 70 deletions(-)
v5 -> v6:
* Patch 9:
- use the device path (qdev_get_dev_path(), i.e. the device's
address on the bus) + "vhost-vsock" suffix as the CPR key instead
of the device ID;
- drop the device ID requirement altogether;
- introduce 'cpr_incoming' local here rather than in patch 14.
* Patch 14:
- lift the CPR blocker entirely instead of keeping it for ID-less
devices;
- skip RESET_OWNER in .pre_save() if the ownership was already
released by a previous failed CPR attempt;
- reword commit message.
v5: https://lore.kernel.org/qemu-devel/20260914-up-vsock-vhost-v5-v5-0-d17423589f48@virtuozzo.com
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
---
Andrey Drobyshev (14):
migration/cpr: forbid saving duplicate CprFds into hash table
tests/unit: add test for duplicate keys in CPR FD table
migration: forbid snapshots in CPR migration modes
tests/qtest/migration: add test for snapshot rejection in CPR modes
vhost-vsock: block CPR migration modes
vhost: add vhost_reset_owner op
vhost-vsock: don't reset connections during CPR
vhost-vsock: fix FD leak in realize()
vhost-vsock: preserve vhost FD during CPR
vhost: factor out vhost_dev_init_backend()
vhost: make vhost_dev_cleanup() safe on a partially initialized device
vhost: add vhost_dev_set_owner() / vhost_dev_reset_owner() helpers
vhost: add vhost_dev_is_initialized() helper
vhost-vsock: hand off device ownership across CPR
backends/hostmem-memfd.c | 5 +-
backends/hostmem-shm.c | 5 +-
backends/iommufd.c | 4 +-
hw/vfio/container-legacy.c | 17 ++--
hw/vfio/cpr-legacy.c | 10 +-
hw/vfio/cpr.c | 6 +-
hw/vfio/pci.c | 5 +-
hw/virtio/vhost-kernel.c | 6 ++
hw/virtio/vhost-vsock.c | 193 +++++++++++++++++++++++++++++++++++---
hw/virtio/vhost.c | 57 ++++++++---
include/hw/vfio/vfio-cpr.h | 6 +-
include/hw/virtio/vhost-backend.h | 2 +
include/hw/virtio/vhost-vsock.h | 1 +
include/hw/virtio/vhost.h | 61 ++++++++++++
include/migration/cpr.h | 2 +-
migration/cpr.c | 55 +++++++----
migration/options.c | 7 ++
system/physmem.c | 5 +-
tests/qtest/migration/cpr-tests.c | 36 ++++++-
tests/unit/meson.build | 1 +
tests/unit/test-cpr.c | 98 +++++++++++++++++++
21 files changed, 512 insertions(+), 70 deletions(-)
---
base-commit: 5f664cd37aec17e8145aa117d8da68f507edc8f1
change-id: 20260908-up-vsock-vhost-v5-c781b39f1c1a
Best regards,
--
Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
On 15.09.26 23:59, Andrey Drobyshev wrote: > v5 -> v6: > > * Patch 9: > - use the device path (qdev_get_dev_path(), i.e. the device's > address on the bus) + "vhost-vsock" suffix as the CPR key instead > of the device ID; > - drop the device ID requirement altogether; > - introduce 'cpr_incoming' local here rather than in patch 14. > > * Patch 14: > - lift the CPR blocker entirely instead of keeping it for ID-less > devices; > - skip RESET_OWNER in .pre_save() if the ownership was already > released by a previous failed CPR attempt; > - reword commit message. > > v5: https://lore.kernel.org/qemu-devel/20260914-up-vsock-vhost-v5-v5-0-d17423589f48@virtuozzo.com > > Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> > --- > Andrey Drobyshev (14): > migration/cpr: forbid saving duplicate CprFds into hash table > tests/unit: add test for duplicate keys in CPR FD table > migration: forbid snapshots in CPR migration modes > tests/qtest/migration: add test for snapshot rejection in CPR modes > vhost-vsock: block CPR migration modes > vhost: add vhost_reset_owner op > vhost-vsock: don't reset connections during CPR > vhost-vsock: fix FD leak in realize() > vhost-vsock: preserve vhost FD during CPR > vhost: factor out vhost_dev_init_backend() > vhost: make vhost_dev_cleanup() safe on a partially initialized device > vhost: add vhost_dev_set_owner() / vhost_dev_reset_owner() helpers > vhost: add vhost_dev_is_initialized() helper > vhost-vsock: hand off device ownership across CPR > > backends/hostmem-memfd.c | 5 +- > backends/hostmem-shm.c | 5 +- > backends/iommufd.c | 4 +- > hw/vfio/container-legacy.c | 17 ++-- > hw/vfio/cpr-legacy.c | 10 +- > hw/vfio/cpr.c | 6 +- > hw/vfio/pci.c | 5 +- > hw/virtio/vhost-kernel.c | 6 ++ > hw/virtio/vhost-vsock.c | 193 +++++++++++++++++++++++++++++++++++--- > hw/virtio/vhost.c | 57 ++++++++--- > include/hw/vfio/vfio-cpr.h | 6 +- > include/hw/virtio/vhost-backend.h | 2 + > include/hw/virtio/vhost-vsock.h | 1 + > include/hw/virtio/vhost.h | 61 ++++++++++++ > include/migration/cpr.h | 2 +- > migration/cpr.c | 55 +++++++---- > migration/options.c | 7 ++ > system/physmem.c | 5 +- > tests/qtest/migration/cpr-tests.c | 36 ++++++- > tests/unit/meson.build | 1 + > tests/unit/test-cpr.c | 98 +++++++++++++++++++ > 21 files changed, 512 insertions(+), 70 deletions(-) > --- > base-commit: 5f664cd37aec17e8145aa117d8da68f507edc8f1 > change-id: 20260908-up-vsock-vhost-v5-c781b39f1c1a > > Best regards, > -- > Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> Hi! Don't you add a test for new functionality? -- Best regards, Vladimir
On 9/17/26 9:03 AM, Vladimir Sementsov-Ogievskiy wrote: > On 15.09.26 23:59, Andrey Drobyshev wrote: >> v5 -> v6: >> >> * Patch 9: >> - use the device path (qdev_get_dev_path(), i.e. the device's >> address on the bus) + "vhost-vsock" suffix as the CPR key instead >> of the device ID; >> - drop the device ID requirement altogether; >> - introduce 'cpr_incoming' local here rather than in patch 14. >> >> * Patch 14: >> - lift the CPR blocker entirely instead of keeping it for ID-less >> devices; >> - skip RESET_OWNER in .pre_save() if the ownership was already >> released by a previous failed CPR attempt; >> - reword commit message. >> >> v5: https://lore.kernel.org/qemu-devel/20260914-up-vsock-vhost-v5-v5-0-d17423589f48@virtuozzo.com >> >> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> >> --- >> Andrey Drobyshev (14): >> migration/cpr: forbid saving duplicate CprFds into hash table >> tests/unit: add test for duplicate keys in CPR FD table >> migration: forbid snapshots in CPR migration modes >> tests/qtest/migration: add test for snapshot rejection in CPR modes >> vhost-vsock: block CPR migration modes >> vhost: add vhost_reset_owner op >> vhost-vsock: don't reset connections during CPR >> vhost-vsock: fix FD leak in realize() >> vhost-vsock: preserve vhost FD during CPR >> vhost: factor out vhost_dev_init_backend() >> vhost: make vhost_dev_cleanup() safe on a partially initialized device >> vhost: add vhost_dev_set_owner() / vhost_dev_reset_owner() helpers >> vhost: add vhost_dev_is_initialized() helper >> vhost-vsock: hand off device ownership across CPR >> >> backends/hostmem-memfd.c | 5 +- >> backends/hostmem-shm.c | 5 +- >> backends/iommufd.c | 4 +- >> hw/vfio/container-legacy.c | 17 ++-- >> hw/vfio/cpr-legacy.c | 10 +- >> hw/vfio/cpr.c | 6 +- >> hw/vfio/pci.c | 5 +- >> hw/virtio/vhost-kernel.c | 6 ++ >> hw/virtio/vhost-vsock.c | 193 +++++++++++++++++++++++++++++++++++--- >> hw/virtio/vhost.c | 57 ++++++++--- >> include/hw/vfio/vfio-cpr.h | 6 +- >> include/hw/virtio/vhost-backend.h | 2 + >> include/hw/virtio/vhost-vsock.h | 1 + >> include/hw/virtio/vhost.h | 61 ++++++++++++ >> include/migration/cpr.h | 2 +- >> migration/cpr.c | 55 +++++++---- >> migration/options.c | 7 ++ >> system/physmem.c | 5 +- >> tests/qtest/migration/cpr-tests.c | 36 ++++++- >> tests/unit/meson.build | 1 + >> tests/unit/test-cpr.c | 98 +++++++++++++++++++ >> 21 files changed, 512 insertions(+), 70 deletions(-) >> --- >> base-commit: 5f664cd37aec17e8145aa117d8da68f507edc8f1 >> change-id: 20260908-up-vsock-vhost-v5-c781b39f1c1a >> >> Best regards, >> -- >> Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> > > Hi! Don't you add a test for new functionality? Hi Vladimir, You're right, there's no dedicated tests yet. Basically there're 2 levels of testing: 1) Launch QEMU without a guest, with the device in question, and perform a CPR. Here we just test that QEMU survives the CPR op, i.e. that FD and device handling is fine from the QEMU side. 2) Actual test would be launching QEMU with a real guest, launch host<->guest data transfer and perform CPR during that. That's what I've been testing when preparing this series. As for the guest, AFAICT there're some functional tests which launch Fedora. So this part should be doable. However one requirement for both tests to work is the host kernel having RESET_OWNER support - that's added by our recent kernel series, which isn't yet merged to kernel master as of now. So whichever Linux distro you run on your host now - it doesn't have this support and is not going to work. I'm not sure it makes sense adding a test which nobody else'd be able to run unless they build their own kernel. What do you think? Andrey
On 17.09.26 15:32, Andrey Drobyshev wrote: > On 9/17/26 9:03 AM, Vladimir Sementsov-Ogievskiy wrote: >> On 15.09.26 23:59, Andrey Drobyshev wrote: >>> v5 -> v6: >>> >>> * Patch 9: >>> - use the device path (qdev_get_dev_path(), i.e. the device's >>> address on the bus) + "vhost-vsock" suffix as the CPR key instead >>> of the device ID; >>> - drop the device ID requirement altogether; >>> - introduce 'cpr_incoming' local here rather than in patch 14. >>> >>> * Patch 14: >>> - lift the CPR blocker entirely instead of keeping it for ID-less >>> devices; >>> - skip RESET_OWNER in .pre_save() if the ownership was already >>> released by a previous failed CPR attempt; >>> - reword commit message. >>> >>> v5: https://lore.kernel.org/qemu-devel/20260914-up-vsock-vhost-v5-v5-0-d17423589f48@virtuozzo.com >>> >>> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> >>> --- >>> Andrey Drobyshev (14): >>> migration/cpr: forbid saving duplicate CprFds into hash table >>> tests/unit: add test for duplicate keys in CPR FD table >>> migration: forbid snapshots in CPR migration modes >>> tests/qtest/migration: add test for snapshot rejection in CPR modes >>> vhost-vsock: block CPR migration modes >>> vhost: add vhost_reset_owner op >>> vhost-vsock: don't reset connections during CPR >>> vhost-vsock: fix FD leak in realize() >>> vhost-vsock: preserve vhost FD during CPR >>> vhost: factor out vhost_dev_init_backend() >>> vhost: make vhost_dev_cleanup() safe on a partially initialized device >>> vhost: add vhost_dev_set_owner() / vhost_dev_reset_owner() helpers >>> vhost: add vhost_dev_is_initialized() helper >>> vhost-vsock: hand off device ownership across CPR >>> >>> backends/hostmem-memfd.c | 5 +- >>> backends/hostmem-shm.c | 5 +- >>> backends/iommufd.c | 4 +- >>> hw/vfio/container-legacy.c | 17 ++-- >>> hw/vfio/cpr-legacy.c | 10 +- >>> hw/vfio/cpr.c | 6 +- >>> hw/vfio/pci.c | 5 +- >>> hw/virtio/vhost-kernel.c | 6 ++ >>> hw/virtio/vhost-vsock.c | 193 +++++++++++++++++++++++++++++++++++--- >>> hw/virtio/vhost.c | 57 ++++++++--- >>> include/hw/vfio/vfio-cpr.h | 6 +- >>> include/hw/virtio/vhost-backend.h | 2 + >>> include/hw/virtio/vhost-vsock.h | 1 + >>> include/hw/virtio/vhost.h | 61 ++++++++++++ >>> include/migration/cpr.h | 2 +- >>> migration/cpr.c | 55 +++++++---- >>> migration/options.c | 7 ++ >>> system/physmem.c | 5 +- >>> tests/qtest/migration/cpr-tests.c | 36 ++++++- >>> tests/unit/meson.build | 1 + >>> tests/unit/test-cpr.c | 98 +++++++++++++++++++ >>> 21 files changed, 512 insertions(+), 70 deletions(-) >>> --- >>> base-commit: 5f664cd37aec17e8145aa117d8da68f507edc8f1 >>> change-id: 20260908-up-vsock-vhost-v5-c781b39f1c1a >>> >>> Best regards, >>> -- >>> Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> >> >> Hi! Don't you add a test for new functionality? > Hi Vladimir, > > You're right, there's no dedicated tests yet. Basically there're 2 > levels of testing: > > 1) Launch QEMU without a guest, with the device in question, and perform > a CPR. Here we just test that QEMU survives the CPR op, i.e. that FD > and device handling is fine from the QEMU side. > > 2) Actual test would be launching QEMU with a real guest, launch > host<->guest data transfer and perform CPR during that. That's what > I've been testing when preparing this series. > > As for the guest, AFAICT there're some functional tests which launch > Fedora. So this part should be doable. If you want, look at my [PATCH 1/5] tests/functional: add test_tap_migration https://lore.kernel.org/qemu-devel/20260914175351.393680-2-vsementsov@yandex-team.ru/ it does local migration with live guest. > However one requirement for > both tests to work is the host kernel having RESET_OWNER support - > that's added by our recent kernel series, which isn't yet merged to > kernel master as of now. So whichever Linux distro you run on your host > now - it doesn't have this support and is not going to work. > > I'm not sure it makes sense adding a test which nobody else'd be able to > run unless they build their own kernel. What do you think? > But one day it (RESET_OWNER) will be merged, I assume? Would be good to have a test at the moment. I don't insist. My (self-serving) idea is that if I have a test, it would be easier to experiment and try to bring a "local migration" interface here (like in the recently merged TAP series) :). Of course, not merged RESET_OWNER make such experiments less possible just now.. For you, the test is the only thing that protects your code from being broken by other changes. Even if you're the only one running this test, when it breaks, you can bisect the breaking commit and say, "Hey, you've broken the existing test with this commit.". Without the test — you have no guarantee and no weapon. -- Best regards, Vladimir
On 9/17/26 4:06 PM, Vladimir Sementsov-Ogievskiy wrote: > On 17.09.26 15:32, Andrey Drobyshev wrote: >> On 9/17/26 9:03 AM, Vladimir Sementsov-Ogievskiy wrote: >>> On 15.09.26 23:59, Andrey Drobyshev wrote: >>>> v5 -> v6: >>>> >>>> * Patch 9: >>>> - use the device path (qdev_get_dev_path(), i.e. the device's >>>> address on the bus) + "vhost-vsock" suffix as the CPR key instead >>>> of the device ID; >>>> - drop the device ID requirement altogether; >>>> - introduce 'cpr_incoming' local here rather than in patch 14. >>>> >>>> * Patch 14: >>>> - lift the CPR blocker entirely instead of keeping it for ID-less >>>> devices; >>>> - skip RESET_OWNER in .pre_save() if the ownership was already >>>> released by a previous failed CPR attempt; >>>> - reword commit message. >>>> >>>> v5: https://lore.kernel.org/qemu-devel/20260914-up-vsock-vhost-v5-v5-0-d17423589f48@virtuozzo.com >>>> >>>> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> >>>> --- >>>> Andrey Drobyshev (14): >>>> migration/cpr: forbid saving duplicate CprFds into hash table >>>> tests/unit: add test for duplicate keys in CPR FD table >>>> migration: forbid snapshots in CPR migration modes >>>> tests/qtest/migration: add test for snapshot rejection in CPR modes >>>> vhost-vsock: block CPR migration modes >>>> vhost: add vhost_reset_owner op >>>> vhost-vsock: don't reset connections during CPR >>>> vhost-vsock: fix FD leak in realize() >>>> vhost-vsock: preserve vhost FD during CPR >>>> vhost: factor out vhost_dev_init_backend() >>>> vhost: make vhost_dev_cleanup() safe on a partially initialized device >>>> vhost: add vhost_dev_set_owner() / vhost_dev_reset_owner() helpers >>>> vhost: add vhost_dev_is_initialized() helper >>>> vhost-vsock: hand off device ownership across CPR >>>> >>>> backends/hostmem-memfd.c | 5 +- >>>> backends/hostmem-shm.c | 5 +- >>>> backends/iommufd.c | 4 +- >>>> hw/vfio/container-legacy.c | 17 ++-- >>>> hw/vfio/cpr-legacy.c | 10 +- >>>> hw/vfio/cpr.c | 6 +- >>>> hw/vfio/pci.c | 5 +- >>>> hw/virtio/vhost-kernel.c | 6 ++ >>>> hw/virtio/vhost-vsock.c | 193 +++++++++++++++++++++++++++++++++++--- >>>> hw/virtio/vhost.c | 57 ++++++++--- >>>> include/hw/vfio/vfio-cpr.h | 6 +- >>>> include/hw/virtio/vhost-backend.h | 2 + >>>> include/hw/virtio/vhost-vsock.h | 1 + >>>> include/hw/virtio/vhost.h | 61 ++++++++++++ >>>> include/migration/cpr.h | 2 +- >>>> migration/cpr.c | 55 +++++++---- >>>> migration/options.c | 7 ++ >>>> system/physmem.c | 5 +- >>>> tests/qtest/migration/cpr-tests.c | 36 ++++++- >>>> tests/unit/meson.build | 1 + >>>> tests/unit/test-cpr.c | 98 +++++++++++++++++++ >>>> 21 files changed, 512 insertions(+), 70 deletions(-) >>>> --- >>>> base-commit: 5f664cd37aec17e8145aa117d8da68f507edc8f1 >>>> change-id: 20260908-up-vsock-vhost-v5-c781b39f1c1a >>>> >>>> Best regards, >>>> -- >>>> Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> >>> >>> Hi! Don't you add a test for new functionality? >> Hi Vladimir, >> >> You're right, there's no dedicated tests yet. Basically there're 2 >> levels of testing: >> >> 1) Launch QEMU without a guest, with the device in question, and perform >> a CPR. Here we just test that QEMU survives the CPR op, i.e. that FD >> and device handling is fine from the QEMU side. >> >> 2) Actual test would be launching QEMU with a real guest, launch >> host<->guest data transfer and perform CPR during that. That's what >> I've been testing when preparing this series. >> >> As for the guest, AFAICT there're some functional tests which launch >> Fedora. So this part should be doable. > > If you want, look at my [PATCH 1/5] tests/functional: add test_tap_migration > > https://lore.kernel.org/qemu-devel/20260914175351.393680-2-vsementsov@yandex-team.ru/ > > it does local migration with live guest. Yes, your test indeed looks like I can derive a lot of things from it. Thanks! >> However one requirement for >> both tests to work is the host kernel having RESET_OWNER support - >> that's added by our recent kernel series, which isn't yet merged to >> kernel master as of now. So whichever Linux distro you run on your host >> now - it doesn't have this support and is not going to work. >> >> I'm not sure it makes sense adding a test which nobody else'd be able to >> run unless they build their own kernel. What do you think? >> > > But one day it (RESET_OWNER) will be merged, I assume? Would be good to > have a test at the moment. > > I don't insist. My (self-serving) idea is that if I have a test, it would > be easier to experiment and try to bring a "local migration" interface > here (like in the recently merged TAP series) :). Of course, not merged > RESET_OWNER make such experiments less possible just now.. > > For you, the test is the only thing that protects your code from being > broken by other changes. Even if you're the only one running this test, > when it breaks, you can bisect the breaking commit and say, > "Hey, you've broken the existing test with this commit.". Without the > test — you have no guarantee and no weapon. Sure we do already have RESET_OWNER in our downstream kernel, so I agree with you that this functionality is non-trivial and adding a test to our own downstream makes perfect sense. I was just not sure that it's meaningful to add it in the upstream where it's known to fail (at least for now). But now that I think of it - the feature itself is also not fully working now with the lack of RESET_OWNER support, so we might as well add the tests along with the actual feature implementation. Thanks, Andrey
© 2016 - 2026 Red Hat, Inc.