[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v10 02/15] libxc/progress: Extend the progress interface
Progress information is logged via a different logger to regular libxc log messages, and currently can only express a range. However, not everything which needs reporting as progress comes with a range. Extend the interface to allow reporting of a single statement. The programming interface now looks like: xc_set_progress_prefix() set the prefix string to be used xc_report_progress_single() report a single action xc_report_progress_step() report $X of $Y The new programming interface is implemented in a compatible way with the existing caller interface (by reporting a single action as "0 of 0"). Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CC: Ian Campbell <Ian.Campbell@xxxxxxxxxx> CC: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> CC: Wei Liu <wei.liu2@xxxxxxxxxx> --- v10: Expand commit message more, and add some asserts() v8: Expand commit message --- tools/libxc/xc_domain_restore.c | 3 ++- tools/libxc/xc_domain_save.c | 3 ++- tools/libxc/xc_private.c | 22 +++++++++++++++------- tools/libxc/xc_private.h | 4 ++-- tools/libxc/xtl_core.c | 9 +++++---- 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/tools/libxc/xc_domain_restore.c b/tools/libxc/xc_domain_restore.c index 2ab9f46..e9c036f 100644 --- a/tools/libxc/xc_domain_restore.c +++ b/tools/libxc/xc_domain_restore.c @@ -1622,7 +1622,8 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, goto out; } - xc_report_progress_start(xch, "Reloading memory pages", dinfo->p2m_size); + xc_set_progress_prefix(xch, "Reloading memory pages"); + xc_report_progress_step(xch, 0, dinfo->p2m_size); /* * Now simply read each saved frame into its new machine frame. diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c index 59323b8..a71442e 100644 --- a/tools/libxc/xc_domain_save.c +++ b/tools/libxc/xc_domain_save.c @@ -1131,7 +1131,8 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter "Saving memory: iter %d (last sent %u skipped %u)", iter, sent_this_iter, skip_this_iter); - xc_report_progress_start(xch, reportbuf, dinfo->p2m_size); + xc_set_progress_prefix(xch, reportbuf); + xc_report_progress_step(xch, 0, dinfo->p2m_size); iter++; sent_this_iter = 0; diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c index 83ead5e..2ffebd9 100644 --- a/tools/libxc/xc_private.c +++ b/tools/libxc/xc_private.c @@ -388,18 +388,26 @@ void xc_osdep_log(xc_interface *xch, xentoollog_level level, int code, const cha va_end(args); } -void xc_report_progress_start(xc_interface *xch, const char *doing, - unsigned long total) { +const char *xc_set_progress_prefix(xc_interface *xch, const char *doing) +{ + const char *old = xch->currently_progress_reporting; + xch->currently_progress_reporting = doing; - xtl_progress(xch->error_handler, "xc", xch->currently_progress_reporting, - 0, total); + return old; +} + +void xc_report_progress_single(xc_interface *xch, const char *doing) +{ + assert(doing); + xtl_progress(xch->error_handler, "xc", doing, 0, 0); } void xc_report_progress_step(xc_interface *xch, - unsigned long done, unsigned long total) { + unsigned long done, unsigned long total) +{ assert(xch->currently_progress_reporting); - xtl_progress(xch->error_handler, "xc", xch->currently_progress_reporting, - done, total); + xtl_progress(xch->error_handler, "xc", + xch->currently_progress_reporting, done, total); } int xc_get_pfn_type_batch(xc_interface *xch, uint32_t dom, diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h index b45b079..247a408 100644 --- a/tools/libxc/xc_private.h +++ b/tools/libxc/xc_private.h @@ -133,8 +133,8 @@ void xc_report(xc_interface *xch, xentoollog_logger *lg, xentoollog_level, int code, const char *fmt, ...) __attribute__((format(printf,5,6))); -void xc_report_progress_start(xc_interface *xch, const char *doing, - unsigned long total); +const char *xc_set_progress_prefix(xc_interface *xch, const char *doing); +void xc_report_progress_single(xc_interface *xch, const char *doing); void xc_report_progress_step(xc_interface *xch, unsigned long done, unsigned long total); diff --git a/tools/libxc/xtl_core.c b/tools/libxc/xtl_core.c index 326b97e..73add92 100644 --- a/tools/libxc/xtl_core.c +++ b/tools/libxc/xtl_core.c @@ -66,13 +66,14 @@ void xtl_log(struct xentoollog_logger *logger, void xtl_progress(struct xentoollog_logger *logger, const char *context, const char *doing_what, unsigned long done, unsigned long total) { - int percent; + int percent = 0; if (!logger->progress) return; - percent = (total < LONG_MAX/100) - ? (done * 100) / total - : done / ((total + 99) / 100); + if ( total ) + percent = (total < LONG_MAX/100) + ? (done * 100) / total + : done / ((total + 99) / 100); logger->progress(logger, context, doing_what, percent, done, total); } -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |