qemu/qapi
Eric Blake d17a34bfb9 mirror: Allow QMP override to declare target already zero
QEMU has an optimization for a just-created drive-mirror destination
that is not possible for blockdev-mirror (which can't create the
destination) - any time we know the destination starts life as all
zeroes, we can skip a pre-zeroing pass on the destination.  Recent
patches have added an improved heuristic for detecting if a file
contains all zeroes, and we plan to use that heuristic in upcoming
patches.  But since a heuristic cannot quickly detect all scenarios,
and there may be cases where the caller is aware of information that
QEMU cannot learn quickly, it makes sense to have a way to tell QEMU
to assume facts about the destination that can make the mirror
operation faster.  Given our existing example of "qemu-img convert
--target-is-zero", it is time to expose this override in QMP for
blockdev-mirror as well.

This patch results in some slight redundancy between the older
s->zero_target (set any time mode==FULL and the destination image was
not just created - ie. clear if drive-mirror is asking to skip the
pre-zero pass) and the newly-introduced s->target_is_zero (in addition
to the QMP override, it is set when drive-mirror creates the
destination image); this will be cleaned up in the next patch.

There is also a subtlety that we must consider.  When drive-mirror is
passing target_is_zero on behalf of a just-created image, we know the
image is sparse (skipping the pre-zeroing keeps it that way), so it
doesn't matter whether the destination also has "discard":"unmap" and
"detect-zeroes":"unmap".  But now that we are letting the user set the
knob for target-is-zero, if the user passes a pre-existing file that
is fully allocated, it is fine to leave the file fully allocated under
"detect-zeroes":"on", but if the file is open with
"detect-zeroes":"unmap", we should really be trying harder to punch
holes in the destination for every region of zeroes copied from the
source.  The easiest way to do this is to still run the pre-zeroing
pass (turning the entire destination file sparse before populating
just the allocated portions of the source), even though that currently
results in double I/O to the portions of the file that are allocated.
A later patch will add further optimizations to reduce redundant
zeroing I/O during the mirror operation.

Since "target-is-zero":true is designed for optimizations, it is okay
to silently ignore the parameter rather than erroring if the user ever
sets the parameter in a scenario where the mirror job can't exploit it
(for example, when doing "sync":"top" instead of "sync":"full", we
can't pre-zero, so setting the parameter won't make a speed
difference).

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20250509204341.3553601-23-eblake@redhat.com>
Reviewed-by: Sunny Zhu <sunnyzhyy@qq.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2025-05-14 16:55:10 -05:00
..
acpi.json qapi: convert "Example" sections without titles 2024-07-17 10:20:53 +02:00
audio.json dbus: add -audio dbus nsamples option 2025-02-03 21:16:07 +04:00
authz.json qapi: Reformat doc comments to conform to current conventions 2023-05-10 10:01:01 +02:00
block-core.json mirror: Allow QMP override to declare target already zero 2025-05-14 16:55:10 -05:00
block-export.json qapi: merge common parts of NbdServerOptions and nbd-server-start data 2025-03-04 16:44:48 -06:00
block.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
char.json qapi/char.json: minor doc rewording for hub device 2025-02-24 13:48:26 +01:00
common.json hw/qdev-properties-system: Introduce EndianMode QAPI enum 2025-02-16 14:33:39 +01:00
compat.json qapi: Belatedly update CompatPolicy documentation for unstable 2023-10-19 07:02:29 +02:00
control.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
crypto.json crypto: Introduce SM3 hash hmac pbkdf algorithm 2024-11-05 18:37:18 +00:00
cryptodev.json qapi: Document QCryptodevBackendServiceType 2024-10-02 09:10:01 +02:00
cxl.json qapi: fix colon in Since tag section 2025-02-10 15:45:04 +01:00
dump.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
ebpf.json qapi/ebpf: Drop temporary 'prefix' 2024-09-10 13:22:47 +02:00
error.json qapi: Reformat doc comments to conform to current conventions 2023-05-10 10:01:01 +02:00
introspect.json qapi/introspect: Supply missing member documentation 2024-10-02 09:10:01 +02:00
job.json qapi: synchronize jobs and block-jobs documentation 2025-05-01 12:12:19 +03:00
machine-common.json qapi/qom: Define cache enumeration and properties for machine 2024-11-05 23:32:25 +00:00
machine-target.json qapi/machine-target.json: fix "in in" typo in comment 2025-05-09 23:49:26 +03:00
machine.json qapi: Rename TargetInfo structure as QemuTargetInfo 2025-04-25 17:09:58 +02:00
meson.build hw/uefi: add var-service-json.c + qapi for NV vars. 2025-03-04 12:02:50 +01:00
migration.json migration: Update migrate_cancel documentation 2025-02-14 15:19:06 -03:00
misc-target.json qapi/machine: Make @dump-skeys command generic 2025-04-23 07:51:25 +02:00
misc.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
net.json net: vhost-user: add QAPI events to report connection state 2025-02-21 07:21:25 -05:00
opts-visitor.c qapi: Inline and remove QERR_INVALID_PARAMETER definition 2024-04-24 09:50:58 +02:00
pci.json qapi/pci: Supply missing member documentation 2024-10-02 09:10:01 +02:00
pragma.json qapi: Document QCryptodevBackendServiceType 2024-10-02 09:10:01 +02:00
qapi-clone-visitor.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
qapi-dealloc-visitor.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
qapi-forward-visitor.c qapi: change 'unsigned special_features' to 'uint64_t features' 2025-02-10 15:45:04 +01:00
qapi-schema.json qapi/qapi-schema: Address the introduction's bit rot 2025-04-08 09:04:34 +02:00
qapi-type-helpers.c qapi: New strv_from_str_list() 2024-03-04 07:12:40 +01:00
qapi-util.c qapi: change 'unsigned special_features' to 'uint64_t features' 2025-02-10 15:45:04 +01:00
qapi-visit-core.c qapi: change 'unsigned special_features' to 'uint64_t features' 2025-02-10 15:45:04 +01:00
qdev.json docs: Fix some typos (found by codespell and typos) 2025-04-13 13:45:04 +03:00
qmp-dispatch.c qapi: change 'unsigned special_features' to 'uint64_t features' 2025-02-10 15:45:04 +01:00
qmp-event.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
qmp-registry.c qapi: change 'unsigned special_features' to 'uint64_t features' 2025-02-10 15:45:04 +01:00
qobject-input-visitor.c qapi: change 'unsigned special_features' to 'uint64_t features' 2025-02-10 15:45:04 +01:00
qobject-output-visitor.c qapi: change 'unsigned special_features' to 'uint64_t features' 2025-02-10 15:45:04 +01:00
qom.json qapi/qom.json: fix "the the" typo in comment 2025-05-09 23:49:26 +03:00
replay.json qapi: convert "Example" sections without titles 2024-07-17 10:20:53 +02:00
rocker.json qapi/rocker: Tidy up query-rocker-of-dpa-flows example 2025-04-08 09:04:20 +02:00
run-state.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
sockets.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
stats.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
string-input-visitor.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
string-output-visitor.c string-output-visitor: Fix (pseudo) struct handling 2024-01-26 11:16:58 +01:00
tpm.json qapi: convert "Example" sections without titles 2024-07-17 10:20:53 +02:00
trace-events qapi: Generalize struct member policy checking 2021-10-29 18:23:09 +02:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
trace.json qapi: convert "Example" sections without titles 2024-07-17 10:20:53 +02:00
transaction.json qapi: Refill doc comments to conform to conventions 2024-08-05 09:31:51 +02:00
uefi.json hw/uefi: add var-service-json.c + qapi for NV vars. 2025-03-04 12:02:50 +01:00
ui.json qapi/ui: Fix documentation of upper bound value in InputMoveEvent 2025-02-10 15:45:04 +01:00
vfio.json qapi/vfio: Rename VfioMigrationState to Qapi*, and drop prefix 2024-09-10 14:03:45 +02:00
virtio.json hw/vmapple/virtio-blk: Add support for apple virtio-blk 2025-03-04 14:45:34 +01:00
yank.json qapi: convert "Example" sections without titles 2024-07-17 10:20:53 +02:00