xen 转换 xml 为 conf

#  virsh dumpxml winvm01 > winvm01.xml    # 当前运行的虚拟机 winvm01
#  cat winvm01.xml     #导出XML文件
#  virsh dumpxml c5vm01 > c5vm01.xml
#  cat c5vm01.xml
#  virsh -c xen:// domxml-to-native xen-xm winvm01.xml >winvm01.conf
#  cat winvm01.conf
#  virsh -c xen:// domxml-to-native xen-xm c5vm01.xml >c5vm01.conf

大体就是先利用xm命令获得虚拟机的名称,然后利用virsh dumpxml <d-name> 获得虚拟机的xml文件;有了此文件就能利用domxml-to-native命令获得本地conf文件了。

但kvm呢?目前只查到了qemu的:http://libvirt.org/drvqemu.html

/usr/bin/kvm -S -M pc -m 512 -smp 2 -name i-56D709C5 -uuid fb973678-04e0-f151-e8a6-07c8f2407833 -monitor pty -pidfile /var/run/libvirt/qemu//i-56D709C5.pid -boot c -kernel /opt/eucalyptus/instances/admin/i-56D709C5/kernel -initrd /opt/eucalyptus/instances/admin/i-56D709C5/ramdisk -append root=/dev/vda1 console=ttyS0 -drive file=/opt/eucalyptus/instances/admin/i-56D709C5/disk,if=virtio,index=0,boot=on -net nic,macaddr=d0:0d:56:d7:09:c5,vlan=0,model=virtio -net tap,fd=16,script=,vlan=0,ifname=vnet0 -serial file:/opt/eucalyptus/instances/admin/i-56D709C5/console.log -parallel none -usb -vnc :24101,password

问题已经很明显了,由于rhel的内核版本太低,导致kvm和libvirt版本过低,所以libvirt不支持scsi模式的硬盘,所以改用了virtio格式的硬盘;而virtio格式的硬盘在虚拟机里需要25以上的内核支持,所以创建模板时需要将18的内核替换为25以上的内核,而且切记,不同版本的系统,内核要对号入座。终于清楚了,费了这么大的功夫……

在使用euca的centos内核启动ns时,mouse和nic还是不正常;在用其自己的18内核时,根本启动不起来。

利用好virsh命令:

 domxml-from-native Convert native config to domain XML
    domxml-to-native Convert domain XML to native config
    dumpxml         XML 中的域信息

这些命令都是很有用的。在http://libvirt.org/drvqemu.html上有些说明。利用domxml-from-native进行转换:

virsh domxml-from-native qemu-argv demo.args

demo.argv的内容为:kvm -m 512 -drive if=virtio,file=neo_1126.img,index=0,boot=on -boot c -balloon virtio

转换后的内容如上所示。

原文地址:https://www.cnblogs.com/chinacloud/p/1891103.html