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