tests/migration-stress/stress.c | 140 +++++----- tests/qtest/migration/bootfile.c | 353 ++++++++++++++++++++++++- tests/qtest/migration/bootfile.h | 23 +- tests/qtest/migration/cpr-tests.c | 52 +++- tests/qtest/migration/framework.c | 269 ++++++------------- tests/qtest/migration/framework.h | 4 +- tests/qtest/migration/misc-tests.c | 1 + tests/qtest/migration/postcopy-tests.c | 6 +- tests/qtest/migration/precopy-tests.c | 19 +- 9 files changed, 606 insertions(+), 261 deletions(-)
There's a class of migration performance bugs that are very specific to the internals of QEMU and most likely require work on our side, but are currently invisible to our testing because migration-test runs a simple guest workload (not even that, really). The more important ones are BQL contention issues that result in vcpu starvation. My plan is to incrementally add some pieces to migration-test to reduce that testing gap. The first piece is adding support for running a kernel + initrd inside the guest which gives us an easy way to start exercising migration of a more loaded guest that can already cause VM exits. This series adds support for -kernel and -initrd arguments to migration-test and runs the same set of tests we currently have, but with the kernel instead of the custom loop. By default it uses the initrd from tests/migration-stress/ which runs a read-write loop over all memory and has customizable vcpu and memory size. I don't intend for this to run in CI nor for it to run by default. The developer needs to pass the options explicitly and bring at least their own kernel. My plan is to do pretty much what we did with the cross-migration work, keep it around, unubtrosive and stable so we can do experimentation and debugging when the need arises in an environment that is closer to where the bugs actually lie. I've been using this sporadically for downstream work and so far tested guests with a couple of TiB of ram and ~256 vcpus. With and without hugepages (more on this below). - patches 1 and 2 bring the stress.c up-to-date with current coding style and fix a bug. (note that guestperf is currently broken, I don't have bandwidth for it). - patch 3 consolidates some code into bootfile.c so we keep framework.c under control. - patch 4 adds parsing of dmesg and detection of panics and such. - patch 5 adds the support for kernel/initrd/append. Minimal invocation is: QTEST_MIG_KERNEL=/boot/vmlinuz-... QTEST_QEMU_BINARY=./qemu-system-x86_64 ./tests/qtest/migration-test extra env vars: QTEST_MIG_APPEND="" allows changing kernel command-line options. QTEST_MIG_GUEST_STDOUT=1 redirects the guest output CI run: https://gitlab.com/farosas/qemu/-/pipelines/3120905449 ==================================================================== Heads up for upcoming work, suggestions welcomed: - Hugepages support: so we can send the host into the costly dirty logging split/restore paths while the guest is loaded. This is already done, I just need to fish it out from a larger branch. - Worker thread: to execute in parallel with the migration so we can poke at QEMU directly instead of hoping for the right timing in the kernel. The worker thread infra is done, but no useful work to put in it so far. I wrote a work function that spams the serial console via qtest, but I haven't had success triggering any issues with it. (I also played a bit with adding the pci-testdev to the guest, but that code seems to have kvm-unit-test assumptions that I haven't figured out yet) Fabiano Rosas (5): tests/migration-stress: Fix stress.c loop tests/migration-stress: Cleanups to stress.c tests/qtest/migration: Move guest workload code into bootfile.c tests/qtest/migration: Adapt wait_for_serial routine for stress.c tests/qtest/migration: Make it possible to run stress.c tests/migration-stress/stress.c | 140 +++++----- tests/qtest/migration/bootfile.c | 353 ++++++++++++++++++++++++- tests/qtest/migration/bootfile.h | 23 +- tests/qtest/migration/cpr-tests.c | 52 +++- tests/qtest/migration/framework.c | 269 ++++++------------- tests/qtest/migration/framework.h | 4 +- tests/qtest/migration/misc-tests.c | 1 + tests/qtest/migration/postcopy-tests.c | 6 +- tests/qtest/migration/precopy-tests.c | 19 +- 9 files changed, 606 insertions(+), 261 deletions(-) -- 2.53.0
On Thu, Nov 26, 2026 at 06:46:59PM -0300, Fabiano Rosas wrote: > There's a class of migration performance bugs that are very specific > to the internals of QEMU and most likely require work on our side, but > are currently invisible to our testing because migration-test runs a > simple guest workload (not even that, really). The more important ones > are BQL contention issues that result in vcpu starvation. > > My plan is to incrementally add some pieces to migration-test to > reduce that testing gap. > > The first piece is adding support for running a kernel + initrd inside > the guest which gives us an easy way to start exercising migration of > a more loaded guest that can already cause VM exits. > > This series adds support for -kernel and -initrd arguments to > migration-test and runs the same set of tests we currently have, but > with the kernel instead of the custom loop. By default it uses the > initrd from tests/migration-stress/ which runs a read-write loop over > all memory and has customizable vcpu and memory size. The whole thing sounds useful, I'll read into details after I flush more of the older patches.. which will take some time (it also depends on if next week I got some more urgent task "injected"..). One high level question: this will grow qtest closer to what the functional test is doing. Have you thought of the relationship between the two, after we move qtest more over there? I assumed not, based on what you mentioned in the rest part of cover letter that you planned to have it only for dev debug purpose. But still, we'll start to ask the question to ourselves at some point, IIUC. So I ask first. :) -- Peter Xu
On Fri, Nov 27, 2026 at 08:45:04AM -0500, Peter Xu wrote: > On Thu, Nov 26, 2026 at 06:46:59PM -0300, Fabiano Rosas wrote: > > There's a class of migration performance bugs that are very specific > > to the internals of QEMU and most likely require work on our side, but > > are currently invisible to our testing because migration-test runs a > > simple guest workload (not even that, really). The more important ones > > are BQL contention issues that result in vcpu starvation. > > > > My plan is to incrementally add some pieces to migration-test to > > reduce that testing gap. > > > > The first piece is adding support for running a kernel + initrd inside > > the guest which gives us an easy way to start exercising migration of > > a more loaded guest that can already cause VM exits. > > > > This series adds support for -kernel and -initrd arguments to > > migration-test and runs the same set of tests we currently have, but > > with the kernel instead of the custom loop. By default it uses the > > initrd from tests/migration-stress/ which runs a read-write loop over > > all memory and has customizable vcpu and memory size. > > The whole thing sounds useful, I'll read into details after I flush more of > the older patches.. which will take some time (it also depends on if next > week I got some more urgent task "injected"..). > > One high level question: this will grow qtest closer to what the functional > test is doing. Have you thought of the relationship between the two, after > we move qtest more over there? I assumed not, based on what you mentioned > in the rest part of cover letter that you planned to have it only for dev > debug purpose. But still, we'll start to ask the question to ourselves at > some point, IIUC. So I ask first. :) In terms of the boundary between functional tests and qtests, I think the guidance is in the names. If it is a "qtest" test then it should be primarily making use of QTest to interrogate the QEMU internalprocess state. If it is a "functional" test, then it is interested in running real kernels & real accelerators and validating the behaviour of QEMU via its external mgmt interfaces. By this definition, IMHO, the migration-test would be a functional test, if it were created from scratch to. It only uses libqtest.h APIs for the purpose of sending QMP commands, not examining internal device state. Essentially it is a historical accident that it is written as a qtest instead of a functional test, as that was the best choice at the time. With regards, Daniel -- |: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Daniel P. Berrangé <berrange@redhat.com> writes: On Fri, Nov 27, 2026 at 08:45:04AM -0500, Peter Xu wrote: >> On Thu, Nov 26, 2026 at 06:46:59PM -0300, Fabiano Rosas wrote: >> > There's a class of migration performance bugs that are very specific >> > to the internals of QEMU and most likely require work on our side, but >> > are currently invisible to our testing because migration-test runs a >> > simple guest workload (not even that, really). The more important ones >> > are BQL contention issues that result in vcpu starvation. >> > >> > My plan is to incrementally add some pieces to migration-test to >> > reduce that testing gap. >> > >> > The first piece is adding support for running a kernel + initrd inside >> > the guest which gives us an easy way to start exercising migration of >> > a more loaded guest that can already cause VM exits. >> > >> > This series adds support for -kernel and -initrd arguments to >> > migration-test and runs the same set of tests we currently have, but >> > with the kernel instead of the custom loop. By default it uses the >> > initrd from tests/migration-stress/ which runs a read-write loop over >> > all memory and has customizable vcpu and memory size. >> > The whole thing sounds useful, I'll read into details after I flush more of > the older patches.. which will take some time (it also depends on if next > week I got some more urgent task "injected"..). > Take your time. I just need to put these out sooner rather than later because my internal branch is growing too big and I need feedback from the list before I get too deep. The hugepages series will come probably sometime next week and then I'll give you a break while I work on other stuff. --- > One high level question: this will grow qtest closer to what the > functional test is doing. Have you thought of the relationship > between the two, after we move qtest more over there? I'm not sure what "move" you mean. Are we porting tests to python? I'm definitely open to discussion, whatever it is. > I assumed not, based on what you mentioned > in the rest part of cover letter that you planned to have it only for dev > debug purpose. But still, we'll start to ask the question to ourselves at > some point, IIUC. So I ask first. :) I'm simply going through the path which I see is of least resistance. These additions are simple enough. Importantly: with this series we would be adding a different workload to the guest, but it still runs all the existing migration-tests. The same with the hugepages support, it's just another mem_type. For this to work with the functional tests we'd need to either duplicate the migration-tests there or write new tests. And we'd isolate the existing tests entirely from these new features. E.g.: I want to work on the migration performance around dirty log disabling, it performs worse when hugepages are enabled, it may trigger softlockups in the guest and it only happens when migration is aborted. The /migration/cancel/src/after/ tests can already exercise that path, work well and have caught bugs before. It just need hugepages and a kernel: args->mem_type=MEM_TYPE_HUGE MIG_KERNEL=vmlinuz \ HUGEPAGES=/dev/hugepages/... \ migration-test -p .../cancel/src/after > > In terms of the boundary between functional tests and qtests, I > think the guidance is in the names. > > If it is a "qtest" test then it should be primarily making use > of QTest to interrogate the QEMU internalprocess state. > Hm, quite arbitrary. A "qtest" is a test that uses QTest, ok, but we can do whatever kind of testing we want with it. If we want to stick to any formal definition, that is. I'm not sure we need to. > If it is a "functional" test, then it is interested in running > real kernels & real accelerators and validating the behaviour of > QEMU via its external mgmt interfaces. > > By this definition, IMHO, the migration-test would be a functional > test, if it were created from scratch to. > By any other definition it already is a functional test. I'm maybe being too literal. What I think you're trying to indicate (maybe Peter as well), is that we should preferably group the functional tests under tests/functional and migration-test.c is more functional test than anything else, so it should be in there as well. Except that since migration-test is written in a different programming language, we would have to leave migration-test.c as is and write new migration tests under tests/functional. > It only uses libqtest.h APIs for the purpose of sending QMP > commands, not examining internal device state. Essentially it is a > historical accident that it is written as a qtest instead of a > functional test, as that was the best choice at the time. > It uses qtest_read* to validate the guest memory, that was probably the reason, no? I also don't understand whatever happened to the whole QGraph/QOS thing, which, by initial commits seemed it had been written explicitly to support live migration testing.
On Fri, Nov 27, 2026 at 12:18:10PM -0300, Fabiano Rosas wrote: > Daniel P. Berrangé <berrange@redhat.com> writes: > On Fri, Nov 27, 2026 at 08:45:04AM -0500, Peter Xu wrote: > > >> On Thu, Nov 26, 2026 at 06:46:59PM -0300, Fabiano Rosas wrote: > >> > There's a class of migration performance bugs that are very specific > >> > to the internals of QEMU and most likely require work on our side, but > >> > are currently invisible to our testing because migration-test runs a > >> > simple guest workload (not even that, really). The more important ones > >> > are BQL contention issues that result in vcpu starvation. > >> > > >> > My plan is to incrementally add some pieces to migration-test to > >> > reduce that testing gap. > >> > > >> > The first piece is adding support for running a kernel + initrd inside > >> > the guest which gives us an easy way to start exercising migration of > >> > a more loaded guest that can already cause VM exits. > >> > > >> > This series adds support for -kernel and -initrd arguments to > >> > migration-test and runs the same set of tests we currently have, but > >> > with the kernel instead of the custom loop. By default it uses the > >> > initrd from tests/migration-stress/ which runs a read-write loop over > >> > all memory and has customizable vcpu and memory size. > >> > > The whole thing sounds useful, I'll read into details after I flush more of > > the older patches.. which will take some time (it also depends on if next > > week I got some more urgent task "injected"..). > > > > Take your time. I just need to put these out sooner rather than later > because my internal branch is growing too big and I need feedback from > the list before I get too deep. > > The hugepages series will come probably sometime next week and then I'll > give you a break while I work on other stuff. > --- > > > One high level question: this will grow qtest closer to what the > > functional test is doing. Have you thought of the relationship > > between the two, after we move qtest more over there? > > I'm not sure what "move" you mean. Are we porting tests to python? I'm > definitely open to discussion, whatever it is. > > > I assumed not, based on what you mentioned > > in the rest part of cover letter that you planned to have it only for dev > > debug purpose. But still, we'll start to ask the question to ourselves at > > some point, IIUC. So I ask first. :) > > I'm simply going through the path which I see is of least > resistance. These additions are simple enough. Importantly: with this > series we would be adding a different workload to the guest, but it > still runs all the existing migration-tests. > > The same with the hugepages support, it's just another mem_type. For > this to work with the functional tests we'd need to either duplicate the > migration-tests there or write new tests. And we'd isolate the existing > tests entirely from these new features. > > E.g.: I want to work on the migration performance around dirty log > disabling, it performs worse when hugepages are enabled, it may trigger > softlockups in the guest and it only happens when migration is aborted. > > The /migration/cancel/src/after/ tests can already exercise that path, > work well and have caught bugs before. It just need hugepages and a > kernel: > > args->mem_type=MEM_TYPE_HUGE > > MIG_KERNEL=vmlinuz \ > HUGEPAGES=/dev/hugepages/... \ > migration-test -p .../cancel/src/after > > > > > In terms of the boundary between functional tests and qtests, I > > think the guidance is in the names. > > > > If it is a "qtest" test then it should be primarily making use > > of QTest to interrogate the QEMU internalprocess state. > > > > Hm, quite arbitrary. A "qtest" is a test that uses QTest, ok, but we can > do whatever kind of testing we want with it. If we want to stick to any > formal definition, that is. I'm not sure we need to. > > > If it is a "functional" test, then it is interested in running > > real kernels & real accelerators and validating the behaviour of > > QEMU via its external mgmt interfaces. > > > > By this definition, IMHO, the migration-test would be a functional > > test, if it were created from scratch to. > > > > By any other definition it already is a functional test. > > I'm maybe being too literal. What I think you're trying to indicate > (maybe Peter as well), is that we should preferably group the functional > tests under tests/functional and migration-test.c is more functional > test than anything else, so it should be in there as well. Except that > since migration-test is written in a different programming language, we > would have to leave migration-test.c as is and write new migration tests > under tests/functional. Yeah, the functional tests have to be python to take advantage of the generic testing framework there, especially the asset download caching. > > It only uses libqtest.h APIs for the purpose of sending QMP > > commands, not examining internal device state. Essentially it is a > > historical accident that it is written as a qtest instead of a > > functional test, as that was the best choice at the time. > > > > It uses qtest_read* to validate the guest memory, that was probably the > reason, no? Oh, indeed, I missed that call :-( > I also don't understand whatever happened to the whole QGraph/QOS thing, > which, by initial commits seemed it had been written explicitly to > support live migration testing. I don't really know the history behind that. With regards, Daniel -- |: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
On Fri, Nov 27, 2026 at 02:01:13PM +0000, Daniel P. Berrangé wrote: > On Fri, Nov 27, 2026 at 08:45:04AM -0500, Peter Xu wrote: > > On Thu, Nov 26, 2026 at 06:46:59PM -0300, Fabiano Rosas wrote: > > > There's a class of migration performance bugs that are very specific > > > to the internals of QEMU and most likely require work on our side, but > > > are currently invisible to our testing because migration-test runs a > > > simple guest workload (not even that, really). The more important ones > > > are BQL contention issues that result in vcpu starvation. > > > > > > My plan is to incrementally add some pieces to migration-test to > > > reduce that testing gap. > > > > > > The first piece is adding support for running a kernel + initrd inside > > > the guest which gives us an easy way to start exercising migration of > > > a more loaded guest that can already cause VM exits. > > > > > > This series adds support for -kernel and -initrd arguments to > > > migration-test and runs the same set of tests we currently have, but > > > with the kernel instead of the custom loop. By default it uses the > > > initrd from tests/migration-stress/ which runs a read-write loop over > > > all memory and has customizable vcpu and memory size. > > > > The whole thing sounds useful, I'll read into details after I flush more of > > the older patches.. which will take some time (it also depends on if next > > week I got some more urgent task "injected"..). > > > > One high level question: this will grow qtest closer to what the functional > > test is doing. Have you thought of the relationship between the two, after > > we move qtest more over there? I assumed not, based on what you mentioned > > in the rest part of cover letter that you planned to have it only for dev > > debug purpose. But still, we'll start to ask the question to ourselves at > > some point, IIUC. So I ask first. :) > > In terms of the boundary between functional tests and qtests, I > think the guidance is in the names. > > If it is a "qtest" test then it should be primarily making use > of QTest to interrogate the QEMU internalprocess state. > > If it is a "functional" test, then it is interested in running > real kernels & real accelerators and validating the behaviour of > QEMU via its external mgmt interfaces. > > By this definition, IMHO, the migration-test would be a functional > test, if it were created from scratch to. True. > > It only uses libqtest.h APIs for the purpose of sending QMP > commands, not examining internal device state. Essentially it is a > historical accident that it is written as a qtest instead of a > functional test, as that was the best choice at the time. Yes, I didn't try to measure functional tests, but I think qtest is good choice even for now being very fast. Then the question is similar, where we will have two functional tests for migration, and we'll at some point think about what we do when they start to overlap (perhaps, already). -- Peter Xu
Peter Xu <peterx@redhat.com> writes: > On Fri, Nov 27, 2026 at 02:01:13PM +0000, Daniel P. Berrangé wrote: >> On Fri, Nov 27, 2026 at 08:45:04AM -0500, Peter Xu wrote: >> > On Thu, Nov 26, 2026 at 06:46:59PM -0300, Fabiano Rosas wrote: >> > > There's a class of migration performance bugs that are very specific >> > > to the internals of QEMU and most likely require work on our side, but >> > > are currently invisible to our testing because migration-test runs a >> > > simple guest workload (not even that, really). The more important ones >> > > are BQL contention issues that result in vcpu starvation. >> > > >> > > My plan is to incrementally add some pieces to migration-test to >> > > reduce that testing gap. >> > > >> > > The first piece is adding support for running a kernel + initrd inside >> > > the guest which gives us an easy way to start exercising migration of >> > > a more loaded guest that can already cause VM exits. >> > > >> > > This series adds support for -kernel and -initrd arguments to >> > > migration-test and runs the same set of tests we currently have, but >> > > with the kernel instead of the custom loop. By default it uses the >> > > initrd from tests/migration-stress/ which runs a read-write loop over >> > > all memory and has customizable vcpu and memory size. >> > >> > The whole thing sounds useful, I'll read into details after I flush more of >> > the older patches.. which will take some time (it also depends on if next >> > week I got some more urgent task "injected"..). >> > >> > One high level question: this will grow qtest closer to what the functional >> > test is doing. Have you thought of the relationship between the two, after >> > we move qtest more over there? I assumed not, based on what you mentioned >> > in the rest part of cover letter that you planned to have it only for dev >> > debug purpose. But still, we'll start to ask the question to ourselves at >> > some point, IIUC. So I ask first. :) >> >> In terms of the boundary between functional tests and qtests, I >> think the guidance is in the names. >> >> If it is a "qtest" test then it should be primarily making use >> of QTest to interrogate the QEMU internalprocess state. >> >> If it is a "functional" test, then it is interested in running >> real kernels & real accelerators and validating the behaviour of >> QEMU via its external mgmt interfaces. >> >> By this definition, IMHO, the migration-test would be a functional >> test, if it were created from scratch to. > > True. > >> >> It only uses libqtest.h APIs for the purpose of sending QMP >> commands, not examining internal device state. Essentially it is a >> historical accident that it is written as a qtest instead of a >> functional test, as that was the best choice at the time. > > Yes, I didn't try to measure functional tests, but I think qtest is good > choice even for now being very fast. > Come on, it's a good choice because it exists. Look at the amount of stuff we test in migration-test.c. > Then the question is similar, where we will have two functional tests for > migration, and we'll at some point think about what we do when they start > to overlap (perhaps, already). We could have avoided putting ourselves in this situation if we had agreed upfront on what the plan would be. We had 3 or 4 useless tests in avocado that could have just been dropped back then and now we'd have only one test-suite for migration functional testing. People insisted anyway and now: ooops, duplicated effort! =) Unfortunately, I get the short end of the stick because instead of implementing some custom solution downstream I decided to use the upstream code for my testing. Do we want to centralize on the python code? Let's decide one way or another. I promise I won't complain after the fact. - We could freeze migration-test.c now and declare new tests go to either qos, functional or unit only. - Or keep migration-test.c as a suite for testing subsystem core features only (the various capabilities, dirty tracking, etc.) and unless a new feature comes up, tests go in functional/. - Or something else... I'm about to start some work on vmstate-static-checker.py now that Pierrick provided us with the infra to build every QEMU version in a container, so it's an opportune time. Don't forget that once the AI gates fully open we'll probably get a flood of new tests, it would be good to have a single message.
© 2016 - 2026 Red Hat, Inc.