101 lines
3.9 KiB
Diff
101 lines
3.9 KiB
Diff
|
From f3180e3c0ef59ab52983903ff806014a4a3171a5 Mon Sep 17 00:00:00 2001
|
||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||
|
Date: Tue, 18 Jan 2022 12:37:51 +0000
|
||
|
Subject: [PATCH] input: xen: Fix assertion error when importing from remote
|
||
|
block device
|
||
|
|
||
|
We never supported this because OpenSSH sftp server does not know how
|
||
|
to open and get the size of a block device. Before modular virt-v2v,
|
||
|
we would detect this situation and print an error:
|
||
|
|
||
|
virt-v2v: error: guest disk sda appears to be zero bytes in size.
|
||
|
|
||
|
There could be several reasons for this:
|
||
|
|
||
|
Check that the guest doesn't really have a zero-sized disk. virt-v2v
|
||
|
cannot convert such a guest.
|
||
|
|
||
|
If you are converting a guest from an ssh source and the guest has a disk
|
||
|
on a block device (eg. on a host partition or host LVM LV), then
|
||
|
conversions of this type are not supported. See the virt-v2v-input-xen(1)
|
||
|
manual for a workaround.
|
||
|
|
||
|
This error was lost in the conversion to modularity, but in any case
|
||
|
the proper way to detect this is in the input_xen driver itself.
|
||
|
|
||
|
In addition to this, when we removed the old virt-v2v-copy-to-local
|
||
|
tool, the text referring to the workaround in the manual became
|
||
|
meaningless, so I added the (ugly, manual) workaround that you have to
|
||
|
do back into the manual, minus the bit about the tool that we removed.
|
||
|
|
||
|
In future we could consider other ways to convert a remote block
|
||
|
device over SSH transparently. (Sending a "dd" command, maybe?)
|
||
|
|
||
|
I also checked what happens when we try to convert an empty disk, and
|
||
|
it fails during inspection with a reasonable error message, so we
|
||
|
don't need to do anything to restore the above error:
|
||
|
|
||
|
$ virt-v2v -i disk /var/tmp/empty -o null
|
||
|
[ 1.1] Opening the source
|
||
|
[ 7.0] Inspecting the source
|
||
|
virt-v2v: error: inspection could not detect the source guest (or physical
|
||
|
machine).
|
||
|
|
||
|
Assuming that you are running virt-v2v/virt-p2v on a source which is
|
||
|
supported (and not, for example, a blank disk), then this should not
|
||
|
happen.
|
||
|
|
||
|
No root device found in this operating system image.
|
||
|
|
||
|
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2041852
|
||
|
Reported-by: Xiaodai Wang
|
||
|
---
|
||
|
docs/virt-v2v-input-xen.pod | 5 +++++
|
||
|
input/input_xen_ssh.ml | 12 +++++++++++-
|
||
|
2 files changed, 16 insertions(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/docs/virt-v2v-input-xen.pod b/docs/virt-v2v-input-xen.pod
|
||
|
index 857a7095..c4948e5e 100644
|
||
|
--- a/docs/virt-v2v-input-xen.pod
|
||
|
+++ b/docs/virt-v2v-input-xen.pod
|
||
|
@@ -99,6 +99,11 @@ This happens because the qemu ssh block driver that we use to access
|
||
|
remote disks uses the ssh sftp protocol, and this protocol cannot
|
||
|
correctly detect the size of host block devices.
|
||
|
|
||
|
+The workaround is to copy the block device from the remote Xen
|
||
|
+server to a regular local file, copy the libvirt guest XML,
|
||
|
+adjust the C<disk> element to point to the local file, and use
|
||
|
+C<-i libvirtxml> mode instead.
|
||
|
+
|
||
|
=head1 SEE ALSO
|
||
|
|
||
|
L<virt-v2v(1)>.
|
||
|
diff --git a/input/input_xen_ssh.ml b/input/input_xen_ssh.ml
|
||
|
index 5bb46bde..cb8b1f91 100644
|
||
|
--- a/input/input_xen_ssh.ml
|
||
|
+++ b/input/input_xen_ssh.ml
|
||
|
@@ -87,9 +87,19 @@ let rec xen_ssh_source dir options args =
|
||
|
On_exit.unlink socket;
|
||
|
|
||
|
match d_type with
|
||
|
- | BlockDev _ | NBD _ | HTTP _ -> (* These should never happen? *)
|
||
|
+ | NBD _ | HTTP _ -> (* These should never happen? *)
|
||
|
assert false
|
||
|
|
||
|
+ | BlockDev _ ->
|
||
|
+ (* Conversion from a remote block device over SSH isn't
|
||
|
+ * supported because OpenSSH sftp server doesn't know how
|
||
|
+ * to get the size of a block device. Therefore we disallow
|
||
|
+ * this and refer users to the manual.
|
||
|
+ *)
|
||
|
+ error (f_"input from xen over ssh does not support disks stored on \
|
||
|
+ remote block devices. See virt-v2v-input-xen(1) \
|
||
|
+ section \"Xen or ssh conversions from block devices\".")
|
||
|
+
|
||
|
| LocalFile path ->
|
||
|
let cor = dir // "convert" in
|
||
|
let bandwidth = options.bandwidth in
|
||
|
--
|
||
|
2.31.1
|
||
|
|