[PATCH 2/3] migration-test: Add -snapshot option for COLO

Lukas Straub posted 3 patches 1 week ago
Maintainers: Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
[PATCH 2/3] migration-test: Add -snapshot option for COLO
Posted by Lukas Straub 1 week ago
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. And the image
won't boot with ide-cd.

As a workaround, use the '-snapshot' option where qemu will internally create
a writable snapshut while leaving the real image read-only.

Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---
 tests/qtest/migration/framework.c | 4 +++-
 tests/qtest/migration/framework.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/qtest/migration/framework.c b/tests/qtest/migration/framework.c
index e35839c95f51d851a3fed8e8457ed2d7e927f59b..8c1fc6e009f16dc05a47e917167f62e0250ca992 100644
--- a/tests/qtest/migration/framework.c
+++ b/tests/qtest/migration/framework.c
@@ -322,7 +322,9 @@ int migrate_args(char **from, char **to, const char *uri, MigrateStart *args)
         }
         arch_opts = g_strdup_printf(
             "-drive if=none,id=d0,file=%s,format=raw "
-            "-device ide-hd,drive=d0,secs=1,cyls=1,heads=1", bootpath);
+            "-device ide-hd,drive=d0,secs=1,cyls=1,heads=1 %s",
+            bootpath,
+            args->is_colo ? "-snapshot" : "");
         start_address = X86_TEST_MEM_START;
         end_address = X86_TEST_MEM_END;
     } else if (g_str_equal(arch, "s390x")) {
diff --git a/tests/qtest/migration/framework.h b/tests/qtest/migration/framework.h
index ed85ed502dd01aa809892b68d3934b5107bd3442..2ea13e7758697550b5531737e66d6d939dd800d1 100644
--- a/tests/qtest/migration/framework.h
+++ b/tests/qtest/migration/framework.h
@@ -134,6 +134,7 @@ typedef struct {
     bool suspend_me;
     /* enable OOB QMP capability */
     bool oob;
+    bool is_colo;
 
     /* Do not connect to target monitor and qtest sockets in qtest_init */
     bool defer_target_connect;

-- 
2.39.5
Re: [PATCH 2/3] migration-test: Add -snapshot option for COLO
Posted by Peter Xu 13 hours ago
On Tue, Dec 30, 2025 at 03:05:45PM +0100, Lukas Straub wrote:
> 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. And the image
> won't boot with ide-cd.
> 
> As a workaround, use the '-snapshot' option where qemu will internally create
> a writable snapshut while leaving the real image read-only.
> 
> Signed-off-by: Lukas Straub <lukasstraub2@web.de>
> ---
>  tests/qtest/migration/framework.c | 4 +++-
>  tests/qtest/migration/framework.h | 1 +
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/qtest/migration/framework.c b/tests/qtest/migration/framework.c
> index e35839c95f51d851a3fed8e8457ed2d7e927f59b..8c1fc6e009f16dc05a47e917167f62e0250ca992 100644
> --- a/tests/qtest/migration/framework.c
> +++ b/tests/qtest/migration/framework.c
> @@ -322,7 +322,9 @@ int migrate_args(char **from, char **to, const char *uri, MigrateStart *args)
>          }
>          arch_opts = g_strdup_printf(
>              "-drive if=none,id=d0,file=%s,format=raw "
> -            "-device ide-hd,drive=d0,secs=1,cyls=1,heads=1", bootpath);
> +            "-device ide-hd,drive=d0,secs=1,cyls=1,heads=1 %s",
> +            bootpath,
> +            args->is_colo ? "-snapshot" : "");

We can use opts_source / opts_target for this.

>          start_address = X86_TEST_MEM_START;
>          end_address = X86_TEST_MEM_END;
>      } else if (g_str_equal(arch, "s390x")) {
> diff --git a/tests/qtest/migration/framework.h b/tests/qtest/migration/framework.h
> index ed85ed502dd01aa809892b68d3934b5107bd3442..2ea13e7758697550b5531737e66d6d939dd800d1 100644
> --- a/tests/qtest/migration/framework.h
> +++ b/tests/qtest/migration/framework.h
> @@ -134,6 +134,7 @@ typedef struct {
>      bool suspend_me;
>      /* enable OOB QMP capability */
>      bool oob;
> +    bool is_colo;
>  
>      /* Do not connect to target monitor and qtest sockets in qtest_init */
>      bool defer_target_connect;
> 
> -- 
> 2.39.5
> 

-- 
Peter Xu