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.
"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;
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,
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);
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);
}