virt-v2v是将外部的虚拟化平台上的虚拟机转化到可以运行的KVM平台上。它可以读取在VMware、Xen运行Hyper-V和其他虚拟机管理程序上的Windows和Linux的虚拟机,并将其转换为KVM的libvirt,OpenStack等几种方式。需在KVM环境下进行迁移操作
0x01 环境准备
所有操作需要在KVM环境下进行,安装如下包即可
$ yum install -y qemu-kvm libvirt virt-manager virt-v2v
0x02 查询宿主机中的VM
迁移前可以先列出宿主机中的所有VM,命令格式为:
$ virsh -c esx://root@esxi.example.com?no_verify=1 list --all ## esxi.example.com 为宿主机的ip或者URL
0x03 迁移VM
使用virt-v2v-copy-to-local命令即可把对应的VM迁移到本地,其中需要输入两次密码,两次的密码均为esxi宿主机的登录密码,迁移完成后会在当前目录生成一个xml文件和disk1磁盘文件
$ virt-v2v-copy-to-local -ic esx://root@esxi.example.com?no_verify=1 guest # esxi.example.com 为宿主机的ip或者URL # guest为迁移的VM名称
0x04 格式转换
迁移完成后,就需要把磁盘文件的格式转换成OpenStack能够识别的格式
$ virt-v2v -i libvirtxml guest.xml -o local -os /var/tmp -of raw #guest.xml为刚才迁移时生成的xml文件 #-os为转换格式后存放的路径 #-of为指定转换的格式为raw
最后,就会在/var/tmp下生成一个raw格式的OpenStack镜像,上传到OpenStack环境中即可使用。

聂扬帆博客
一个分享IT运维相关工作经验和实战技巧的个人博客
2017年10月23日 下午7:48 沙发
非常好的分享,谢谢。
2018年1月3日 上午10:55 板凳
virt-v2v -ic esx://192.168.0.8/?no_verify=1 -os vmdisk -of qcow2 -b br0 confluence
virt-v2v: 连接 ESX 服务器失败:Bad Request
请问博主,又遇到这个问题吗?
还有为什么我安装工具后,执行virt-v2v-copy-to-local,会提示:-bash: virt-v2v-copy-to-local: command not found 这是为什么?
我的机器是CentOS 6.5 Mini化安装的
2018年1月3日 下午8:42 1层
@Young 目前没遇到过,检查下网络或其它限制先
2020年3月22日 下午9:38 1层
@Young virt-v2v-copy-to-loca 没有识别到这个命令
2018年8月27日 上午10:19 地板
感谢分享,有用
2019年12月29日 下午3:58 4楼
你好,请教一下,v2v迁移转换格式时候,遇到以下错误,请问有遇到过吗
root@localhost ~]# virt-v2v -i libvirtxml centos-test.xml -o local -os /root -of raw
[ 0.0] Opening the source -i libvirtxml centos-test.xml
[ 0.0] Creating an overlay to protect the source from being modified
[ 0.1] Opening the overlay
virt-v2v: error: libguestfs error: /usr/bin/supermin5 exited with error
status 127.
To see full error messages you may need to enable debugging.
Do:
export LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1
and run the command again. For further information, read:
http://libguestfs.org/guestfs-faq.1.html#debugging-libguestfs
You can also run ‘libguestfs-test-tool’ and post the *complete* output
into a bug report or message to the libguestfs mailing list.
If reporting bugs, run virt-v2v with debugging enabled and include the
complete output:
virt-v2v -v -x […]
2020年1月8日 下午4:01 1层
@周宇航 这个没遇到过,你开启debug模式看看吧
2020年3月22日 下午9:47 5楼
博主你好,我想请问一下,这台esxi的虚机,前期需要做什么配置吗
2021年3月10日 下午12:16 6楼
virt-v2v请问运行在centos6上的还是运行在centos7上的
2021年3月15日 上午8:53 1层
@chen centos7
2021年9月30日 下午12:53 7楼
哥 ,我这个怎么报错呀
2021年9月30日 下午12:55 8楼
楼主 我这个错是什么意思呀
openstack image create ceshi –file ceshi-sda –disk-format qcow2 –container-format bare –public
HttpException: 500: Server Error for url: http://192.168.7.102:9292/v2/images?name=ceshi, Internal Server Error
2021年10月5日 下午3:25 1层
@hyk123 你是运行到哪一步报的错