[PATCH v2] v2v: ova: Don't rely on qemu-img version, test "offset"
by Richard W.M. Jones
v1 -> v2:
- Use 'qemu-img info' which avoids one of the temporary files
(thanks Tomáš).
- Add a unit test.
Unfortunately when I run 'make -C v2v check' I don't think this code
is being run at all, so there may be something else going on here
which I don't understand.
Rich.
7 years, 10 months
[PATCH v3] resize: support non-local output disks (RHBZ#1404182)
by Pino Toscano
Parse the output disk as URI, and use all its attributes just like
it is done for the input disk. The only change is that the fsync of the
output disk is limited now for local URIs only, since it will not work
with remote protocols.
---
resize/resize.ml | 56 ++++++++++++++++++++++++++++++++++----------------
resize/virt-resize.pod | 6 +++---
2 files changed, 41 insertions(+), 21 deletions(-)
diff --git a/resize/resize.ml b/resize/resize.ml
index 19cd8df..2fce9ee 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -315,6 +315,13 @@ read the man page virt-resize(1).
error (f_"error parsing URI '%s'. Look for error messages printed above.")
infile in
+ (* outfile can be a URI. *)
+ let outfile =
+ try (outfile, URI.parse_uri outfile)
+ with Invalid_argument "URI.parse_uri" ->
+ error (f_"error parsing URI '%s'. Look for error messages printed above.")
+ outfile in
+
infile, outfile, align_first, alignment, copy_boot_loader,
deletes,
dryrun, expand, expand_content, extra_partition, format, ignores,
@@ -326,16 +333,25 @@ read the man page virt-resize(1).
let btrfs_available = ref true in
let xfs_available = ref true in
+ (* Add a drive to an handle using the elements of the URI,
+ * and few additional parameters.
+ *)
+ let add_drive_uri (g : Guestfs.guestfs) ?format ?readonly ?cachemode
+ uri =
+ let { URI.path = path; protocol = protocol;
+ server = server; username = username;
+ password = password } = uri in
+ g#add_drive ?format ?readonly ?cachemode
+ ~protocol ?server ?username ?secret:password path
+ in
+
(* Add in and out disks to the handle and launch. *)
let connect_both_disks () =
let g = open_guestfs () in
- let _, { URI.path = path; protocol = protocol;
- server = server; username = username;
- password = password } = infile in
- g#add_drive ?format ~readonly:true ~protocol ?server ?username ?secret:password path;
+ add_drive_uri g ?format (snd infile);
(* The output disk is being created, so use cache=unsafe here. *)
- g#add_drive ?format:output_format ~readonly:false ~cachemode:"unsafe"
- outfile;
+ add_drive_uri g ?format:output_format ~readonly:false ~cachemode:"unsafe"
+ (snd outfile);
if not (quiet ()) then Progress.set_up_progress_bar ~machine_readable g;
g#launch ();
@@ -368,7 +384,7 @@ read the man page virt-resize(1).
let insize = g#blockdev_getsize64 "/dev/sda" in
let outsize = g#blockdev_getsize64 "/dev/sdb" in
debug "%s size %Ld bytes" (fst infile) insize;
- debug "%s size %Ld bytes" outfile outsize;
+ debug "%s size %Ld bytes" (fst outfile) outsize;
sectsize, insize, outsize in
let max_bootloader =
@@ -390,7 +406,7 @@ read the man page virt-resize(1).
(fst infile) insize;
if outsize < Int64.of_int max_bootloader then
error (f_"%s: file is too small to be a disk image (%Ld bytes)")
- outfile outsize;
+ (fst outfile) outsize;
(* Get the source partition type. *)
let parttype, parttype_string =
@@ -983,7 +999,7 @@ read the man page virt-resize(1).
(* Try hard to initialize the partition table. This might involve
* relaunching another handle.
*)
- message (f_"Setting up initial partition table on %s") outfile;
+ message (f_"Setting up initial partition table on %s") (fst outfile);
let last_error = ref "" in
let rec initialize_partition_table g attempts =
@@ -1301,8 +1317,8 @@ read the man page virt-resize(1).
let g = open_guestfs () in
(* The output disk is being created, so use cache=unsafe here. *)
- g#add_drive ?format:output_format ~readonly:false ~cachemode:"unsafe"
- outfile;
+ add_drive_uri g ?format:output_format ~readonly:false ~cachemode:"unsafe"
+ (snd outfile);
if not (quiet ()) then Progress.set_up_progress_bar ~machine_readable g;
g#launch ();
@@ -1378,13 +1394,17 @@ read the man page virt-resize(1).
g#shutdown ();
g#close ();
- (* Because we used cache=unsafe when writing the output file, the
- * file might not be committed to disk. This is a problem if qemu is
- * immediately used afterwards with cache=none (which uses O_DIRECT
- * and therefore bypasses the host cache). In general you should not
- * use cache=none.
- *)
- Fsync.file outfile;
+ (* Try to sync the destination disk only if it is a local file. *)
+ (match outfile with
+ | _, { URI.protocol = (""|"file"); path = path } ->
+ (* Because we used cache=unsafe when writing the output file, the
+ * file might not be committed to disk. This is a problem if qemu is
+ * immediately used afterwards with cache=none (which uses O_DIRECT
+ * and therefore bypasses the host cache). In general you should not
+ * use cache=none.
+ *)
+ Fsync.file path
+ | _ -> ());
if not (quiet ()) then (
print_newline ();
diff --git a/resize/virt-resize.pod b/resize/virt-resize.pod
index 2344056..98c4b10 100644
--- a/resize/virt-resize.pod
+++ b/resize/virt-resize.pod
@@ -121,9 +121,9 @@ Or use L<virsh(1)> vol-create-as to create a libvirt storage volume:
=item 5. Resize
-virt-resize takes two mandatory parameters, the input disk
-(eg. device, file, or a URI to a remote disk) and the output disk.
-The output disk is the one created in the previous step.
+virt-resize takes two mandatory parameters, the input disk and the
+output disk (both can be e.g. a device, a file, or a URI to a remote
+disk). The output disk is the one created in the previous step.
# virt-resize indisk outdisk
--
2.9.3
7 years, 10 months
virt-p2v migration
by cmc
Hi,
I've been trying to migrate a physical host with two disks (the first,
sda, is the OS disk and the second, sdb, is a data disk) into a VM,
and it always fails on the second disk. The first disk, the OS disk,
migrates fine, but when it starts on the second it fails almost
straightaway with the following error:
(0.00/100%)^Mqemu-img: Could not open '/var/tmp/v2vovl811e67.qcow2':
Could not open backing file: Failed to connect socket: Connection
refused
I can't see this backing file, but it may be deleted when the process
fails, as unfortunately it cleans up and deletes not only the
successfully migrated sda and associated files, but I suspect the
second as well. Most of the rest of the log can be seen at:
http://theninthdimension.blogspot.co.uk/2017/02/virt-p2v-error.html
The conversion host has plenty of disk space in the migration path:
the image of sdb is about 700GB, and it has 5TB free.
I can always successfully migrate just sda. I can't just choose sdb as
it needs an OS disk included.
Details of the hosts being migrated: RHEL 5 x86_64
Details of the conversion server: Fedora 23 with
virt-v2v-1.32.10-1.fc23.x86_64, libvirt-1.2.18.4-1.fc23.x86_64
The boot image was created on the conversion host using both Fedora 23
and CentOS 7.3 (both see the same issue)
Any ideas?
Thanks,
Cam
7 years, 10 months
[PATCH v2] resize: support non-local output disks (RHBZ#1404182)
by Pino Toscano
Parse the output disk as URI, and use all its attributes just like
it is done for the input disk. The only change is that the fsync of the
output disk is limited now for local URIs only, since it will not work
with remote protocols.
---
resize/resize.ml | 43 +++++++++++++++++++++++++++++++------------
resize/virt-resize.pod | 6 +++---
2 files changed, 34 insertions(+), 15 deletions(-)
diff --git a/resize/resize.ml b/resize/resize.ml
index 19cd8df..7e16cb5 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -315,6 +315,13 @@ read the man page virt-resize(1).
error (f_"error parsing URI '%s'. Look for error messages printed above.")
infile in
+ (* outfile can be a URI. *)
+ let outfile =
+ try (outfile, URI.parse_uri outfile)
+ with Invalid_argument "URI.parse_uri" ->
+ error (f_"error parsing URI '%s'. Look for error messages printed above.")
+ outfile in
+
infile, outfile, align_first, alignment, copy_boot_loader,
deletes,
dryrun, expand, expand_content, extra_partition, format, ignores,
@@ -333,9 +340,12 @@ read the man page virt-resize(1).
server = server; username = username;
password = password } = infile in
g#add_drive ?format ~readonly:true ~protocol ?server ?username ?secret:password path;
+ let _, { URI.path = path; protocol = protocol;
+ server = server; username = username;
+ password = password } = outfile in
(* The output disk is being created, so use cache=unsafe here. *)
g#add_drive ?format:output_format ~readonly:false ~cachemode:"unsafe"
- outfile;
+ ~protocol ?server ?username ?secret:password path;
if not (quiet ()) then Progress.set_up_progress_bar ~machine_readable g;
g#launch ();
@@ -368,7 +378,7 @@ read the man page virt-resize(1).
let insize = g#blockdev_getsize64 "/dev/sda" in
let outsize = g#blockdev_getsize64 "/dev/sdb" in
debug "%s size %Ld bytes" (fst infile) insize;
- debug "%s size %Ld bytes" outfile outsize;
+ debug "%s size %Ld bytes" (fst outfile) outsize;
sectsize, insize, outsize in
let max_bootloader =
@@ -390,7 +400,7 @@ read the man page virt-resize(1).
(fst infile) insize;
if outsize < Int64.of_int max_bootloader then
error (f_"%s: file is too small to be a disk image (%Ld bytes)")
- outfile outsize;
+ (fst outfile) outsize;
(* Get the source partition type. *)
let parttype, parttype_string =
@@ -983,7 +993,7 @@ read the man page virt-resize(1).
(* Try hard to initialize the partition table. This might involve
* relaunching another handle.
*)
- message (f_"Setting up initial partition table on %s") outfile;
+ message (f_"Setting up initial partition table on %s") (fst outfile);
let last_error = ref "" in
let rec initialize_partition_table g attempts =
@@ -1300,9 +1310,12 @@ read the man page virt-resize(1).
g#close ();
let g = open_guestfs () in
+ let _, { URI.path = path; protocol = protocol;
+ server = server; username = username;
+ password = password } = outfile in
(* The output disk is being created, so use cache=unsafe here. *)
g#add_drive ?format:output_format ~readonly:false ~cachemode:"unsafe"
- outfile;
+ ~protocol ?server ?username ?secret:password path;
if not (quiet ()) then Progress.set_up_progress_bar ~machine_readable g;
g#launch ();
@@ -1378,13 +1391,19 @@ read the man page virt-resize(1).
g#shutdown ();
g#close ();
- (* Because we used cache=unsafe when writing the output file, the
- * file might not be committed to disk. This is a problem if qemu is
- * immediately used afterwards with cache=none (which uses O_DIRECT
- * and therefore bypasses the host cache). In general you should not
- * use cache=none.
- *)
- Fsync.file outfile;
+ (* Try to sync the destination disk only if it is a local file. *)
+ let () =
+ let _, { URI.protocol = protocol; path = path } = outfile in
+ match protocol with
+ | "" | "file" ->
+ (* Because we used cache=unsafe when writing the output file, the
+ * file might not be committed to disk. This is a problem if qemu is
+ * immediately used afterwards with cache=none (which uses O_DIRECT
+ * and therefore bypasses the host cache). In general you should not
+ * use cache=none.
+ *)
+ Fsync.file path
+ | _ -> () in
if not (quiet ()) then (
print_newline ();
diff --git a/resize/virt-resize.pod b/resize/virt-resize.pod
index 2344056..98c4b10 100644
--- a/resize/virt-resize.pod
+++ b/resize/virt-resize.pod
@@ -121,9 +121,9 @@ Or use L<virsh(1)> vol-create-as to create a libvirt storage volume:
=item 5. Resize
-virt-resize takes two mandatory parameters, the input disk
-(eg. device, file, or a URI to a remote disk) and the output disk.
-The output disk is the one created in the previous step.
+virt-resize takes two mandatory parameters, the input disk and the
+output disk (both can be e.g. a device, a file, or a URI to a remote
+disk). The output disk is the one created in the previous step.
# virt-resize indisk outdisk
--
2.9.3
7 years, 10 months
[PATCH v2] fuse: use the configured program name
by Pino Toscano
When initializing FUSE, use the program name as set (either
automatically or manually) in the guestfs handle.
---
lib/fuse.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/fuse.c b/lib/fuse.c
index 0180f8f..98bbc8d 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
@@ -989,8 +989,7 @@ guestfs_impl_mount_local (guestfs_h *g, const char *localmountpoint,
return -1;
/* Create the FUSE 'args'. */
- /* XXX we don't have a program name */
- if (fuse_opt_add_arg (&args, "guestfs_mount_local") == -1) {
+ if (fuse_opt_add_arg (&args, g->program) == -1) {
arg_error:
perrorf (g, _("fuse_opt_add_arg: %s"), localmountpoint);
fuse_opt_free_args (&args);
--
2.9.3
7 years, 10 months
[PATCH v7 0/1] Import directly from OVA tar archive if possible
by Tomáš Golembiovský
v7:
- rebased because patch 1/3 has been pushed
- changes to nsplit have been dropped (2/3)
- addressed Richard's comments, notably the subfolder function was moved to
mllib and renamed to subdirectory
v6:
- just rebase
v5:
- rebase, patches 1,3,5 were merged
- 1/3: we still need to discuss whether to detect compressed discs
- 2/3:
- renamed argument noempty to keep_empty
- tests were not run
- 3/3:
- using JSON module to generate JSON (as suggested by Pino)
- all the other comments raised by Pino
v4:
- rebase to more recent master
- 1/6: using just "quote" instead of "Filename.quote"
- 2/6: reformated block of code according to Richards suggestion
- 4/6: added tests for nsplit
v3: Addressed Pino's comments, namely:
- input_ova.ml
- untar takes list of paths
- renamed untar_partial to untar_metadata
- replaced uggly regex with nsplit
- tests
- test changes are part of the main commit
- renamed test-data/guestfs-hashsums.sh to test-data/test-utils.sh
- renamed qemu_version to qemu_is_version and moved it to
test-data/test-utils.sh
- normalize paths in expect files
v2:
- rewritten the tar invocations, the output processing is now done in
OcaML rather than with a shell code; it turned out to be easier and
more readable than I have feared.
- added QEMU version check
- addressed Pino's comments
- changed tests; the expected result is now based on the QEMU used
during testing
This series is related to the problem of inefficient import of OVA
files. The needed enhancements of QEMU were merged into the codebase and
are available in QEMU 2.8. From there we can use 'size' and
'offset' options in raw driver to tell QEMU to use only subset of a file
as an image.
The patch set is more or less complete. The only outstanding issue is
the missing detection of sparse files inside tar. But this can be done
in a separate patch. As pointed out before I didn't find a way how to
detect that by using the tar tool only and would probably require use of
some external library.
Tomáš Golembiovský (1):
v2v: ova: don't extract files from OVA if it's not needed
mllib/common_utils.ml | 9 +++
mllib/common_utils.mli | 10 +++
mllib/common_utils_tests.ml | 7 ++
test-data/test-utils.sh | 19 +++++
v2v/Makefile.am | 2 +
v2v/input_ova.ml | 109 +++++++++++++++++++++----
v2v/test-v2v-i-ova-formats.sh | 5 +-
v2v/test-v2v-i-ova-subfolders.expected2 | 18 +++++
v2v/test-v2v-i-ova-subfolders.sh | 13 ++-
v2v/test-v2v-i-ova-tar.expected | 18 +++++
v2v/test-v2v-i-ova-tar.expected2 | 18 +++++
v2v/test-v2v-i-ova-tar.ovf | 138 ++++++++++++++++++++++++++++++++
v2v/test-v2v-i-ova-tar.sh | 72 +++++++++++++++++
v2v/test-v2v-i-ova-two-disks.expected2 | 19 +++++
v2v/test-v2v-i-ova-two-disks.sh | 13 ++-
v2v/utils.ml | 72 +++++++++++++++++
v2v/utils.mli | 12 +++
17 files changed, 530 insertions(+), 24 deletions(-)
create mode 100644 v2v/test-v2v-i-ova-subfolders.expected2
create mode 100644 v2v/test-v2v-i-ova-tar.expected
create mode 100644 v2v/test-v2v-i-ova-tar.expected2
create mode 100644 v2v/test-v2v-i-ova-tar.ovf
create mode 100755 v2v/test-v2v-i-ova-tar.sh
create mode 100644 v2v/test-v2v-i-ova-two-disks.expected2
--
2.11.0
7 years, 10 months
[nbdkit PATCH 0/2] Ruby bindings for .zero
by Eric Blake
Similar to python and perl. But MUCH easier (especially considering
that this is the first time I've every tried to run Ruby). I even
had fun making set_error() polymorphic.
Eric Blake (2):
ruby: Expose nbdkit_set_error to ruby script
ruby: Support zero callback
plugins/ruby/example.rb | 11 ++++++++
plugins/ruby/nbdkit-ruby-plugin.pod | 54 +++++++++++++++++++++++++++++++++----
plugins/ruby/ruby.c | 51 +++++++++++++++++++++++++++++++++++
3 files changed, 111 insertions(+), 5 deletions(-)
--
2.9.3
7 years, 10 months