From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=49149 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJqPa-0002Ki-Cq for qemu-devel@nongnu.org; Sat, 20 Nov 2010 11:35:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PJqPZ-0003HM-99 for qemu-devel@nongnu.org; Sat, 20 Nov 2010 11:35:38 -0500 Received: from mail-vw0-f45.google.com ([209.85.212.45]:46028) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PJqPZ-0003CC-0T for qemu-devel@nongnu.org; Sat, 20 Nov 2010 11:35:37 -0500 Received: by mail-vw0-f45.google.com with SMTP id 5so2991784vws.4 for ; Sat, 20 Nov 2010 08:35:36 -0800 (PST) Message-ID: <4CE7313B.1070103@codemonkey.ws> Date: Fri, 19 Nov 2010 20:23:55 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] stop the iteration when too many pages is transferred References: <4CE49053.3000608@cn.fujitsu.com> In-Reply-To: <4CE49053.3000608@cn.fujitsu.com> Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wen Congyang Cc: qemu-devel On 11/17/2010 08:32 PM, Wen Congyang wrote: > When the total sent page size is larger than max_factor > times of the size of guest OS's memory, stop the > iteration. > The default value of max_factor is 3. > > This is similar to XEN. > > > Signed-off-by: Wen Congyang > I'm strongly opposed to doing this. I think Xen gets this totally wrong. Migration is a contract. When you set the stop time, you're saying that you want only want the guest to experience a fixed amount of downtime. Stopping the guest after some arbitrary number of iterations makes the downtime non-deterministic. With a very large guest, this could wreak havoc causing dropped networking connections, etc. It's totally unsafe. If a management tool wants this behavior, they can set a timeout and explicitly stop the guest during the live migration. IMHO, such a management tool is not doing it's job properly but it still can be implemented. Regards, Anthony Liguori > --- > arch_init.c | 13 ++++++++++++- > 1 files changed, 12 insertions(+), 1 deletions(-) > > diff --git a/arch_init.c b/arch_init.c > index 4486925..67e90f8 100644 > --- a/arch_init.c > +++ b/arch_init.c > @@ -212,6 +212,14 @@ uint64_t ram_bytes_total(void) > return total; > } > > +static uint64_t ram_blocks_total(void) > +{ > + return ram_bytes_total() / TARGET_PAGE_SIZE; > +} > + > +static uint64_t blocks_transferred = 0; > +static int max_factor = 3; > + > int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) > { > ram_addr_t addr; > @@ -234,6 +242,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) > bytes_transferred = 0; > last_block = NULL; > last_offset = 0; > + blocks_transferred = 0; > > /* Make sure all dirty bits are set */ > QLIST_FOREACH(block, &ram_list.blocks, next) { > @@ -266,6 +275,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) > > bytes_sent = ram_save_block(f); > bytes_transferred += bytes_sent; > + blocks_transferred += !!bytes_sent; > if (bytes_sent == 0) { /* no more blocks */ > break; > } > @@ -295,7 +305,8 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) > > expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth; > > - return (stage == 2) && (expected_time <= migrate_max_downtime()); > + return (stage == 2) && ((expected_time <= migrate_max_downtime()) > + || (blocks_transferred > ram_blocks_total() * max_factor)); > } > > static inline void *host_from_stream_offset(QEMUFile *f, >