Package: libvirt-vmcfg
libvirt_vmcfglibvirt_vmcfgis a library for generating XML VM specifications for use in libvirt.It's in an alpha state but pull requests welcome.Documentation is poor at the moment as I have other priorities. When I have time, I'll create better docs.ExamplesDomain builderfromlxmlimportetreefromlibvirt_vmcfg.dom.profiles.linux_virtioimportkvm_default_hardwarefromlibvirt_vmcfg.dom.elements.devicesimportBridgedInterfacefromlibvirt_vmcfg.dom.elements.devicesimportDiskTargetCDROM,DiskTargetDiskfromlibvirt_vmcfg.dom.elements.devicesimport(DiskSourceBlockPath,DiskSourceNetHTTP,TargetBus)fromlibvirt_vmcfg.dom.elements.devicesimport(Driver,DriverType,DriverCache,DriverIO,DriverOptions)fromlibvirt_vmcfg.dom.elements.devicesimportDiskfromlibvirt_vmcfg.dom.util.diskimportdisk_letterfromlibvirt_vmcfg.domimportDomaindev=disk_letter("vd")elements=kvm_default_hardware(name="poopty",vcpus=2,memory=64*(1024**2),boot_dev_order=["hd"])# Build up the disksource_disk=DiskSourceBlockPath("/dev/zeta-vg/debian-test-01")target_disk=DiskTargetDisk(next(dev),bus=TargetBus.VIRTIO)driver_opts_disk=DriverOptions(driver=Driver.QEMU,type=DriverType.RAW,cache=DriverCache.NONE,io=DriverIO.NATIVE)disk=Disk(source_disk,target_disk,driver_opts_disk,False)# Now the CDsource_http=DiskSourceNetHTTP("http://localhost/install/install.iso")target_cdrom=DiskTargetCDROM(next(dev),bus=TargetBus.VIRTIO)driver_opts_cdrom=DriverOptions(driver=Driver.QEMU)cdrom=Disk(source_http,target_cdrom,driver_opts_cdrom,True)# Specify the Interfaceinterface=BridgedInterface("br0")elements.extend((disk,cdrom,interface))d=Domain(elements=elements)print(repr(d))print(d.emit_xml(pretty_print=True))Volumesfromlibvirt_vmcfg.volimportVolumeGIGABYTE=1073741824# Note the default unit for volumes is gigabytesvol=Volume(name="test",size=3*GIGABYTE)print(vol.emit_xml(pretty_print=True))TODOA lot. I'll get around to most of these eventually. I hope. I'm sadly quite busy these days.More interface typesMore disk types, like LUNsMore hardware profiles, like for Windows, old Linux, BSD, etc.More hardware that isn't virtioMore hardware, periodMore hardware options, like more timers, etc.More hypervisors (Xen, VirtualBox, VMWare Workstation, and ESXi are probably the only other relevant ones)Ensure hypervisor portabilityInvestigate other architectures, like ppc64le and aarch64, add relevant bits from thoseEnsure portability to said platformsDocumentationMakevolumeinteroperate withdomainwhere relevantFlesh outvolmoduleContributionsSee thecontributing filefor more information.LicenseCC0, dedicated to the public domain. Do whatever you want with it.Unfortunately I have to say this, because this comes up a lot in other projects. Let me make it clear: the project "licensing" (insofar a public domain dedication can be considered a license) is not up for debate. I wanted CC0 and it was a deliberate thoughtful choice. I am fully aware of its ramifications and have no intention to reverse my course on the matter. I was not — nor am not — willing or even able to enforce any restrictions on people or companies. Just do what you want with this. Relicensing is allowed; you may do so if you wish. Or don't. I don't care one way or the other.Say thanksYou can thank me atmy Say Thanks.You can alsodonateto help keep me afloat during these tough times.