|
|
46b2f6 |
From 8d39f6bcf21a7c76e29c270b9304c978bbf2e8ba Mon Sep 17 00:00:00 2001
|
|
|
46b2f6 |
From: Nir Soffer <nirsof@gmail.com>
|
|
|
46b2f6 |
Date: Fri, 1 Nov 2019 22:56:18 +0100
|
|
|
46b2f6 |
Subject: [PATCH] v2v: Optimize convert for images with small holes
|
|
|
46b2f6 |
MIME-Version: 1.0
|
|
|
46b2f6 |
Content-Type: text/plain; charset=UTF-8
|
|
|
46b2f6 |
Content-Transfer-Encoding: 8bit
|
|
|
46b2f6 |
|
|
|
46b2f6 |
"qemu-img convert" detects zeroes in allocated areas and punch holes in
|
|
|
46b2f6 |
the destination image. This may save space on the destination image, but
|
|
|
46b2f6 |
slows down conversion when using outputs such as rhv-upload, which have
|
|
|
46b2f6 |
very large overhead per requests.
|
|
|
46b2f6 |
|
|
|
46b2f6 |
Using the -S flag, we can treat small areas filled with zeroes as data,
|
|
|
46b2f6 |
limiting the number of requests, and speeding the operation.
|
|
|
46b2f6 |
|
|
|
46b2f6 |
Here is an example converting Fedora 30 image:
|
|
|
46b2f6 |
|
|
|
46b2f6 |
$ virt-builder fedora-30 -o src.img
|
|
|
46b2f6 |
...
|
|
|
46b2f6 |
|
|
|
46b2f6 |
$ qemu-img map -f raw --output json src.img | wc -l
|
|
|
46b2f6 |
213
|
|
|
46b2f6 |
|
|
|
46b2f6 |
$ qemu-img convert -f raw -O raw -t none -T none src.img dst.img
|
|
|
46b2f6 |
|
|
|
46b2f6 |
$ qemu-img map -f raw --output json dst.img | wc -l
|
|
|
46b2f6 |
1443
|
|
|
46b2f6 |
|
|
|
46b2f6 |
$ ls -lhs *.img
|
|
|
46b2f6 |
1.2G -rw-r--r--. 1 nsoffer nsoffer 6.0G Nov 1 21:48 dst.img
|
|
|
46b2f6 |
1.2G -rw-r--r--. 1 nsoffer nsoffer 6.0G Nov 1 21:46 src.img
|
|
|
46b2f6 |
|
|
|
46b2f6 |
Qemu did 1443 writes instead of 213 (5.8X). Lets repeat this conversion
|
|
|
46b2f6 |
with the -S option:
|
|
|
46b2f6 |
|
|
|
46b2f6 |
$ qemu-img convert -f raw -O raw -t none -T none -S 64k src.img dst.img
|
|
|
46b2f6 |
|
|
|
46b2f6 |
$ qemu-img map -f raw --output json dst.img | wc -l
|
|
|
46b2f6 |
213
|
|
|
46b2f6 |
|
|
|
46b2f6 |
$ ls -lhs *.img
|
|
|
46b2f6 |
1.2G -rw-r--r--. 1 nsoffer nsoffer 6.0G Nov 1 21:48 dst.img
|
|
|
46b2f6 |
1.2G -rw-r--r--. 1 nsoffer nsoffer 6.0G Nov 1 21:46 src.img
|
|
|
46b2f6 |
|
|
|
46b2f6 |
Picking a good value for -S is not easy. Testing show that 64k is best
|
|
|
46b2f6 |
value for this test image for limiting the number of requests:
|
|
|
46b2f6 |
|
|
|
46b2f6 |
$ for size in 4k 8k 16k 32k 64k; do \
|
|
|
46b2f6 |
printf "%5s: " $size; \
|
|
|
46b2f6 |
qemu-img convert -f raw -O raw -t none -T none -S $size src.img dst.img; \
|
|
|
46b2f6 |
qemu-img map -f raw --output json dst.img | wc -l; \
|
|
|
46b2f6 |
done
|
|
|
46b2f6 |
4k: 1443
|
|
|
46b2f6 |
8k: 731
|
|
|
46b2f6 |
16k: 521
|
|
|
46b2f6 |
32k: 387
|
|
|
46b2f6 |
64k: 213
|
|
|
46b2f6 |
|
|
|
46b2f6 |
We need more testing with oVirt to measure the performance improvement
|
|
|
46b2f6 |
and pick a good value. This should probably be an option, but lets start
|
|
|
46b2f6 |
with a minimal change.
|
|
|
46b2f6 |
|
|
|
46b2f6 |
(cherry picked from commit 2aa78ade2d48e926b7b04050338ebd8a0c5e3f05
|
|
|
46b2f6 |
in virt-v2v)
|
|
|
46b2f6 |
---
|
|
|
46b2f6 |
v2v/v2v.ml | 1 +
|
|
|
46b2f6 |
1 file changed, 1 insertion(+)
|
|
|
46b2f6 |
|
|
|
46b2f6 |
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
|
|
|
46b2f6 |
index d7a868659..a81a2320a 100644
|
|
|
46b2f6 |
--- a/v2v/v2v.ml
|
|
|
46b2f6 |
+++ b/v2v/v2v.ml
|
|
|
46b2f6 |
@@ -754,6 +754,7 @@ and copy_targets cmdline targets input output =
|
|
|
46b2f6 |
(if not (quiet ()) then [ "-p" ] else []) @
|
|
|
46b2f6 |
[ "-n"; "-f"; "qcow2"; "-O"; t.target_format ] @
|
|
|
46b2f6 |
(if cmdline.compressed then [ "-c" ] else []) @
|
|
|
46b2f6 |
+ [ "-S"; "64k" ] @
|
|
|
46b2f6 |
[ overlay_file; filename ] in
|
|
|
46b2f6 |
let start_time = gettimeofday () in
|
|
|
46b2f6 |
if run_command cmd <> 0 then
|
|
|
46b2f6 |
--
|
|
|
d60042 |
2.25.4
|
|
|
46b2f6 |
|