From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WBYhA-0007no-Ci for qemu-devel@nongnu.org; Thu, 06 Feb 2014 18:49:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WBYh1-0004cb-G6 for qemu-devel@nongnu.org; Thu, 06 Feb 2014 18:49:24 -0500 Received: from mail-qa0-x234.google.com ([2607:f8b0:400d:c00::234]:38648) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WBYh1-0004cM-9V for qemu-devel@nongnu.org; Thu, 06 Feb 2014 18:49:15 -0500 Received: by mail-qa0-f52.google.com with SMTP id j15so4121560qaq.11 for ; Thu, 06 Feb 2014 15:49:14 -0800 (PST) Sender: Paolo Bonzini Message-ID: <52F41F77.7000608@redhat.com> Date: Fri, 07 Feb 2014 00:49:11 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <52F0938F.2040102@ozlabs.ru> <52F0C523.30102@redhat.com> <52F0D611.7070105@ozlabs.ru> <52F0D810.4070806@redhat.com> <52F0DA04.9040003@ozlabs.ru> <52F0F26A.5020304@redhat.com> <52F16708.8060902@ozlabs.ru> <52F1E5BA.60902@redhat.com> <20140205090912.GA2398@work-vm> <52F2685D.2050405@redhat.com> <20140205164219.GJ2398@work-vm> <52F26AC0.5040104@redhat.com> <52F2FD2B.9010504@ozlabs.ru> In-Reply-To: <52F2FD2B.9010504@ozlabs.ru> Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] migration: broken ram_save_pending List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy , "Dr. David Alan Gilbert" Cc: "qemu-devel@nongnu.org" , Alex Graf Il 06/02/2014 04:10, Alexey Kardashevskiy ha scritto: >> > Ok, I thought Alexey was saying we are not redirtying that handful of pages. > > Every iteration we read the dirty map from KVM and send all dirty pages > across the stream. But we never finish because qemu_savevm_state_pending is only called _after_ the g_usleep? And thus there's time for the guest to redirty those pages. Does something like this fix it (of course for a proper pages the goto should be eliminated)? diff --git a/migration.c b/migration.c index 7235c23..804c3bd 100644 --- a/migration.c +++ b/migration.c @@ -589,6 +589,7 @@ static void *migration_thread(void *opaque) } else { int ret; +final_phase: DPRINTF("done iterating\n"); qemu_mutex_lock_iothread(); start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); @@ -640,10 +641,16 @@ static void *migration_thread(void *opaque) qemu_file_reset_rate_limit(s->file); initial_time = current_time; initial_bytes = qemu_ftell(s->file); - } - if (qemu_file_rate_limit(s->file)) { - /* usleep expects microseconds */ - g_usleep((initial_time + BUFFER_DELAY - current_time)*1000); + } else if (qemu_file_rate_limit(s->file)) { + pending_size = qemu_savevm_state_pending(s->file, max_size); + DPRINTF("pending size %" PRIu64 " max %" PRIu64 "\n", + pending_size, max_size); + if (pending_size >= max_size) { + /* usleep expects microseconds */ + g_usleep((initial_time + BUFFER_DELAY - current_time)*1000); + } else { + goto final_phase; + } } }