From: Ian Campbell Subject: [PATCH 1 of 4] libxc: logger: add newline when progress is complete Date: Fri, 03 Sep 2010 14:06:14 +0100 Message-ID: <75d86afe717e84ad04b0.1283519174@localhost.localdomain> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Brendan Cully List-Id: xen-devel@lists.xenproject.org # HG changeset patch # User Ian Campbell # Date 1283519032 -3600 # Node ID 75d86afe717e84ad04b0b16190b182553980e0c7 # Parent 9eb7b1ebaaf813eedac5b1941b03b8c999e12b61 libxc: logger: add newline when progress is complete In xc_domain_save ensure that we signal completion at the end of each batch. This ensures that the next logged line starts on a new line. e.g. instead of: Savefile contains xl domain config xc: Saving memory: iter 3 (last sent 0 skipped 0): 0/32768 0%migration target: Transfer complete, requesting permission to start domain. migration sender: Target has acknowledged transfer. what is desired is: Savefile contains xl domain config xc: Saving memory: iter 0 (last sent 0 skipped 0): 32768/32768 100% xc: Saving memory: iter 1 (last sent 32576 skipped 192): 32768/32768 100% xc: Saving memory: iter 2 (last sent 217 skipped 0): 32768/32768 100% xc: Saving memory: iter 3 (last sent 0 skipped 0): 32768/32768 100% migration target: Transfer complete, requesting permission to start domain. migration sender: Target has acknowledged transfer. Signed-off-by: Ian Campbell diff -r 9eb7b1ebaaf8 -r 75d86afe717e tools/libxc/xc_domain_save.c --- a/tools/libxc/xc_domain_save.c Fri Sep 03 13:38:36 2010 +0100 +++ b/tools/libxc/xc_domain_save.c Fri Sep 03 14:03:52 2010 +0100 @@ -1461,6 +1461,8 @@ int xc_domain_save(xc_interface *xch, in skip: + xc_report_progress_step(xch, dinfo->p2m_size, dinfo->p2m_size); + total_sent += sent_this_iter; if ( last_iter ) diff -r 9eb7b1ebaaf8 -r 75d86afe717e tools/libxc/xtl_logger_stdio.c --- a/tools/libxc/xtl_logger_stdio.c Fri Sep 03 13:38:36 2010 +0100 +++ b/tools/libxc/xtl_logger_stdio.c Fri Sep 03 14:03:52 2010 +0100 @@ -108,9 +108,12 @@ static void stdiostream_progress(struct if (lg->progress_erase_len) putc('\r', lg->f); - newpel = fprintf(lg->f, "%s%s" "%s: %lu/%lu %3d%%", + lg->progress_last_percent = percent; + + newpel = fprintf(lg->f, "%s%s" "%s: %lu/%lu %3d%%%s", context?context:"", context?": ":"", - doing_what, done, total, percent); + doing_what, done, total, percent, + done == total ? "\n" : ""); extra_erase = lg->progress_erase_len - newpel; if (extra_erase > 0)