Laszlo Ersek
2022-Apr-08 13:16 UTC
[Libguestfs] [v2v PATCH] input_vmx: cleanly reject guests with snapshots when using "-it ssh"
For traversing a backing chain of VMDK descriptor files over ssh, two
things are necessary:
- qemu-nbd with the ssh block driver, rather than nbdkit-ssh-plugin,
- a remote SSH URL (for qemu-nbd) without a query string appended, as
qemu-nbd cannot update the last pathname component (for tracking the
relative pathnames of VMDK descriptor files) if a query string is
appended.
Before commit 7a6f6113a25f ("v2v: -i vmx -it ssh: Replace qemu block ssh
driver with nbdkit-ssh-plugin.", 2019-10-08), we passed the
"?host_key_check=no" query string in the URL to qemu-nbd, so we
can't just
return to that, for accessing snapshotted guests with vmx+ssh.
But, we shouldn't return to qemu-nbd for vmx+ssh even without a query
string, as that would undo the other benefit(s) of commit 7a6f6113a25f.
Instead, clearly document that snapshotted guests are not supported over
vmx+ssh, and cleanly reject this situation in the code as well. Recommend
the two alternative transports that allow the user to convert such guests.
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1774386
Signed-off-by: Laszlo Ersek <lersek at redhat.com>
---
input/input_vmx.ml | 23 +++++---------------
docs/virt-v2v-input-vmware.pod | 9 +++++++-
2 files changed, 14 insertions(+), 18 deletions(-)
diff --git a/input/input_vmx.ml b/input/input_vmx.ml
index 9921419b5a85..a22ea288b4a7 100644
--- a/input/input_vmx.ml
+++ b/input/input_vmx.ml
@@ -81,23 +81,12 @@ module VMX = struct
let vmx_path = path_of_uri uri in
let abs_path = absolute_path_from_other_file vmx_path filename in
- let format = "vmdk" in
+ let flat_vmdk = PCRE.replace (PCRE.compile "\\.vmdk$")
+ "-flat.vmdk" abs_path in
- (* XXX This is a hack to work around qemu / VMDK limitation
- * "Cannot use relative extent paths with VMDK descriptor
file"
- * We can remove this if the above is fixed.
- *)
- let abs_path, format - let flat_vmdk -
PCRE.replace (PCRE.compile "\\.vmdk$") "-flat.vmdk" abs_path
in
- if remote_file_exists uri flat_vmdk then (flat_vmdk,
"raw")
- else (abs_path, format) in
-
- (* XXX In virt-v2v 1.42+ importing from VMX over SSH
- * was broken if the -flat.vmdk file did not exist.
- * It is still broken here.
- *)
- ignore format;
+ (* RHBZ#1774386 *)
+ if not (remote_file_exists uri flat_vmdk) then
+ failwith "this transport does not support guests with
snapshots";
let server = server_of_uri uri in
let port = Option.map string_of_int (port_of_uri uri) in
@@ -110,7 +99,7 @@ module VMX = struct
let cor = dir // "convert" in
let bandwidth = options.bandwidth in
let nbdkit = Nbdkit_ssh.create_ssh ?bandwidth ~cor ~password
- ~server ?port ?user abs_path in
+ ~server ?port ?user flat_vmdk in
let _, pid = Nbdkit.run_unix socket nbdkit in
On_exit.kill pid
) filenames
diff --git a/docs/virt-v2v-input-vmware.pod b/docs/virt-v2v-input-vmware.pod
index 2c90e0afc7cd..468d1ce06224 100644
--- a/docs/virt-v2v-input-vmware.pod
+++ b/docs/virt-v2v-input-vmware.pod
@@ -51,6 +51,11 @@ to ESXi to read the F<GUEST.vmx> file and associated
disks. This
requires that you have enabled SSH access to the VMware ESXi
hypervisor - in the default ESXi configuration this is turned off.
+Note that when using this transport, a guest that has snapshots present
+on the ESXi hypervisor cannot be converted. For such guests, use
+just B<-i vmx> (above), or B<-ic vpx://...> B<-it vddk> or
+B<-ic esx://...> B<-it vddk> (below).
+
=item B<-ic vpx://...> B<-it vddk>
=item B<-ic esx://...> B<-it vddk>
@@ -106,7 +111,9 @@ a C</vmfs/volumes> folder containing the virtual
machines.
If you find a folder of files called F<I<guest>.vmx>,
F<I<guest>.vmxf>, F<I<guest>.nvram> and one or more
F<.vmdk> disk
-images, then you can use this method.
+images, then you can use this method. The SSH transport is not usable
+if the guest has snapshots (files called F<I<guest>-000001.vmdk>
and
+similar); refer to L<https://bugzilla.redhat.com/1774386>.
=head2 VMX: Guest must be shut down
--
2.19.1.3.g30247aa5d201
Richard W.M. Jones
2022-Apr-08 14:55 UTC
[Libguestfs] [v2v PATCH] input_vmx: cleanly reject guests with snapshots when using "-it ssh"
On Fri, Apr 08, 2022 at 03:16:39PM +0200, Laszlo Ersek wrote:> + (* RHBZ#1774386 *) > + if not (remote_file_exists uri flat_vmdk) then > + failwith "this transport does not support guests with snapshots";This message isn't translated; use error (f_"...") Also, it's better to have an actionable error message (that is, tell the user not only what the problem is, but guide them to information to fix it). I really hate error messages that have some jargon and tell me nothing about what I need to do now. Something like: error (f_"this transport does not support guests with snapshots. \ Either collapse the snapshots for this guest and try the \ conversion again, or use one of the alternate conversion \ methods described in virt-v2v-input-vmware(1) section \ \"NOTES\".") and then ...> diff --git a/docs/virt-v2v-input-vmware.pod b/docs/virt-v2v-input-vmware.pod > index 2c90e0afc7cd..468d1ce06224 100644 > --- a/docs/virt-v2v-input-vmware.pod > +++ b/docs/virt-v2v-input-vmware.pod > @@ -51,6 +51,11 @@ to ESXi to read the F<GUEST.vmx> file and associated disks. This > requires that you have enabled SSH access to the VMware ESXi > hypervisor - in the default ESXi configuration this is turned off. > > +Note that when using this transport, a guest that has snapshots present > +on the ESXi hypervisor cannot be converted. For such guests, use > +just B<-i vmx> (above), or B<-ic vpx://...> B<-it vddk> or > +B<-ic esx://...> B<-it vddk> (below). > > =item B<-ic vpx://...> B<-it vddk> > > =item B<-ic esx://...> B<-it vddk> > @@ -106,7 +111,9 @@ a C</vmfs/volumes> folder containing the virtual machines. > > If you find a folder of files called F<I<guest>.vmx>, > F<I<guest>.vmxf>, F<I<guest>.nvram> and one or more F<.vmdk> disk > -images, then you can use this method. > +images, then you can use this method. The SSH transport is not usable > +if the guest has snapshots (files called F<I<guest>-000001.vmdk> and > +similar); refer to L<https://bugzilla.redhat.com/1774386>.My suggestion is to add a new NOTES section -- to make it easy to find, just after the DESCRIPTION section and before the INPUT FROM VMWARE VMX section. In this you can talk about snapshots and which methods won't and will work. Then reference the new section from the error message and from the hunks above. The patch itself is fine otherwise. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW