找到要迁移的虚拟机&停止
通过virsh list --all
找到你要迁移的虚拟机
[root@xxxxx ~]# virsh list --all
Id Name State
----------------------------------------------------
1 xxxx2 running
2 xxxx3 running
3 xxxx4 running
4 xxxx5 running
[root@xxxxx ~]# virsh shutdown xxxx2
通过virsh shutdown xxxx2
停止虚拟机
转换磁盘镜像
如果不知道的话,可以用virsh edit xxx
来获取磁盘路径,如:
...
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/var/lib/libvirt/images/xxxx2.img'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/var/lib/libvirt/images/xxxx3.img'/>
<target dev='vdd' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</disk>
...
[root@xxxxx lib]# cd /var/lib/libvirt/images
[root@xxxxx images]# ll
total 1006795428
-rw-r--r-- 1 root root 3679387648 May 9 2022 xxxx2.image
-rw-r--r-- 1 qemu qemu 9454813184 Apr 11 10:44 xxxx3.img
-rw-r--r-- 1 qemu qemu 644245094400 Apr 11 10:44 xxxx4.img
-rw-r--r-- 1 qemu qemu 107011833856 Apr 11 10:44 xxxx5.img
将kvm下img文件格式的虚拟机转换成vmdk格式
qemu-img convert /var/lib/libvirt/images/xxxx2.img -O vmdk /var/lib/libvirt/images/xxxx2.vmdk
上传到VMware
在VMware vSphere环境里创建一个虚拟机 “选择自定义”,不用创建磁盘使用刚刚转换的vmdk文件,开启虚拟机即可