migration queue
[Qemu-devel] [PULL 01/10] migration/xen: Check return value of qemu_fclose
In reply to Dr. David Alan Gilbert (git)From: Ross Lagerwall <[email protected]>
QEMUFile uses buffered IO so when writing small amounts (such as the Xen device state file), the actual write call and any errors that may occur only happen as part of qemu_fclose(). Therefore, report IO errors when saving the device state under Xen by checking the return value of qemu_fclose().
Message-Id: <[email protected]>
--- migration/savevm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
migration/savevm.c +1 -2
@@ -2284,8 +2284,7 @@ void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live, f =qemu_fopen_channel_output (QIO_CHANNEL (ioc));object_unref (OBJECT (ioc)); ret =qemu_save_device_state (f); -qemu_fclose (f); -if (ret <0 ) { +if (ret <0 ||qemu_fclose (f) <0 ) {error_setg (errp,QERR_IO_ERROR ); }else {/* libxl calls the QMP command "stop" before calling
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 04/10] migration: Fix early failure cleanup
In reply to Dr. David Alan Gilbert (git)From: "Dr. David Alan Gilbert" <[email protected]>
Avoid crash in cleanup after a very early migration failure (possibly due to my 688a3dcba980bf01344a 'Route errors down ...')
Message-Id: <[email protected]>
--- migration/ram.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
migration/ram.c +7 -5
@@ -1602,11 +1602,13 @@ static void xbzrle_load_cleanup(void)static void ram_state_cleanup (RAMState **rsp) { -migration_page_queue_free (*rsp); -qemu_mutex_destroy (&(*rsp)->bitmap_mutex); -qemu_mutex_destroy (&(*rsp)->src_page_req_mutex); -g_free (*rsp); - *rsp =NULL ; +if (*rsp) { +migration_page_queue_free (*rsp); +qemu_mutex_destroy (&(*rsp)->bitmap_mutex); +qemu_mutex_destroy (&(*rsp)->src_page_req_mutex); +g_free (*rsp); + *rsp =NULL ; + } }static void xbzrle_cleanup (void )
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 05/10] tests/migration: Add test for migration to bad destination
In reply to Dr. David Alan Gilbert (git)From: "Dr. David Alan Gilbert" <[email protected]>
Check the source survives.
Message-Id: <[email protected]>
--- tests/migration-test.c | 65 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 15 deletions(-)
tests/migration-test.c +50 -15
@@ -434,28 +434,31 @@ static void test_migrate_start(QTestState **from, QTestState **to,g_free (cmd_dst); } -static void test_migrate_end (QTestState *from,QTestState *to) +static void test_migrate_end (QTestState *from,QTestState *to,bool test_dest) {unsigned char dest_byte_a, dest_byte_b, dest_byte_c, dest_byte_d;qtest_quit (from); -qtest_memread (to, start_address, &dest_byte_a,1 ); +if (test_dest) { +qtest_memread (to, start_address, &dest_byte_a,1 ); -/* Destination still running, wait for a byte to change */ -do { -qtest_memread (to, start_address, &dest_byte_b,1 ); -usleep (1000 *10 ); - }while (dest_byte_a == dest_byte_b); +/* Destination still running, wait for a byte to change */ +do { +qtest_memread (to, start_address, &dest_byte_b,1 ); +usleep (1000 *10 ); + }while (dest_byte_a == dest_byte_b); + +qtest_qmp_discard_response (to,"{ 'execute' : 'stop'}" ); -qtest_qmp_discard_response (to,"{ 'execute' : 'stop'}" ); -/* With it stopped, check nothing changes */ -qtest_memread (to, start_address, &dest_byte_c,1 ); -usleep (1000 *200 ); -qtest_memread (to, start_address, &dest_byte_d,1 ); - g_assert_cmpint(dest_byte_c, ==, dest_byte_d); +/* With it stopped, check nothing changes */ +qtest_memread (to, start_address, &dest_byte_c,1 ); +usleep (1000 *200 ); +qtest_memread (to, start_address, &dest_byte_d,1 ); + g_assert_cmpint(dest_byte_c, ==, dest_byte_d); -check_guests_ram (to); +check_guests_ram (to); + }qtest_quit (to);
@@ -547,7 +550,38 @@ static void test_migrate(void)g_free (uri); -test_migrate_end (from, to); +test_migrate_end (from, to, true); +} + +static void test_baddest (void ) +{ +QTestState *from, *to; +QDict *rsp, *rsp_return; +const char *status; +bool failed; + +test_migrate_start (&from, &to,"tcp:0:0" ); +migrate (from,"tcp:0:0" ); +do { + rsp =wait_command (from,"{ 'execute': 'query-migrate' }" ); + rsp_return =qdict_get_qdict (rsp,"return" ); + + status =qdict_get_str (rsp_return,"status" ); + +g_assert (!strcmp (status,"setup" ) || !(strcmp (status,"failed" ))); + failed = !strcmp (status,"failed" ); +QDECREF (rsp); + }while (!failed); + +/* Is the machine currently running? */ + rsp =wait_command (from,"{ 'execute': 'query-status' }" ); +g_assert (qdict_haskey (rsp,"return" )); + rsp_return =qdict_get_qdict (rsp,"return" ); +g_assert (qdict_haskey (rsp_return,"running" )); +g_assert (qdict_get_bool (rsp_return,"running" )); +QDECREF (rsp); + +test_migrate_end (from, to, false); }int main (int argc,char **argv)
@@ -571,6 +605,7 @@ int main(int argc, char **argv)qtest_add_func ("/migration/postcopy/unix" , test_migrate);qtest_add_func ("/migration/deprecated" , test_deprecated); +qtest_add_func ("/migration/bad_dest" , test_baddest); ret =g_test_run ();
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 02/10] migration: improve documentation of postcopy-ram
In reply to Dr. David Alan Gilbert (git)From: Greg Kurz <[email protected]>
This capability must have the same value on both source and destination, otherwise migration fails (commit 875fcd013ab6 "migration: incoming postcopy advise sanity checks").
Let's write it down in various places where postcopy-ram is documented.
Message-Id: <[email protected]>
--- docs/devel/migration.rst | 4 ++-- hmp-commands.hx | 3 ++- qapi/migration.json | 10 ++++++---- 3 files changed, 10 insertions(+), 7 deletions(-)
docs/devel/migration.rst +2 -2
@@ -387,8 +387,8 @@ doesn't finish in a given time the switch is made to postcopy. Enabling postcopy ----------------- -To enable postcopy, issue this command on the monitor prior to the -start of migration: +To enable postcopy, issue this command on the monitor (both source and +destination) prior to the start of migration: ``migrate_set_capability postcopy-ram on``
hmp-commands.hx +2 -1
@@ -1041,7 +1041,8 @@ ETEXI .params = "", .help = "Followup to a migration command to switch the migration" " to postcopy mode. The postcopy-ram capability must " - "be set before the original migration command.", + "be set on both source and destination before the " + "original migration command .", .cmd = hmp_migrate_start_postcopy, },
qapi/migration.json +6 -4
@@ -327,8 +327,10 @@ # to speed up convergence of RAM migration. (since 1.6) # # @postcopy-ram: Start executing on the migration target before all of RAM has -# been migrated, pulling the remaining pages along as needed. NOTE: If -# the migration fails during postcopy the VM will fail. (since 2.6) +# been migrated, pulling the remaining pages along as needed. The +# capacity must have the same setting on both source and target +# or migration will not even start. NOTE: If the migration fails during +# postcopy the VM will fail. (since 2.6) # # @x-colo: If enabled, migration will never end, and the state of the VM on the # primary side will be migrated continuously to the VM on secondary
@@ -742,8 +744,8 @@ # @migrate-start-postcopy: # # Followup to a migration command to switch the migration to postcopy mode. -# The postcopy-ram capability must be set before the original migration -# command. +# The postcopy-ram capability must be set on both source and destination +# before the original migration command. # # Since: 2.5 #
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 07/10] migration: reuse mis->userfault_quit_fd
In reply to Dr. David Alan Gilbert (git)From: Peter Xu <[email protected]>
It was only used for quitting the page fault thread before. Let it be something more useful - now we can use it to notify a "wake" for the page fault thread (for any reason), and it only means "quit" if the fault_thread_quit is set.
Since we changed what it does, renaming it to userfault_event_fd.
Message-Id: <[email protected]>
--- migration/migration.h | 6 ++++-- migration/postcopy-ram.c | 29 ++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 11 deletions(-)
migration/migration.h +4 -2
@@ -35,6 +35,8 @@ struct MigrationIncomingState {bool have_fault_thread;QemuThread fault_thread;QemuSemaphore fault_thread_sem; +/* Set this when we want the fault thread to quit */ +bool fault_thread_quit;bool have_listen_thread;QemuThread listen_thread;
@@ -42,8 +44,8 @@ struct MigrationIncomingState {/* For the kernel to send us notifications */ int userfault_fd; -/* To tell the fault_thread to quit */ -int userfault_quit_fd; +/* To notify the fault_thread to wake, e.g., when need to quit */ +int userfault_event_fd;QEMUFile *to_src_file;QemuMutex rp_mutex;/* We send replies from multiple threads */ void *postcopy_tmp_page;
migration/postcopy-ram.c +20 -9
@@ -387,17 +387,18 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)* currently be at 0, we're going to increment it to 1 */ tmp64 =1 ; -if (write (mis->userfault_quit_fd, &tmp64,8 ) ==8 ) { +atomic_set (&mis->fault_thread_quit,1 ); +if (write (mis->userfault_event_fd, &tmp64,8 ) ==8 ) {trace_postcopy_ram_incoming_cleanup_join ();qemu_thread_join (&mis->fault_thread); }else {/* Not much we can do here, but may as well report it */ -error_report ("%s: incrementing userfault_quit_fd: %s" , __func__, +error_report ("%s: incrementing userfault_event_fd: %s" , __func__,strerror (errno)); }trace_postcopy_ram_incoming_cleanup_closeuf ();close (mis->userfault_fd); -close (mis->userfault_quit_fd); +close (mis->userfault_event_fd); mis->have_fault_thread = false; }
@@ -520,7 +521,7 @@ static void *postcopy_ram_fault_thread(void *opaque) pfd[0 ].fd = mis->userfault_fd; pfd[0 ].events =POLLIN ; pfd[0 ].revents =0 ; - pfd[1 ].fd = mis->userfault_quit_fd; + pfd[1 ].fd = mis->userfault_event_fd; pfd[1 ].events =POLLIN ;/* Waiting for eventfd to go positive */ pfd[1 ].revents =0 ;
@@ -530,8 +531,18 @@ static void *postcopy_ram_fault_thread(void *opaque) }if (pfd[1 ].revents) { -trace_postcopy_ram_fault_thread_quit (); -break ; +uint64_t tmp64 =0 ; + +/* Consume the signal */ +if (read (mis->userfault_event_fd, &tmp64,8 ) !=8 ) { +/* Nothing obviously nicer than posting this error. */ +error_report ("%s: read() failed" , __func__); + } + +if (atomic_read (&mis->fault_thread_quit)) { +trace_postcopy_ram_fault_thread_quit (); +break ; + } } ret =read (mis->userfault_fd, &msg,sizeof (msg));
@@ -610,9 +621,9 @@ int postcopy_ram_enable_notify(MigrationIncomingState *mis) }/* Now an eventfd we use to tell the fault-thread to quit */ - mis->userfault_quit_fd =eventfd (0 ,EFD_CLOEXEC ); -if (mis->userfault_quit_fd ==-1 ) { -error_report ("%s: Opening userfault_quit_fd: %s" , __func__, + mis->userfault_event_fd =eventfd (0 ,EFD_CLOEXEC ); +if (mis->userfault_event_fd ==-1 ) { +error_report ("%s: Opening userfault_event_fd: %s" , __func__,strerror (errno));close (mis->userfault_fd);return -1 ;
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 06/10] migration: better error handling with QEMUFile
In reply to Dr. David Alan Gilbert (git)From: Peter Xu <[email protected]>
If the postcopy down due to some reason, we can always see this on dst:
qemu-system-x86_64: RP: Received invalid message 0x0000 length 0x0000
However in most cases that's not the real issue. The problem is that qemu_get_be16() has no way to show whether the returned data is valid or not, and we are _always_ assuming it is valid. That's possibly not wise.
The best approach to solve this would be: refactoring QEMUFile interface to allow the APIs to return error if there is. However it needs quite a bit of work and testing. For now, let's explicitly check the validity first before using the data in all places for qemu_get_*().
This patch tries to fix most of the cases I can see. Only if we are with this, can we make sure we are processing the valid data, and also can we make sure we can capture the channel down events correctly.
Message-Id: <[email protected]>
--- migration/migration.c | 5 +++++ migration/ram.c | 21 +++++++++++++++++---- migration/savevm.c | 40 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 60 insertions(+), 6 deletions(-)
migration/migration.c +5 -0
@@ -1709,6 +1709,11 @@ static void *source_return_path_thread(void *opaque) header_type =qemu_get_be16 (rp); header_len =qemu_get_be16 (rp); +if (qemu_file_get_error (rp)) { +mark_source_rp_bad (ms); + goto out; + } +if (header_type >=MIG_RP_MSG_MAX || header_type ==MIG_RP_MSG_INVALID ) { error_report("RP: Received invalid message 0x%04x length 0x%04x",
migration/ram.c +17 -4
@@ -2700,6 +2700,16 @@ static int ram_load_postcopy(QEMUFile *f)uint8_t ch; addr =qemu_get_be64 (f); + +/* +* If qemu file error, we should stop here, and then "addr" +* may be invalid +*/ + ret =qemu_file_get_error (f); +if (ret) { +break ; + } + flags = addr & ~TARGET_PAGE_MASK ; addr &=TARGET_PAGE_MASK ;
@@ -2780,9 +2790,15 @@ static int ram_load_postcopy(QEMUFile *f)error_report ("Unknown combination of migration flags: %#x" " (postcopy mode)" , flags); ret = -EINVAL ; +break ; + } + +/* Detect for any possible file errors */ +if (!ret &&qemu_file_get_error (f)) { + ret =qemu_file_get_error (f); } -if (place_needed) { +if (!ret && place_needed) {/* This gets called at the last target page in the host page */ void *place_dest = host +TARGET_PAGE_SIZE - block->page_size;
@@ -2794,9 +2810,6 @@ static int ram_load_postcopy(QEMUFile *f) place_source, block); } } -if (!ret) { - ret =qemu_file_get_error (f); - } }return ret;
migration/savevm.c +38 -2
@@ -1781,6 +1781,11 @@ static int loadvm_process_command(QEMUFile *f) cmd =qemu_get_be16 (f); len =qemu_get_be16 (f); +/* Check validity before continue processing of cmds */ +if (qemu_file_get_error (f)) { +return qemu_file_get_error (f); + } +trace_loadvm_process_command (cmd, len);if (cmd >=MIG_CMD_MAX || cmd ==MIG_CMD_INVALID ) {error_report ("MIG_CMD 0x%x unknown (len 0x%x)" , cmd, len);
@@ -1846,6 +1851,7 @@ static int loadvm_process_command(QEMUFile *f)*/ static bool check_section_footer (QEMUFile *f,SaveStateEntry *se) { +int ret;uint8_t read_mark;uint32_t read_section_id;
@@ -1856,6 +1862,13 @@ static bool check_section_footer(QEMUFile *f, SaveStateEntry *se) read_mark =qemu_get_byte (f); + ret =qemu_file_get_error (f); +if (ret) { +error_report ("%s: Read section footer failed: %d" , + __func__, ret); +return false; + } +if (read_mark !=QEMU_VM_SECTION_FOOTER ) {error_report ("Missing section footer for %s" , se->idstr);return false;
@@ -1891,6 +1904,13 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis) instance_id =qemu_get_be32 (f); version_id =qemu_get_be32 (f); + ret =qemu_file_get_error (f); +if (ret) { +error_report ("%s: Failed to read instance/version ID: %d" , + __func__, ret); +return ret; + } +trace_qemu_loadvm_state_section_startfull (section_id, idstr, instance_id, version_id);/* Find savevm section */
@@ -1938,6 +1958,13 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis) section_id =qemu_get_be32 (f); + ret =qemu_file_get_error (f); +if (ret) { +error_report ("%s: Failed to read section ID: %d" , + __func__, ret); +return ret; + } +trace_qemu_loadvm_state_section_partend (section_id); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {if (se->load_section_id == section_id) {
@@ -2005,8 +2032,14 @@ static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis)uint8_t section_type;int ret =0 ; -while ((section_type =qemu_get_byte (f)) !=QEMU_VM_EOF ) { - ret =0 ; +while (true) { + section_type =qemu_get_byte (f); + +if (qemu_file_get_error (f)) { + ret =qemu_file_get_error (f); +break ; + } +trace_qemu_loadvm_state_section (section_type);switch (section_type) {case QEMU_VM_SECTION_START :
@@ -2030,6 +2063,9 @@ static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis) goto out; }break ; +case QEMU_VM_EOF : +/* This is the end of migration */ + goto out;default :error_report ("Unknown savevm section type %d" , section_type); ret = -EINVAL ;
Signature · 1 line
2.14.3
From: "Dr. David Alan Gilbert" <[email protected]>
The following changes since commit bec9c64ef7be8063f1192608b83877bc5c9ea217:
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2018-02-13 18:24:08 +0000)
are available in the Git repository at:
git://github.com/dagrh/qemu.git tags/pull-migration-20180214a
for you to fetch changes up to 3e0c8050ebba3f55dc2d92b3790a3cfb80786d07:
migration: pass MigrationState to migrate_init() (2018-02-14 10:37:09 +0000)
----------------------------------------------------------------
Migration pull 20180214
Note that the 'Add test for migration to bad destination' displays a 'Connection refused' during running, but still gives the correct exit code and OK (It's checking that the source doesn't fail when it can't connect, so that's the right error).
If it's particularly disliked that patch can be skipped individually.
----------------------------------------------------------------
Dr. David Alan Gilbert (3):
tests/migration: Add source to PC boot block
migration: Fix early failure cleanup tests/migration: Add test for migration to bad destination
Greg Kurz (1):
migration: improve documentation of postcopy-ram
Peter Xu (5):
migration: better error handling with QEMUFile
migration: reuse mis->userfault_quit_fd
migration: provide postcopy_fault_thread_notify()
migration: allow send_rq to fail
migration: pass MigrationState to migrate_init()
Ross Lagerwall (1):
migration/xen: Check return value of qemu_fclose
docs/devel/migration.rst | 4 +- hmp-commands.hx | 3 +- migration/migration.c | 47 +++++++++---- migration/migration.h | 10 +-- migration/postcopy-ram.c | 60 ++++++++++------ migration/postcopy-ram.h | 2 + migration/ram.c | 33 ++++++--- migration/savevm.c | 48 +++++++++++-- qapi/migration.json | 10 +-- tests/migration-test.c | 117 ++++++++++++++----------------- tests/migration/rebuild-x86-bootblock.sh | 33 +++++++++ tests/migration/x86-a-b-bootblock.h | 51 ++++++++++++++ tests/migration/x86-a-b-bootblock.s | 92 ++++++++++++++++++++++++ 13 files changed, 388 insertions(+), 122 deletions(-) create mode 100755 tests/migration/rebuild-x86-bootblock.sh create mode 100644 tests/migration/x86-a-b-bootblock.h create mode 100644 tests/migration/x86-a-b-bootblock.s
[Qemu-devel] [PULL 03/10] tests/migration: Add source to PC boot block
From: "Dr. David Alan Gilbert" <[email protected]>
The boot block used in the migration test is currently only shipped as a hex (with the source in the git commit message of ea0c6d62), change this to actually include the source.
A script is added to rebuild the header but the expectation is that the generated hex is shipped as well as the .s, so that there's no requirement to have just the right assembler etc.
Message-Id: <[email protected]>
Removed blank line at end of script
--- tests/migration-test.c | 52 ++---------------- tests/migration/rebuild-x86-bootblock.sh | 33 ++++++++++++ tests/migration/x86-a-b-bootblock.h | 51 ++++++++++++++++++ tests/migration/x86-a-b-bootblock.s | 92 ++++++++++++++++++++++++++++++++ 4 files changed, 180 insertions(+), 48 deletions(-) create mode 100755 tests/migration/rebuild-x86-bootblock.sh create mode 100644 tests/migration/x86-a-b-bootblock.h create mode 100644 tests/migration/x86-a-b-bootblock.s
tests/migration-test.c +4 -48
@@ -1,7 +1,7 @@/* * QTest testcase for migration * -* Copyright (c) 2016 Red Hat, Inc. and/or its affiliates +* Copyright (c) 2016-2018 Red Hat, Inc. and/or its affiliates * based on the vhost-user-test.c that is: * Copyright (c) 2014 Virtual Open Systems Sarl. *
@@ -78,59 +78,15 @@ static bool ufd_version_check(void)static const char *tmpfs;/* A simple PC boot sector that modifies memory (1-100MB) quickly -* outputing a 'B' every so often if it's still running. +* outputting a 'B' every so often if it's still running. */ -unsigned char bootsect[] = { -0xfa ,0x0f ,0x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ration/x86-a-b-bootblock.h" static void init_bootfile_x86 (const char *bootpath) {FILE *bootfile =fopen (bootpath,"wb" ); - g_assert_cmpint(fwrite(bootsect, 512, 1, bootfile), ==, 1); + g_assert_cmpint(fwrite(x86_bootsect, 512, 1, bootfile), ==, 1);fclose (bootfile); }
tests/migration/rebuild-x86-bootblock.sh new file +33 -0
@@ -0,0 +1,33 @@ +#!/bin/sh +# Copyright (c) 2016-2018 Red Hat, Inc. and/or its affiliates +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. +# +# Author: [email protected] + +ASMFILE=$PWD/tests/migration/x86-a-b-bootblock.s +HEADER=$PWD/tests/migration/x86-a-b-bootblock.h + +if [ ! -e "$ASMFILE" ] +then + echo "Couldn't find $ASMFILE" >&2 + exit 1 +fi + +ASM_WORK_DIR=$(mktemp -d --tmpdir X86BB.XXXXXX) +cd "$ASM_WORK_DIR" && +as --32 -march=i486 "$ASMFILE" -o x86.o && +objcopy -O binary x86.o x86.boot && +dd if=x86.boot of=x86.bootsect bs=256 count=2 skip=124 && +xxd -i x86.bootsect | +sed -e 's/.*int.*//' > x86.hex && +cat - x86.hex <<HERE > "$HEADER" +/* This file is automatically generated from + * tests/migration/x86-a-b-bootblock.s, edit that and then run + * tests/migration/rebuild-x86-bootblock.sh to update, + * and then remember to send both in your patch submission. + */ +HERE + +rm x86.hex x86.bootsect x86.boot x86.o +cd .. && rmdir "$ASM_WORK_DIR"
tests/migration/x86-a-b-bootblock.h new file +51 -0
51 lines not on this page · raw message
tests/migration/x86-a-b-bootblock.s new file +92 -0
92 lines not on this page · raw message
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 09/10] migration: allow send_rq to fail
In reply to Dr. David Alan Gilbert (git)From: Peter Xu <[email protected]>
We will not allow failures to happen when sending data from destination to source via the return path. However it is possible that there can be errors along the way. This patch allows the migrate_send_rp_message() to return error when it happens, and further extended it to migrate_send_rp_req_pages().
Message-Id: <[email protected]>
--- migration/migration.c | 35 ++++++++++++++++++++++++++++------- migration/migration.h | 2 +- 2 files changed, 29 insertions(+), 8 deletions(-)
migration/migration.c +28 -7
@@ -205,17 +205,35 @@ static void deferred_incoming_migration(Error **errp)* Send a message on the return channel back to the source * of the migration. */ -static void migrate_send_rp_message (MigrationIncomingState *mis, -enum mig_rp_message_type message_type, -uint16_t len,void *data) +static int migrate_send_rp_message (MigrationIncomingState *mis, +enum mig_rp_message_type message_type, +uint16_t len,void *data) { +int ret =0 ; +trace_migrate_send_rp_message ((int )message_type, len);qemu_mutex_lock (&mis->rp_mutex); + +/* +* It's possible that the file handle got lost due to network +* failures. +*/ +if (!mis->to_src_file) { + ret = -EIO ; + goto error; + } +qemu_put_be16 (mis->to_src_file, (unsigned int )message_type);qemu_put_be16 (mis->to_src_file, len);qemu_put_buffer (mis->to_src_file, data, len);qemu_fflush (mis->to_src_file); + +/* It's possible that qemu file got error during sending */ + ret =qemu_file_get_error (mis->to_src_file); + +error:qemu_mutex_unlock (&mis->rp_mutex); +return ret; }/* Request a range of pages from the source VM at the given
@@ -225,11 +243,12 @@ static void migrate_send_rp_message(MigrationIncomingState *mis,* Start: Address offset within the RB * Len: Length in bytes required - must be a multiple of pagesize */ -void migrate_send_rp_req_pages (MigrationIncomingState *mis,const char *rbname, -ram_addr_t start,size_t len) +int migrate_send_rp_req_pages (MigrationIncomingState *mis,const char *rbname, +ram_addr_t start,size_t len) {uint8_t bufc[12 +1 +255 ];/* start (8), len (4), rbname up to 256 */ size_t msglen =12 ;/* start + len */ +enum mig_rp_message_type msg_type; *(uint64_t *)bufc =cpu_to_be64 ((uint64_t )start); *(uint32_t *)(bufc +8 ) =cpu_to_be32 ((uint32_t )len);
@@ -241,10 +260,12 @@ void migrate_send_rp_req_pages(MigrationIncomingState *mis, const char *rbname, bufc[msglen++] = rbname_len;memcpy (bufc + msglen, rbname, rbname_len); msglen += rbname_len; -migrate_send_rp_message (mis,MIG_RP_MSG_REQ_PAGES_ID , msglen, bufc); + msg_type =MIG_RP_MSG_REQ_PAGES_ID ; }else { -migrate_send_rp_message (mis,MIG_RP_MSG_REQ_PAGES , msglen, bufc); + msg_type =MIG_RP_MSG_REQ_PAGES ; } + +return migrate_send_rp_message (mis, msg_type, msglen, bufc); }void qemu_start_incoming_migration (const char *uri,Error **errp)
migration/migration.h +1 -1
@@ -230,7 +230,7 @@ void migrate_send_rp_shut(MigrationIncomingState *mis, uint32_t value);void migrate_send_rp_pong (MigrationIncomingState *mis,uint32_t value); -void migrate_send_rp_req_pages (MigrationIncomingState *mis,const char * rbname, +int migrate_send_rp_req_pages (MigrationIncomingState *mis,const char * rbname,ram_addr_t start,size_t len);#endif
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 10/10] migration: pass MigrationState to migrate_init()
In reply to Dr. David Alan Gilbert (git)From: Peter Xu <[email protected]>
Let the callers take the object, then pass it to migrate_init().
Message-Id: <[email protected]>
--- migration/migration.c | 7 ++----- migration/migration.h | 2 +- migration/savevm.c | 5 ++++- 3 files changed, 7 insertions(+), 7 deletions(-)
migration/migration.c +2 -5
@@ -1258,10 +1258,8 @@ bool migration_is_idle(void)return false; } -MigrationState *migrate_init (void ) +void migrate_init (MigrationState *s) { -MigrationState *s =migrate_get_current (); -/* * Reinitialise all migration state, except * parameters/capabilities that the user set, and
@@ -1291,7 +1289,6 @@ MigrationState *migrate_init(void) s->vm_was_running = false; s->iteration_initial_bytes =0 ; s->threshold_size =0 ; -return s; }static GSList *migration_blockers;
@@ -1399,7 +1396,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,migrate_set_block_incremental (s, true); } - s =migrate_init (); +migrate_init (s);if (strstart (uri,"tcp:" , &p)) {tcp_start_outgoing_migration (s, p, &local_err);
migration/migration.h +1 -1
@@ -193,7 +193,7 @@ void migrate_fd_error(MigrationState *s, const Error *error);void migrate_fd_connect (MigrationState *s,Error *error_in); -MigrationState *migrate_init (void ); +void migrate_init (MigrationState *s);bool migration_is_blocked (Error **errp);/* True if outgoing migration has entered postcopy phase */ bool migration_in_postcopy (void );
migration/savevm.c +4 -1
@@ -1257,8 +1257,11 @@ void qemu_savevm_state_cleanup(void)static int qemu_savevm_state (QEMUFile *f,Error **errp) {int ret; -MigrationState *ms =migrate_init (); +MigrationState *ms =migrate_get_current ();MigrationStatus status; + +migrate_init (ms); + ms->to_dst_file = f;if (migration_is_blocked (errp)) {
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 08/10] migration: provide postcopy_fault_thread_notify()
In reply to Dr. David Alan Gilbert (git)From: Peter Xu <[email protected]>
A general helper to notify the fault thread.
Message-Id: <[email protected]>
--- migration/postcopy-ram.c | 35 ++++++++++++++++++++--------------- migration/postcopy-ram.h | 2 ++ 2 files changed, 22 insertions(+), 15 deletions(-)
migration/postcopy-ram.c +20 -15
@@ -377,25 +377,15 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)trace_postcopy_ram_incoming_cleanup_entry ();if (mis->have_fault_thread) { -uint64_t tmp64; -if (qemu_ram_foreach_block (cleanup_range, mis)) {return -1 ; } -/* -* Tell the fault_thread to exit, it's an eventfd that should -* currently be at 0, we're going to increment it to 1 -*/ - tmp64 =1 ; +/* Let the fault thread quit */ atomic_set (&mis->fault_thread_quit,1 ); -if (write (mis->userfault_event_fd, &tmp64,8 ) ==8 ) { -trace_postcopy_ram_incoming_cleanup_join (); -qemu_thread_join (&mis->fault_thread); - }else { -/* Not much we can do here, but may as well report it */ -error_report ("%s: incrementing userfault_event_fd: %s" , __func__, -strerror (errno)); - } +postcopy_fault_thread_notify (mis); +trace_postcopy_ram_incoming_cleanup_join (); +qemu_thread_join (&mis->fault_thread); +trace_postcopy_ram_incoming_cleanup_closeuf ();close (mis->userfault_fd);close (mis->userfault_event_fd);
@@ -824,6 +814,21 @@ void *postcopy_get_tmp_page(MigrationIncomingState *mis)/* ------------------------------------------------------------------------- */ +void postcopy_fault_thread_notify (MigrationIncomingState *mis) +{ +uint64_t tmp64 =1 ; + +/* +* Wakeup the fault_thread. It's an eventfd that should currently +* be at 0, we're going to increment it to 1 +*/ +if (write (mis->userfault_event_fd, &tmp64,8 ) !=8 ) { +/* Not much we can do here, but may as well report it */ +error_report ("%s: incrementing failed: %s" , __func__, +strerror (errno)); + } +} +/** * postcopy_discard_send_init: Called at the start of each RAMBlock before * asking to discard individual ranges.
migration/postcopy-ram.h +2 -0
@@ -114,4 +114,6 @@ PostcopyState postcopy_state_get(void);/* Set the state and return the old state */ PostcopyState postcopy_state_set (PostcopyState new_state); +void postcopy_fault_thread_notify (MigrationIncomingState *mis); +#endif
Signature · 1 line
2.14.3
Quoted 17 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
The following changes since commit
bec9c64ef7be8063f1192608b83877bc5c9ea217:Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2018-02-13 18:24:08 +0000)
are available in the Git repository at:
git://github.com/dagrh/qemu.gittags/pull-migration-20180214afor you to fetch changes up to
3e0c8050ebba3f55dc2d92b3790a3cfb80786d07:migration: pass MigrationState to
migrate_init()(2018-02-14 10:37:09 +0000)----------------------------------------------------------------
Migration pull 20180214
Quoted 7 lines
Note that the 'Add test for migration to bad destination' displays a 'Connection refused' during running, but still gives the correct exit code and OK (It's checking that the source doesn't fail when it can't connect, so that's the right error).
If it's particularly disliked that patch can be skipped individually.----------------------------------------------------------------
Hi. This fails 'make check' on aarch64 host:
QTEST_QEMU_BINARY=hppa-softmmu/qemu-system-hppa QTEST_QEMU_IMG=qemu-img MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM
:-0} % 255 + 1))} gtester -k --verbose -m=quick tests/boot-serial-test tests/qmp-test tests/device-introspect-test test
s/qom-test tests/test-hmp
TEST: tests/boot-serial-test... (pid=2306)
/hppa/boot-serial/hppa: **
ERROR:/home/pm215/qemu/tests/boot-serial-test.c:137:check_guest_output:
assertion failed: (output_ok)
FAIL
GTester: last random seed: R02S43359b02a322915508b897be44a0e9c6 (pid=7220)
FAIL: tests/boot-serial-test
thanks
-- PMM
Quoted 27 lines · * Peter Maydell ([email protected]) wrote:
Quoted 17 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
The following changes since commit
bec9c64ef7be8063f1192608b83877bc5c9ea217:Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2018-02-13 18:24:08 +0000)
are available in the Git repository at:
git://github.com/dagrh/qemu.gittags/pull-migration-20180214afor you to fetch changes up to
3e0c8050ebba3f55dc2d92b3790a3cfb80786d07:migration: pass MigrationState to
migrate_init()(2018-02-14 10:37:09 +0000)----------------------------------------------------------------
Migration pull 20180214Quoted 7 lines
Note that the 'Add test for migration to bad destination' displays a 'Connection refused' during running, but still gives the correct exit code and OK (It's checking that the source doesn't fail when it can't connect, so that's the right error).
If it's particularly disliked that patch can be skipped individually.----------------------------------------------------------------
Quoted 15 lines
Hi. This fails 'make check' on aarch64 host:
QTEST_QEMU_BINARY=hppa-softmmu/qemu-system-hppa QTEST_QEMU_IMG=qemu-img MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM
:-0} % 255 + 1))} gtester -k --verbose -m=quick tests/boot-serial-test tests/qmp-test tests/device-introspect-test test
s/qom-test tests/test-hmp
TEST: tests/boot-serial-test... (pid=2306)
/hppa/boot-serial/hppa: **
ERROR:/home/pm215/qemu/tests/boot-serial-test.c:137:check_guest_output:
assertion failed: (output_ok)
FAIL
GTester: last random seed: R02S43359b02a322915508b897be44a0e9c6 (pid=7220)
FAIL: tests/boot-serial-test
I can't obviously see a reason why it should in any way affect that test; however I'll try and grab an aarch64 box tomorrow.
Dave
Quoted 4 lines
thanks
-- PMM
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 44 lines · Dr. David Alan Gilbert
Quoted 27 lines · * Peter Maydell ([email protected]) wrote:
Quoted 17 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
The following changes since commit
bec9c64ef7be8063f1192608b83877bc5c9ea217:Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2018-02-13 18:24:08 +0000)
are available in the Git repository at:
git://github.com/dagrh/qemu.gittags/pull-migration-20180214afor you to fetch changes up to
3e0c8050ebba3f55dc2d92b3790a3cfb80786d07:migration: pass MigrationState to
migrate_init()(2018-02-14 10:37:09 +0000)----------------------------------------------------------------
Migration pull 20180214Quoted 7 lines
Note that the 'Add test for migration to bad destination' displays a 'Connection refused' during running, but still gives the correct exit code and OK (It's checking that the source doesn't fail when it can't connect, so that's the right error).
If it's particularly disliked that patch can be skipped individually.----------------------------------------------------------------
Quoted 15 lines
Hi. This fails 'make check' on aarch64 host:
QTEST_QEMU_BINARY=hppa-softmmu/qemu-system-hppa QTEST_QEMU_IMG=qemu-img MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM
:-0} % 255 + 1))} gtester -k --verbose -m=quick tests/boot-serial-test tests/qmp-test tests/device-introspect-test test
s/qom-test tests/test-hmp
TEST: tests/boot-serial-test... (pid=2306)
/hppa/boot-serial/hppa: **
ERROR:/home/pm215/qemu/tests/boot-serial-test.c:137:check_guest_output:
assertion failed: (output_ok)
FAIL
GTester: last random seed: R02S43359b02a322915508b897be44a0e9c6 (pid=7220)
FAIL: tests/boot-serial-test
Quoted 2 lines
I can't obviously see a reason why it should in any way affect that test; however I'll try and grab an aarch64 box tomorrow.
For the records: It's a bug in the boot-serial tester. I've just sent a mail with a fix: "tests/boot-serial-test: Fix problem with timeout due to dropped characters".
Thomas
Peter Maydell
AppliedQuoted 17 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
The following changes since commit
bec9c64ef7be8063f1192608b83877bc5c9ea217:Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2018-02-13 18:24:08 +0000)
are available in the Git repository at:
git://github.com/dagrh/qemu.gittags/pull-migration-20180214afor you to fetch changes up to
3e0c8050ebba3f55dc2d92b3790a3cfb80786d07:migration: pass MigrationState to
migrate_init()(2018-02-14 10:37:09 +0000)----------------------------------------------------------------
Migration pull 20180214
Quoted 7 lines
Note that the 'Add test for migration to bad destination' displays a 'Connection refused' during running, but still gives the correct exit code and OK (It's checking that the source doesn't fail when it can't connect, so that's the right error).
If it's particularly disliked that patch can be skipped individually.----------------------------------------------------------------
Applied, thanks.
-- PMM