Received: from eggs.gnu.org ([2001:4830:134:3::10]:46112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFHSo-0005lu-8J for qemu-devel@nongnu.org; Wed, 15 Jul 2015 03:50:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZFHSg-0000GL-Bv for qemu-devel@nongnu.org; Wed, 15 Jul 2015 03:50:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54088) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFHSf-0000GD-V0 for qemu-devel@nongnu.org; Wed, 15 Jul 2015 03:50:38 -0400 Date: Wed, 15 Jul 2015 13:20:22 +0530 From: Amit Shah Message-ID: <20150715075022.GO10280@grmbl.mre> References: <1434450415-11339-1-git-send-email-dgilbert@redhat.com> <1434450415-11339-16-git-send-email-dgilbert@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1434450415-11339-16-git-send-email-dgilbert@redhat.com> Subject: Re: [Qemu-devel] [PATCH v7 15/42] Return path: Source handling of return path List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert (git)" Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, quintela@redhat.com, liang.z.li@intel.com, qemu-devel@nongnu.org, luis@cs.umu.se, pbonzini@redhat.com, david@gibson.dropbear.id.au On (Tue) 16 Jun 2015 [11:26:28], Dr. David Alan Gilbert (git) wrote: > From: "Dr. David Alan Gilbert" > > Open a return path, and handle messages that are received upon it. > > Signed-off-by: Dr. David Alan Gilbert > -/* migration thread support */ > +/* > + * Something bad happened to the RP stream, mark an error > + * The caller shall print something to indicate why > + */ > +static void source_return_path_bad(MigrationState *s) Can you rename this to something like mark_source_rp_bad() ? Intent is clearer that way. Also, the comment says caller will print something, but the invocations below are a mix of printfs and traces. Not saying the caller has to print always, but maybe only comment needs update. > +{ > + s->rp_state.error = true; > + migrate_fd_cleanup_src_rp(s); > +} > + > +/* > + * Handles messages sent on the return path towards the source VM > + * > + */ > +static void *source_return_path_thread(void *opaque) > +{ > + MigrationState *ms = opaque; > + QEMUFile *rp = ms->rp_state.file; > + uint16_t expected_len, header_len, header_type; > + const int max_len = 512; > + uint8_t buf[max_len]; > + uint32_t tmp32; > + int res; > + > + trace_source_return_path_thread_entry(); > + while (rp && !qemu_file_get_error(rp) && > + migration_already_active(ms)) { > + trace_source_return_path_thread_loop_top(); > + header_type = qemu_get_be16(rp); > + header_len = qemu_get_be16(rp); > + > + switch (header_type) { > + case MIG_RP_MSG_SHUT: > + case MIG_RP_MSG_PONG: > + expected_len = 4; > + break; > + > + default: > + error_report("RP: Received invalid message 0x%04x length 0x%04x", > + header_type, header_len); > + source_return_path_bad(ms); > + goto out; > + } > > + if (header_len > expected_len) { > + error_report("RP: Received message 0x%04x with" > + "incorrect length %d expecting %d", > + header_type, header_len, > + expected_len); > + source_return_path_bad(ms); > + goto out; > + } > + > + /* We know we've got a valid header by this point */ > + res = qemu_get_buffer(rp, buf, header_len); > + if (res != header_len) { > + trace_source_return_path_thread_failed_read_cmd_data(); > + source_return_path_bad(ms); > + goto out; > + } Amit