Migration 20230602 patches
The following changes since commit a86d7b9ec0adb2f1efce8ab30d9ed2b72db0236e:
Merge tag 'migration-20230601-pull-request' of https://gitlab.com/juan.quintela/qemu into staging (2023-06-01 20:59:28 -0700)
are available in the Git repository at:
https://gitlab.com/juan.quintela/qemu.git tags/migration-20230602-pull-request
for you to fetch changes up to b861383c2690501ff2687f9ef9268b128b0fb3b3:
qtest/migration: Document live=true cases (2023-06-02 11:46:20 +0200)
----------------------------------------------------------------
Migration Pull request (20230602 vintage)
This PULL request get:
- All migration-test patches except last one (daniel)
- Documentation about live test cases (peter)
Please apply.
----------------------------------------------------------------
Daniel P. Berrangé (9):
tests/qtest: add various qtest_qmp_assert_success() variants tests/qtest: add support for callback to receive QMP events tests/qtest: get rid of 'qmp_command' helper in migration test tests/qtest: get rid of some 'qtest_qmp' usage in migration test tests/qtest: switch to using event callbacks for STOP event tests/qtest: replace wait_command() with qtest_qmp_assert_success tests/qtest: capture RESUME events during migration tests/qtest: distinguish src/dst migration VM stop/resume events tests/qtest: make more migration pre-copy scenarios run non-live
Peter Xu (1):
qtest/migration: Document live=true cases
tests/qtest/libqtest.h | 158 ++++++++++++- tests/qtest/migration-helpers.h | 16 +- tests/qtest/libqtest.c | 121 +++++++++- tests/qtest/migration-helpers.c | 103 ++------- tests/qtest/migration-test.c | 386 ++++++++++++++++++-------------- 5 files changed, 505 insertions(+), 279 deletions(-)
Signature · 1 line
2.40.1
[PULL 10/10] qtest/migration: Document live=true cases
From: Peter Xu <[email protected]>
Document every single live=true use cases on why it should be done in the live manner. Also document on the parameter so new precopy cases should always use live=off unless with explicit reasonings.
Message-Id: <[email protected]>
--- tests/qtest/migration-test.c | 37 ++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-)
tests/qtest/migration-test.c +31 -6
@@ -580,7 +580,14 @@ typedef struct {/* Optional: set number of migration passes to wait for, if live==true */ unsigned int iterations; -/* Optional: whether the guest CPUs should be running during migration */ +/* +* Optional: whether the guest CPUs should be running during a precopy +* migration test. We used to always run with live but it took much +* longer so we reduced live tests to only the ones that have solid +* reason to be tested live-only. For each of the new test cases for +* precopy please provide justifications to use live explicitly (please +* refer to existing ones with live=true), or use live=off by default. +*/ bool live;/* Postcopy specific fields */
@@ -1491,7 +1498,10 @@ static void test_precopy_unix_plain(void)MigrateCommon args = { .listen_uri = uri, .connect_uri = uri, - +/* +* The simplest use case of precopy, covering smoke tests of +* get-dirty-log dirty tracking. +*/ .live = true, };
@@ -1508,7 +1518,10 @@ static void test_precopy_unix_dirty_ring(void) }, .listen_uri = uri, .connect_uri = uri, - +/* +* Besides the precopy/unix basic test, cover dirty ring interface +* rather than get-dirty-log. +*/ .live = true, };
@@ -1617,10 +1630,12 @@ static void test_precopy_unix_xbzrle(void)MigrateCommon args = { .connect_uri = uri, .listen_uri = uri, - .start_hook = test_migrate_xbzrle_start, - .iterations =2 , +/* +* XBZRLE needs pages to be modified when doing the 2nd+ round +* iteration to have real data pushed to the stream. +*/ .live = true, };
@@ -1639,6 +1654,11 @@ static void test_precopy_unix_compress(void)* the previous iteration. */ .iterations = 2, +/* +* We make sure the compressor can always work well even if guest +* memory is changing. See commit 34ab9e9743 where we used to fix +* a bug when only trigger-able with guest memory changing. +*/ .live = true, };
@@ -1657,6 +1677,7 @@ static void test_precopy_unix_compress_nowait(void)* the previous iteration. */ .iterations = 2, + /* Same reason for the wait version of precopy compress test */ .live = true, };
@@ -2066,7 +2087,11 @@ static void test_multifd_tcp_none(void)MigrateCommon args = { .listen_uri ="defer" , .start_hook = test_migrate_precopy_tcp_multifd_start, - +/* +* Multifd is more complicated than most of the features, it +* directly takes guest page buffers when sending, make sure +* everything will work alright even if guest page is changing. +*/ .live = true, };test_precopy_common (&args);
Signature · 1 line
2.40.1
[PULL 02/10] tests/qtest: add support for callback to receive QMP events
In reply to Juan QuintelaFrom: Daniel P. Berrangé <[email protected]>
Currently code must call one of the qtest_qmp_event* functions to fetch events. These are only usable if the immediate caller knows the particular event they want to capture, and are only interested in one specific event type. Adding ability to register an event callback lets the caller capture a range of events over any period of time.
Message-Id: <[email protected]>
--- tests/qtest/libqtest.h | 43 ++++++++++++++++++++++++++++++++++++++++-- tests/qtest/libqtest.c | 18 ++++++++++++++++-- 2 files changed, 57 insertions(+), 4 deletions(-)
tests/qtest/libqtest.h +41 -2
@@ -238,17 +238,52 @@ QDict *qtest_qmp_receive_dict(QTestState *s);* @s: #QTestState instance to operate on. * * Reads a QMP message from QEMU and returns the response. -* Buffers all the events received meanwhile, until a -* call to qtest_qmp_eventwait +* +* If a callback is registered with qtest_qmp_set_event_callback, +* it will be invoked for every event seen, otherwise events +* will be buffered until a call to one of the qtest_qmp_eventwait +* family of functions. */ QDict *qtest_qmp_receive (QTestState *s); +/* +* QTestQMPEventCallback: +* @s: #QTestState instance event was received on +* @name: name of the event type +* @event: #QDict for the event details +* @opaque: opaque data from time of callback registration +* +* This callback will be invoked whenever an event is received. +* If the callback returns true the event will be consumed, +* otherwise it will be put on the list of pending events. +* Pending events can be later handled by calling either +* qtest_qmp_eventwait or qtest_qmp_eventwait_ref. +* +* Return: true to consume the event, false to let it be queued +*/ +typedef bool (*QTestQMPEventCallback )(QTestState *s,const char *name, +QDict *event,void *opaque); + +/** +* qtest_qmp_set_event_callback: +* @s: #QTestSTate instance to operate on +* @cb: callback to invoke for events +* @opaque: data to pass to @cb +* +* Register a callback to be invoked whenever an event arrives +*/ +void qtest_qmp_set_event_callback (QTestState *s, +QTestQMPEventCallback cb,void *opaque); +/** * qtest_qmp_eventwait: * @s: #QTestState instance to operate on. * @event: event to wait for. * * Continuously polls for QMP responses until it receives the desired event. +* +* Any callback registered with qtest_qmp_set_event_callback will +* be invoked for every event seen. */ void qtest_qmp_eventwait (QTestState *s,const char *event);
@@ -258,6 +293,10 @@ void qtest_qmp_eventwait(QTestState *s, const char *event);* @event: event to wait for. * * Continuously polls for QMP responses until it receives the desired event. +* +* Any callback registered with qtest_qmp_set_event_callback will +* be invoked for every event seen. +* * Returns a copy of the event for further investigation. */ QDict *qtest_qmp_eventwait_ref (QTestState *s,const char *event);
tests/qtest/libqtest.c +16 -2
@@ -82,6 +82,8 @@ struct QTestStateGString *rx;QTestTransportOps ops;GList *pending_events; +QTestQMPEventCallback eventCB; +void *eventData; };static GHookList abrt_hooks;
@@ -703,8 +705,13 @@ QDict *qtest_qmp_receive(QTestState *s)if (!qdict_get_try_str (response,"event" )) {return response; } -/* Stash the event for a later consumption */ - s->pending_events =g_list_append (s->pending_events, response); + +if (!s->eventCB || + !s->eventCB (s,qdict_get_str (response,"event" ), + response, s->eventData)) { +/* Stash the event for a later consumption */ + s->pending_events =g_list_append (s->pending_events, response); + } } }
@@ -808,6 +815,13 @@ void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...)va_end (ap); } +void qtest_qmp_set_event_callback (QTestState *s, +QTestQMPEventCallback cb,void *opaque) +{ + s->eventCB = cb; + s->eventData = opaque; +} +QDict *qtest_qmp_event_ref (QTestState *s,const char *event) {while (s->pending_events) {
Signature · 1 line
2.40.1
[PULL 06/10] tests/qtest: replace wait_command() with qtest_qmp_assert_success
In reply to Juan QuintelaFrom: Daniel P. Berrangé <[email protected]>
Most usage of wait_command() is followed by qobject_unref(), which is just a verbose re-implementation of qtest_qmp_assert_success().
Message-Id: <[email protected]>
--- tests/qtest/migration-helpers.h | 8 -- tests/qtest/migration-helpers.c | 53 +--------- tests/qtest/migration-test.c | 170 +++++++++++++------------------- 3 files changed, 74 insertions(+), 157 deletions(-)
tests/qtest/migration-helpers.h +0 -8
@@ -18,14 +18,6 @@bool migrate_watch_for_stop (QTestState *who,const char *name,QDict *event,void *opaque); -#ifndef _WIN32 -G_GNUC_PRINTF(3, 4) -QDict *wait_command_fd (QTestState *who,int fd,const char *command, ...); -#endif - -G_GNUC_PRINTF(2, 3) -QDict *wait_command (QTestState *who,const char *command, ...); - G_GNUC_PRINTF(3, 4)void migrate_qmp (QTestState *who,const char *uri,const char *fmt, ...);
tests/qtest/migration-helpers.c +3 -50
71 lines not on this page · raw message
tests/qtest/migration-test.c +71 -99
292 lines not on this page · raw message
Signature · 1 line
2.40.1
[PULL 09/10] tests/qtest: make more migration pre-copy scenarios run non-live
In reply to Juan QuintelaFrom: Daniel P. Berrangé <[email protected]>
There are 27 pre-copy live migration scenarios being tested. In all of these we force non-convergence and run for one iteration, then let it converge and wait for completion during the second (or following) iterations. At 3 mbps bandwidth limit the first iteration takes a very long time (~30 seconds).
While it is important to test the migration passes and convergence logic, it is overkill to do this for all 27 pre-copy scenarios. The TLS migration scenarios in particular are merely exercising different code paths during connection establishment.
To optimize time taken, switch most of the test scenarios to run non-live (ie guest CPUs paused) with no bandwidth limits. This gives a massive speed up for most of the test scenarios.
For test coverage the following scenarios are unchanged
* Precopy with UNIX sockets
* Precopy with UNIX sockets and dirty ring tracking
* Precopy with XBZRLE
* Precopy with UNIX compress
* Precopy with UNIX compress (nowait)
* Precopy with multifd
On a test machine this reduces execution time from 13 minutes to 8 minutes.
Message-Id: <[email protected]>
--- tests/qtest/migration-test.c | 83 +++++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 16 deletions(-)
tests/qtest/migration-test.c +67 -16
@@ -577,9 +577,12 @@ typedef struct {MIG_TEST_FAIL_DEST_QUIT_ERR , } result; -/* Optional: set number of migration passes to wait for */ +/* Optional: set number of migration passes to wait for, if live==true */ unsigned int iterations; +/* Optional: whether the guest CPUs should be running during migration */ +bool live; +/* Postcopy specific fields */ void *postcopy_data;bool postcopy_preempt;
@@ -1385,8 +1388,6 @@ static void test_precopy_common(MigrateCommon *args)return ; } -migrate_ensure_non_converge (from); -if (args->start_hook) { data_hook = args->start_hook (from, to); }
@@ -1396,6 +1397,31 @@ static void test_precopy_common(MigrateCommon *args)wait_for_serial ("src_serial" ); } +if (args->live) { +/* +* Testing live migration, we want to ensure that some +* memory is re-dirtied after being transferred, so that +* we exercise logic for dirty page handling. We achieve +* this with a ridiculosly low bandwidth that guarantees +* non-convergance. +*/ +migrate_ensure_non_converge (from); + }else { +/* +* Testing non-live migration, we allow it to run at +* full speed to ensure short test case duration. +* For tests expected to fail, we don't need to +* change anything. +*/ +if (args->result ==MIG_TEST_SUCCEED ) { +qtest_qmp_assert_success (from,"{ 'execute' : 'stop'}" ); +if (!got_src_stop) { +qtest_qmp_eventwait (from,"STOP" ); + } +migrate_ensure_converge (from); + } + } +if (!args->connect_uri) { g_autofree char *local_connect_uri =migrate_get_socket_address (to,"socket-address" );
@@ -1413,26 +1439,42 @@ static void test_precopy_common(MigrateCommon *args)qtest_set_expected_status (to,EXIT_FAILURE ); } }else { -if (args->iterations) { -while (args->iterations--) { +if (args->live) { +if (args->iterations) { +while (args->iterations--) { +wait_for_migration_pass (from); + } + }else {wait_for_migration_pass (from); } + +migrate_ensure_converge (from); + +/* +* We do this first, as it has a timeout to stop us +* hanging forever if migration didn't converge +*/ +wait_for_migration_complete (from); + +if (!got_src_stop) { +qtest_qmp_eventwait (from,"STOP" ); + } }else { -wait_for_migration_pass (from); +wait_for_migration_complete (from); +/* +* Must wait for dst to finish reading all incoming +* data on the socket before issuing 'cont' otherwise +* it'll be ignored +*/ +wait_for_migration_complete (to); + +qtest_qmp_assert_success (to,"{ 'execute' : 'cont'}" ); } -migrate_ensure_converge (from); - -/* We do this first, as it has a timeout to stop us -* hanging forever if migration didn't converge */ -wait_for_migration_complete (from); - -if (!got_src_stop) { -qtest_qmp_eventwait (from,"STOP" ); +if (!got_dst_resume) { +qtest_qmp_eventwait (to,"RESUME" ); } -qtest_qmp_eventwait (to,"RESUME" ); -wait_for_serial ("dest_serial" ); }
@@ -1449,6 +1491,8 @@ static void test_precopy_unix_plain(void)MigrateCommon args = { .listen_uri = uri, .connect_uri = uri, + + .live = true, };test_precopy_common (&args);
@@ -1464,6 +1508,8 @@ static void test_precopy_unix_dirty_ring(void) }, .listen_uri = uri, .connect_uri = uri, + + .live = true, };test_precopy_common (&args);
@@ -1575,6 +1621,7 @@ static void test_precopy_unix_xbzrle(void) .start_hook = test_migrate_xbzrle_start, .iterations = 2, + .live = true, };test_precopy_common (&args);
@@ -1592,6 +1639,7 @@ static void test_precopy_unix_compress(void)* the previous iteration. */ .iterations = 2, + .live = true, };test_precopy_common (&args);
@@ -1609,6 +1657,7 @@ static void test_precopy_unix_compress_nowait(void)* the previous iteration. */ .iterations = 2, + .live = true, };test_precopy_common (&args);
@@ -2017,6 +2066,8 @@ static void test_multifd_tcp_none(void)MigrateCommon args = { .listen_uri ="defer" , .start_hook = test_migrate_precopy_tcp_multifd_start, + + .live = true, };test_precopy_common (&args); }
Signature · 1 line
2.40.1
[PULL 08/10] tests/qtest: distinguish src/dst migration VM stop/resume events
In reply to Juan QuintelaFrom: Daniel P. Berrangé <[email protected]>
The 'got_stop' and 'got_resume' global variables apply to the src and dst migration VM respectively. Change their names to make this explicit to developers.
Message-Id: <[email protected]>
--- tests/qtest/migration-test.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
tests/qtest/migration-test.c +13 -13
@@ -43,8 +43,8 @@unsigned start_address;unsigned end_address;static bool uffd_feature_thread_id; -static bool got_stop; -static bool got_resume; +static bool got_src_stop; +static bool got_dst_resume;/* * Dirtylimit stop working if dirty page rate error
@@ -227,7 +227,7 @@ static void wait_for_migration_pass(QTestState *who)uint64_t pass;/* Wait for the 1st sync */ -while (!got_stop && !initial_pass) { +while (!got_src_stop && !initial_pass) {usleep (1000 ); initial_pass =get_migration_pass (who); }
@@ -235,7 +235,7 @@ static void wait_for_migration_pass(QTestState *who)do {usleep (1000 ); pass =get_migration_pass (who); - }while (pass == initial_pass && !got_stop); + }while (pass == initial_pass && !got_src_stop); }static void check_guests_ram (QTestState *who)
@@ -487,7 +487,7 @@ static void migrate_postcopy_start(QTestState *from, QTestState *to) {qtest_qmp_assert_success (from,"{ 'execute': 'migrate-start-postcopy' }" ); -if (!got_stop) { +if (!got_src_stop) {qtest_qmp_eventwait (from,"STOP" ); }
@@ -607,8 +607,8 @@ static int test_migrate_start(QTestState **from, QTestState **to, } } - got_stop = false; - got_resume = false; + got_src_stop = false; + got_dst_resume = false; bootpath =g_strdup_printf ("%s/bootsect" , tmpfs);if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) {/* the assembled x86 boot sector should be exactly one sector large */
@@ -696,7 +696,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, *from =qtest_init (cmd_source);qtest_qmp_set_event_callback (*from, migrate_watch_for_stop, - &got_stop); + &got_src_stop); } cmd_target = g_strdup_printf("-accel kvm%s -accel tcg%s%s "
@@ -716,7 +716,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, *to =qtest_init (cmd_target);qtest_qmp_set_event_callback (*to, migrate_watch_for_resume, - &got_resume); + &got_dst_resume);/* * Remove shmem file immediately to avoid memory leak in test failed case.
@@ -1427,7 +1427,7 @@ static void test_precopy_common(MigrateCommon *args)* hanging forever if migration didn't converge */ wait_for_migration_complete (from); -if (!got_stop) { +if (!got_src_stop) {qtest_qmp_eventwait (from,"STOP" ); }
@@ -1537,7 +1537,7 @@ static void test_ignore_shared(void)wait_for_migration_pass (from); -if (!got_stop) { +if (!got_src_stop) {qtest_qmp_eventwait (from,"STOP" ); }
@@ -1942,7 +1942,7 @@ static void test_migrate_auto_converge(void)break ; }usleep (20 ); -g_assert_false (got_stop); +g_assert_false (got_src_stop); }while (true);/* The first percentage of throttling should be at least init_pct */ g_assert_cmpint(percentage, >=, init_pct);
@@ -2275,7 +2275,7 @@ static void test_multifd_tcp_cancel(void)wait_for_migration_pass (from); -if (!got_stop) { +if (!got_src_stop) {qtest_qmp_eventwait (from,"STOP" ); }qtest_qmp_eventwait (to2,"RESUME" );
Signature · 1 line
2.40.1
[PULL 07/10] tests/qtest: capture RESUME events during migration
In reply to Juan QuintelaFrom: Daniel P. Berrangé <[email protected]>
When running migration tests we monitor for a STOP event so we can skip redundant waits. This will be needed for the RESUME event too shortly.
Message-Id: <[email protected]>
--- tests/qtest/migration-helpers.h | 2 ++ tests/qtest/migration-helpers.c | 13 +++++++++++++ tests/qtest/migration-test.c | 5 +++++ 3 files changed, 20 insertions(+)
tests/qtest/migration-helpers.h +2 -0
@@ -17,6 +17,8 @@bool migrate_watch_for_stop (QTestState *who,const char *name,QDict *event,void *opaque); +bool migrate_watch_for_resume (QTestState *who,const char *name, +QDict *event,void *opaque); G_GNUC_PRINTF(3, 4)void migrate_qmp (QTestState *who,const char *uri,const char *fmt, ...);
tests/qtest/migration-helpers.c +13 -0
@@ -36,6 +36,19 @@ bool migrate_watch_for_stop(QTestState *who, const char *name,return false; } +bool migrate_watch_for_resume (QTestState *who,const char *name, +QDict *event,void *opaque) +{ +bool *seen = opaque; + +if (g_str_equal (name,"RESUME" )) { + *seen = true; +return true; + } + +return false; +} +/* * Send QMP command "migrate". * Arguments are built from @fmt... (formatted like
tests/qtest/migration-test.c +5 -0
@@ -44,6 +44,7 @@ unsigned start_address;unsigned end_address;static bool uffd_feature_thread_id;static bool got_stop; +static bool got_resume;/* * Dirtylimit stop working if dirty page rate error
@@ -607,6 +608,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, } got_stop = false; + got_resume = false; bootpath =g_strdup_printf ("%s/bootsect" , tmpfs);if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) {/* the assembled x86 boot sector should be exactly one sector large */
@@ -712,6 +714,9 @@ static int test_migrate_start(QTestState **from, QTestState **to, args->opts_target ? args->opts_target :"" , ignore_stderr); *to =qtest_init (cmd_target); +qtest_qmp_set_event_callback (*to, + migrate_watch_for_resume, + &got_resume);/* * Remove shmem file immediately to avoid memory leak in test failed case.
Signature · 1 line
2.40.1
[PULL 03/10] tests/qtest: get rid of 'qmp_command' helper in migration test
In reply to Juan QuintelaFrom: Daniel P. Berrangé <[email protected]>
This function duplicates logic of qtest_qmp_assert_success_ref. The qtest_qmp_assert_success_ref method has better diagnostics on failure because it prints the entire QMP response, instead of just asserting on existance of the 'error' key.
Message-Id: <[email protected]>
--- tests/qtest/migration-helpers.h | 3 --- tests/qtest/migration-helpers.c | 22 ---------------------- tests/qtest/migration-test.c | 29 +++++++++++++++-------------- 3 files changed, 15 insertions(+), 39 deletions(-)
tests/qtest/migration-helpers.h +0 -3
@@ -25,9 +25,6 @@ QDict *wait_command_fd(QTestState *who, int fd, const char *command, ...); G_GNUC_PRINTF(2, 3)QDict *wait_command (QTestState *who,const char *command, ...); -G_GNUC_PRINTF(2, 3) -QDict *qmp_command (QTestState *who,const char *command, ...); - G_GNUC_PRINTF(3, 4)void migrate_qmp (QTestState *who,const char *uri,const char *fmt, ...);
tests/qtest/migration-helpers.c +0 -22
@@ -85,28 +85,6 @@ QDict *wait_command(QTestState *who, const char *command, ...)return ret; } -/* -* Execute the qmp command only -*/ -QDict *qmp_command (QTestState *who,const char *command, ...) -{ -va_list ap; -QDict *resp, *ret; - -va_start (ap, command); - resp =qtest_vqmp (who, command, ap); -va_end (ap); - -g_assert (!qdict_haskey (resp,"error" )); -g_assert (qdict_haskey (resp,"return" )); - - ret =qdict_get_qdict (resp,"return" ); -qobject_ref (ret); -qobject_unref (resp); - -return ret; -} -/* * Send QMP command "migrate". * Arguments are built from @fmt... (formatted like
tests/qtest/migration-test.c +15 -14
@@ -2322,32 +2322,33 @@ static void test_multifd_tcp_cancel(void)static void calc_dirty_rate (QTestState *who,uint64_t calc_time) { -qobject_unref (qmp_command (who, -"{ 'execute': 'calc-dirty-rate'," -"'arguments': { " -"'calc-time': %" PRIu64"," -"'mode': 'dirty-ring' }}" , - calc_time)); +qtest_qmp_assert_success (who, +"{ 'execute': 'calc-dirty-rate'," +"'arguments': { " +"'calc-time': %" PRIu64"," +"'mode': 'dirty-ring' }}" , + calc_time); }static QDict *query_dirty_rate (QTestState *who) { -return qmp_command (who,"{ 'execute': 'query-dirty-rate' }" ); +return qtest_qmp_assert_success_ref (who, +"{ 'execute': 'query-dirty-rate' }" ); }static void dirtylimit_set_all (QTestState *who,uint64_t dirtyrate) { -qobject_unref (qmp_command (who, -"{ 'execute': 'set-vcpu-dirty-limit'," -"'arguments': { " -"'dirty-rate': %" PRIu64" } }" , - dirtyrate)); +qtest_qmp_assert_success (who, +"{ 'execute': 'set-vcpu-dirty-limit'," +"'arguments': { " +"'dirty-rate': %" PRIu64" } }" , + dirtyrate); }static void cancel_vcpu_dirty_limit (QTestState *who) { -qobject_unref (qmp_command (who, -"{ 'execute': 'cancel-vcpu-dirty-limit' }" )); +qtest_qmp_assert_success (who, +"{ 'execute': 'cancel-vcpu-dirty-limit' }" ); }static QDict *query_vcpu_dirty_limit (QTestState *who)
Signature · 1 line
2.40.1
[PULL 04/10] tests/qtest: get rid of some 'qtest_qmp' usage in migration test
In reply to Juan QuintelaFrom: Daniel P. Berrangé <[email protected]>
Some of the usage is just a verbose way of re-inventing the qtest_qmp_assert_success(_ref) methods.
Message-Id: <[email protected]>
--- tests/qtest/migration-helpers.c | 8 ++--- tests/qtest/migration-test.c | 52 ++++++++++++--------------------- 2 files changed, 21 insertions(+), 39 deletions(-)
tests/qtest/migration-helpers.c +3 -5
@@ -93,7 +93,7 @@ QDict *wait_command(QTestState *who, const char *command, ...)void migrate_qmp (QTestState *who,const char *uri,const char *fmt, ...) {va_list ap; -QDict *args, *rsp; +QDict *args;va_start (ap, fmt); args =qdict_from_vjsonf_nofail (fmt, ap);
@@ -102,10 +102,8 @@ void migrate_qmp(QTestState *who, const char *uri, const char *fmt, ...)g_assert (!qdict_haskey (args,"uri" ));qdict_put_str (args,"uri" , uri); - rsp =qtest_qmp (who,"{ 'execute': 'migrate', 'arguments': %p}" , args); - -g_assert (qdict_haskey (rsp,"return" )); -qobject_unref (rsp); +qtest_qmp_assert_success (who, +"{ 'execute': 'migrate', 'arguments': %p}" , args); }/*
tests/qtest/migration-test.c +18 -34
76 lines not on this page · raw message
Signature · 1 line
2.40.1
[PULL 05/10] tests/qtest: switch to using event callbacks for STOP event
In reply to Juan QuintelaFrom: Daniel P. Berrangé <[email protected]>
Change the migration test to use the new qtest event callback to watch for the stop event. This ensures that we only watch for the STOP event on the source QEMU. The previous code would set the single 'got_stop' flag when either source or dest QEMU got the STOP event.
Message-Id: <[email protected]>
--- tests/qtest/migration-helpers.h | 3 ++- tests/qtest/migration-helpers.c | 19 +++++++++---------- tests/qtest/migration-test.c | 4 ++++ 3 files changed, 15 insertions(+), 11 deletions(-)
tests/qtest/migration-helpers.h +2 -1
@@ -15,7 +15,8 @@#include "libqtest.h" -extern bool got_stop; +bool migrate_watch_for_stop (QTestState *who,const char *name, +QDict *event,void *opaque);#ifndef _WIN32G_GNUC_PRINTF (3 ,4 )
tests/qtest/migration-helpers.c +9 -10
@@ -23,15 +23,17 @@*/ #define MIGRATION_STATUS_WAIT_TIMEOUT 120 -bool got_stop; - -static void check_stop_event (QTestState *who) +bool migrate_watch_for_stop (QTestState *who,const char *name, +QDict *event,void *opaque) { -QDict *event =qtest_qmp_event_ref (who,"STOP" ); -if (event) { - got_stop = true; -qobject_unref (event); +bool *seen = opaque; + +if (g_str_equal (name,"STOP" )) { + *seen = true; +return true; } + +return false; }#ifndef _WIN32
@@ -48,7 +50,6 @@ QDict *wait_command_fd(QTestState *who, int fd, const char *command, ...)va_end (ap); resp =qtest_qmp_receive (who); -check_stop_event (who);g_assert (!qdict_haskey (resp,"error" ));g_assert (qdict_haskey (resp,"return" ));
@@ -73,8 +74,6 @@ QDict *wait_command(QTestState *who, const char *command, ...) resp =qtest_vqmp (who, command, ap);va_end (ap); -check_stop_event (who); -g_assert (!qdict_haskey (resp,"error" ));g_assert (qdict_haskey (resp,"return" ));
tests/qtest/migration-test.c +4 -0
@@ -43,6 +43,7 @@unsigned start_address;unsigned end_address;static bool uffd_feature_thread_id; +static bool got_stop;/* * Dirtylimit stop working if dirty page rate error
@@ -703,6 +704,9 @@ static int test_migrate_start(QTestState **from, QTestState **to, ignore_stderr);if (!args->only_target) { *from =qtest_init (cmd_source); +qtest_qmp_set_event_callback (*from, + migrate_watch_for_stop, + &got_stop); } cmd_target = g_strdup_printf("-accel kvm%s -accel tcg%s%s "
Signature · 1 line
2.40.1
[PULL 01/10] tests/qtest: add various qtest_qmp_assert_success() variants
In reply to Juan QuintelaFrom: Daniel P. Berrangé <[email protected]>
Add several counterparts of qtest_qmp_assert_success() that can
* Use va_list instead of ...
* Accept a list of FDs to send
* Return the response data
Message-Id: <[email protected]>
--- tests/qtest/libqtest.h | 115 +++++++++++++++++++++++++++++++++++++++++ tests/qtest/libqtest.c | 103 ++++++++++++++++++++++++++++++++---- 2 files changed, 208 insertions(+), 10 deletions(-)
tests/qtest/libqtest.h +115 -0
@@ -693,6 +693,86 @@ void qtest_add_abrt_handler(GHookFunc fn, const void *data);*/ void qtest_remove_abrt_handler (void *data); +/** +* qtest_vqmp_assert_success_ref: +* @qts: QTestState instance to operate on +* @fmt: QMP message to send to qemu, formatted like +* qobject_from_jsonf_nofail(). See parse_interpolation() for what's +* supported after '%'. +* @args: variable arguments for @fmt +* +* Sends a QMP message to QEMU, asserts that a 'return' key is present in +* the response, and returns the response. +*/ +QDict *qtest_vqmp_assert_success_ref (QTestState *qts, +const char *fmt,va_list args) +G_GNUC_PRINTF (2 ,0 ); + +/** +* qtest_vqmp_assert_success: +* @qts: QTestState instance to operate on +* @fmt: QMP message to send to qemu, formatted like +* qobject_from_jsonf_nofail(). See parse_interpolation() for what's +* supported after '%'. +* @args: variable arguments for @fmt +* +* Sends a QMP message to QEMU and asserts that a 'return' key is present in +* the response. +*/ +void qtest_vqmp_assert_success(QTestState *qts, + const char *fmt, va_list args) + G_GNUC_PRINTF(2, 0); + +#ifndef _WIN32 +/** +* qtest_vqmp_fds_assert_success_ref: +* @qts: QTestState instance to operate on +* @fds: the file descriptors to send +* @nfds: number of @fds to send +* @fmt: QMP message to send to qemu, formatted like +* qobject_from_jsonf_nofail(). See parse_interpolation() for what's +* supported after '%'. +* @args: variable arguments for @fmt +* +* Sends a QMP message with file descriptors to QEMU, +* asserts that a 'return' key is present in the response, +* and returns the response. +*/ +QDict *qtest_vqmp_fds_assert_success_ref (QTestState *qts,int *fds,size_t nfds, +const char *fmt,va_list args) +G_GNUC_PRINTF (4 ,0 ); + +/** +* qtest_vqmp_fds_assert_success: +* @qts: QTestState instance to operate on +* @fds: the file descriptors to send +* @nfds: number of @fds to send +* @fmt: QMP message to send to qemu, formatted like +* qobject_from_jsonf_nofail(). See parse_interpolation() for what's +* supported after '%'. +* @args: variable arguments for @fmt +* +* Sends a QMP message with file descriptors to QEMU and +* asserts that a 'return' key is present in the response. +*/ +void qtest_vqmp_fds_assert_success(QTestState *qts, int *fds, size_t nfds, + const char *fmt, va_list args) + G_GNUC_PRINTF(4, 0); +#endif /* !_WIN32 */ + +/** +* qtest_qmp_assert_success_ref: +* @qts: QTestState instance to operate on +* @fmt: QMP message to send to qemu, formatted like +* qobject_from_jsonf_nofail(). See parse_interpolation() for what's +* supported after '%'. +* +* Sends a QMP message to QEMU, asserts that a 'return' key is present in +* the response, and returns the response. +*/ +QDict *qtest_qmp_assert_success_ref (QTestState *qts,const char *fmt, ...) +G_GNUC_PRINTF (2 ,3 ); +/** * qtest_qmp_assert_success: * @qts: QTestState instance to operate on
@@ -706,6 +786,41 @@ void qtest_remove_abrt_handler(void *data); void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...) G_GNUC_PRINTF(2, 3); +#ifndef _WIN32 +/** +* qtest_qmp_fd_assert_success_ref: +* @qts: QTestState instance to operate on +* @fds: the file descriptors to send +* @nfds: number of @fds to send +* @fmt: QMP message to send to qemu, formatted like +* qobject_from_jsonf_nofail(). See parse_interpolation() for what's +* supported after '%'. +* +* Sends a QMP message with file descriptors to QEMU, +* asserts that a 'return' key is present in the response, +* and returns the response. +*/ +QDict *qtest_qmp_fds_assert_success_ref (QTestState *qts,int *fds,size_t nfds, +const char *fmt, ...) +G_GNUC_PRINTF (4 ,5 ); + +/** +* qtest_qmp_fd_assert_success: +* @qts: QTestState instance to operate on +* @fds: the file descriptors to send +* @nfds: number of @fds to send +* @fmt: QMP message to send to qemu, formatted like +* qobject_from_jsonf_nofail(). See parse_interpolation() for what's +* supported after '%'. +* +* Sends a QMP message with file descriptors to QEMU and +* asserts that a 'return' key is present in the response. +*/ +void qtest_qmp_fds_assert_success(QTestState *qts, int *fds, size_t nfds, + const char *fmt, ...) + G_GNUC_PRINTF(4, 5); +#endif /* !_WIN32 */ +/** * qtest_cb_for_every_machine: * @cb: Pointer to the callback function
tests/qtest/libqtest.c +93 -10
117 lines not on this page · raw message
Signature · 1 line
2.40.1
Richard Henderson
AppliedQuoted 12 lines · Juan Quintela
The following changes since commit
a86d7b9ec0adb2f1efce8ab30d9ed2b72db0236e:Merge tag 'migration-20230601-pull-request' of https://gitlab.com/juan.quintela/qemu into staging (2023-06-01 20:59:28 -0700)are available in the Git repository at:
https://gitlab.com/juan.quintela/qemu.git tags/migration-20230602-pull-requestfor you to fetch changes up to
b861383c2690501ff2687f9ef9268b128b0fb3b3:qtest/migration: Document live=true cases (2023-06-02 11:46:20 +0200)
Quoted 8 lines
----------------------------------------------------------------
Migration Pull request (20230602 vintage)This PULL request get:
- All migration-test patches except last one (daniel)
- Documentation about live test cases (peter)Please apply.
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/8.1 as appropriate.
r~