Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 0.0.3 instead.
Reason given by maintainers: Totally supplanted.

libvirt_vmcfg

libvirt_vmcfg is 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.

Examples

Domain builder

from libvirt_vmcfg.domain.profiles.linux_virtio import kvm_default_hardwar
from libvirt_vmcfg.domain.devices.interface import BridgedInterface
from libvirt_vmcfg.domain.devices.disk import (QemuDiskBlock, QemuDiskNet,
                                               DeviceType)
from libvirt_vmcfg.domain.util.disk import (TargetDevGenerator,
                                            qemu_driver_attrs_raw)
from libvirt_vmcfg.domain import Domain


# Automatic generator for target devices
t = TargetDevGenerator()

# Shorthand for creating the devices we need, based on what virt-install does
# This doesn't do everything - you still need disks and a network interface.
# You can also create your own hardware specification, see
# libvirt_vmcfg/profiles/linux_virtio.py for details.
elements = kvm_default_hardware(name="test", vcpus=2, memory=786432,
                                boot_dev_order=["hd"])

# This is the hard disk specification, using a block device
# Note how we use qemu_driver_attrs_raw here, these are the recommended
# parameters for a raw device with QEMU
hard_disk = QemuDiskBlock(device=DeviceType.DISK,
                          source_dev="/dev/foo-vg/lvm_disk_partition",
                          target_dev=t.next_virtio(),
                          driver_attrs=qemu_driver_attrs_raw)

# This is the CD specification
cdrom = QemuDiskNet(device=DeviceType.CDROM,
                    source_url="http://example.com/install/cloudinit-seed.iso",
                    target_dev=t.next_virtio(), readonly=True)

# Network interface, only bridging is supported right now
interface = BridgedInterface("br0")

# Obvious
elements.extend((hard_disk, cdrom, interface))

# Create our domain and emit the XML
# Since this is an example, we print it out
dom = Domain(elements=elements)
print(dom.emit_xml(pretty_print=True))

Volumes

from libvirt_vmcfg.volume import Volume


GIGABYTE = 1073741824

vol = Volume(name="test", size=3 * GIGABYTE)
print(vol.emit_xml(pretty_print=True))

TODO

A lot. I'll get around to most of these eventually. I hope. I'm sadly quite busy these days.

  • More interface types
  • More disk types, like LUNs
  • More hardware profiles, like for Windows, old Linux, BSD, etc.
  • More hardware that isn't virtio
  • More hardware, period
  • More hardware options, like more timers, etc.
  • More hypervisors (Xen, VirtualBox, VMWare Workstation, and ESXi are probably the only other relevant ones)
    • Ensure hypervisor portability
  • Investigate other architectures, like ppc64le and aarch64, add relevant bits from those
    • Ensure portability to said platforms
  • Creation of XML for volumes
  • Documentation
  • Find a better way to handle driver_attrs with disks
  • Find a clean way to add all the relevant doodads from the (very complicated) disk specification
  • Make volume interoperate with domain where relevant

Contributions

See the contributing file for more information.

License

CC0, 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 thanks

You can thank me at my Say Thanks.

You can also donate to help keep me afloat during these tough times.

Release files for libvirt-vmcfg 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for libvirt-vmcfg 0.0.1
File Size Uploaded
libvirt_vmcfg-0.0.1.tar.gz 13.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for libvirt-vmcfg 0.0.1
File Interpreter ABI Platform
libvirt_vmcfg-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size:33.9 kB

Release files / libvirt_vmcfg-0.0.1.tar.gz

Download URL libvirt_vmcfg-0.0.1.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5be682dd8fd7039eb3e5ab80996d85fa981ec30ca6ac876661087f559659b76a
BLAKE2b-256 checksum
How to use checksums
a645889c214c9ef791f5e908cf2e2c1e441ee7654a87aaa47276b0407c35472d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / libvirt_vmcfg-0.0.1-py3-none-any.whl

Download URL libvirt_vmcfg-0.0.1-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb1f5433dfadc50f4a662c12f6a7b6462c5f029b6c642ebffaa773e3a8f3bfa4
BLAKE2b-256 checksum
How to use checksums
501fd3276f0633f4b1e746ef66d2f92637af8f307fddbc47fdeb99c7167e66a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release history Release notifications | RSS feed

0.0.3

2 release files

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page