mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
tests/qtest: migration: Use migrate_incoming_qmp where appropriate
Use the new migrate_incoming_qmp helper in the places that currently open-code calling migrate-incoming. Reviewed-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: Fabiano Rosas <farosas@suse.de> Signed-off-by: Juan Quintela <quintela@redhat.com> Message-ID: <20230712190742.22294-4-farosas@suse.de>
This commit is contained in:
parent
28fa97e006
commit
6830e53b4b
3 changed files with 14 additions and 76 deletions
|
@ -11,6 +11,7 @@
|
|||
#include "libqtest.h"
|
||||
#include "libqos/pci.h"
|
||||
#include "libqos/pci-pc.h"
|
||||
#include "migration-helpers.h"
|
||||
#include "qapi/qmp/qdict.h"
|
||||
#include "qapi/qmp/qlist.h"
|
||||
#include "qapi/qmp/qjson.h"
|
||||
|
@ -736,26 +737,10 @@ static void test_migrate_out(gconstpointer opaque)
|
|||
machine_stop(qts);
|
||||
}
|
||||
|
||||
static QDict *get_migration_event(QTestState *qts)
|
||||
{
|
||||
QDict *resp;
|
||||
QDict *data;
|
||||
|
||||
resp = qtest_qmp_eventwait_ref(qts, "MIGRATION");
|
||||
g_assert(qdict_haskey(resp, "data"));
|
||||
|
||||
data = qdict_get_qdict(resp, "data");
|
||||
g_assert(qdict_haskey(data, "status"));
|
||||
qobject_ref(data);
|
||||
qobject_unref(resp);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static void test_migrate_in(gconstpointer opaque)
|
||||
{
|
||||
QTestState *qts;
|
||||
QDict *resp, *args, *ret;
|
||||
QDict *resp, *ret;
|
||||
g_autofree gchar *uri = g_strdup_printf("exec: cat %s", (gchar *)opaque);
|
||||
|
||||
qts = machine_start(BASE_MACHINE
|
||||
|
@ -787,18 +772,7 @@ static void test_migrate_in(gconstpointer opaque)
|
|||
check_one_card(qts, true, "standby0", MAC_STANDBY0);
|
||||
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
|
||||
|
||||
args = qdict_from_jsonf_nofail("{}");
|
||||
g_assert_nonnull(args);
|
||||
qdict_put_str(args, "uri", uri);
|
||||
|
||||
resp = qtest_qmp(qts, "{ 'execute': 'migrate-incoming', 'arguments': %p}",
|
||||
args);
|
||||
g_assert(qdict_haskey(resp, "return"));
|
||||
qobject_unref(resp);
|
||||
|
||||
resp = get_migration_event(qts);
|
||||
g_assert_cmpstr(qdict_get_str(resp, "status"), ==, "setup");
|
||||
qobject_unref(resp);
|
||||
migrate_incoming_qmp(qts, uri, "{}");
|
||||
|
||||
resp = get_failover_negociated_event(qts);
|
||||
g_assert_cmpstr(qdict_get_str(resp, "device-id"), ==, "standby0");
|
||||
|
@ -888,7 +862,7 @@ static void test_off_migrate_out(gconstpointer opaque)
|
|||
static void test_off_migrate_in(gconstpointer opaque)
|
||||
{
|
||||
QTestState *qts;
|
||||
QDict *resp, *args, *ret;
|
||||
QDict *ret;
|
||||
g_autofree gchar *uri = g_strdup_printf("exec: cat %s", (gchar *)opaque);
|
||||
|
||||
qts = machine_start(BASE_MACHINE
|
||||
|
@ -920,18 +894,7 @@ static void test_off_migrate_in(gconstpointer opaque)
|
|||
check_one_card(qts, true, "standby0", MAC_STANDBY0);
|
||||
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
|
||||
|
||||
args = qdict_from_jsonf_nofail("{}");
|
||||
g_assert_nonnull(args);
|
||||
qdict_put_str(args, "uri", uri);
|
||||
|
||||
resp = qtest_qmp(qts, "{ 'execute': 'migrate-incoming', 'arguments': %p}",
|
||||
args);
|
||||
g_assert(qdict_haskey(resp, "return"));
|
||||
qobject_unref(resp);
|
||||
|
||||
resp = get_migration_event(qts);
|
||||
g_assert_cmpstr(qdict_get_str(resp, "status"), ==, "setup");
|
||||
qobject_unref(resp);
|
||||
migrate_incoming_qmp(qts, uri, "{}");
|
||||
|
||||
check_one_card(qts, true, "standby0", MAC_STANDBY0);
|
||||
check_one_card(qts, true, "primary0", MAC_PRIMARY0);
|
||||
|
@ -1026,7 +989,7 @@ static void test_guest_off_migrate_out(gconstpointer opaque)
|
|||
static void test_guest_off_migrate_in(gconstpointer opaque)
|
||||
{
|
||||
QTestState *qts;
|
||||
QDict *resp, *args, *ret;
|
||||
QDict *ret;
|
||||
g_autofree gchar *uri = g_strdup_printf("exec: cat %s", (gchar *)opaque);
|
||||
|
||||
qts = machine_start(BASE_MACHINE
|
||||
|
@ -1058,18 +1021,7 @@ static void test_guest_off_migrate_in(gconstpointer opaque)
|
|||
check_one_card(qts, true, "standby0", MAC_STANDBY0);
|
||||
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
|
||||
|
||||
args = qdict_from_jsonf_nofail("{}");
|
||||
g_assert_nonnull(args);
|
||||
qdict_put_str(args, "uri", uri);
|
||||
|
||||
resp = qtest_qmp(qts, "{ 'execute': 'migrate-incoming', 'arguments': %p}",
|
||||
args);
|
||||
g_assert(qdict_haskey(resp, "return"));
|
||||
qobject_unref(resp);
|
||||
|
||||
resp = get_migration_event(qts);
|
||||
g_assert_cmpstr(qdict_get_str(resp, "status"), ==, "setup");
|
||||
qobject_unref(resp);
|
||||
migrate_incoming_qmp(qts, uri, "{}");
|
||||
|
||||
check_one_card(qts, true, "standby0", MAC_STANDBY0);
|
||||
check_one_card(qts, false, "primary0", MAC_PRIMARY0);
|
||||
|
@ -1728,7 +1680,7 @@ static void test_multi_out(gconstpointer opaque)
|
|||
static void test_multi_in(gconstpointer opaque)
|
||||
{
|
||||
QTestState *qts;
|
||||
QDict *resp, *args, *ret;
|
||||
QDict *resp, *ret;
|
||||
g_autofree gchar *uri = g_strdup_printf("exec: cat %s", (gchar *)opaque);
|
||||
|
||||
qts = machine_start(BASE_MACHINE
|
||||
|
@ -1794,18 +1746,7 @@ static void test_multi_in(gconstpointer opaque)
|
|||
check_one_card(qts, true, "standby1", MAC_STANDBY1);
|
||||
check_one_card(qts, false, "primary1", MAC_PRIMARY1);
|
||||
|
||||
args = qdict_from_jsonf_nofail("{}");
|
||||
g_assert_nonnull(args);
|
||||
qdict_put_str(args, "uri", uri);
|
||||
|
||||
resp = qtest_qmp(qts, "{ 'execute': 'migrate-incoming', 'arguments': %p}",
|
||||
args);
|
||||
g_assert(qdict_haskey(resp, "return"));
|
||||
qobject_unref(resp);
|
||||
|
||||
resp = get_migration_event(qts);
|
||||
g_assert_cmpstr(qdict_get_str(resp, "status"), ==, "setup");
|
||||
qobject_unref(resp);
|
||||
migrate_incoming_qmp(qts, uri, "{}");
|
||||
|
||||
resp = get_failover_negociated_event(qts);
|
||||
g_assert_cmpstr(qdict_get_str(resp, "device-id"), ==, "standby0");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue