summaryrefslogtreecommitdiff
path: root/migration/migration.c
diff options
context:
space:
mode:
authorPeter Xu <peterx@redhat.com>2018-02-08 18:31:05 +0800
committerDr. David Alan Gilbert <dgilbert@redhat.com>2018-02-14 10:34:56 +0000
commit7a9ddfbfae4aaf8a7e4dafb57ac9fecad807a6b7 (patch)
tree1a678f726395f20f2bda3e9018efa1e15a4b365a /migration/migration.c
parent2c9bb29703caa8fd31078cc38b3b53762557c27c (diff)
downloadqemu-7a9ddfbfae4aaf8a7e4dafb57ac9fecad807a6b7.tar.gz
migration: better error handling with QEMUFile
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. Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> Message-Id: <20180208103132.28452-2-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Diffstat (limited to 'migration/migration.c')
-rw-r--r--migration/migration.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/migration/migration.c b/migration/migration.c
index 86d69120a6..e2a5a832c6 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -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",