Skip to contentSkip to conversation

tests/migration-test: Check error-desc after pre-switch cancel tests

PATCH In review Peter Xu 2 participants 6 messages Oct 31, 2025 – Nov 18, 2025

lore
Share & tools
lore

Peter Xu

author
#0 lore raw

PATCH 1/1 tests/migration-test: Check error-desc after pre-switch cancel tests

error-desc should present on dest QEMU after migration failed on dest when exit-on-error is set to FALSE. Check the error message.

---
 tests/qtest/migration/precopy-tests.c | 9 +++++++++
 1 file changed, 9 insertions(+)
tests/qtest/migration/precopy-tests.c +9 -0
index 57ca623de5..5f02e35324 100644
@@ -759,6 +759,14 @@ static void test_cancel_src_after_none(QTestState *from, QTestState *to,
     wait_for_migration_complete(to);
 }
 
+static void assert_migration_error(QTestState *vm)
+{
+    QDict *rep = migrate_query(vm);
+
+    g_assert(qdict_get_str(rep, "error-desc"));
+    qobject_unref(rep);
+}
+
 static void test_cancel_src_pre_switchover(QTestState *from, QTestState *to,
                                            const char *uri, const char *phase)
 {
@@ -784,6 +792,7 @@ static void test_cancel_src_pre_switchover(QTestState *from, QTestState *to,
 
     wait_for_migration_status(to, "failed",
                               (const char * []) { "completed", NULL });
+    assert_migration_error(to);
 }
 
 static void test_cancel_src_after_status(void *opaque)
Signature · 1 line
2.50.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Peter,

Quoted 13 lines · Peter Xu

error-desc should present on dest QEMU after migration failed on dest when exit-on-error is set to FALSE. Check the error message.

---
 tests/qtest/migration/precopy-tests.c | 9 +++++++++
 1 file changed, 9 insertions(+)
tests/qtest/migration/precopy-tests.c +0 -0
index 57ca623de5..5f02e35324 100644

tests/qtest/migration/precopy-tests.c static void test_cancel_src_after_none(QTestState *from, QTestState *to, · line 766

Quoted 8 lines
tests/qtest/migration/precopy-tests.c +5 -0
@@ -759,6 +759,14 @@ static void test_cancel_src_after_none(QTestState *from, QTestState *to,
     wait_for_migration_complete(to);
 }
 
+static void assert_migration_error(QTestState *vm)
+{
+    QDict *rep = migrate_query(vm);
+
+    g_assert(qdict_get_str(rep, "error-desc"));

I think it would be beneficial to also check if there even is "error-desc". That way if the "error-desc" is missing, it fails on assert with SIGABRT instead of SIGSEGV inside qdict_get_str().

With this change you can add my:

tests/qtest/migration/precopy-tests.c +1 -0
index 5f02e35324..87e33b8965 100644
@@ -763,6 +763,7 @@ static void assert_migration_error(QTestState *vm)
 {
     QDict *rep = migrate_query(vm);
 
+    g_assert(qdict_get(rep, "error-desc"));
     g_assert(qdict_get_str(rep, "error-desc"));
     qobject_unref(rep);
 }
Quoted 17 lines
tests/qtest/migration/precopy-tests.c +4 -0
+    qobject_unref(rep);
+}
+
 static void test_cancel_src_pre_switchover(QTestState *from, QTestState *to,
                                            const char *uri, const char *phase)
 {
@@ -784,6 +792,7 @@ static void test_cancel_src_pre_switchover(QTestState *from, QTestState *to,
 
     wait_for_migration_status(to, "failed",
                               (const char * []) { "completed", NULL });
+    assert_migration_error(to);
 }
 
 static void test_cancel_src_after_status(void *opaque)
Signature · 1 line
2.50.1
author
#2 lore raw
Quoted 19 lines · Juraj Marcin

Hi Peter,

Quoted 16 lines · Peter Xu

error-desc should present on dest QEMU after migration failed on dest when exit-on-error is set to FALSE. Check the error message.

---
 tests/qtest/migration/precopy-tests.c | 9 +++++++++
 1 file changed, 9 insertions(+)
tests/qtest/migration/precopy-tests.c +0 -0
index 57ca623de5..5f02e35324 100644
@@ -759,6 +759,14 @@ static void test_cancel_src_after_none(QTestState *from, QTestState *to,
     wait_for_migration_complete(to);
 }
 
Quoted 9 lines

tests/qtest/migration/precopy-tests.c static void test_cancel_src_after_none(QTestState *from, QTestState *to, · line 766

Quoted 5 lines
tests/qtest/migration/precopy-tests.c +5 -0
+static void assert_migration_error(QTestState *vm)
+{
+    QDict *rep = migrate_query(vm);
+
+    g_assert(qdict_get_str(rep, "error-desc"));

I think it would be beneficial to also check if there even is "error-desc". That way if the "error-desc" is missing, it fails on assert with SIGABRT instead of SIGSEGV inside qdict_get_str().

IMHO it doesn't matter on how the test would crash.

Quoted 4 lines

With this change you can add my:

I would go ahead and merge a test patch if it had both lines, definitely not a huge deal.

However strictly speaking, qdict_get_str() is actually pretty efficient to make sure both that exists && is_string when used in testings. Would you agree?

I definitely still want your R-b one way or another!

Quoted 34 lines
tests/qtest/migration/precopy-tests.c +1 -0
index 5f02e35324..87e33b8965 100644
@@ -763,6 +763,7 @@ static void assert_migration_error(QTestState *vm)
 {
     QDict *rep = migrate_query(vm);
 
+    g_assert(qdict_get(rep, "error-desc"));
     g_assert(qdict_get_str(rep, "error-desc"));
     qobject_unref(rep);
 }
Quoted 19 lines
tests/qtest/migration/precopy-tests.c +4 -0
+    qobject_unref(rep);
+}
+
 static void test_cancel_src_pre_switchover(QTestState *from, QTestState *to,
                                            const char *uri, const char *phase)
 {
@@ -784,6 +792,7 @@ static void test_cancel_src_pre_switchover(QTestState *from, QTestState *to,
 
     wait_for_migration_status(to, "failed",
                               (const char * []) { "completed", NULL });
+    assert_migration_error(to);
 }
 
 static void test_cancel_src_after_status(void *opaque)
Signature · 1 line
2.50.1
Signature · 1 line
Peter Xu
#3 lore raw
Quoted 35 lines · Peter Xu
Quoted 19 lines · Juraj Marcin

Hi Peter,

Quoted 16 lines · Peter Xu

error-desc should present on dest QEMU after migration failed on dest when exit-on-error is set to FALSE. Check the error message.

---
 tests/qtest/migration/precopy-tests.c | 9 +++++++++
 1 file changed, 9 insertions(+)
tests/qtest/migration/precopy-tests.c +0 -0
index 57ca623de5..5f02e35324 100644
@@ -759,6 +759,14 @@ static void test_cancel_src_after_none(QTestState *from, QTestState *to,
     wait_for_migration_complete(to);
 }
 
Quoted 9 lines

tests/qtest/migration/precopy-tests.c static void test_cancel_src_after_none(QTestState *from, QTestState *to, · line 766

Quoted 5 lines
tests/qtest/migration/precopy-tests.c +5 -0
+static void assert_migration_error(QTestState *vm)
+{
+    QDict *rep = migrate_query(vm);
+
+    g_assert(qdict_get_str(rep, "error-desc"));

I think it would be beneficial to also check if there even is "error-desc". That way if the "error-desc" is missing, it fails on assert with SIGABRT instead of SIGSEGV inside qdict_get_str().

IMHO it doesn't matter on how the test would crash.

Quoted 3 lines

With this change you can add my:

Quoted 8 lines
Quoted 1 line

I would go ahead and merge a test patch if it had both lines, definitely not a huge deal.

However strictly speaking, qdict_get_str() is actually pretty efficient to make sure both that exists && is_string when used in testings. Would you agree?

It is an efficient way, I just thought the less efficient might be a little bit easier to deduce why the test failed. But if nobody else opposes, you can also keep it as proposed,

Quoted 2 lines

I definitely still want your R-b one way or another!

and also add my R-b.

Quoted 39 lines
Quoted 35 lines
tests/qtest/migration/precopy-tests.c +1 -0
index 5f02e35324..87e33b8965 100644
@@ -763,6 +763,7 @@ static void assert_migration_error(QTestState *vm)
 {
     QDict *rep = migrate_query(vm);
 
+    g_assert(qdict_get(rep, "error-desc"));
     g_assert(qdict_get_str(rep, "error-desc"));
     qobject_unref(rep);
 }
Quoted 19 lines
tests/qtest/migration/precopy-tests.c +4 -0
+    qobject_unref(rep);
+}
+
 static void test_cancel_src_pre_switchover(QTestState *from, QTestState *to,
                                            const char *uri, const char *phase)
 {
@@ -784,6 +792,7 @@ static void test_cancel_src_pre_switchover(QTestState *from, QTestState *to,
 
     wait_for_migration_status(to, "failed",
                               (const char * []) { "completed", NULL });
+    assert_migration_error(to);
 }
 
 static void test_cancel_src_after_status(void *opaque)
Signature · 1 line
2.50.1
Signature · 1 line
Peter Xu
author
#4 lore raw
Quoted 45 lines · Juraj Marcin
Quoted 35 lines · Peter Xu
Quoted 19 lines · Juraj Marcin

Hi Peter,

Quoted 16 lines · Peter Xu

error-desc should present on dest QEMU after migration failed on dest when exit-on-error is set to FALSE. Check the error message.

---
 tests/qtest/migration/precopy-tests.c | 9 +++++++++
 1 file changed, 9 insertions(+)
tests/qtest/migration/precopy-tests.c +0 -0
index 57ca623de5..5f02e35324 100644
@@ -759,6 +759,14 @@ static void test_cancel_src_after_none(QTestState *from, QTestState *to,
     wait_for_migration_complete(to);
 }
 
Quoted 9 lines

tests/qtest/migration/precopy-tests.c static void test_cancel_src_after_none(QTestState *from, QTestState *to, · line 766

Quoted 5 lines
tests/qtest/migration/precopy-tests.c +5 -0
+static void assert_migration_error(QTestState *vm)
+{
+    QDict *rep = migrate_query(vm);
+
+    g_assert(qdict_get_str(rep, "error-desc"));

I think it would be beneficial to also check if there even is "error-desc". That way if the "error-desc" is missing, it fails on assert with SIGABRT instead of SIGSEGV inside qdict_get_str().

IMHO it doesn't matter on how the test would crash.

Quoted 3 lines

With this change you can add my:

Quoted 8 lines
Quoted 1 line

I would go ahead and merge a test patch if it had both lines, definitely not a huge deal.

However strictly speaking, qdict_get_str() is actually pretty efficient to make sure both that exists && is_string when used in testings. Would you agree?

Quoted 8 lines

It is an efficient way, I just thought the less efficient might be a little bit easier to deduce why the test failed. But if nobody else opposes, you can also keep it as proposed,

Quoted 2 lines

I definitely still want your R-b one way or another!

and also add my R-b.

Thanks. I wanted to have this coverage asap, so I collected it for -rc.

Signature · 1 line
Peter Xu
author
#5 lore raw
In reply to Peter Xu
Quoted 28 lines · Peter Xu

error-desc should present on dest QEMU after migration failed on dest when exit-on-error is set to FALSE. Check the error message.

---
 tests/qtest/migration/precopy-tests.c | 9 +++++++++
 1 file changed, 9 insertions(+)
tests/qtest/migration/precopy-tests.c +8 -0
index 57ca623de5..5f02e35324 100644
@@ -759,6 +759,14 @@ static void test_cancel_src_after_none(QTestState *from, QTestState *to,
     wait_for_migration_complete(to);
 }
 
+static void assert_migration_error(QTestState *vm)
+{
+    QDict *rep = migrate_query(vm);
+
+    g_assert(qdict_get_str(rep, "error-desc"));
+    qobject_unref(rep);
+}
+
 static void test_cancel_src_pre_switchover(QTestState *from, QTestState *to,
                                            const char *uri, const char *phase)
 {

tests/qtest/migration/precopy-tests.c static void test_cancel_src_pre_switchover(QTestState *from, QTestState *to, · line 795

Quoted 4 lines
tests/qtest/migration/precopy-tests.c +1 -0
@@ -784,6 +792,7 @@ static void test_cancel_src_pre_switchover(QTestState *from, QTestState *to,
 
     wait_for_migration_status(to, "failed",
                               (const char * []) { "completed", NULL });
+    assert_migration_error(to);

While I was running more tests I found this assertion might still trigger but only randomly. I think it might be caused by some migration failure path not setting the error string even if it'll fail the migration. I'll unqueuing this one for now and put this into backlog as of now..

Signature · 1 line
Peter Xu