=head1 NAME

virt-v2v-input-xen - Using virt-v2v to convert guests from Xen

=head1 SYNOPSIS

 virt-v2v -ic 'xen+ssh://root@xen.example.com'
          -ip passwordfile
          GUEST_NAME [-o* options]

=head1 DESCRIPTION

This page documents how to use L<virt-v2v(1)> to convert guests from
RHEL 5 Xen, or SLES and OpenSUSE Xen hosts.

=head1 INPUT FROM XEN

=head2 SSH authentication

You can use SSH password authentication, by supplying the name of a
file containing the password to the I<-ip> option (note this option
does I<not> take the password directly).  You may need to adjust
F</etc/ssh/sshd_config> on the Xen server to set
C<PasswordAuthentication yes>.

If you are not using password authentication, an alternative is to use
ssh-agent, and add your ssh public key to
F</root/.ssh/authorized_keys> (on the Xen host).  After doing this,
you should check that passwordless access works from the virt-v2v
server to the Xen host.  For example:

 $ ssh root@xen.example.com
 [ logs straight into the shell, no password is requested ]

Note that support for non-interactive authentication via the I<-ip>
option is incomplete.  Some operations remain that still require the
user to enter the password manually.  Therefore ssh-agent is recommended
over the I<-ip> option.  See L<https://bugzilla.redhat.com/1854275>.

With some modern ssh implementations, legacy crypto algorithms required
to interoperate with RHEL 5 sshd are disabled.  To enable them, you may
need to add the following C<Host> stanza to your F<~/.ssh/config>:

 Host xen.example.com
   KexAlgorithms            +diffie-hellman-group14-sha1
   MACs                     +hmac-sha1
   HostKeyAlgorithms        +ssh-rsa
   PubkeyAcceptedKeyTypes   +ssh-rsa
   PubkeyAcceptedAlgorithms +ssh-rsa

(C<PubkeyAcceptedKeyTypes> and C<PubkeyAcceptedAlgorithms> have
identical meaning; the former is the old option name, the latter is the
new one. Virt-v2v uses both C<libssh> and C<ssh> when converting a guest
from Xen, and on some operating systems, C<libssh> and C<ssh> may not
both accept the same option variant.)

When connecting to RHEL 5 sshd from RHEL 9, the SHA1 algorithm's use in
signatures has to be re-enabled at the OpenSSL level, in addition to the
above SSH configuration.  Create a file called F<$HOME/openssl-sha1.cnf>
with the following contents:

 .include /etc/ssl/openssl.cnf
 [openssl_init]
 alg_section = evp_properties
 [evp_properties]
 rh-allow-sha1-signatures = yes

and export the following variable into the environment of the
C<virt-v2v> process:

 OPENSSL_CONF=$HOME/openssl-sha1.cnf

Note that the C<OPENSSL_CONF> environment variable will only take effect
if the libvirt client library used by virt-v2v is at least version
8.6.0.

=head2 Test libvirt connection to remote Xen host

Use the L<virsh(1)> command to list the guests on the remote Xen host:

 $ virsh -c xen+ssh://root@xen.example.com list --all
  Id    Name                           State
 ----------------------------------------------------
  0     Domain-0                       running
  -     rhel49-x86_64-pv               shut off

You should also try dumping the metadata from any guest on your
server, like this:

 $ virsh -c xen+ssh://root@xen.example.com dumpxml rhel49-x86_64-pv
 <domain type='xen'>
   <name>rhel49-x86_64-pv</name>
   [...]
 </domain>

B<If the above commands do not work, then virt-v2v is not going to
work either>.  Fix your libvirt configuration or the remote server
before continuing.

B<If the guest disks are located on a host block device>, then the
conversion will fail.  See L</Xen or ssh conversions from block devices>
below for a workaround.

=head2 Importing a guest

To import a particular guest from a Xen server, do:

 $ virt-v2v -ic 'xen+ssh://root@xen.example.com' \
           rhel49-x86_64-pv \
           -o local -os /var/tmp

where C<rhel49-x86_64-pv> is the name of the guest (which must be shut
down).

In this case the output flags are set to write the converted guest to
a temporary directory as this is just an example, but you can also
write to libvirt or any other supported target.

=head2 Xen or ssh conversions from block devices

Currently virt-v2v cannot directly access a Xen guest (or any guest
located remotely over ssh) if that guest’s disks are located on host
block devices.

To tell if a Xen guest uses host block devices, look at the guest XML.
You will see:

  <disk type='block' device='disk'>
    ...
    <source dev='/dev/VG/guest'/>

where C<type='block'>, C<source dev=> and C</dev/...> are all
indications that the disk is located on a host block device.

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)>.

=head1 AUTHOR

Richard W.M. Jones

=head1 COPYRIGHT

Copyright (C) 2009-2025 Red Hat Inc.
