[PATCH v3 4/4] v2v: Add --print-estimate option to print copy size
by Richard W.M. Jones
I rethought this again, as I think that it's a dangerous assumption to
bake qemu-img measure output into our API.
This patch series runs qemu-img measure behind the scenes, but then
parses the output and sums it to a single number which we print.
Doing that required a bit of reworking, moving the Jansson [JSON
parser] bindings from virt-builder into the common directory and
a couple of other minor changes, hence this has grown to 4 commits.
Rich.
6 years, 3 months
[PATCH nbdkit] tests: Add a root only test of the file plugin with
by Richard W.M. Jones
In libguestfs we have a few tests that require root privileges and
they are skipped by default (normally you should not build or test as
root), but you can do this to run them:
sudo make check-root
In nbdkit I wanted to check that the file plugin works with block
devices (this is not tested), and the only way I can sensibly think to
do this is using a loopback device and root. This commit therefore
adds a similar mechanism for running root tests and a test of the file
plugin using loop.
It's somewhat hard to say whether this is testing the full fallocate,
trim and zero range paths that might be exercised by Nir's forthcoming
patch.
With the current codebase of nbdkit we can see that fallocate seems to
do the right thing:
commandrvf: stdout=e stderr=y flags=0x10000
commandrvf: /bin/sh -c "fallocate -nzl 64k /dev/sda"
nbdkit: file.8: debug: zero count=65536 offset=0 may_trim=0 fua=0
nbdkit: file.7: debug: flush
but fstrim possibly does not:
commandrvf: fstrim -v /sysroot/
nbdkit: file.2: debug: pread count=1024 offset=336896
nbdkit: file.6: debug: pread count=1024 offset=343040
/sysroot/: 91.2 MiB (95629312 bytes) trimmed
Another question is whether the Linux loop device supports all these
ioctls (and indeed whether the Linux -> qemu -> loop path that
libguestfs uses does too). I admit I did not yet look at the kernel
and qemu code to find out. An easier way is probably to add debug
messages to Nir's patch.
(An alternative might have been to use scsi_debug, but that is a
rather specialized device.)
Rich.
6 years, 3 months
[PATCH v2 0/4] file: Zero for block devices and older file systems
by Nir Soffer
This is the third version to support efficient zero for block devices
on older kernels (e.g. RHEL 7.5), and file systems that do not support
yet FALLOC_FS_ZERO_RANGE (e.g. NFS 4.2).
Changes since v2:
- Revert file_can_trim change, since it is too late to change the value
after negotiation. Changing the capability dinamically may be useful
internally, but it should be done via other means.
- Do not depend on FALLOC_FL_* when including <linux/fs.h>.
- Add common/includes/isaligned.h for is_aligned helper, implemented
in a more efficient way with bitwise math.
- If getting sector size fail, fall back to safe guess instead of
hard failure.
- More efficient alignment check using bitwise math.
- For BLKZEROOUT, treat ENOTTY as EOPNOTSUPP. Theoretically possible
with a mix of new headers and old or strangely configured kernel.
- Use default multi line comment style.
- Fix few typos in comments and commit message
Issues to explore later:
- Eric suggested to use the new FALLOC_FL_NO_HIDE_STALE. Requires
benchmarking with a system supporting this flag.
- Eric suggested to use tri-state for can_* flags. I don't see a need at
this point.
- Eric suggested to add can_zero. I'm not sure about the semantics of
this, and it has the same issue of can_trim, reporting dynamic value.
v2 was here:
https://www.redhat.com/archives/libguestfs/2018-August/msg00025.html
Changes since v1:
- Split to smaller patches
- Skip linux only includes on other systems
- Skip code using BLKZEROOUT if the macro is not defined
- Try BLKZEROOUT only if the offset and count are aligned to device
sector size.
- initialize h->can_* properly. Before they were uninitialized if
FALLOC_FL_* macros were not defined.
- Use new h->can_punch_hole in file_can_trim, so now we report the
actual capability once we detected it.
- Use h->can_punch_hole in file_trim, so we try only once if the
operation is not supported.
v1 was here:
https://www.redhat.com/archives/libguestfs/2018-July/msg00084.html
Nir Soffer (4):
file: Avoid unsupported fallocate() calls
file: Support zero without ZERO_RANGE
common: Add isaligned helper module
file: Zero for block devices on old kernels
common/include/isaligned.h | 50 ++++++++++
plugins/file/Makefile.am | 3 +-
plugins/file/file.c | 182 +++++++++++++++++++++++++++++--------
3 files changed, 196 insertions(+), 39 deletions(-)
create mode 100644 common/include/isaligned.h
--
2.17.1
6 years, 3 months
[PATCH] build: Build synopsis.c before main.c
by Nir Soffer
synopsis.c was defined as dependency of the nbdkit program, but it
should be define as dependency of main.c. Otherwise "make" fail with:
main.c:180:10: fatal error: synopsis.c: No such file or directory
#include "synopsis.c"
^~~~~~~~~~~~
Fixes commit 445e18f3dbb2 (src, docs: Generate the nbdkit command
synopsis from a single source).
---
src/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 5c67bf8..046bdc3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -80,7 +80,7 @@ nbdkit_LDFLAGS = \
# used to generate the man page.
EXTRA_DIST = synopsis.c
-nbdkit_DEPENDENCIES = synopsis.c
+main.c: synopsis.c
synopsis.c: $(top_srcdir)/docs/synopsis.txt
rm -f $@ $@-t
$(SED) -e 's/\(.*\)/"\1\\n"/g' $< > $@-t
--
2.17.1
6 years, 3 months
buffer overflow detected error
by Davone Desouza
So I'm using the libguests library in my Java code and when running my vm I
am seeing this error:
***buffer overflow detected***:/bin/java terminated
Backtrace:=========
/lib64/libc.so.6(__fortify_fail+0x37)[ox7f7932b4ed87]
/lib64/libc.so.6(+0x10df40)[0x7f7932b4cf40]
/lib64/libc.so.6(+0x10df40)[0x7f7932b4ecf7]
/lib64/libguestfs.so.0(+0xa6508)[0x7f78755bd508]
/lib64/libguestfs.so.0(+0xa6e3c)[0x7f78755bde3c]
/lib64/libguestfs.so.0(+0xa8e12)[0x7f78755bfe12]
/lib64/libguestfs.so.0(guestfs_disk_create_argv+0xbf)[0x7f7875567c6f]
/lib64/libguestfs.so.0(+0xc48f2)[0x7f78755db8f2]
/lib64/libguestfs.so.0(+0xc54b1[0x7f78755dc4b1]
/lib64/libguestfs.so.0(+0xbfc75)[0x7f78755d6c75]
/usr/lib64/libguestfs_jni.so.1.36.3(Java_com_redhat_et_libguestfs_Gues
tFs__1launch+0x14[0x7f7875875de4]
[0x7f791ee77570]
Any idea what is going on or how can I fix this?
...
...
6 years, 3 months
[PATCH v2] v2v: Add --print-estimate option to print copy size estimate.
by Richard W.M. Jones
This option prints the estimated size of the data that will be copied
from the source disk.
Currently this overestimates by the size of the qcow2 header, but for
real disk images that doesn't matter much.
For example:
$ virt-builder fedora-27
$ virt-v2v -i disk fedora-27.img -o null --machine-readable --print-estimate
[...]
virt-v2v: This guest has virtio drivers installed.
[ 44.0] Mapping filesystem data to avoid copying unused and blank areas
[ 44.5] Closing the overlay
{ "disks": [
{
"required": 1047920640,
"fully-allocated": 6443696128
}
] }
---
v2v/Makefile.am | 2 ++
v2v/cmdline.ml | 17 +++++++++++--
v2v/cmdline.mli | 2 ++
v2v/test-v2v-print-estimate.sh | 45 ++++++++++++++++++++++++++++++++++
v2v/v2v.ml | 26 ++++++++++++++++++++
v2v/virt-v2v.pod | 19 ++++++++++++++
6 files changed, 109 insertions(+), 2 deletions(-)
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index 5461055d1..2ea0dd1d5 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
@@ -379,6 +379,7 @@ TESTS += \
test-v2v-oa-option.sh \
test-v2v-of-option.sh \
test-v2v-on-option.sh \
+ test-v2v-print-estimate.sh \
test-v2v-print-source.sh \
test-v2v-sound.sh \
$(SLOW_TESTS) \
@@ -534,6 +535,7 @@ EXTRA_DIST += \
test-v2v-oa-option.sh \
test-v2v-of-option.sh \
test-v2v-on-option.sh \
+ test-v2v-print-estimate.sh \
test-v2v-print-source.expected \
test-v2v-print-source.sh \
test-v2v-print-source.xml \
diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
index 5b2df3555..74cc27714 100644
--- a/v2v/cmdline.ml
+++ b/v2v/cmdline.ml
@@ -33,10 +33,12 @@ type cmdline = {
debug_overlays : bool;
do_copy : bool;
in_place : bool;
+ machine_readable : bool;
network_map : Networks.t;
output_alloc : output_allocation;
output_format : string option;
output_name : string option;
+ print_estimate : bool;
print_source : bool;
root_choice : root_choice;
}
@@ -49,6 +51,7 @@ let parse_cmdline () =
let debug_overlays = ref false in
let do_copy = ref true in
let machine_readable = ref false in
+ let print_estimate = ref false in
let print_source = ref false in
let qemu_boot = ref false in
@@ -235,6 +238,8 @@ let parse_cmdline () =
s_"Set output storage location";
[ L"password-file" ], Getopt.String ("filename", set_string_option_once "--password-file" input_password),
s_"Same as ‘-ip filename’";
+ [ L"print-estimate" ], Getopt.Set print_estimate,
+ s_"Estimate size of source and stop";
[ L"print-source" ], Getopt.Set print_source,
s_"Print source and stop";
[ L"qemu-boot" ], Getopt.Set qemu_boot, s_"Boot in qemu (-o qemu only)";
@@ -330,6 +335,7 @@ read the man page virt-v2v(1).
let output_options = List.rev !output_options in
let output_password = !output_password in
let output_storage = !output_storage in
+ let print_estimate = !print_estimate in
let print_source = !print_source in
let qemu_boot = !qemu_boot in
let root_choice = !root_choice in
@@ -355,6 +361,12 @@ read the man page virt-v2v(1).
exit 0
);
+ (* Some options cannot be used with --in-place. *)
+ if in_place then (
+ if print_estimate then
+ error (f_"--in-place and --print-estimate cannot be used together")
+ );
+
(* Input transport affects whether some input options should or
* should not be used.
*)
@@ -620,8 +632,9 @@ read the man page virt-v2v(1).
output_format, output_alloc in
{
- compressed; debug_overlays; do_copy; in_place; network_map;
+ compressed; debug_overlays; do_copy; in_place;
+ machine_readable; network_map;
output_alloc; output_format; output_name;
- print_source; root_choice;
+ print_estimate; print_source; root_choice;
},
input, output
diff --git a/v2v/cmdline.mli b/v2v/cmdline.mli
index 25beb1c95..9b5bd4098 100644
--- a/v2v/cmdline.mli
+++ b/v2v/cmdline.mli
@@ -23,10 +23,12 @@ type cmdline = {
debug_overlays : bool;
do_copy : bool;
in_place : bool;
+ machine_readable : bool;
network_map : Networks.t;
output_alloc : Types.output_allocation;
output_format : string option;
output_name : string option;
+ print_estimate : bool;
print_source : bool;
root_choice : Types.root_choice;
}
diff --git a/v2v/test-v2v-print-estimate.sh b/v2v/test-v2v-print-estimate.sh
new file mode 100755
index 000000000..bbc810151
--- /dev/null
+++ b/v2v/test-v2v-print-estimate.sh
@@ -0,0 +1,45 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2018 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# Test --print-estimate option.
+
+set -e
+
+$TEST_FUNCTIONS
+skip_if_skipped
+skip_unless_phony_guest windows.img
+
+f=test-v2v-print-estimate.out
+rm -f $f
+
+echo "Actual:"
+du -s -B 1 ../test-data/phony-guests/windows.img
+
+$VG virt-v2v --debug-gc \
+ -i libvirtxml test-v2v-print-source.xml \
+ -o local -os $(pwd) \
+ --print-estimate --quiet > $f
+
+echo "Estimate:"
+cat $f
+
+# Check the output looks reasonable. This is not a very good test XXX.
+grep "required" $f
+grep "fully allocated size" $f
+
+rm -f $f
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 1775200d3..23dea0012 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -156,6 +156,12 @@ let rec main () =
(match conversion_mode with
| In_place -> ()
| Copying overlays ->
+ (* Print copy size estimate and stop. *)
+ if cmdline.print_estimate then (
+ print_copy_size_estimate cmdline overlays;
+ exit 0
+ );
+
message (f_"Assigning disks to buses");
let target_buses =
Target_bus_assignment.target_bus_assignment source guestcaps in
@@ -371,6 +377,26 @@ and print_mpstat chan { mp_dev = dev; mp_path = path;
fprintf chan " bsize=%Ld blocks=%Ld bfree=%Ld bavail=%Ld\n"
s.Guestfs.bsize s.Guestfs.blocks s.Guestfs.bfree s.Guestfs.bavail
+(* Print the estimated size that will be copied for each disk. *)
+and print_copy_size_estimate cmdline overlays =
+ let json = cmdline.machine_readable in
+ if json then printf "{ \"disks\": [\n%!";
+ List.iteri (
+ fun i { ov_overlay_file } ->
+ if json && i > 0 then printf ",\n%!";
+ let cmd =
+ [ Guestfs_config.qemu_img; "measure";
+ (* For use of -O qcow2 here, see this thread:
+ * https://www.redhat.com/archives/libguestfs/2018-August/thread.html#00142
+ *)
+ "-f"; "qcow2"; "-O"; "qcow2";
+ "--output=" ^ (if json then "json" else "human");
+ ov_overlay_file ] in
+ if run_command cmd <> 0 then
+ error (f_"qemu-img measure failed, see earlier errors");
+ ) overlays;
+ if json then printf "] }%!\n"
+
(* Conversion can fail if there is no space on the guest filesystems
* (RHBZ#1139543). To avoid this situation, check there is some
* headroom. Mainly we care about the root filesystem.
diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod
index 303fe425c..53529c95c 100644
--- a/v2v/virt-v2v.pod
+++ b/v2v/virt-v2v.pod
@@ -794,6 +794,25 @@ C<root>.
You will get an error if virt-v2v is unable to mount/write to the
Export Storage Domain.
+=item B<--print-estimate>
+
+Print the estimated size of the data which will be copied from the
+source disk(s) and stop. The estimate is produced by the
+L<qemu-img(1)> C<measure> command, so the output fields are the same
+as for that command.
+
+The default is to produce human readable output. For parsable JSON
+output use:
+
+ virt-v2v [-i options ...] -o null --print-estimate --machine-readable
+
+and throw away all lines sent to stdout before C</^{ "disks"/>.
+
+When using this option you must specify an output mode. This is
+because virt-v2v has to perform the conversion in order to print the
+estimate, and the conversion depends on the output mode. Using
+I<-o null> should be safe for most purposes.
+
=item B<--print-source>
Print information about the source guest and stop. This option is
--
2.18.0
6 years, 3 months
[PATCH] v2v: Add --print-estimate option to print source size estimate.
by Richard W.M. Jones
This option prints the estimated size of the data that will be copied
from the source disk.
For interest, the test prints:
3747840 ../test-data/phony-guests/windows.img
Estimate: 3710976
---
v2v/Makefile.am | 2 ++
v2v/cmdline.ml | 17 ++++++++++--
v2v/cmdline.mli | 2 ++
v2v/test-v2v-print-estimate.sh | 47 +++++++++++++++++++++++++++++++++
v2v/v2v.ml | 48 ++++++++++++++++++++++++++++++++++
v2v/virt-v2v.pod | 17 ++++++++++++
6 files changed, 131 insertions(+), 2 deletions(-)
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index 5461055d1..2ea0dd1d5 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
@@ -379,6 +379,7 @@ TESTS += \
test-v2v-oa-option.sh \
test-v2v-of-option.sh \
test-v2v-on-option.sh \
+ test-v2v-print-estimate.sh \
test-v2v-print-source.sh \
test-v2v-sound.sh \
$(SLOW_TESTS) \
@@ -534,6 +535,7 @@ EXTRA_DIST += \
test-v2v-oa-option.sh \
test-v2v-of-option.sh \
test-v2v-on-option.sh \
+ test-v2v-print-estimate.sh \
test-v2v-print-source.expected \
test-v2v-print-source.sh \
test-v2v-print-source.xml \
diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
index 5b2df3555..74cc27714 100644
--- a/v2v/cmdline.ml
+++ b/v2v/cmdline.ml
@@ -33,10 +33,12 @@ type cmdline = {
debug_overlays : bool;
do_copy : bool;
in_place : bool;
+ machine_readable : bool;
network_map : Networks.t;
output_alloc : output_allocation;
output_format : string option;
output_name : string option;
+ print_estimate : bool;
print_source : bool;
root_choice : root_choice;
}
@@ -49,6 +51,7 @@ let parse_cmdline () =
let debug_overlays = ref false in
let do_copy = ref true in
let machine_readable = ref false in
+ let print_estimate = ref false in
let print_source = ref false in
let qemu_boot = ref false in
@@ -235,6 +238,8 @@ let parse_cmdline () =
s_"Set output storage location";
[ L"password-file" ], Getopt.String ("filename", set_string_option_once "--password-file" input_password),
s_"Same as ‘-ip filename’";
+ [ L"print-estimate" ], Getopt.Set print_estimate,
+ s_"Estimate size of source and stop";
[ L"print-source" ], Getopt.Set print_source,
s_"Print source and stop";
[ L"qemu-boot" ], Getopt.Set qemu_boot, s_"Boot in qemu (-o qemu only)";
@@ -330,6 +335,7 @@ read the man page virt-v2v(1).
let output_options = List.rev !output_options in
let output_password = !output_password in
let output_storage = !output_storage in
+ let print_estimate = !print_estimate in
let print_source = !print_source in
let qemu_boot = !qemu_boot in
let root_choice = !root_choice in
@@ -355,6 +361,12 @@ read the man page virt-v2v(1).
exit 0
);
+ (* Some options cannot be used with --in-place. *)
+ if in_place then (
+ if print_estimate then
+ error (f_"--in-place and --print-estimate cannot be used together")
+ );
+
(* Input transport affects whether some input options should or
* should not be used.
*)
@@ -620,8 +632,9 @@ read the man page virt-v2v(1).
output_format, output_alloc in
{
- compressed; debug_overlays; do_copy; in_place; network_map;
+ compressed; debug_overlays; do_copy; in_place;
+ machine_readable; network_map;
output_alloc; output_format; output_name;
- print_source; root_choice;
+ print_estimate; print_source; root_choice;
},
input, output
diff --git a/v2v/cmdline.mli b/v2v/cmdline.mli
index 25beb1c95..9b5bd4098 100644
--- a/v2v/cmdline.mli
+++ b/v2v/cmdline.mli
@@ -23,10 +23,12 @@ type cmdline = {
debug_overlays : bool;
do_copy : bool;
in_place : bool;
+ machine_readable : bool;
network_map : Networks.t;
output_alloc : Types.output_allocation;
output_format : string option;
output_name : string option;
+ print_estimate : bool;
print_source : bool;
root_choice : Types.root_choice;
}
diff --git a/v2v/test-v2v-print-estimate.sh b/v2v/test-v2v-print-estimate.sh
new file mode 100755
index 000000000..d952d1a37
--- /dev/null
+++ b/v2v/test-v2v-print-estimate.sh
@@ -0,0 +1,47 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2018 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# Test --print-estimate option.
+
+set -e
+
+$TEST_FUNCTIONS
+skip_if_skipped
+skip_unless_phony_guest windows.img
+
+f=test-v2v-print-estimate.out
+rm -f $f
+
+du -s -B 1 ../test-data/phony-guests/windows.img
+
+$VG virt-v2v --debug-gc \
+ -i libvirtxml test-v2v-print-source.xml \
+ -o local -os $(pwd) \
+ --print-estimate --quiet > $f
+
+echo -n "Estimate: "
+cat $f
+
+# Check the output is a single number.
+if [ "$(cat $f | wc -l)" -ne 1 ]; then
+ echo "$0: expecting one line of output"
+ exit 1
+fi
+grep -E '^[[:digit:]]+$' $f
+
+rm -f $f
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 1775200d3..e24a9adf6 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -104,6 +104,12 @@ let rec main () =
(* Decrypt the disks. *)
inspect_decrypt g;
+ (* Print source disk size estimate and stop. *)
+ if cmdline.print_estimate then (
+ print_source_disk_size_estimate cmdline g;
+ exit 0
+ );
+
(* Inspection - this also mounts up the filesystems. *)
(match conversion_mode with
| Copying _ -> message (f_"Inspecting the overlay")
@@ -371,6 +377,48 @@ and print_mpstat chan { mp_dev = dev; mp_path = path;
fprintf chan " bsize=%Ld blocks=%Ld bfree=%Ld bavail=%Ld\n"
s.Guestfs.bsize s.Guestfs.blocks s.Guestfs.bfree s.Guestfs.bavail
+(* Print the estimated size of the source disk(s).
+ *
+ * These are somewhat related to mpstats above, except that
+ * we must also collect information about devices which do
+ * not contain mountable filesystems and so we must assume
+ * are copied completely.
+ *
+ * This function will unmount and mount filesystems
+ * randomly, but that's OK because we exit afterwards.
+ *)
+and print_source_disk_size_estimate cmdline g =
+ let fses = List.map fst (g#list_filesystems ()) in
+
+ let size =
+ List.fold_left (
+ fun size dev ->
+ g#umount_all ();
+ let mounted =
+ try g#mount_ro dev "/"; true
+ with G.Error _ -> false in
+
+ let sz, what =
+ if mounted then (
+ let { Guestfs.bfree; blocks; bsize } = g#statvfs "/" in
+ (blocks -^ bfree) *^ bsize, "filesystem"
+ )
+ else (
+ (* Assume the full size of the filesystem will have
+ * to be copied.
+ *)
+ g#blockdev_getsize64 dev, "device"
+ ) in
+
+ debug "print-estimate: %s %s uses %Ld (%s)"
+ what dev sz (human_size sz);
+ size +^ sz
+ ) 0L fses in
+
+ g#umount_all ();
+
+ printf "%Ld\n" size
+
(* Conversion can fail if there is no space on the guest filesystems
* (RHBZ#1139543). To avoid this situation, check there is some
* headroom. Mainly we care about the root filesystem.
diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod
index 303fe425c..80b765983 100644
--- a/v2v/virt-v2v.pod
+++ b/v2v/virt-v2v.pod
@@ -794,6 +794,23 @@ C<root>.
You will get an error if virt-v2v is unable to mount/write to the
Export Storage Domain.
+=item B<--print-estimate>
+
+Print the estimated size of the data which will be copied from the
+source disk(s) and stop.
+
+A single number is printed on stdout which is the estimated size of
+data that will be copied, in bytes.
+
+This estimate is the sum across all disks, because guest features such
+as LVM and MD means that it is not meaningful to provide separate
+estimates for each disk. The size does not include deleted files and
+empty space in the source, but it cannot detect used-but-zero space
+and so it usually overestimates.
+
+You usually want to use this option in conjunction with the I<--quiet>
+option so that the result is not mixed in with standard messages.
+
=item B<--print-source>
Print information about the source guest and stop. This option is
--
2.18.0
6 years, 3 months
[PATCH v2] v2v: parse_libvirt_xml: number disks from 0
by Pino Toscano
When parsing the libvirt XML, make sure to assign the IDs for disks
(s_disk_id) from 0 instead of 1. This does not change the actual
behaviour, just makes the IDs like in all the other input modes not
based on libvirt XML.
---
v2v/parse_libvirt_xml.ml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/v2v/parse_libvirt_xml.ml b/v2v/parse_libvirt_xml.ml
index 78a6e71c0..dac99511c 100644
--- a/v2v/parse_libvirt_xml.ml
+++ b/v2v/parse_libvirt_xml.ml
@@ -246,7 +246,7 @@ let parse_libvirt_xml ?conn xml =
(* Non-removable disk devices. *)
let disks =
let get_disks, add_disk =
- let disks = ref [] and i = ref 0 in
+ let disks = ref [] and i = ref (-1) in
let get_disks () = List.rev !disks in
let add_disk qemu_uri format controller p_source =
incr i;
--
2.17.1
6 years, 3 months