migration: Add COLO multifd support and COLO migration unit test
v2 cover migration: Add COLO multifd support and COLO migration unit test
Hello everyone,
This adds COLO multifd support and migration unit tests for COLO migration and failover.
Regards,
Lukas
---
Changes in v2:
- Fix review comments
- Hide stderr in colo migration test since the logged errors are expected
- Add benchmarking data for multifd
- Add myself as maintainer for COLO migration framework
- Link to v1: https://lore.kernel.org/qemu-devel/[email protected]
---
Lukas Straub (8):
MAINTAINERS: Add myself as maintainer for COLO migration framework
MAINTAINERS: Remove Hailiang Zhang from COLO migration framework Move ram state receive into multifd_ram_state_recv()
multifd: Add COLO support
migration-test: Add COLO migration unit test
Convert colo main documentation to restructuredText qemu-colo.rst: Miscellaneous changes
qemu-colo.rst: Simplify the block replication setup
MAINTAINERS | 6 +- docs/COLO-FT.txt | 334 ---------------------------------- docs/system/index.rst | 1 + docs/system/qemu-colo.rst | 355 +++++++++++++++++++++++++++++++++++++ migration/meson.build | 2 +- migration/multifd-colo.c | 49 +++++ migration/multifd-colo.h | 26 +++ migration/multifd.c | 23 ++- migration/multifd.h | 1 + tests/qtest/meson.build | 7 +- tests/qtest/migration-test.c | 1 + tests/qtest/migration/colo-tests.c | 113 ++++++++++++ tests/qtest/migration/framework.c | 87 ++++++++- tests/qtest/migration/framework.h | 10 ++ 14 files changed, 675 insertions(+), 340 deletions(-)
---
base-commit: 42a5675aa9dd718f395ca3279098051dfdbbc6e1
change-id: 20251230-colo_unit_test_multifd-8bf58dcebd46
Best regards,
Signature · 1 line
Lukas Straub <[email protected]>
PATCH v2 1/8 MAINTAINERS: Add myself as maintainer for COLO migration framework
I am ready to maintain it.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -3835,6 +3835,7 @@ F: qapi/yank.json COLO Framework M: Hailiang Zhang <[email protected]> +M: Lukas Straub <[email protected]> S: Maintained F: migration/colo* F: include/migration/colo.h
Signature · 1 line
2.39.5
Re: [PATCH v2 1/8] MAINTAINERS: Add myself as maintainer for COLO migration framework
Quoted 3 lines · Lukas Straub
I am ready to maintain it.
Signed-off-by Lukas Straub <[email protected]>
Signature · 1 line
Peter Xu
Zhang Chen
Reviewed-byRe: [PATCH v2 1/8] MAINTAINERS: Add myself as maintainer for COLO migration framework
Quoted 8 lines · Peter Xu
Quoted 3 lines · Lukas Straub
I am ready to maintain it.
Signed-off-by Lukas Straub <[email protected]>Reviewed-by Peter Xu <[email protected]>
Quoted 3 lines
--
Peter Xu
PATCH v2 2/8 MAINTAINERS: Remove Hailiang Zhang from COLO migration framework
In reply to Lukas StraubHis last email to the mailing list is from December 2021:
https://lore.kernel.org/qemu-devel/[email protected]/
--- MAINTAINERS | 1 - 1 file changed, 1 deletion(-)
MAINTAINERS +0 -1
@@ -3834,7 +3834,6 @@ F: include/qemu/yank.h F: qapi/yank.json COLO Framework -M: Hailiang Zhang <[email protected]> M: Lukas Straub <[email protected]> S: Maintained F: migration/colo*
Signature · 1 line
2.39.5
Re: [PATCH v2 2/8] MAINTAINERS: Remove Hailiang Zhang from COLO migration framework
Quoted 4 lines · Lukas Straub
His last email to the mailing list is from December 2021:
https://lore.kernel.org/qemu-devel/[email protected]/Signed-off-by Lukas Straub <[email protected]>
Signature · 1 line
Peter Xu
Zhang Chen
Reviewed-byRe: [PATCH v2 2/8] MAINTAINERS: Remove Hailiang Zhang from COLO migration framework
Quoted 9 lines · Peter Xu
Quoted 4 lines · Lukas Straub
His last email to the mailing list is from December 2021:
https://lore.kernel.org/qemu-devel/[email protected]/Signed-off-by Lukas Straub <[email protected]>Reviewed-by Peter Xu <[email protected]>
Quoted 3 lines
--
Peter Xu
PATCH v2 3/8 Move ram state receive into multifd_ram_state_recv()
In reply to Lukas StraubThis is in preparation for the next patch.
--- migration/multifd.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
migration/multifd.c +10 -1
@@ -1265,6 +1265,15 @@ static int multifd_device_state_recv(MultiFDRecvParams *p, Error **errp)return ret; } +static int multifd_ram_state_recv (MultiFDRecvParams *p,Error **errp) +{ +int ret; + + ret = multifd_recv_state->ops->recv (p, errp); + +return ret; +} +static void *multifd_recv_thread (void *opaque) {MigrationState *s =migrate_get_current ();
@@ -1399,7 +1408,7 @@ static void *multifd_recv_thread(void *opaque)assert (use_packets); ret =multifd_device_state_recv (p, &local_err); }else { - ret = multifd_recv_state->ops->recv (p, &local_err); + ret =multifd_ram_state_recv (p, &local_err); }if (ret !=0 ) {break ;
Signature · 1 line
2.39.5
Re: [PATCH v2 3/8] Move ram state receive into multifd_ram_state_recv()
Quoted 3 lines · Lukas Straub
This is in preparation for the next patch.
Signed-off-by Lukas Straub <[email protected]>
Signature · 1 line
Peter Xu
PATCH v2 4/8 multifd: Add COLO support
In reply to Lukas StraubLike in the normal ram_load() path, put the received pages into the colo cache and mark the pages in the bitmap so that they will be flushed to the guest later.
Multifd with COLO is useful to reduce the VM pause time during checkpointing for latency sensitive workloads. In such workloads the worst-case latency is especially important.
Also, multifd migration is the preferred way to do migration nowadays and this allows to use multifd compression with COLO.
Benchmark:
Cluster nodes
- Intel Xenon E5-2630 v3
- 48Gb RAM
- 10G Ethernet
Guest
- Windows Server 2016
- 6Gb RAM
- 4 cores
Workload
- Upload a file to the guest with SMB to simulate moderate memory dirtying
- Measure the memory transfer time portion of each checkpoint
- 600ms COLO checkpoint interval
Results
Plain
idle mean: 4.50ms 99per: 10.33ms
load mean: 24.30ms 99per: 78.05ms
Multifd-4
idle mean: 6.48ms 99per: 10.41ms
load mean: 14.12ms 99per: 31.27ms
Evaluation
While multifd has slightly higher latency when the guest idles, it is 10ms faster under load and more importantly it's worst case latency is less than 1/2 of plain under load as can be seen in the 99. Percentile.
--- MAINTAINERS | 1 + migration/meson.build | 2 +- migration/multifd-colo.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ migration/multifd-colo.h | 26 +++++++++++++++++++++++++ migration/multifd.c | 12 ++++++++++++ migration/multifd.h | 1 + 6 files changed, 90 insertions(+), 1 deletion(-)
MAINTAINERS +1 -0
@@ -3837,6 +3837,7 @@ COLO Framework M: Lukas Straub <[email protected]> S: Maintained F: migration/colo* +F: migration/multifd-colo.* F: include/migration/colo.h F: include/migration/failover.h F: docs/COLO-FT.txt
migration/meson.build +1 -1
@@ -40,7 +40,7 @@ system_ss.add(files( ), gnutls, zlib) if get_option('replication').allowed() - system_ss.add(files('colo-failover.c', 'colo.c')) + system_ss.add(files('colo-failover.c', 'colo.c', 'multifd-colo.c')) else system_ss.add(files('colo-stubs.c')) endif
migration/multifd-colo.c new file +49 -0
49 lines not on this page · raw message
migration/multifd-colo.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* multifd colo header +* +* Copyright (c) Lukas Straub <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef QEMU_MIGRATION_MULTIFD_COLO_H +#define QEMU_MIGRATION_MULTIFD_COLO_H + +#ifdef CONFIG_REPLICATION + +void multifd_colo_prepare_recv (MultiFDRecvParams *p); +void multifd_colo_process_recv (MultiFDRecvParams *p); + +#else + +static inline void multifd_colo_prepare_recv (MultiFDRecvParams *p) {} +static inline void multifd_colo_process_recv (MultiFDRecvParams *p) {} + +#endif +#endif
migration/multifd.c +12 -0
@@ -29,6 +29,7 @@#include "qemu-file.h" #include "trace.h" #include "multifd.h" +#include "multifd-colo.h" #include "threadinfo.h" #include "options.h" #include "qemu/yank.h"
@@ -1269,7 +1270,18 @@ static int multifd_ram_state_recv(MultiFDRecvParams *p, Error **errp) {int ret; +if (migrate_colo ()) { +multifd_colo_prepare_recv (p); + } + ret = multifd_recv_state->ops->recv (p, errp); +if (ret !=0 ) { +return ret; + } + +if (migrate_colo ()) { +multifd_colo_process_recv (p); + }return ret; }
migration/multifd.h +1 -0
@@ -280,6 +280,7 @@ typedef struct {/* ramblock */ RAMBlock *block;/* ramblock host address */ +/* or points to the corresponding address in the colo cache */ uint8_t *host;/* buffers to recv */ struct iovec *iov;
Signature · 1 line
2.39.5
Re: [PATCH v2 4/8] multifd: Add COLO support
Quoted 26 lines · Lukas Straub
Like in the normal
ram_load()path, put the received pages into the colo cache and mark the pages in the bitmap so that they will be flushed to the guest later.Multifd with COLO is useful to reduce the VM pause time during checkpointing for latency sensitive workloads. In such workloads the worst-case latency is especially important.
Also, multifd migration is the preferred way to do migration nowadays and this allows to use multifd compression with COLO.
Benchmark:
Cluster nodes
- Intel Xenon E5-2630 v3
- 48Gb RAM
- 10G Ethernet
Guest
- Windows Server 2016
- 6Gb RAM
- 4 cores
Workload
- Upload a file to the guest with SMB to simulate moderate memory dirtying
- Measure the memory transfer time portion of each checkpoint
- 600ms COLO checkpoint interval
Quoted 7 lines
Results
Plain
idle mean: 4.50ms 99per: 10.33ms
load mean: 24.30ms 99per: 78.05ms
Multifd-4
idle mean: 6.48ms 99per: 10.41ms
load mean: 14.12ms 99per: 31.27ms
Thanks for the numbers. They're persuasive at least from 1st look.
Said that, one major question is, multifd should only help with throughput when cpu is a bottleneck sending, in your case it's 10Gbps NIC. Normally any decent cpu should be able to push closer to 10Gbps even without multifd.
Per my previous experiences, multifd can only show a difference when the hosts have at least 25GBps+ bandwidth available.
Maybe you turned on compression already? If so, worth stating the compressor methods chosen / parameters.
Quoted 74 lines
Evaluation
While multifd has slightly higher latency when the guest idles, it is 10ms faster under load and more importantly it's worst case latency is less than 1/2 of plain under load as can be seen in the 99. Percentile.Signed-off-by Juan Quintela <[email protected]>Signed-off-by Lukas Straub <[email protected]>--- MAINTAINERS | 1 + migration/meson.build | 2 +- migration/multifd-colo.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ migration/multifd-colo.h | 26 +++++++++++++++++++++++++ migration/multifd.c | 12 ++++++++++++ migration/multifd.h | 1 + 6 files changed, 90 insertions(+), 1 deletion(-)MAINTAINERS +1
-0@@ -3837,6 +3837,7 @@ COLO Framework M: Lukas Straub <[email protected]> S: Maintained F: migration/colo* +F: migration/multifd-colo.* F: include/migration/colo.h F: include/migration/failover.h F: docs/COLO-FT.txtmigration/meson.build +1
-1@@ -40,7 +40,7 @@ system_ss.add(files( ), gnutls, zlib) if get_option('replication').allowed() - system_ss.add(files('colo-failover.c', 'colo.c')) + system_ss.add(files('colo-failover.c', 'colo.c', 'multifd-colo.c')) else system_ss.add(files('colo-stubs.c')) endifmigration/multifd-colo.c new file +26
-0@@ -0,0 +1,49 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* multifd colo implementation +* +* Copyright (c) Lukas Straub <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "exec/target_page.h" +#include "qemu/error-report.h" +#include "qapi/error.h" +#include "ram.h" +#include "multifd.h" +#include "options.h" +#include "io/channel-socket.h" +#include "migration/colo.h" +#include "multifd-colo.h" +#include "system/ramblock.h" + +void multifd_colo_prepare_recv (MultiFDRecvParams *p) +{ +assert (p->block->colo_cache);
migration/multifd-colo.c line 36
Quoted 10 lines
migration/multifd-colo.c new file +10
-0+ +/* +* While we're still in precopy state (not yet in colo state), we copy +* received pages to both guest and cache. No need to set dirty bits, +* since guest and cache memory are in sync. +*/ +if (migration_incoming_in_colo_state ()) { +colo_record_bitmap (p->block, p->normal, p->normal_num); + } + p->host = p->block->colo_cache;
I should have mentioned it while reviewing the previous version, anyway..
IMHO it would be better to have one place setting p->host instead of overwritting it.
So instead of hooking before ->recv(), we should do it in multifd_ram_unfill_packet(), moving the p->host update to the end of function and hook it there with COLO (so that you can still record the bitmaps, only after normal[]).
Another thing, which might be more important: you seem to have ignored zero[], but I think you need it. zero[] keeps all pages that are zeros (which may not used to be zeros). So IMHO you'll need to record them as dirty too in COLO's dest bitmap, otherwise you may hit hard to debug RAM corruptions.
migration/multifd-colo.c line 48
Quoted 12 lines
migration/multifd-colo.c new file +12
-0+} + +void multifd_colo_process_recv (MultiFDRecvParams *p) +{ +if (!migration_incoming_in_colo_state ()) { +for (int i =0 ; i < p->normal_num; i++) { +void *guest = p->block->host + p->normal[i]; +void *cache = p->host + p->normal[i]; +memcpy (guest, cache,multifd_ram_page_size ()); + } + } + p->host = p->block->host;
Is resetting the pointer required? If not, we can skip it.
Quoted 69 lines
migration/multifd-colo.c new file +1
-0+}migration/multifd-colo.h new file +26
-0@@ -0,0 +1,26 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* multifd colo header +* +* Copyright (c) Lukas Straub <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef QEMU_MIGRATION_MULTIFD_COLO_H +#define QEMU_MIGRATION_MULTIFD_COLO_H + +#ifdef CONFIG_REPLICATION + +void multifd_colo_prepare_recv (MultiFDRecvParams *p); +void multifd_colo_process_recv (MultiFDRecvParams *p); + +#else + +static inline void multifd_colo_prepare_recv (MultiFDRecvParams *p) {} +static inline void multifd_colo_process_recv (MultiFDRecvParams *p) {} + +#endif +#endif migration/multifd.c +12
-0@@ -29,6 +29,7 @@#include "qemu-file.h" #include "trace.h" #include "multifd.h" +#include "multifd-colo.h" #include "threadinfo.h" #include "options.h" #include "qemu/yank.h" @@ -1269,7 +1270,18 @@ static int multifd_ram_state_recv(MultiFDRecvParams *p, Error **errp) {int ret; +if (migrate_colo ()) { +multifd_colo_prepare_recv (p); + } + ret = multifd_recv_state->ops->recv (p, errp); +if (ret !=0 ) { +return ret; + } + +if (migrate_colo ()) { +multifd_colo_process_recv (p); + }return ret; }migration/multifd.h +0
-0
migration/multifd.h typedef struct { · line 283
Quoted 4 lines
migration/multifd.h +1
-0@@ -280,6 +280,7 @@ typedef struct {/* ramblock */ RAMBlock *block;/* ramblock host address */ +/* or points to the corresponding address in the colo cache */
Nit: we can merge it with /* ... */, and some wording change:
/*
* Normally, it points to ramblock's host address. When COLO
* enabled, it points to the mirror cache for the ramblock. */
Quoted 7 lines
migration/multifd.h +0
-0uint8_t *host;/* buffers to recv */ struct iovec *iov;Signature · 2 lines
-- 2.39.5
Signature · 1 line
Peter Xu
Re: [PATCH v2 4/8] multifd: Add COLO support
Quoted 35 lines · Peter Xu
Quoted 26 lines · Lukas Straub
Like in the normal
ram_load()path, put the received pages into the colo cache and mark the pages in the bitmap so that they will be flushed to the guest later.Multifd with COLO is useful to reduce the VM pause time during checkpointing for latency sensitive workloads. In such workloads the worst-case latency is especially important.
Also, multifd migration is the preferred way to do migration nowadays and this allows to use multifd compression with COLO.
Benchmark:
Cluster nodes
- Intel Xenon E5-2630 v3
- 48Gb RAM
- 10G Ethernet
Guest
- Windows Server 2016
- 6Gb RAM
- 4 cores
Workload
- Upload a file to the guest with SMB to simulate moderate memory dirtying
- Measure the memory transfer time portion of each checkpoint
- 600ms COLO checkpoint intervalQuoted 7 lines
Results
Plain
idle mean: 4.50ms 99per: 10.33ms
load mean: 24.30ms 99per: 78.05ms
Multifd-4
idle mean: 6.48ms 99per: 10.41ms
load mean: 14.12ms 99per: 31.27ms
Quoted 6 lines
Thanks for the numbers. They're persuasive at least from 1st look.
Said that, one major question is, multifd should only help with throughput when cpu is a bottleneck sending, in your case it's 10Gbps NIC. Normally any decent cpu should be able to push closer to 10Gbps even without multifd.
That assumes the CPUs used by migration are otherwise idle though. If the host is busy running guest workloads, only small timeslices may be available for use by migration threads. Using multifd would better utilize what's available if multiple host CPUs have partial availability.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH v2 4/8] multifd: Add COLO support
Quoted 43 lines · Daniel P. Berrangé
Quoted 35 lines · Peter Xu
Quoted 26 lines · Lukas Straub
Like in the normal
ram_load()path, put the received pages into the colo cache and mark the pages in the bitmap so that they will be flushed to the guest later.Multifd with COLO is useful to reduce the VM pause time during checkpointing for latency sensitive workloads. In such workloads the worst-case latency is especially important.
Also, multifd migration is the preferred way to do migration nowadays and this allows to use multifd compression with COLO.
Benchmark:
Cluster nodes
- Intel Xenon E5-2630 v3
- 48Gb RAM
- 10G Ethernet
Guest
- Windows Server 2016
- 6Gb RAM
- 4 cores
Workload
- Upload a file to the guest with SMB to simulate moderate memory dirtying
- Measure the memory transfer time portion of each checkpoint
- 600ms COLO checkpoint intervalQuoted 7 lines
Results
Plain
idle mean: 4.50ms 99per: 10.33ms
load mean: 24.30ms 99per: 78.05ms
Multifd-4
idle mean: 6.48ms 99per: 10.41ms
load mean: 14.12ms 99per: 31.27msQuoted 6 lines
Thanks for the numbers. They're persuasive at least from 1st look.
Said that, one major question is, multifd should only help with throughput when cpu is a bottleneck sending, in your case it's 10Gbps NIC. Normally any decent cpu should be able to push closer to 10Gbps even without multifd.
Quoted 4 lines
That assumes the CPUs used by migration are otherwise idle though. If the host is busy running guest workloads, only small timeslices may be available for use by migration threads. Using multifd would better utilize what's available if multiple host CPUs have partial availability.
Hmm, I'm not sure this is the case for when the test was run above. I rarely see a host's CPUs been completely occupied. Say, on 16 cores system it means ~1600% CPU utilization.
I think it's because normally when a host will be hosting VMs, we should normally have some of CPU resources reserved for host housekeeping. Otherwise I'm not sure how to guarantee general availability of the host.. and IIUC it may also affect the guest.
Here, IMHO as long as there's >100% CPU resource on this host (e.g. out of 1600% on a 16 cores system), enabling multifd or not shouldn't matter much when the NIC is 10Gbps.
Old but decent processor should be able to push 10~15Gbps, new processor should be able to push to ~25Gbps or more, with 100% CPU resource.
It's because the scheduler will schedule whatever thread (either the migration thread alone, or multifd threads) onto whatever core that will still be free (or some cores that have free cycles).
When all CPUs are occupied, IMHO multifd shouldn't help much either.. maybe >1 threads make it easier to get scheduled (hence more time slices from scheduler), but I believe that's not the major use case for multifd.. it should really be when there're plenty of CPU resources.
Thanks,
Signature · 1 line
Peter Xu
Re: [PATCH v2 4/8] multifd: Add COLO support
In reply to Peter XuQuoted 42 lines · On Tue, 20 Jan 2026 12:13:58 -0500 Peter Xu <[email protected]> wrote:
Quoted 26 lines · Lukas Straub
Like in the normal
ram_load()path, put the received pages into the colo cache and mark the pages in the bitmap so that they will be flushed to the guest later.Multifd with COLO is useful to reduce the VM pause time during checkpointing for latency sensitive workloads. In such workloads the worst-case latency is especially important.
Also, multifd migration is the preferred way to do migration nowadays and this allows to use multifd compression with COLO.
Benchmark:
Cluster nodes
- Intel Xenon E5-2630 v3
- 48Gb RAM
- 10G Ethernet
Guest
- Windows Server 2016
- 6Gb RAM
- 4 cores
Workload
- Upload a file to the guest with SMB to simulate moderate memory dirtying
- Measure the memory transfer time portion of each checkpoint
- 600ms COLO checkpoint intervalQuoted 7 lines
Results
Plain
idle mean: 4.50ms 99per: 10.33ms
load mean: 24.30ms 99per: 78.05ms
Multifd-4
idle mean: 6.48ms 99per: 10.41ms
load mean: 14.12ms 99per: 31.27msThanks for the numbers. They're persuasive at least from 1st look.
Said that, one major question is, multifd should only help with throughput when cpu is a bottleneck sending, in your case it's 10Gbps NIC. Normally any decent cpu should be able to push closer to 10Gbps even without multifd.
Quoted 5 lines
Per my previous experiences, multifd can only show a difference when the hosts have at least 25GBps+ bandwidth available.
Maybe you turned on compression already? If so, worth stating the compressor methods chosen / parameters.
No, it's just the old Haswell CPU I guess. My clients also use it on embedded platforms with embedded/mobile CPUs, so not necessarily the fastest CPUs.
Btw, I forgot to mention, it's already worth it for the precopy phase as it helps with converging. And also for my other patch that sends dirty ram in the time between the checkpoints.
Quoted 88 lines
Quoted 75 lines
Evaluation
While multifd has slightly higher latency when the guest idles, it is 10ms faster under load and more importantly it's worst case latency is less than 1/2 of plain under load as can be seen in the 99. Percentile.Signed-off-by Juan Quintela <[email protected]>Signed-off-by Lukas Straub <[email protected]>--- MAINTAINERS | 1 + migration/meson.build | 2 +- migration/multifd-colo.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ migration/multifd-colo.h | 26 +++++++++++++++++++++++++ migration/multifd.c | 12 ++++++++++++ migration/multifd.h | 1 + 6 files changed, 90 insertions(+), 1 deletion(-)MAINTAINERS +1
-0@@ -3837,6 +3837,7 @@ COLO Framework M: Lukas Straub <[email protected]> S: Maintained F: migration/colo* +F: migration/multifd-colo.* F: include/migration/colo.h F: include/migration/failover.h F: docs/COLO-FT.txtmigration/meson.build +1
-1@@ -40,7 +40,7 @@ system_ss.add(files( ), gnutls, zlib) if get_option('replication').allowed() - system_ss.add(files('colo-failover.c', 'colo.c')) + system_ss.add(files('colo-failover.c', 'colo.c', 'multifd-colo.c')) else system_ss.add(files('colo-stubs.c')) endifmigration/multifd-colo.c new file +26
-0@@ -0,0 +1,49 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* multifd colo implementation +* +* Copyright (c) Lukas Straub <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "exec/target_page.h" +#include "qemu/error-report.h" +#include "qapi/error.h" +#include "ram.h" +#include "multifd.h" +#include "options.h" +#include "io/channel-socket.h" +#include "migration/colo.h" +#include "multifd-colo.h" +#include "system/ramblock.h" + +void multifd_colo_prepare_recv (MultiFDRecvParams *p) +{ +assert (p->block->colo_cache);migration/multifd-colo.c line 36
Quoted 10 lines
migration/multifd-colo.c new file +10
-0+ +/* +* While we're still in precopy state (not yet in colo state), we copy +* received pages to both guest and cache. No need to set dirty bits, +* since guest and cache memory are in sync. +*/ +if (migration_incoming_in_colo_state ()) { +colo_record_bitmap (p->block, p->normal, p->normal_num); + } + p->host = p->block->colo_cache;I should have mentioned it while reviewing the previous version, anyway..
Quoted 7 lines
IMHO it would be better to have one place setting
p->hostinstead of overwritting it.So instead of hooking before ->recv(), we should do it in
multifd_ram_unfill_packet(), moving thep->hostupdate to the end of function and hook it there with COLO (so that you can still record the bitmaps, only after normal[]).
Okay, will fix that in the next version.
Quoted 6 lines
Another thing, which might be more important: you seem to have ignored zero[], but I think you need it. zero[] keeps all pages that are zeros (which may not used to be zeros). So IMHO you'll need to record them as dirty too in COLO's dest bitmap, otherwise you may hit hard to debug RAM corruptions.
Yes, that is a good catch. I missed that during forward porting.
Quoted 15 lines
migration/multifd-colo.c line 48
Quoted 13 lines
migration/multifd-colo.c new file +12
-0+} + +void multifd_colo_process_recv (MultiFDRecvParams *p) +{ +if (!migration_incoming_in_colo_state ()) { +for (int i =0 ; i < p->normal_num; i++) { +void *guest = p->block->host + p->normal[i]; +void *cache = p->host + p->normal[i]; +memcpy (guest, cache,multifd_ram_page_size ()); + } + } + p->host = p->block->host;Is resetting the pointer required? If not, we can skip it.
Not that I can see, i will remove this in the next version.
Quoted 77 lines
Quoted 70 lines
migration/multifd-colo.c new file +1
-0+}migration/multifd-colo.h new file +26
-0@@ -0,0 +1,26 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* multifd colo header +* +* Copyright (c) Lukas Straub <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef QEMU_MIGRATION_MULTIFD_COLO_H +#define QEMU_MIGRATION_MULTIFD_COLO_H + +#ifdef CONFIG_REPLICATION + +void multifd_colo_prepare_recv (MultiFDRecvParams *p); +void multifd_colo_process_recv (MultiFDRecvParams *p); + +#else + +static inline void multifd_colo_prepare_recv (MultiFDRecvParams *p) {} +static inline void multifd_colo_process_recv (MultiFDRecvParams *p) {} + +#endif +#endif migration/multifd.c +12
-0@@ -29,6 +29,7 @@#include "qemu-file.h" #include "trace.h" #include "multifd.h" +#include "multifd-colo.h" #include "threadinfo.h" #include "options.h" #include "qemu/yank.h" @@ -1269,7 +1270,18 @@ static int multifd_ram_state_recv(MultiFDRecvParams *p, Error **errp) {int ret; +if (migrate_colo ()) { +multifd_colo_prepare_recv (p); + } + ret = multifd_recv_state->ops->recv (p, errp); +if (ret !=0 ) { +return ret; + } + +if (migrate_colo ()) { +multifd_colo_process_recv (p); + }return ret; }migration/multifd.h +0
-0migration/multifd.h typedef struct { · line 283
Quoted 4 lines
migration/multifd.h +1
-0@@ -280,6 +280,7 @@ typedef struct {/* ramblock */ RAMBlock *block;/* ramblock host address */ +/* or points to the corresponding address in the colo cache */ Nit: we can merge it with /* ... */, and some wording change:
Quoted 4 lines
/*
* Normally, it points to ramblock's host address. When COLO
* enabled, it points to the mirror cache for the ramblock. */
Okay, will fix this.
Quoted 9 lines
Quoted 8 lines
migration/multifd.h +0
-0uint8_t *host;/* buffers to recv */ struct iovec *iov;Signature · 2 lines
-- 2.39.5
PATCH v2 5/8 migration-test: Add COLO migration unit test
In reply to Lukas StraubAdd a COLO migration test for COLO migration and failover.
COLO does not support q35 machine at this time.
--- MAINTAINERS | 1 + tests/qtest/meson.build | 7 ++- tests/qtest/migration-test.c | 1 + tests/qtest/migration/colo-tests.c | 113 +++++++++++++++++++++++++++++++++++++ tests/qtest/migration/framework.c | 87 +++++++++++++++++++++++++++- tests/qtest/migration/framework.h | 10 ++++ 6 files changed, 217 insertions(+), 2 deletions(-)
MAINTAINERS +1 -0
@@ -3840,6 +3840,7 @@ F: migration/colo* F: migration/multifd-colo.* F: include/migration/colo.h F: include/migration/failover.h +F: tests/qtest/migration/colo-tests.c F: docs/COLO-FT.txt COLO Proxy
tests/qtest/meson.build +6 -1
@@ -367,6 +367,11 @@ if gnutls.found() endif endif +migration_colo_files = [] +if get_option('replication').allowed() + migration_colo_files = [files('migration/colo-tests.c')] +endif + qtests = { 'aspeed_hace-test': files('aspeed-hace-utils.c', 'aspeed_hace-test.c'), 'aspeed_smc-test': files('aspeed-smc-utils.c', 'aspeed_smc-test.c'),
@@ -378,7 +383,7 @@ qtests = { 'migration/migration-util.c') + dbus_vmstate1, 'erst-test': files('erst-test.c'), 'ivshmem-test': [rt, '../../contrib/ivshmem-server/ivshmem-server.c'], - 'migration-test': test_migration_files + migration_tls_files, + 'migration-test': test_migration_files + migration_tls_files + migration_colo_files, 'pxe-test': files('boot-sector.c'), 'pnv-xive2-test': files('pnv-xive2-common.c', 'pnv-xive2-flush-sync.c', 'pnv-xive2-nvpg_bar.c'),
tests/qtest/migration-test.c +1 -0
@@ -55,6 +55,7 @@ int main(int argc, char **argv)migration_test_add_precopy (env);migration_test_add_cpr (env);migration_test_add_misc (env); +migration_test_add_colo (env); ret =g_test_run ();
tests/qtest/migration/colo-tests.c new file +113 -0
113 lines not on this page · raw message
tests/qtest/migration/framework.c +86 -1
99 lines not on this page · raw message
tests/qtest/migration/framework.h +10 -0
@@ -139,6 +139,9 @@ typedef struct {/* Do not connect to target monitor and qtest sockets in qtest_init */ bool defer_target_connect; +/* Use pc machine for x86_64 */ +bool force_pc_machine; +/* * Migration capabilities to be set in both source and * destination. For unilateral capabilities, use
@@ -248,6 +251,8 @@ void test_postcopy_common(MigrateCommon *args);void test_postcopy_recovery_common (MigrateCommon *args);int test_precopy_common (MigrateCommon *args);void test_file_common (MigrateCommon *args,bool stop_src); +int test_colo_common (MigrateCommon *args,bool failover_during_checkpoint, +bool colo_primary_failover);void *migrate_hook_start_precopy_tcp_multifd_common (QTestState *from,QTestState *to,const char *method);
@@ -267,5 +272,10 @@ void migration_test_add_file(MigrationTestEnv *env);void migration_test_add_precopy (MigrationTestEnv *env);void migration_test_add_cpr (MigrationTestEnv *env);void migration_test_add_misc (MigrationTestEnv *env); +#ifdef CONFIG_REPLICATION +void migration_test_add_colo (MigrationTestEnv *env); +#else +static inline void migration_test_add_colo (MigrationTestEnv *env) {}; +#endif #endif /* TEST_FRAMEWORK_H */
Signature · 1 line
2.39.5
Re: [PATCH v2 5/8] migration-test: Add COLO migration unit test
Quoted 187 lines · Lukas Straub
Add a COLO migration test for COLO migration and failover.
COLO does not support q35 machine at this time.
Signed-off-by Lukas Straub <[email protected]>--- MAINTAINERS | 1 + tests/qtest/meson.build | 7 ++- tests/qtest/migration-test.c | 1 + tests/qtest/migration/colo-tests.c | 113 +++++++++++++++++++++++++++++++++++++ tests/qtest/migration/framework.c | 87 +++++++++++++++++++++++++++- tests/qtest/migration/framework.h | 10 ++++ 6 files changed, 217 insertions(+), 2 deletions(-)MAINTAINERS +1
-0@@ -3840,6 +3840,7 @@ F: migration/colo* F: migration/multifd-colo.* F: include/migration/colo.h F: include/migration/failover.h +F: tests/qtest/migration/colo-tests.c F: docs/COLO-FT.txt COLO Proxytests/qtest/meson.build +6
-1@@ -367,6 +367,11 @@ if gnutls.found() endif endif +migration_colo_files = [] +if get_option('replication').allowed() + migration_colo_files = [files('migration/colo-tests.c')] +endif + qtests = { 'aspeed_hace-test': files('aspeed-hace-utils.c', 'aspeed_hace-test.c'), 'aspeed_smc-test': files('aspeed-smc-utils.c', 'aspeed_smc-test.c'),@@ -378,7 +383,7 @@ qtests = { 'migration/migration-util.c') + dbus_vmstate1, 'erst-test': files('erst-test.c'), 'ivshmem-test': [rt, '../../contrib/ivshmem-server/ivshmem-server.c'], - 'migration-test': test_migration_files + migration_tls_files, + 'migration-test': test_migration_files + migration_tls_files + migration_colo_files, 'pxe-test': files('boot-sector.c'), 'pnv-xive2-test': files('pnv-xive2-common.c', 'pnv-xive2-flush-sync.c', 'pnv-xive2-nvpg_bar.c'),tests/qtest/migration-test.c +1
-0@@ -55,6 +55,7 @@ int main(int argc, char **argv)migration_test_add_precopy (env);migration_test_add_cpr (env);migration_test_add_misc (env); +migration_test_add_colo (env); ret =g_test_run ();tests/qtest/migration/colo-tests.c new file +113
-0@@ -0,0 +1,113 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* QTest testcases for COLO migration +* +* Copyright (c) 2025 Lukas Straub <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#include "qemu/osdep.h" +#include "libqtest.h" +#include "migration/framework.h" +#include "migration/migration-qmp.h" +#include "migration/migration-util.h" +#include "qemu/module.h" + +static void test_colo_plain_common (MigrateCommon *args, +bool failover_during_checkpoint, +bool primary_failover) +{ + args->listen_uri ="tcp:127.0.0.1:0" ; +test_colo_common (args, failover_during_checkpoint, primary_failover); +} + +static void *hook_start_multifd (QTestState *from,QTestState *to) +{ +return migrate_hook_start_precopy_tcp_multifd_common (from, to,"none" ); +} + +static void test_colo_multifd_common (MigrateCommon *args, +bool failover_during_checkpoint, +bool primary_failover) +{ + args->listen_uri ="defer" ; + args->start_hook = hook_start_multifd; + args->start.caps[MIGRATION_CAPABILITY_MULTIFD ] = true; +test_colo_common (args, failover_during_checkpoint, primary_failover); +} + +static void test_colo_plain_primary_failover (char *name,MigrateCommon *args) +{ +test_colo_plain_common (args, false, true); +} + +static void test_colo_plain_secondary_failover (char *name,MigrateCommon *args) +{ +test_colo_plain_common (args, false, false); +} + +static void test_colo_multifd_primary_failover (char *name,MigrateCommon *args) +{ +test_colo_multifd_common (args, false, true); +} + +static void test_colo_multifd_secondary_failover (char *name, +MigrateCommon *args) +{ +test_colo_multifd_common (args, false, false); +} + +static void test_colo_plain_primary_failover_checkpoint (char *name, +MigrateCommon *args) +{ +test_colo_plain_common (args, true, true); +} + +static void test_colo_plain_secondary_failover_checkpoint (char *name, +MigrateCommon *args) +{ +test_colo_plain_common (args, true, false); +} + +static void test_colo_multifd_primary_failover_checkpoint (char *name, +MigrateCommon *args) +{ +test_colo_multifd_common (args, true, true); +} + +static void test_colo_multifd_secondary_failover_checkpoint (char *name, +MigrateCommon *args) +{ +test_colo_multifd_common (args, true, false); +} + +void migration_test_add_colo (MigrationTestEnv *env) +{ +if (!env->full_set) { +return ; + } + +migration_test_add ("/migration/colo/plain/primary_failover" , + test_colo_plain_primary_failover); +migration_test_add ("/migration/colo/plain/secondary_failover" , + test_colo_plain_secondary_failover); + +migration_test_add ("/migration/colo/multifd/primary_failover" , + test_colo_multifd_primary_failover); +migration_test_add ("/migration/colo/multifd/secondary_failover" , + test_colo_multifd_secondary_failover); + +migration_test_add ("/migration/colo/plain/primary_failover_checkpoint" , + test_colo_plain_primary_failover_checkpoint); +migration_test_add ("/migration/colo/plain/secondary_failover_checkpoint" , + test_colo_plain_secondary_failover_checkpoint); + +migration_test_add ("/migration/colo/multifd/primary_failover_checkpoint" , + test_colo_multifd_primary_failover_checkpoint); +migration_test_add ("/migration/colo/multifd/secondary_failover_checkpoint" , + test_colo_multifd_secondary_failover_checkpoint); +}tests/qtest/migration/framework.c +0
-0
tests/qtest/migration/framework.c int migrate_args(char **from, char **to, const char *uri, MigrateStart *args) · line 318
Quoted 5 lines
tests/qtest/migration/framework.c +1
-1@@ -315,7 +315,7 @@ int migrate_args(char **from, char **to, const char *uri, MigrateStart *args)if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { memory_size ="150M" ; -if (g_str_equal (arch,"i386" )) { +if (g_str_equal (arch,"i386" ) || args->force_pc_machine) {
The naming is better, thanks. Said that, force_pc_machine is unwanted either.. if we can drop it. I asked this in v1:
https://lore.kernel.org/qemu-devel/[email protected]/
Can we explore that possibility?
Quoted 26 lines
tests/qtest/migration/framework.c +19
-0machine_alias ="pc" ; }else { machine_alias ="q35" ;@@ -1066,6 +1066,91 @@ void *migrate_hook_start_precopy_tcp_multifd_common(QTestState *from,return NULL ; } +int test_colo_common (MigrateCommon *args,bool failover_during_checkpoint, +bool primary_failover) +{ +QTestState *from, *to; +void *data_hook =NULL ; + +/* +* For the COLO test, both VMs will run in parallel. Thus both VMs want to +* open the image read/write at the same time. Using read-only=on is not +* possible here, because ide-hd does not support read-only backing image. +* +* So use -snapshot, where each qemu instance creates its own writable +* snapshot internally while leaving the real image read-only. +*/ + args->start.opts_source ="-snapshot" ; + args->start.opts_target ="-snapshot" ; + +/* +* COLO migration code logs many errors when the migration socket
tests/qtest/migration/framework.c void *migrate_hook_start_precopy_tcp_multifd_common(QTestState *from, · line 1097
Quoted 10 lines
tests/qtest/migration/framework.c +10
-0+* is shut down, these are expected so we hide them here. +*/ + args->start.hide_stderr = true; + +/* +* COLO currently does not work with Q35 machine +*/ + args->start.force_pc_machine = true; + + args->start.oob = true;
Just curious: is OOB required in COLO for some reason? I understand yank you used below uses OOB, so the question is behind that, on what can be blocked in main thread, and special in COLO.
Quoted 9 lines
tests/qtest/migration/framework.c +9
-0+ args->start.caps[MIGRATION_CAPABILITY_X_COLO ] = true; + +if (migrate_start (&from, &to, args->listen_uri, &args->start)) { +return -1 ; + } + +migrate_set_parameter_int (from,"x-checkpoint-delay" ,300 ); + +if (args->start_hook) {
tests/qtest/migration/framework.c void *migrate_hook_start_precopy_tcp_multifd_common(QTestState *from, · line 1116
Quoted 10 lines
tests/qtest/migration/framework.c +10
-0+ data_hook = args->start_hook (from, to); + } + +migrate_ensure_converge (from); +wait_for_serial ("src_serial" ); + +migrate_qmp (from, to, args->connect_uri,NULL ,"{}" ); + +wait_for_migration_status (from,"colo" ,NULL ); +wait_for_resume (to, &dst_state);
We can move this whole function into colo-tests.c. Here you may want to use get_dst() instead.
Quoted 78 lines
tests/qtest/migration/framework.c +37
-0+ +wait_for_serial ("src_serial" ); +wait_for_serial ("dest_serial" ); + +/* wait for 3 checkpoints */ +for (int i =0 ; i <3 ; i++) { +qtest_qmp_eventwait (to,"RESUME" ); +wait_for_serial ("src_serial" ); +wait_for_serial ("dest_serial" ); + } + +if (failover_during_checkpoint) { +qtest_qmp_eventwait (to,"STOP" ); + } +if (primary_failover) { +qtest_qmp_assert_success (from,"{'exec-oob': 'yank', 'id': 'yank-cmd', " +"'arguments': {'instances':" +"[{'type': 'migration'}]}}" ); +qtest_qmp_assert_success (from,"{'execute': 'x-colo-lost-heartbeat'}" ); +wait_for_serial ("src_serial" ); + }else { +qtest_qmp_assert_success (to,"{'exec-oob': 'yank', 'id': 'yank-cmd', " +"'arguments': {'instances':" +"[{'type': 'migration'}]}}" ); +qtest_qmp_assert_success (to,"{'execute': 'x-colo-lost-heartbeat'}" ); +wait_for_serial ("dest_serial" ); + } + +if (args->end_hook) { + args->end_hook (from, to, data_hook); + } + +migrate_end (from, to, !primary_failover); + +return 0 ; +} +QTestMigrationState *get_src (void ) {return &src_state;tests/qtest/migration/framework.h +10
-0@@ -139,6 +139,9 @@ typedef struct {/* Do not connect to target monitor and qtest sockets in qtest_init */ bool defer_target_connect; +/* Use pc machine for x86_64 */ +bool force_pc_machine; +/* * Migration capabilities to be set in both source and * destination. For unilateral capabilities, use @@ -248,6 +251,8 @@ void test_postcopy_common(MigrateCommon *args);void test_postcopy_recovery_common (MigrateCommon *args);int test_precopy_common (MigrateCommon *args);void test_file_common (MigrateCommon *args,bool stop_src); +int test_colo_common (MigrateCommon *args,bool failover_during_checkpoint, +bool colo_primary_failover);void *migrate_hook_start_precopy_tcp_multifd_common (QTestState *from,QTestState *to,const char *method);@@ -267,5 +272,10 @@ void migration_test_add_file(MigrationTestEnv *env);void migration_test_add_precopy (MigrationTestEnv *env);void migration_test_add_cpr (MigrationTestEnv *env);void migration_test_add_misc (MigrationTestEnv *env); +#ifdef CONFIG_REPLICATION +void migration_test_add_colo (MigrationTestEnv *env); +#else +static inline void migration_test_add_colo (MigrationTestEnv *env) {}; +#endif #endif /* TEST_FRAMEWORK_H */ Signature · 2 lines
-- 2.39.5
Signature · 1 line
Peter Xu
Re: [PATCH v2 5/8] migration-test: Add COLO migration unit test
Quoted 197 lines · On Tue, 20 Jan 2026 12:23:08 -0500 Peter Xu <[email protected]> wrote:
Quoted 187 lines · Lukas Straub
Add a COLO migration test for COLO migration and failover.
COLO does not support q35 machine at this time.
Signed-off-by Lukas Straub <[email protected]>--- MAINTAINERS | 1 + tests/qtest/meson.build | 7 ++- tests/qtest/migration-test.c | 1 + tests/qtest/migration/colo-tests.c | 113 +++++++++++++++++++++++++++++++++++++ tests/qtest/migration/framework.c | 87 +++++++++++++++++++++++++++- tests/qtest/migration/framework.h | 10 ++++ 6 files changed, 217 insertions(+), 2 deletions(-)MAINTAINERS +1
-0@@ -3840,6 +3840,7 @@ F: migration/colo* F: migration/multifd-colo.* F: include/migration/colo.h F: include/migration/failover.h +F: tests/qtest/migration/colo-tests.c F: docs/COLO-FT.txt COLO Proxytests/qtest/meson.build +6
-1@@ -367,6 +367,11 @@ if gnutls.found() endif endif +migration_colo_files = [] +if get_option('replication').allowed() + migration_colo_files = [files('migration/colo-tests.c')] +endif + qtests = { 'aspeed_hace-test': files('aspeed-hace-utils.c', 'aspeed_hace-test.c'), 'aspeed_smc-test': files('aspeed-smc-utils.c', 'aspeed_smc-test.c'),@@ -378,7 +383,7 @@ qtests = { 'migration/migration-util.c') + dbus_vmstate1, 'erst-test': files('erst-test.c'), 'ivshmem-test': [rt, '../../contrib/ivshmem-server/ivshmem-server.c'], - 'migration-test': test_migration_files + migration_tls_files, + 'migration-test': test_migration_files + migration_tls_files + migration_colo_files, 'pxe-test': files('boot-sector.c'), 'pnv-xive2-test': files('pnv-xive2-common.c', 'pnv-xive2-flush-sync.c', 'pnv-xive2-nvpg_bar.c'),tests/qtest/migration-test.c +1
-0@@ -55,6 +55,7 @@ int main(int argc, char **argv)migration_test_add_precopy (env);migration_test_add_cpr (env);migration_test_add_misc (env); +migration_test_add_colo (env); ret =g_test_run ();tests/qtest/migration/colo-tests.c new file +113
-0@@ -0,0 +1,113 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* QTest testcases for COLO migration +* +* Copyright (c) 2025 Lukas Straub <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#include "qemu/osdep.h" +#include "libqtest.h" +#include "migration/framework.h" +#include "migration/migration-qmp.h" +#include "migration/migration-util.h" +#include "qemu/module.h" + +static void test_colo_plain_common (MigrateCommon *args, +bool failover_during_checkpoint, +bool primary_failover) +{ + args->listen_uri ="tcp:127.0.0.1:0" ; +test_colo_common (args, failover_during_checkpoint, primary_failover); +} + +static void *hook_start_multifd (QTestState *from,QTestState *to) +{ +return migrate_hook_start_precopy_tcp_multifd_common (from, to,"none" ); +} + +static void test_colo_multifd_common (MigrateCommon *args, +bool failover_during_checkpoint, +bool primary_failover) +{ + args->listen_uri ="defer" ; + args->start_hook = hook_start_multifd; + args->start.caps[MIGRATION_CAPABILITY_MULTIFD ] = true; +test_colo_common (args, failover_during_checkpoint, primary_failover); +} + +static void test_colo_plain_primary_failover (char *name,MigrateCommon *args) +{ +test_colo_plain_common (args, false, true); +} + +static void test_colo_plain_secondary_failover (char *name,MigrateCommon *args) +{ +test_colo_plain_common (args, false, false); +} + +static void test_colo_multifd_primary_failover (char *name,MigrateCommon *args) +{ +test_colo_multifd_common (args, false, true); +} + +static void test_colo_multifd_secondary_failover (char *name, +MigrateCommon *args) +{ +test_colo_multifd_common (args, false, false); +} + +static void test_colo_plain_primary_failover_checkpoint (char *name, +MigrateCommon *args) +{ +test_colo_plain_common (args, true, true); +} + +static void test_colo_plain_secondary_failover_checkpoint (char *name, +MigrateCommon *args) +{ +test_colo_plain_common (args, true, false); +} + +static void test_colo_multifd_primary_failover_checkpoint (char *name, +MigrateCommon *args) +{ +test_colo_multifd_common (args, true, true); +} + +static void test_colo_multifd_secondary_failover_checkpoint (char *name, +MigrateCommon *args) +{ +test_colo_multifd_common (args, true, false); +} + +void migration_test_add_colo (MigrationTestEnv *env) +{ +if (!env->full_set) { +return ; + } + +migration_test_add ("/migration/colo/plain/primary_failover" , + test_colo_plain_primary_failover); +migration_test_add ("/migration/colo/plain/secondary_failover" , + test_colo_plain_secondary_failover); + +migration_test_add ("/migration/colo/multifd/primary_failover" , + test_colo_multifd_primary_failover); +migration_test_add ("/migration/colo/multifd/secondary_failover" , + test_colo_multifd_secondary_failover); + +migration_test_add ("/migration/colo/plain/primary_failover_checkpoint" , + test_colo_plain_primary_failover_checkpoint); +migration_test_add ("/migration/colo/plain/secondary_failover_checkpoint" , + test_colo_plain_secondary_failover_checkpoint); + +migration_test_add ("/migration/colo/multifd/primary_failover_checkpoint" , + test_colo_multifd_primary_failover_checkpoint); +migration_test_add ("/migration/colo/multifd/secondary_failover_checkpoint" , + test_colo_multifd_secondary_failover_checkpoint); +}tests/qtest/migration/framework.c +0
-0tests/qtest/migration/framework.c int migrate_args(char **from, char **to, const char *uri, MigrateStart *args) · line 318
Quoted 5 lines
tests/qtest/migration/framework.c +1
-1@@ -315,7 +315,7 @@ int migrate_args(char **from, char **to, const char *uri, MigrateStart *args)if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { memory_size ="150M" ; -if (g_str_equal (arch,"i386" )) { +if (g_str_equal (arch,"i386" ) || args->force_pc_machine) {The naming is better, thanks. Said that,
force_pc_machineis unwanted either.. if we can drop it. I asked this in v1:
Quoted 3 lines
https://lore.kernel.org/qemu-devel/[email protected]/
Can we explore that possibility?
Never mind. I found the issue and will remove this in the next version.
Quoted 56 lines
Quoted 27 lines
tests/qtest/migration/framework.c +19
-0machine_alias ="pc" ; }else { machine_alias ="q35" ;@@ -1066,6 +1066,91 @@ void *migrate_hook_start_precopy_tcp_multifd_common(QTestState *from,return NULL ; } +int test_colo_common (MigrateCommon *args,bool failover_during_checkpoint, +bool primary_failover) +{ +QTestState *from, *to; +void *data_hook =NULL ; + +/* +* For the COLO test, both VMs will run in parallel. Thus both VMs want to +* open the image read/write at the same time. Using read-only=on is not +* possible here, because ide-hd does not support read-only backing image. +* +* So use -snapshot, where each qemu instance creates its own writable +* snapshot internally while leaving the real image read-only. +*/ + args->start.opts_source ="-snapshot" ; + args->start.opts_target ="-snapshot" ; + +/* +* COLO migration code logs many errors when the migration socket tests/qtest/migration/framework.c void *migrate_hook_start_precopy_tcp_multifd_common(QTestState *from, · line 1097
Quoted 10 lines
tests/qtest/migration/framework.c +10
-0+* is shut down, these are expected so we hide them here. +*/ + args->start.hide_stderr = true; + +/* +* COLO currently does not work with Q35 machine +*/ + args->start.force_pc_machine = true; + + args->start.oob = true;Just curious: is OOB required in COLO for some reason? I understand yank you used below uses OOB, so the question is behind that, on what can be blocked in main thread, and special in COLO.
Quoted 14 lines
tests/qtest/migration/framework.c +14
-0+ args->start.caps[MIGRATION_CAPABILITY_X_COLO ] = true; + +if (migrate_start (&from, &to, args->listen_uri, &args->start)) { +return -1 ; + } + +migrate_set_parameter_int (from,"x-checkpoint-delay" ,300 ); + +if (args->start_hook) { + data_hook = args->start_hook (from, to); + } + +migrate_ensure_converge (from); +wait_for_serial ("src_serial" );
Quoted 8 lines
tests/qtest/migration/framework.c void *migrate_hook_start_precopy_tcp_multifd_common(QTestState *from, · line 1116
Quoted 5 lines
tests/qtest/migration/framework.c +5
-0+ +migrate_qmp (from, to, args->connect_uri,NULL ,"{}" ); + +wait_for_migration_status (from,"colo" ,NULL ); +wait_for_resume (to, &dst_state);We can move this whole function into
colo-tests.c. Here you may want to useget_dst()instead.
Okey, will do that.
Quoted 80 lines
Quoted 79 lines
tests/qtest/migration/framework.c +37
-0+ +wait_for_serial ("src_serial" ); +wait_for_serial ("dest_serial" ); + +/* wait for 3 checkpoints */ +for (int i =0 ; i <3 ; i++) { +qtest_qmp_eventwait (to,"RESUME" ); +wait_for_serial ("src_serial" ); +wait_for_serial ("dest_serial" ); + } + +if (failover_during_checkpoint) { +qtest_qmp_eventwait (to,"STOP" ); + } +if (primary_failover) { +qtest_qmp_assert_success (from,"{'exec-oob': 'yank', 'id': 'yank-cmd', " +"'arguments': {'instances':" +"[{'type': 'migration'}]}}" ); +qtest_qmp_assert_success (from,"{'execute': 'x-colo-lost-heartbeat'}" ); +wait_for_serial ("src_serial" ); + }else { +qtest_qmp_assert_success (to,"{'exec-oob': 'yank', 'id': 'yank-cmd', " +"'arguments': {'instances':" +"[{'type': 'migration'}]}}" ); +qtest_qmp_assert_success (to,"{'execute': 'x-colo-lost-heartbeat'}" ); +wait_for_serial ("dest_serial" ); + } + +if (args->end_hook) { + args->end_hook (from, to, data_hook); + } + +migrate_end (from, to, !primary_failover); + +return 0 ; +} +QTestMigrationState *get_src (void ) {return &src_state;tests/qtest/migration/framework.h +10
-0@@ -139,6 +139,9 @@ typedef struct {/* Do not connect to target monitor and qtest sockets in qtest_init */ bool defer_target_connect; +/* Use pc machine for x86_64 */ +bool force_pc_machine; +/* * Migration capabilities to be set in both source and * destination. For unilateral capabilities, use @@ -248,6 +251,8 @@ void test_postcopy_common(MigrateCommon *args);void test_postcopy_recovery_common (MigrateCommon *args);int test_precopy_common (MigrateCommon *args);void test_file_common (MigrateCommon *args,bool stop_src); +int test_colo_common (MigrateCommon *args,bool failover_during_checkpoint, +bool colo_primary_failover);void *migrate_hook_start_precopy_tcp_multifd_common (QTestState *from,QTestState *to,const char *method);@@ -267,5 +272,10 @@ void migration_test_add_file(MigrationTestEnv *env);void migration_test_add_precopy (MigrationTestEnv *env);void migration_test_add_cpr (MigrationTestEnv *env);void migration_test_add_misc (MigrationTestEnv *env); +#ifdef CONFIG_REPLICATION +void migration_test_add_colo (MigrationTestEnv *env); +#else +static inline void migration_test_add_colo (MigrationTestEnv *env) {}; +#endif #endif /* TEST_FRAMEWORK_H */ Signature · 2 lines
-- 2.39.5
Re: [PATCH v2 5/8] migration-test: Add COLO migration unit test
Quoted 35 lines · On Wed, 21 Jan 2026 20:37:51 +0100 Lukas Straub <[email protected]> wrote:
Quoted 32 lines · On Tue, 20 Jan 2026 12:23:08 -0500 Peter Xu <[email protected]> wrote:
Quoted 31 lines · Lukas Straub
Add a COLO migration test for COLO migration and failover.
COLO does not support q35 machine at this time.
[...]
tests/qtest/migration/framework.c +25
-0+int test_colo_common (MigrateCommon *args,bool failover_during_checkpoint, +bool primary_failover) +{ +QTestState *from, *to; +void *data_hook =NULL ; + +/* +* For the COLO test, both VMs will run in parallel. Thus both VMs want to +* open the image read/write at the same time. Using read-only=on is not +* possible here, because ide-hd does not support read-only backing image. +* +* So use -snapshot, where each qemu instance creates its own writable +* snapshot internally while leaving the real image read-only. +*/ + args->start.opts_source ="-snapshot" ; + args->start.opts_target ="-snapshot" ; + +/* +* COLO migration code logs many errors when the migration socket +* is shut down, these are expected so we hide them here. +*/ + args->start.hide_stderr = true; + +/* +* COLO currently does not work with Q35 machine
Quoted 8 lines
Quoted 8 lines
tests/qtest/migration/framework.c void *migrate_hook_start_precopy_tcp_multifd_common(QTestState *from, · line 1097
Quoted 4 lines
tests/qtest/migration/framework.c +4
-0+*/ + args->start.force_pc_machine = true; + + args->start.oob = true;Just curious: is OOB required in COLO for some reason? I understand yank you used below uses OOB, so the question is behind that, on what can be blocked in main thread, and special in COLO.
There is a lot that can hang:
The netfilters all run on the main loop and use blocking write. fiter-mirror on the primary side mirrors packets to the secondary and can hang.
filter-redirect on the secondary side redirects packets to primary's colo-compare and can hang.
The nbd client on the primary side that is connected to the nbd server on the secondary side can hang. Especially during vm_stop() which fluses all inflight block io with BQL held.
Regards,
Lukas Straub
Quoted 68 lines
Quoted 15 lines
Quoted 15 lines
tests/qtest/migration/framework.c +14
-0+ args->start.caps[MIGRATION_CAPABILITY_X_COLO ] = true; + +if (migrate_start (&from, &to, args->listen_uri, &args->start)) { +return -1 ; + } + +migrate_set_parameter_int (from,"x-checkpoint-delay" ,300 ); + +if (args->start_hook) { + data_hook = args->start_hook (from, to); + } + +migrate_ensure_converge (from); +wait_for_serial ("src_serial" );Quoted 8 lines
tests/qtest/migration/framework.c void *migrate_hook_start_precopy_tcp_multifd_common(QTestState *from, · line 1116
Quoted 5 lines
tests/qtest/migration/framework.c +5
-0+ +migrate_qmp (from, to, args->connect_uri,NULL ,"{}" ); + +wait_for_migration_status (from,"colo" ,NULL ); +wait_for_resume (to, &dst_state);We can move this whole function into
colo-tests.c. Here you may want to useget_dst()instead.Okey, will do that.
Quoted 42 lines
Quoted 42 lines
tests/qtest/migration/framework.c +37
-0+ +wait_for_serial ("src_serial" ); +wait_for_serial ("dest_serial" ); + +/* wait for 3 checkpoints */ +for (int i =0 ; i <3 ; i++) { +qtest_qmp_eventwait (to,"RESUME" ); +wait_for_serial ("src_serial" ); +wait_for_serial ("dest_serial" ); + } + +if (failover_during_checkpoint) { +qtest_qmp_eventwait (to,"STOP" ); + } +if (primary_failover) { +qtest_qmp_assert_success (from,"{'exec-oob': 'yank', 'id': 'yank-cmd', " +"'arguments': {'instances':" +"[{'type': 'migration'}]}}" ); +qtest_qmp_assert_success (from,"{'execute': 'x-colo-lost-heartbeat'}" ); +wait_for_serial ("src_serial" ); + }else { +qtest_qmp_assert_success (to,"{'exec-oob': 'yank', 'id': 'yank-cmd', " +"'arguments': {'instances':" +"[{'type': 'migration'}]}}" ); +qtest_qmp_assert_success (to,"{'execute': 'x-colo-lost-heartbeat'}" ); +wait_for_serial ("dest_serial" ); + } + +if (args->end_hook) { + args->end_hook (from, to, data_hook); + } + +migrate_end (from, to, !primary_failover); + +return 0 ; +} +QTestMigrationState *get_src (void ) {return &src_state;
Re: [PATCH v2 5/8] migration-test: Add COLO migration unit test
Quoted 47 lines · Lukas Straub
Quoted 35 lines · On Wed, 21 Jan 2026 20:37:51 +0100 Lukas Straub <[email protected]> wrote:
Quoted 32 lines · On Tue, 20 Jan 2026 12:23:08 -0500 Peter Xu <[email protected]> wrote:
Quoted 31 lines · Lukas Straub
Add a COLO migration test for COLO migration and failover.
COLO does not support q35 machine at this time.
[...]
tests/qtest/migration/framework.c +25
-0+int test_colo_common (MigrateCommon *args,bool failover_during_checkpoint, +bool primary_failover) +{ +QTestState *from, *to; +void *data_hook =NULL ; + +/* +* For the COLO test, both VMs will run in parallel. Thus both VMs want to +* open the image read/write at the same time. Using read-only=on is not +* possible here, because ide-hd does not support read-only backing image. +* +* So use -snapshot, where each qemu instance creates its own writable +* snapshot internally while leaving the real image read-only. +*/ + args->start.opts_source ="-snapshot" ; + args->start.opts_target ="-snapshot" ; + +/* +* COLO migration code logs many errors when the migration socket +* is shut down, these are expected so we hide them here. +*/ + args->start.hide_stderr = true; + +/* +* COLO currently does not work with Q35 machine Quoted 8 lines
Quoted 8 lines
tests/qtest/migration/framework.c void *migrate_hook_start_precopy_tcp_multifd_common(QTestState *from, · line 1097
Quoted 4 lines
tests/qtest/migration/framework.c +4
-0+*/ + args->start.force_pc_machine = true; + + args->start.oob = true;Just curious: is OOB required in COLO for some reason? I understand yank you used below uses OOB, so the question is behind that, on what can be blocked in main thread, and special in COLO.
Quoted 9 lines
There is a lot that can hang:
The netfilters all run on the main loop and use blocking write. fiter-mirror on the primary side mirrors packets to the secondary and can hang.
filter-redirect on the secondary side redirects packets to primary's colo-compare and can hang.
The nbd client on the primary side that is connected to the nbd server on the secondary side can hang. Especially duringvm_stop()which fluses all inflight block io with BQL held.
None of them are used in this unit test, right?
I agree if OOB is needed in production we should also enable it in the unit tests. Said that, would you please add a comment into the test case explaining this? E.g. what can fail in reality, and why we still test OOB (because we want to get as close to production COLO use case as possible).
Thanks,
Signature · 1 line
Peter Xu
PATCH v2 6/8 Convert colo main documentation to restructuredText
In reply to Lukas Straub--- MAINTAINERS | 2 +- docs/COLO-FT.txt | 334 ------------------------------------------ docs/system/index.rst | 1 + docs/system/qemu-colo.rst | 361 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 363 insertions(+), 335 deletions(-)
MAINTAINERS +1 -1
@@ -3841,7 +3841,7 @@ F: migration/multifd-colo.* F: include/migration/colo.h F: include/migration/failover.h F: tests/qtest/migration/colo-tests.c -F: docs/COLO-FT.txt +F: docs/devel/qemu-colo.rst COLO Proxy M: Zhang Chen <[email protected]>
docs/COLO-FT.txt deleted +0 -334
334 lines not on this page · raw message
docs/system/index.rst +1 -0
@@ -41,3 +41,4 @@ or Hypervisor.Framework. igvm vm-templating sriov + qemu-colo
docs/system/qemu-colo.rst new file +361 -0
361 lines not on this page · raw message
Signature · 1 line
2.39.5
Re: [PATCH v2 6/8] Convert colo main documentation to restructuredText
Quoted 7 lines · Lukas Straub
Signed-off-by Lukas Straub <[email protected]>--- MAINTAINERS | 2 +- docs/COLO-FT.txt | 334 ------------------------------------------ docs/system/index.rst | 1 + docs/system/qemu-colo.rst | 361 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 363 insertions(+), 335 deletions(-)
Thank you.
MAINTAINERS F: migration/multifd-colo.* · line 3844
Quoted 11 lines
MAINTAINERS +1
-1@@ -3841,7 +3841,7 @@ F: migration/multifd-colo.* F: include/migration/colo.h F: include/migration/failover.h F: tests/qtest/migration/colo-tests.c -F: docs/COLO-FT.txt +F: docs/devel/qemu-colo.rst
Should we still put it under docs/devel/migration?
COLO framework is under migration/. COLO tests will be under tests/qtest/migration/. I still think we should keep doc under migration/ too, IOW when someone touches that we want to get copied too.
I also raised some other requests while discussing with you on the COLO details. If you want, feel free to attach one more patch to add those contents into the doc (after this conversion patch), on either doubled mem consumption of SVM, or RAM mgmt details.
Thanks,
Signature · 1 line
Peter Xu
Re: [PATCH v2 6/8] Convert colo main documentation to restructuredText
Quoted 25 lines · On Tue, 20 Jan 2026 12:26:17 -0500 Peter Xu <[email protected]> wrote:
Quoted 7 lines · Lukas Straub
Signed-off-by Lukas Straub <[email protected]>--- MAINTAINERS | 2 +- docs/COLO-FT.txt | 334 ------------------------------------------ docs/system/index.rst | 1 + docs/system/qemu-colo.rst | 361 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 363 insertions(+), 335 deletions(-)Thank you.
MAINTAINERS F: migration/multifd-colo.* · line 3844
Quoted 11 lines
MAINTAINERS +1
-1@@ -3841,7 +3841,7 @@ F: migration/multifd-colo.* F: include/migration/colo.h F: include/migration/failover.h F: tests/qtest/migration/colo-tests.c -F: docs/COLO-FT.txt +F: docs/devel/qemu-colo.rstShould we still put it under docs/devel/migration?
Quoted 3 lines
COLO framework is under migration/. COLO tests will be under tests/qtest/migration/. I still think we should keep doc under migration/ too, IOW when someone touches that we want to get copied too.
Whoops, this should be docs/system/qemu-colo.rst so user documentation.
I think this document is more for users, so they can test it just with standalone qemu.
Also I want to replace the wiki page with this so they don't go out of sync.
Quoted 5 lines
I also raised some other requests while discussing with you on the COLO details. If you want, feel free to attach one more patch to add those contents into the doc (after this conversion patch), on either doubled mem consumption of SVM, or RAM mgmt details.
Will do.
I think I will make a extra doc for devel/migration.
Quoted 3 lines
Thanks,
PATCH v2 7/8 qemu-colo.rst: Miscellaneous changes
In reply to Lukas Straub--- docs/system/qemu-colo.rst | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-)
docs/system/qemu-colo.rst +12 -18
@@ -1,14 +1,6 @@ Qemu COLO Fault Tolerance ========================= -| Copyright (c) 2016 Intel Corporation -| Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD. -| Copyright (c) 2016 Fujitsu, Corp. -| Copyright (c) 2026 Lukas Straub <[email protected]> - -This work is licensed under the terms of the GNU GPL, version 2 or later. -See the COPYING file in the top-level directory. - This document gives an overview of COLO's design and how to use it. Background
@@ -83,8 +75,8 @@ Overview:: | Storage | |External Network| | External Network | | Storage | +---------------+ +----------------+ +------------------+ +--------------+ -Components introduction -^^^^^^^^^^^^^^^^^^^^^^^ +Components +^^^^^^^^^^ You can see there are several components in COLO's diagram of architecture. Their functions are described below.
@@ -158,14 +150,14 @@ in test procedure. Test procedure -------------- -Note: Here we are running both instances on the same host for testing, +Here we are running both instances on the same host for testing, change the IP Addresses if you want to run it on two hosts. Initially ``127.0.0.1`` is the Primary Host and ``127.0.0.2`` is the Secondary Host. Startup qemu ^^^^^^^^^^^^ **1. Primary**: -Note: Initially, ``$imagefolder/primary.qcow2`` needs to be copied to all hosts. +Initially, ``$imagefolder/primary.qcow2`` needs to be copied to all hosts. You don't need to change any IP's here, because ``0.0.0.0`` listens on any interface. The chardev's with ``127.0.0.1`` IP's loopback to the local qemu instance::
@@ -193,7 +185,7 @@ instance:: **2. Secondary**: -Note: Active and hidden images need to be created only once and the +Active and hidden images need to be created only once and the size should be the same as ``primary.qcow2``. Again, you don't need to change any IP's here, except for the ``$primary_ip`` variable::
@@ -354,8 +346,10 @@ Wait until disk is synced, then:: {"execute": "migrate-set-capabilities", "arguments":{ "capabilities": [ {"capability": "x-colo", "state": true } ] } } {"execute": "migrate", "arguments":{ "uri": "tcp:127.0.0.1:9998" } } -TODO ----- -1. Support shared storage. -2. Develop the heartbeat part. -3. Reduce checkpoint VM’s downtime while doing checkpoint. +| Copyright (c) 2016 Intel Corporation +| Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD. +| Copyright (c) 2016 Fujitsu, Corp. +| Copyright (c) 2026 Lukas Straub <[email protected]> + +This work is licensed under the terms of the GNU GPL, version 2 or later. +See the COPYING file in the top-level directory.
Signature · 1 line
2.39.5
Re: [PATCH v2 7/8] qemu-colo.rst: Miscellaneous changes
Quoted 10 lines · Lukas Straub
Signed-off-by Lukas Straub <[email protected]>--- docs/system/qemu-colo.rst | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-)docs/system/qemu-colo.rst +0
-0
docs/system/qemu-colo.rst line 7
Quoted 7 lines
docs/system/qemu-colo.rst +0
-4@@ -1,14 +1,6 @@ Qemu COLO Fault Tolerance ========================= -| Copyright (c) 2016 Intel Corporation -| Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD. -| Copyright (c) 2016 Fujitsu, Corp. -| Copyright (c) 2026 Lukas Straub <[email protected]>
Hmm, I don't see this copyright line in the current code base. I think you added it in previous conversion patch.
When converting, we should keep that patch change nothing in the content but only convert things.
If you want to propose new things to the doc, it needs to be separately done and reviewed.
We'd better not hide real changes within a conversion patch.
Here, I'm not sure you should add your copyright line. IIUC, that can be added only if you made prominent contribution to this solution in the code base. Becoming a maintainer is definitely a bless, however not justified for an additional copyright update. I can also be wrong, but please justify.
Quoted 65 lines
docs/system/qemu-colo.rst +12
-14- -This work is licensed under the terms of the GNU GPL, version 2 or later. -See the COPYING file in the top-level directory. - This document gives an overview of COLO's design and how to use it. Background@@ -83,8 +75,8 @@ Overview:: | Storage | |External Network| | External Network | | Storage | +---------------+ +----------------+ +------------------+ +--------------+ -Components introduction -^^^^^^^^^^^^^^^^^^^^^^^ +Components +^^^^^^^^^^ You can see there are several components in COLO's diagram of architecture. Their functions are described below.@@ -158,14 +150,14 @@ in test procedure. Test procedure -------------- -Note: Here we are running both instances on the same host for testing, +Here we are running both instances on the same host for testing, change the IP Addresses if you want to run it on two hosts. Initially ``127.0.0.1`` is the Primary Host and ``127.0.0.2`` is the Secondary Host. Startup qemu ^^^^^^^^^^^^ **1. Primary**: -Note: Initially, ``$imagefolder/primary.qcow2`` needs to be copied to all hosts. +Initially, ``$imagefolder/primary.qcow2`` needs to be copied to all hosts. You don't need to change any IP's here, because ``0.0.0.0`` listens on any interface. The chardev's with ``127.0.0.1`` IP's loopback to the local qemu instance::@@ -193,7 +185,7 @@ instance:: **2. Secondary**: -Note: Active and hidden images need to be created only once and the +Active and hidden images need to be created only once and the size should be the same as ``primary.qcow2``. Again, you don't need to change any IP's here, except for the ``$primary_ip`` variable::@@ -354,8 +346,10 @@ Wait until disk is synced, then:: {"execute": "migrate-set-capabilities", "arguments":{ "capabilities": [ {"capability": "x-colo", "state": true } ] } } {"execute": "migrate", "arguments":{ "uri": "tcp:127.0.0.1:9998" } } -TODO ----- -1. Support shared storage. -2. Develop the heartbeat part. -3. Reduce checkpoint VM’s downtime while doing checkpoint. +| Copyright (c) 2016 Intel Corporation +| Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD. +| Copyright (c) 2016 Fujitsu, Corp. +| Copyright (c) 2026 Lukas Straub <[email protected]> + +This work is licensed under the terms of the GNU GPL, version 2 or later. +See the COPYING file in the top-level directory.Signature · 2 lines
-- 2.39.5
Signature · 1 line
Peter Xu
PATCH v2 8/8 qemu-colo.rst: Simplify the block replication setup
In reply to Lukas StraubOn the primary side we don't actually need the replication block driver, since it only passes trough all IO. So simplify the setup and also use 'blockdev-add' instead of 'human-monitor-command'.
--- docs/system/qemu-colo.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
docs/system/qemu-colo.rst +7 -7
@@ -233,8 +233,8 @@ Note: **4.** On Primary VM's QEMU monitor, issue command:: {"execute":"qmp_capabilities"} - {"execute": "human-monitor-command", "arguments": {"command-line": "drive_add -n buddy driver=replication,mode=primary,file.driver=nbd,file.host=127.0.0.2,file.port=9999,file.export=parent0,node-name=replication0"}} - {"execute": "x-blockdev-change", "arguments":{"parent": "colo-disk0", "node": "replication0" } } + {"execute": "blockdev-add", "arguments": {"driver": "nbd", "node-name": "nbd0", "server": {"type": "inet", "host": "127.0.0.2", "port": "9999"}, "export": "parent0", "detect-zeroes": "on"} } + {"execute": "x-blockdev-change", "arguments":{"parent": "colo-disk0", "node": "nbd0" } } {"execute": "migrate-set-capabilities", "arguments": {"capabilities": [ {"capability": "x-colo", "state": true } ] } } {"execute": "migrate", "arguments": {"uri": "tcp:127.0.0.2:9998" } }
@@ -262,7 +262,7 @@ Primary Failover The Secondary died, resume on the Primary:: {"execute": "x-blockdev-change", "arguments":{ "parent": "colo-disk0", "child": "children.1"} } - {"execute": "human-monitor-command", "arguments":{ "command-line": "drive_del replication0" } } + {"execute": "blockdev-del", "arguments": {"node-name": "nbd0"} } {"execute": "object-del", "arguments":{ "id": "comp0" } } {"execute": "object-del", "arguments":{ "id": "iothread1" } } {"execute": "object-del", "arguments":{ "id": "m0" } }
@@ -302,8 +302,8 @@ Wait until disk is synced, then:: {"execute": "stop"} {"execute": "block-job-cancel", "arguments":{ "device": "resync"} } - {"execute": "human-monitor-command", "arguments":{ "command-line": "drive_add -n buddy driver=replication,mode=primary,file.driver=nbd,file.host=127.0.0.2,file.port=9999,file.export=parent0,node-name=replication0"}} - {"execute": "x-blockdev-change", "arguments":{ "parent": "colo-disk0", "node": "replication0" } } + {"execute": "blockdev-add", "arguments": {"driver": "nbd", "node-name": "nbd0", "server": {"type": "inet", "host": "127.0.0.2", "port": "9999"}, "export": "parent0", "detect-zeroes": "on"} } + {"execute": "x-blockdev-change", "arguments":{ "parent": "colo-disk0", "node": "nbd0" } } {"execute": "object-add", "arguments":{ "qom-type": "filter-mirror", "id": "m0", "netdev": "hn0", "queue": "tx", "outdev": "mirror0" } } {"execute": "object-add", "arguments":{ "qom-type": "filter-redirector", "id": "redire0", "netdev": "hn0", "queue": "rx", "indev": "compare_out" } }
@@ -334,8 +334,8 @@ Wait until disk is synced, then:: {"execute": "stop"} {"execute": "block-job-cancel", "arguments":{ "device": "resync" } } - {"execute": "human-monitor-command", "arguments":{ "command-line": "drive_add -n buddy driver=replication,mode=primary,file.driver=nbd,file.host=127.0.0.1,file.port=9999,file.export=parent0,node-name=replication0"}} - {"execute": "x-blockdev-change", "arguments":{ "parent": "colo-disk0", "node": "replication0" } } + {"execute": "blockdev-add", "arguments": {"driver": "nbd", "node-name": "nbd0", "server": {"type": "inet", "host": "127.0.0.1", "port": "9999"}, "export": "parent0", "detect-zeroes": "on"} } + {"execute": "x-blockdev-change", "arguments":{ "parent": "colo-disk0", "node": "nbd0" } } {"execute": "object-add", "arguments":{ "qom-type": "filter-mirror", "id": "m0", "insert": "before", "position": "id=rew0", "netdev": "hn0", "queue": "tx", "outdev": "mirror0" } } {"execute": "object-add", "arguments":{ "qom-type": "filter-redirector", "id": "redire0", "insert": "before", "position": "id=rew0", "netdev": "hn0", "queue": "rx", "indev": "compare_out" } }
Signature · 1 line
2.39.5
Re: [PATCH v2 8/8] qemu-colo.rst: Simplify the block replication setup
Quoted 7 lines · Lukas Straub
On the primary side we don't actually need the replication block driver, since it only passes trough all IO. So simplify the setup and also use 'blockdev-add' instead of 'human-monitor-command'.
Signed-off-by Lukas Straub <[email protected]>Tested-by Lukas Straub <[email protected]>
We can drop this line; Tested-by is normally not used on one's own patch. Proposer should always test one's own patch..
I'll leave it to Chen and others to review this patch. Please consider copy Zhijian and Dave when you repost; you'll get higher chance to get it reviewed.
Thanks,
Quoted 54 lines
--- docs/system/qemu-colo.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)docs/system/qemu-colo.rst +7
-7@@ -233,8 +233,8 @@ Note: **4.** On Primary VM's QEMU monitor, issue command:: {"execute":"qmp_capabilities"} - {"execute": "human-monitor-command", "arguments": {"command-line": "drive_add -n buddy driver=replication,mode=primary,file.driver=nbd,file.host=127.0.0.2,file.port=9999,file.export=parent0,node-name=replication0"}} - {"execute": "x-blockdev-change", "arguments":{"parent": "colo-disk0", "node": "replication0" } } + {"execute": "blockdev-add", "arguments": {"driver": "nbd", "node-name": "nbd0", "server": {"type": "inet", "host": "127.0.0.2", "port": "9999"}, "export": "parent0", "detect-zeroes": "on"} } + {"execute": "x-blockdev-change", "arguments":{"parent": "colo-disk0", "node": "nbd0" } } {"execute": "migrate-set-capabilities", "arguments": {"capabilities": [ {"capability": "x-colo", "state": true } ] } } {"execute": "migrate", "arguments": {"uri": "tcp:127.0.0.2:9998" } }@@ -262,7 +262,7 @@ Primary Failover The Secondary died, resume on the Primary:: {"execute": "x-blockdev-change", "arguments":{ "parent": "colo-disk0", "child": "children.1"} } - {"execute": "human-monitor-command", "arguments":{ "command-line": "drive_del replication0" } } + {"execute": "blockdev-del", "arguments": {"node-name": "nbd0"} } {"execute": "object-del", "arguments":{ "id": "comp0" } } {"execute": "object-del", "arguments":{ "id": "iothread1" } } {"execute": "object-del", "arguments":{ "id": "m0" } }@@ -302,8 +302,8 @@ Wait until disk is synced, then:: {"execute": "stop"} {"execute": "block-job-cancel", "arguments":{ "device": "resync"} } - {"execute": "human-monitor-command", "arguments":{ "command-line": "drive_add -n buddy driver=replication,mode=primary,file.driver=nbd,file.host=127.0.0.2,file.port=9999,file.export=parent0,node-name=replication0"}} - {"execute": "x-blockdev-change", "arguments":{ "parent": "colo-disk0", "node": "replication0" } } + {"execute": "blockdev-add", "arguments": {"driver": "nbd", "node-name": "nbd0", "server": {"type": "inet", "host": "127.0.0.2", "port": "9999"}, "export": "parent0", "detect-zeroes": "on"} } + {"execute": "x-blockdev-change", "arguments":{ "parent": "colo-disk0", "node": "nbd0" } } {"execute": "object-add", "arguments":{ "qom-type": "filter-mirror", "id": "m0", "netdev": "hn0", "queue": "tx", "outdev": "mirror0" } } {"execute": "object-add", "arguments":{ "qom-type": "filter-redirector", "id": "redire0", "netdev": "hn0", "queue": "rx", "indev": "compare_out" } }@@ -334,8 +334,8 @@ Wait until disk is synced, then:: {"execute": "stop"} {"execute": "block-job-cancel", "arguments":{ "device": "resync" } } - {"execute": "human-monitor-command", "arguments":{ "command-line": "drive_add -n buddy driver=replication,mode=primary,file.driver=nbd,file.host=127.0.0.1,file.port=9999,file.export=parent0,node-name=replication0"}} - {"execute": "x-blockdev-change", "arguments":{ "parent": "colo-disk0", "node": "replication0" } } + {"execute": "blockdev-add", "arguments": {"driver": "nbd", "node-name": "nbd0", "server": {"type": "inet", "host": "127.0.0.1", "port": "9999"}, "export": "parent0", "detect-zeroes": "on"} } + {"execute": "x-blockdev-change", "arguments":{ "parent": "colo-disk0", "node": "nbd0" } } {"execute": "object-add", "arguments":{ "qom-type": "filter-mirror", "id": "m0", "insert": "before", "position": "id=rew0", "netdev": "hn0", "queue": "tx", "outdev": "mirror0" } } {"execute": "object-add", "arguments":{ "qom-type": "filter-redirector", "id": "redire0", "insert": "before", "position": "id=rew0", "netdev": "hn0", "queue": "rx", "indev": "compare_out" } }Signature · 2 lines
-- 2.39.5
Signature · 1 line
Peter Xu