首页 > 代码库 > kvm创建(python)
kvm创建(python)
#!/usr/bin/python import libvirt conn = libvirt.open(‘qemu:///system‘) xmldesc = ‘‘‘ <domain type=‘kvm‘> <name>centos_6.5</name> <memory unit=‘KiB‘>524288</memory> <currentMemory unit=‘KiB‘>524288</currentMemory> <vcpu placement=‘static‘>1</vcpu> <os> <type arch=‘x86_64‘ machine=‘rhel6.5.0‘>hvm</type> <boot dev=‘cdrom‘/> </os> <features> <acpi/> <apic/> <pae/> </features> <clock offset=‘utc‘/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/libexec/qemu-kvm</emulator> <disk type=‘file‘ device=‘disk‘> <driver name=‘qemu‘ type=‘qcow2‘/> <source file=‘/home/centos_6.5.qcow2‘/> <--- qemu-img create -f qcow2 /home/centos_6.5.qcow2 10G <target dev=‘hda‘ bus=‘ide‘/> </disk> <disk type=‘file‘ device=‘cdrom‘> <source file=‘/data0/xcloud/iso/CentOS_6.5_x86_64-minimal.iso‘/> <target dev=‘hdc‘ bus=‘ide‘/> </disk> <controller type=‘usb‘ index=‘0‘> <address type=‘pci‘ domain=‘0x0000‘ bus=‘0x00‘ slot=‘0x01‘ function=‘0x2‘/> </controller> <controller type=‘ide‘ index=‘0‘> <address type=‘pci‘ domain=‘0x0000‘ bus=‘0x00‘ slot=‘0x01‘ function=‘0x1‘/> </controller> <interface type=‘bridge‘> <mac address=‘52:54:00:a7:40:f7‘/> <source bridge=‘br0‘/> <address type=‘pci‘ domain=‘0x0000‘ bus=‘0x00‘ slot=‘0x03‘ function=‘0x0‘/> </interface> <serial type=‘pty‘> <target port=‘0‘/> </serial> <console type=‘pty‘> <target type=‘serial‘ port=‘0‘/> </console> <input type=‘mouse‘ bus=‘ps2‘/> <graphics type=‘vnc‘ port=‘5905‘ autoport=‘no‘ listen=‘0.0.0.0‘> <listen type=‘address‘ address=‘0.0.0.0‘/> </graphics> <video> <model type=‘cirrus‘ vram=‘9216‘ heads=‘1‘/> <address type=‘pci‘ domain=‘0x0000‘ bus=‘0x00‘ slot=‘0x02‘ function=‘0x0‘/> </video> <memballoon model=‘virtio‘> <address type=‘pci‘ domain=‘0x0000‘ bus=‘0x00‘ slot=‘0x04‘ function=‘0x0‘/> </memballoon> </devices> </domain> ‘‘‘ dom = conn.createLinux(xmldesc,0) print "Domain:id %d running %s"% (dom.ID(),dom.OSType())
本文出自 “muzinan的技术博客” 博客,谢绝转载!
kvm创建(python)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。