virt-v2v (1) Linux Manual Page
NAME
virt-v2v – Convert a guest to use KVM
SYNOPSIS
virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi vmware_guest virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi vmware_guest \ -o rhev -os rhev.nfs:/export_domain --network rhevm virt-v2v -i libvirtxml guest-domain.xml -o local -os /var/tmp virt-v2v -i disk disk.img -o local -os /var/tmp virt-v2v -i disk disk.img -o glance
DESCRIPTION
Virt-v2v converts guests from a foreign hypervisor to run on KVM. It can read Linux and Windows guests running on VMware, Xen, Hyper-V and some other hypervisors, and convert them to KVM managed by libvirt, OpenStack, oVirt, Red Hat Enterprise Virtualisation (RHEV) or several other targets.
There is also a companion front-end called virt-p2v(1) which comes as an ISO, CD or PXE image that can be booted on physical machines to virtualize those machines (physical to virtual, or p2v).
This manual page documents the rewritten virt-v2v included in libguestfs ≥ 1.28.
INPUT AND OUTPUT MODES
┌────────────┐ ┌─────────▶ -o null
-i disk ────────────┐ │ │ ─┘┌───────▶ -o local
-i ova ──────────┐ └──▶ │ virt-v2v │ ──┘┌───────▶ -o qemu
└────▶ │ conversion │ ───┘┌────────────┐
VMware─▶┌────────────┐ │ server │ ────▶ -o libvirt │─▶ KVM
Xen ───▶│ -i libvirt ──▶ │ │ │ (default) │
... ───▶│ (default) │ │ │ ──┐ └────────────┘
└────────────┘ │ │ ─┐└──────▶ -o glance
-i libvirtxml ─────────▶ │ │ ┐└─────────▶ -o rhev
└────────────┘ └──────────▶ -o vdsm
Virt-v2v has a number of possible input and output modes, selected using the -i and -o options. Only one input and output mode can be selected for each run of virt-v2v.
-i disk is used for reading from local disk images (mainly for testing).
-i libvirt is used for reading from any libvirt source. Since libvirt can connect to many different hypervisors, it is used for reading guests from VMware, RHEL 5 Xen and more. The -ic option selects the precise libvirt source.
-i libvirtxml is used to read from libvirt XML files. This is the method used by virt-p2v(1) behind the scenes.
-i ova is used for reading from a VMware ova source file.
-o glance is used for writing to OpenStack Glance.
-o libvirt is used for writing to any libvirt target. Libvirt can connect to local or remote KVM hypervisors. The -oc option selects the precise libvirt target.
-o local is used to write to a local disk image with a local libvirt configuration file (mainly for testing).
-o qemu writes to a local disk image with a shell script for booting the guest directly in qemu (mainly for testing).
-o rhev is used to write to a RHEV-M / oVirt target. -o vdsm is only used when virt-v2v runs under VDSM control.
EXAMPLES
Convert from VMware vCenter server to local libvirt
You have a VMware vCenter server called "vcenter.example.com", a datacenter called "Datacenter", and an ESXi hypervisor called "esxi". You want to convert a guest called "vmware_guest" to run locally under libvirt.
virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi vmware_guest
In this case you will most likely have to run virt-v2v as "root", since it needs to talk to the system libvirt daemon and copy the guest disks to /var/lib/libvirt/images.
For more information see “INPUT FROM VMWARE VCENTER SERVER” below.
Convert from VMware to RHEV-M/oVirt
This is the same as the previous example, except you want to send the guest to a RHEV-M Export Storage Domain which is located remotely (over NFS) at "rhev.nfs:/export_domain". If you are unclear about the location of the Export Storage Domain you should check the settings on your RHEV-M management console. Guest network interface(s) are connected to the target network called "rhevm".
virt-v2v -ic vpx://vcenter.example.com/Datacenter/esxi vmware_guest \ -o rhev -os rhev.nfs:/export_domain --network rhevm
In this case the host running virt-v2v acts as a conversion server.
Note that after conversion, the guest will appear in the RHEV-M Export Storage Domain, from where you will need to import it using the RHEV-M user interface. (See “OUTPUT TO RHEV”).
Convert disk image to OpenStack glance
Given a disk image from another hypervisor that you want to convert to run on OpenStack (only KVM-based OpenStack is supported), you can do:
virt-v2v -i disk disk.img -o glance
See “OUTPUT TO GLANCE” below.
Convert disk image to disk image
Given a disk image from another hypervisor that you want to convert to run on KVM, you have two options. The simplest way is to try:
virt-v2v -i disk disk.img -o local -os /var/tmp
where virt-v2v guesses everything about the input disk.img and (in this case) writes the converted result to /var/tmp.
A more complex method is to write some libvirt XML describing the input guest (if you can get the source hypervisor to provide you with libvirt XML, then so much the better). You can then do:
virt-v2v -i libvirtxml guest-domain.xml -o local -os /var/tmp
Since guest-domain.xml contains the path(s) to the guest disk image(s) you do not need to specify the name of the disk image on the command line.
OPTIONS
–help- Display help.
-b…–bridge…- See –network below.
–colors–colours- Use ANSI colour sequences to colourize messages. This is the default when the output is a tty. If the output of the program is redirected to a file, ANSI colour sequences are disabled unless you use this option.
–compressed- Write a compressed output file. This is only allowed if the output format is qcow2 (see -of below), and is equivalent to the -c option of qemu-img(1).
–debug-gc- Debug garbage collection and memory allocation. This is only useful when debugging memory problems in virt-v2v or the OCaml libguestfs bindings.
–debug-overlays- Save the overlay file(s) created during conversion. This option is only used for debugging virt-v2v and may be removed in a future version.
-i disk- Set the input method to disk.
In this mode you can read a virtual machine disk image with no metadata. virt-v2v tries to guess the best default metadata. This is usually adequate but you can get finer control (eg. of memory and vCPUs) by using -i libvirtxml instead. Only guests that use a single disk can be imported this way.
-i libvirt- Set the input method to libvirt. This is the default.
In this mode you have to specify a libvirt guest name or UUID on the command line. You may also specify a libvirt connection URI (see -ic).
-i libvirtxml- Set the input method to libvirtxml.
In this mode you have to pass a libvirt XML file on the command line. This file is read in order to get metadata about the source guest (such as its name, amount of memory), and also to locate the input disks. See “MINIMAL XML FOR -i libvirtxml OPTION” below.
-i local- This is the same as -i disk.
-i ova- Set the input method to ova.
In this mode you can read a VMware ova file. Virt-v2v will read the ova manifest file and check the vmdk volumes for validity (checksums) as well as analyzing the ovf file, and then convert the guest. See “INPUT FROM VMWARE OVA” below
-iclibvirtURI- Specify a libvirt connection URI to use when reading the guest. This is only used when -i libvirt.
Only local libvirt connections, VMware vCenter connections, or RHEL 5 Xen remote connections can be used. Other remote libvirt connections will not work in general.
See also “INPUT FROM VMWARE VCENTER SERVER”, “INPUT FROM RHEL 5 XEN” below.
-ifformat- For -i disk only, this specifies the format of the input disk image. For other input methods you should specify the input format in the metadata.
–machine-readable- This option is used to make the output more machine friendly when being parsed by other programs. See “MACHINE READABLE OUTPUT” below.
-nin:out-nout–networkin:out–networkout-bin:out-bout–bridgein:out–bridgeout- Map network (or bridge) called "in" to network (or bridge) called "out". If no "in:" prefix is given, all other networks (or bridges) are mapped to "out".
See “NETWORKS AND BRIDGES” below.
–no-copy- Don’t copy the disks. Instead, conversion is performed (and thrown away), and metadata is written, but no disks are created. See also discussion of -o null below.
This is useful in two cases: Either you want to test if conversion is likely to succeed, without the long copying process. Or you are only interested in looking at the metadata.
This option is not compatible with -o libvirt since it would create a faulty guest (one with no disks).
This option is not compatible with -o glance for technical reasons.
–no-trim all–no-trimmp[,mp…]- By default virt-v2v runs fstrim(8) to reduce the amount of data that needs to be copied. This is known to break some buggy bootloaders causing boot failures after conversion (see for example https://bugzilla.redhat.com/show_bug.cgi?id=1141145#c27).
You can use –no-trim all to disable all trimming. Note this will greatly increase the amount of data that has to be copied and can make virt-v2v run much more slowly.
You can also disable trimming on selected filesystems only (specified by a comma-separated list of their mount point(s) in the guest). Typically you would use –no-trim /boot to work around the grub bug mentioned above.
You can also disable trimming on partitions using the libguestfs naming scheme for devices, eg: –no-trim /dev/sdb2 means do not trim the second partition on the second block device. Use virt-filesystems(1) to list filesystem names in a guest.
-o disk- This is the same as -o local.
-o glance- Set the output method to OpenStack Glance. In this mode the converted guest is uploaded to Glance. See “OUTPUT TO GLANCE” below.
-o libvirt- Set the output method to libvirt. This is the default.
In this mode, the converted guest is created as a libvirt guest. You may also specify a libvirt connection URI (see -oc).
See “OUTPUT TO LIBVIRT” below.
-o local- Set the output method to local.
In this mode, the converted guest is written to a local directory specified by -os /dir (the directory must exist). The converted guest’s disks are written as:
/dir/name-sda /dir/name-sdb [etc]
and a libvirt XML file is created containing guest metadata:
/dir/name.xml
where "name" is the guest name.
-o null- Set the output method to null.
The guest is converted and copied (unless you also specify –no-copy), but the results are thrown away and no metadata is written.
-o ovirt- This is the same as -o rhev.
-o qemu- Set the output method to qemu.
This is similar to -o local, except that a shell script is written which you can use to boot the guest in qemu. The converted disks and shell script are written to the directory specified by -os.
-o rhev- Set the output method to rhev.
The converted guest is written to a RHEV Export Storage Domain. The -os parameter must also be used to specify the location of the Export Storage Domain. Note this does not actually import the guest into RHEV. You have to do that manually later using the UI.
See “OUTPUT TO RHEV” below.
-o vdsm- Set the output method to vdsm.
This mode is similar to -o rhev, but the full path to the data domain must be given: /rhev/data-center/<data-center-uuid>/<data-domain-uuid>. This mode is only used when virt-v2v runs under VDSM control.
-oa sparse-oa preallocated- Set the output file allocation mode. The default is "sparse".
-oclibvirtURI- Specify a libvirt connection to use when writing the converted guest. This is only used when -o libvirt. See “OUTPUT TO LIBVIRT” below.
Only local libvirt connections can be used. Remote libvirt connections will not work.
-offormat- When converting the guest, convert the disks to the given format.
If not specified, then the input format is used.
-onname- Rename the guest when converting it. If this option is not used then the output name is the same as the input name.
-osstorage- The location of the storage for the converted guest.
For -o libvirt, this is a libvirt directory pool (see "virsh pool-list") or pool UUID.
For -o local and -o qemu, this is a directory name. The directory must exist.
For -o rhev, this can be an NFS path of the Export Storage Domain of the form "<host>:<path>", eg:
rhev-storage.example.com:/rhev/export
The NFS export must be mountable and writable by the user and host running virt-v2v, since the virt-v2v program has to actually mount it when it runs. So you probably have to run virt-v2v as "root".
Or:You can mount the Export Storage Domain yourself, and point -os to the mountpoint. Note that virt-v2v will still need to write to this remote directory, so virt-v2v will still need to run as "root".You will get an error if virt-v2v is unable to mount/write to the Export Storage Domain.
–password-filefile- Instead of asking for password(s) interactively, pass the password through a file. Note the file should contain the whole password,
without any trailing newline, and for security the file should have mode 0600 so that others cannot read it. –print-source- Print information about the source guest and stop. This option is useful when you are setting up network and bridge maps. See “NETWORKS AND BRIDGES”.
-q–quiet- This disables progress bars and other unnecessary output.
–root ask–root single–root first–root/dev/sdX–root/dev/VG/LV- Choose the root filesystem to be converted.
In the case where the virtual machine is dual-boot or multi-boot, or where the VM has other filesystems that look like operating systems, this option can be used to select the root filesystem (a.k.a. "C:" drive or /) of the operating system that is to be converted. The Windows Recovery Console, certain attached DVD drives, and bugs in libguestfs inspection heuristics, can make a guest look like a multi-boot operating system.
The default in virt-v2v ≤ 0.7.1 was –root single, which causes virt-v2v to die if a multi-boot operating system is found.
Since virt-v2v ≥ 0.7.2 the default is now –root ask: If the VM is found to be multi-boot, then virt-v2v will stop and list the possible root filesystems and ask the user which to use. This requires that virt-v2v is run interactively.
–root first means to choose the first root device in the case of a multi-boot operating system. Since this is a heuristic, it may sometimes choose the wrong one.
You can also name a specific root device, eg. –root /dev/sda2 would mean to use the second partition on the first hard drive. If the named root device does not exist or was not detected as a root device, then virt-v2v will fail.
Note that there is a bug in grub which prevents it from successfully booting a multiboot system if VirtIO is enabled. Grub is only able to boot an operating system from the first VirtIO disk. Specifically, /boot must be on the first VirtIO disk, and it cannot chainload an OS which is not in the first VirtIO disk.
–vdsm-compat=0.10–vdsm-compat=1.1- If -o vdsm and the output format is qcow2, then we add the qcow2 compat=0.10 option to the output file for compatibility with RHEL 6 (see https://bugzilla.redhat.com/1145582).
If –vdsm-compat=1.1 is used then modern qcow2 (compat=1.1) files are generated instead.
Currently –vdsm-compat=0.10 is the default, but this will change to –vdsm-compat=1.1 in a future version of virt-v2v (when we can assume that everyone is using a modern version of qemu).
Note this option only affects-o vdsmoutput. All other output modes (including -o rhev) generate modern qcow2 compat=1.1 files, always. –vdsm-image-uuidUUID–vdsm-vol-uuidUUID–vdsm-vm-uuidUUID–vdsm-ovf-output- Normally the RHEV output mode chooses random UUIDs for the target guest. However VDSM needs to control the UUIDs and passes these parameters when virt-v2v runs under VDSM control. The parameters control:
-
- •
- the image directory of each guest disk (–vdsm-image-uuid) (this option is passed once for each guest disk)
- •
- UUIDs for each guest disk (–vdsm-vol-uuid) (this option is passed once for each guest disk)
- •
- the OVF file name (–vdsm-vm-uuid).
- •
- the OVF output directory (default current directory) (–vdsm-ovf-output).
-
The format of UUIDs is: "12345678-1234-1234-1234-123456789abc" (each hex digit can be "0-9" or "a-f"), conforming to OSF DCE 1.1.
These options can only be used with -o vdsm.
-v–verbose- Enable verbose messages for debugging.
-V–version- Display version number and exit.
–vmtype desktop–vmtype server- For the -o rhev or -o vdsm targets only, specify the type of guest. You can set this to "desktop" or "server". If the option is not given, then a suitable default is chosen based on the detected guest operating system.
-x- Enable tracing of libguestfs API calls.
XEN PARAVIRTUALIZED GUESTS
Older versions of virt-v2v could turn a Xen paravirtualized (PV) guest into a KVM guest by installing a new kernel. This version of virt-v2v does not attempt to install any new kernels. Instead it will give you an error if there are only Xen PV kernels available.
Therefore before conversion you should check that a regular kernel is installed. For some older Linux distributions, this means installing a kernel from the table below:
RHEL 3 (Does not apply, as there was no Xen PV kernel)
RHEL 4 i686 with > 10GB of RAM: install 'kernel-hugemem'
i686 SMP: install 'kernel-smp'
other i686: install 'kernel'
x86-64 SMP with > 8 CPUs: install 'kernel-largesmp'
x86-64 SMP: install 'kernel-smp'
other x86-64: install 'kernel'
RHEL 5 i686: install 'kernel-PAE'
x86-64: install 'kernel'
SLES 10 i586 with > 10GB of RAM: install 'kernel-bigsmp'
i586 SMP: install 'kernel-smp'
other i586: install 'kernel-default'
x86-64 SMP: install 'kernel-smp'
other x86-64: install 'kernel-default'
SLES 11+ i586: install 'kernel-pae'
x86-64: install 'kernel-default'
Windows (Does not apply, as there is no Xen PV Windows kernel)
ENABLING VIRTIO
“Virtio” is the name for a set of drivers which make disk (block device), network and other guest operations work much faster on KVM.
Older versions of virt-v2v could install these drivers for certain Linux guests. This version of virt-v2v does not attempt to install new Linux kernels or drivers, but will warn you if they are not installed already.
In order to enable virtio, and hence improve performance of the guest after conversion, you should ensure that the minimum versions of packages are installed before conversion, by consulting the table below.
RHEL 3 No virtio drivers are available
RHEL 4 kernel >= 2.5.9 - 89.EL lvm2 >=
2.02.42 - 5.el4 device - mapper >= 1.02.28 - 2.el4 selinux - policy - targeted >= 1.17.30 - 2.152.el4 policycoreutils >= 1.18.1 - 4.13
RHEL 5 kernel >=
2.6.18 - 128.el5 lvm2 >= 2.02.40 - 6.el5 selinux - policy - targeted >= 2.4.6 - 203.el5
RHEL 6 +
All versions support virtio
Fedora All versions support virtio
SLES 11 +
All versions support virtio
SLES 10 kernel >=
2.6.16.60 - 0.85.1
OpenSUSE 11 +
All versions support virtio
OpenSUSE 10 kernel >=
2.6.25.5 - 1.1 Windows Drivers are installed from the directory pointed to by
"VIRTIO_WIN" environment
variable(/ usr / share / virtio - win by default) if present
RHEL 4
SELinux relabel appears to hang forever
In RHEL ≤ 4.7 there was a bug which causes SELinux relabelling to appear to hang forever at:
*** Warning -- SELinux relabel is required. *** *** Disabling security enforcement. *** *** Relabeling could take a very long time, *** *** depending on file system size. ***
In reality it is waiting for you to press a key (but there is no visual indication of this). You can either hit the "[Return]" key, at which point the guest will finish relabelling and reboot, or you can install policycoreutils ≥ 1.18.1-4.13 before starting the v2v conversion. See also https://bugzilla.redhat.com/show_bug.cgi?id=244636
WINDOWS
Windows ≥ 8 Fast Startup is incompatible with virt-v2v
Guests which use the Windows ≥ 8 “Fast Startup” feature (or guests which are hibernated) cannot be converted with virt-v2v. You will see an error:
virt-v2v: error: unable to mount the disk image for writing. This has probably happened because Windows Hibernation or Fast Restart is being used in this guest. You have to disable this (in the guest) in order to use virt-v2v.
As the message says, you need to boot the guest and disable the “Fast Startup” feature (Control Panel → Power Options → Choose what the power buttons do → Change settings that are currently unavailable → Turn on fast startup), and shut down the guest, and then you will be able to convert it.
For more information, see: “WINDOWS HIBERNATION AND WINDOWS 8 FAST STARTUP” in guestfs(3).
Boot failure: 0x0000007B
This boot failure is caused by Windows being unable to find or load the right disk driver (eg. viostor.sys). If you experience this error, here are some things to check:
- •
- First ensure that the guest boots on the source hypervisor before conversion.
- •
- Check you have the Windows virtio drivers available in /usr/share/virtio-win, and that virt-v2v did not print any warning about not being able to install virtio drivers.
On Red Hat Enterprise Linux 7, you will need to install the signed drivers available in the "virtio-win" package. If you do not have access to the signed drivers, then you will probably need to disable driver signing in the boot menus.
- •
- Check that you are presenting a virtio-blk interface (
notvirtio-scsi andnotide) to the guest. On the qemu/KVM command line you should see something similar to this:... -drive file=windows-sda,if=virtio ...
In libvirt XML, you should see:
<target dev='vda' bus='virtio'/>
- •
- Check that Windows Group Policy does not prevent the driver from being installed or used. Try deleting Windows Group Policy before conversion.
- •
- Check there is no anti-virus or other software which implements Group Policy-like prohibitions on installing or using new drivers.
- •
- Enable boot debugging and check the viostor.sys driver is being loaded.
OpenStack and Windows reactivation
OpenStack does not offer stable device / PCI addresses to guests. Every time it creates or starts a guest, it regenerates the libvirt XML for that guest from scratch. The libvirt XML will have no <address> fields. Libvirt will then assign addresses to devices, in a predictable manner. Addresses may change if any of the following are true:
- •
- A new disk or network device has been added or removed from the guest.
- •
- The version of OpenStack or (possibly) libvirt has changed.
Because Windows does not like “hardware” changes of this kind, it may trigger Windows reactivation.
This can also prevent booting with a 7B error [see previous section] if the guest has group policy containing "Device Installation Restrictions".
UEFI
VMware allows you to present UEFI firmware to guests (instead of the ordinary PC BIOS). Virt-v2v can convert these guests, but requires that UEFI is supported by the target hypervisor.
Currently KVM supports OVMF, an open source UEFI firmware, and can run these guests.
Since OVMF support was only recently added to KVM (in 2014/2015), not all target environments support UEFI guests yet:
- UEFI on libvirt, qemu
- Supported. Virt-v2v will generate the correct libvirt XML (metadata) automatically, but note that the same version of OVMF must be installed on the conversion host as is installed on the target hypervisor, else you will have to adjust paths in the metadata.
On RHEL ≥ 7.3, only qemu-kvm-rhev (not qemu-kvm) is supported.
- UEFI on OpenStack
- Not supported.
- UEFI on RHEV
- Not supported.
NETWORKS AND BRIDGES
Guests are usually connected to one or more networks, and when converted to the target hypervisor you usually want to reconnect those networks at the destination. The options –network and –bridge allow you to do that.
If you are unsure of what networks and bridges are in use on the source hypervisor, then you can examine the source metadata (libvirt XML, vCenter information, etc.). Or you can run virt-v2v with the –print-source option which causes virt-v2v to print out the information it has about the guest on the source and then exit.
In the –print-source output you will see a section showing the guest’s Network Interface Cards (NICs):
$ virt – v2v[-i…]– print – source name[…] NICs : Network “default” mac : 52 : 54 : 00 : d0 : cf : 0e
This is typical of a libvirt guest: It has a single network interface connected to a network called "default".
To map a specific network to a target network, for example "default" on the source to "rhevm" on the target, use:
virt-v2v [...] --network default:rhevm
To map every network to a target network, use:
virt-v2v [...] --network rhevm
Bridges are handled in the same way, but you have to use the –bridge option instead. For example:
$ virt – v2v[-i…]– print – source name[…] NICs : Bridge “br0”
$ virt –
v2v[…]– bridge br0 : targetbr
INPUT FROM VMWARE VCENTER SERVER
Virt-v2v is able to import guests from VMware vCenter Server.
vCenter ≥ 5.0 is required. If you don’t have vCenter, using OVA is recommended instead (see “INPUT FROM VMWARE OVA” below), or if that is not possible then see “INPUT FROM VMWARE ESXi HYPERVISOR”.
Virt-v2v uses libvirt for access to vCenter, and therefore the input mode should be -i libvirt. As this is the default, you don’t need to specify it on the command line.
VCENTER: REMOVE VMWARE TOOLS FROM WINDOWS GUESTS
For Windows guests, you should remove VMware tools before conversion. Although this is not strictly necessary, and the guest will still be able to run, if you don’t do this then the converted guest will complain on every boot. The tools cannot be removed after conversion because the uninstaller checks if it is running on VMware and refuses to start (which is also the reason that virt-v2v cannot remove them).
This is not necessary for Linux guests, as virt-v2v is able to remove VMware tools.
VCENTER: URI
The libvirt URI of a vCenter server looks something like this:
vpx://user@server/Datacenter/esxi
where:
- "user@"
- is the (optional, but recommended) user to connect as.
If the username contains a backslash (eg. "DOMAIN
