libvirt创建KVM虚拟机

1 安装虚拟化相关组件

yum -y install qemu-img qemu-kvm  libvirt

2 启动libvirt服务

systemctl  start libvirtd

3 配置xml,创建空镜像

qemu-img create -f qcow2  test.qcow2  20G
'kvm'> 
    test_jkk 
    1048576 
    1048576
    1
     
      'x86_64' machine='pc'>hvm 
      'cdrom'/>
'localtime'/> destroy restart destroy /usr/libexec/qemu-kvm 'file' device='disk'> 'qemu' type='qcow2'/> '/home/kvm/test.qcow2'/> 'hda' bus='ide'/> 'file' device='cdrom'> '/home/kvm/centos_minimal.iso'/> 'hdb' bus='ide'/> <interface type='bridge'> 'virbr0'/> interface> 'mouse' bus='ps2'/> 'vnc' port='-1' autoport='yes' listen = '0.0.0.0' keymap='en-us'/>

4  定义启动虚拟机

virsh define test.xml
virsh start  test_jkk
virsh  vncdisplay   test_jkk  查看虚拟机vnc串口
virsh domblklist demo 查看虚拟机的磁盘文件
virsh dumpxml demo 查看虚拟机xml

 

你可能感兴趣的:(libvirt创建KVM虚拟机)