[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/18] Add documentation for qemu_progress_{init, pr
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 06/18] Add documentation for qemu_progress_{init, print}() |
Date: |
Thu, 19 May 2011 14:33:20 +0200 |
From: Jes Sorensen <address@hidden>
Signed-off-by: Jes Sorensen <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
qemu-common.h | 2 +-
qemu-progress.c | 24 +++++++++++++++++++++---
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/qemu-common.h b/qemu-common.h
index bba8dfe..b851b20 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -341,7 +341,7 @@ void qemu_iovec_memset_skip(QEMUIOVector *qiov, int c,
size_t count,
void qemu_progress_init(int enabled, float min_skip);
void qemu_progress_end(void);
-void qemu_progress_print(float percent, int max);
+void qemu_progress_print(float delta, int max);
#define QEMU_FILE_TYPE_BIOS 0
#define QEMU_FILE_TYPE_KEYMAP 1
diff --git a/qemu-progress.c b/qemu-progress.c
index a4894c0..8ebe8ef 100644
--- a/qemu-progress.c
+++ b/qemu-progress.c
@@ -96,6 +96,13 @@ static void progress_dummy_init(void)
state.end = progress_dummy_end;
}
+/*
+ * Initialize progress reporting.
+ * If @enabled is false, actual reporting is suppressed. The user can
+ * still trigger a report by sending a SIGUSR1.
+ * Reports are also suppressed unless we've had at least @min_skip
+ * percent progress since the last report.
+ */
void qemu_progress_init(int enabled, float min_skip)
{
state.min_skip = min_skip;
@@ -111,14 +118,25 @@ void qemu_progress_end(void)
state.end();
}
-void qemu_progress_print(float percent, int max)
+/*
+ * Report progress.
+ * @delta is how much progress we made.
+ * If @max is zero, @delta is an absolut value of the total job done.
+ * Else, @delta is a progress delta since the last call, as a fraction
+ * of @max. I.e. the delta is @delta * @max / 100. This allows
+ * relative accounting of functions which may be a different fraction of
+ * the full job, depending on the context they are called in. I.e.
+ * a function might be considered 40% of the full job if used from
+ * bdrv_img_create() but only 20% if called from img_convert().
+ */
+void qemu_progress_print(float delta, int max)
{
float current;
if (max == 0) {
- current = percent;
+ current = delta;
} else {
- current = state.current + percent / 100 * max;
+ current = state.current + delta / 100 * max;
}
if (current > 100) {
current = 100;
--
1.7.2.3
- [Qemu-devel] [PULL 00/18] Block patches, Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 04/18] hw/xen_disk: Remove unused local variable, Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 06/18] Add documentation for qemu_progress_{init, print}(),
Kevin Wolf <=
- [Qemu-devel] [PATCH 08/18] qemu-tool: Stub out qemu-timer functions, Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 07/18] ahci: Fix crashes on duplicate BH registration, Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 09/18] qed: Periodically flush and clear need check bit, Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 11/18] qed: support for growing images, Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 12/18] ide: Split qdev "ide-drive" into "ide-hd" and "ide-cd", Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 10/18] qemu_img: is_not_zero() optimization, Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 14/18] defaults: ide-cd, ide-hd and scsi-cd devices suppress default CD-ROM, Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 13/18] scsi: Split qdev "scsi-disk" into "scsi-hd" and "scsi-cd", Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 15/18] block QMP: Deprecate query-block's "type", drop info block's "type=", Kevin Wolf, 2011/05/19
- [Qemu-devel] [PATCH 16/18] blockdev: Store -drive option media in DriveInfo, Kevin Wolf, 2011/05/19