KVM Creation (python)

Source: Internet
Author: User

#!/usr/bin/pythonimport libvirtconn = 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 ())


This article from "Muzinan Technology blog" blog, declined reprint!

KVM Creation (python)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.