提交 8e42c50b 编写于 作者: E Eric Blake

qemu: improve efficiency of dd during snapshots

POSIX states about dd:

If the bs=expr operand is specified and no conversions other than
sync, noerror, or notrunc are requested, the data returned from each
input block shall be written as a separate output block; if the read
returns less than a full block and the sync conversion is not
specified, the resulting output block shall be the same size as the
input block. If the bs=expr operand is not specified, or a conversion
other than sync, noerror, or notrunc is requested, the input shall be
processed and collected into full-sized output blocks until the end of
the input is reached.

Since we aren't using conv=sync, there is no zero-padding, but our
use of bs= means that a short read results in a short write.  If
instead we use ibs= and obs=, then short reads are collected and dd
only has to do a single write, which can make dd more efficient.

* src/qemu/qemu_monitor.c (qemuMonitorMigrateToFile):
Avoid 'dd bs=', since it can cause short writes.
上级 6eaa4ee4
...@@ -1511,10 +1511,11 @@ int qemuMonitorMigrateToFile(qemuMonitorPtr mon, ...@@ -1511,10 +1511,11 @@ int qemuMonitorMigrateToFile(qemuMonitorPtr mon,
* <> redirection to avoid truncating a regular file. */ * <> redirection to avoid truncating a regular file. */
if (virAsprintf(&dest, "exec:" VIR_WRAPPER_SHELL_PREFIX "%s | " if (virAsprintf(&dest, "exec:" VIR_WRAPPER_SHELL_PREFIX "%s | "
"{ dd bs=%llu seek=%llu if=/dev/null && " "{ dd bs=%llu seek=%llu if=/dev/null && "
"dd bs=%llu; } 1<>%s" VIR_WRAPPER_SHELL_SUFFIX, "dd ibs=%llu obs=%llu; } 1<>%s" VIR_WRAPPER_SHELL_SUFFIX,
argstr, QEMU_MONITOR_MIGRATE_TO_FILE_BS, argstr, QEMU_MONITOR_MIGRATE_TO_FILE_BS,
offset / QEMU_MONITOR_MIGRATE_TO_FILE_BS, offset / QEMU_MONITOR_MIGRATE_TO_FILE_BS,
QEMU_MONITOR_MIGRATE_TO_FILE_TRANSFER_SIZE, QEMU_MONITOR_MIGRATE_TO_FILE_TRANSFER_SIZE,
QEMU_MONITOR_MIGRATE_TO_FILE_TRANSFER_SIZE,
safe_target) < 0) { safe_target) < 0) {
virReportOOMError(); virReportOOMError();
goto cleanup; goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册