the-basement/libvirt

This package implements the domain service contract for the libvirt hypervisor.

v0.1.0 2024-05-13 01:14 UTC

This package is auto-updated.

Last update: 2024-11-13 02:22:05 UTC


README

Latest Version on Packagist Software License Total Downloads

This package is a basic QEMU management interface using the interfaces from the-basement/common.

Install

Via Composer

$ composer require the-basement/libvirt

Basic Usage

Creating a VM in QEMU/KVM

// This assumes you have an ubuntu server image available from your KVM host
// This also assumes the default image location of the disks created by KVM.
// Both of these can be changed; disks that exist will not be overwritten
// disks that don't exist will be created.
$service = new TheBasement\Libvirt\LibvirtService();
$service->createServer([
    'name' => 'my-virtual-machine',
    'memory' => (string) (1024 * 1024), // 1G in KiB
    'cores' => 1,
    'threads' => 1,
    'iso_path' => '/var/lib/libvirt/iso/ubuntu-22.04.4-live-server-amd64.iso',
    'storage_pool' => 'default',
    'network_mac' => '',
    'video_ram' => '65536', // bytes of video ram
    'disk_path' => '/var/lib/libvirt/images/ubuntu22.04-2.qcow2',
    'disk_name' => 'ubuntu22.04-2.qcow2',
    'disk_capacity' => 10 * 1024 * 1024 * 1024, // 10 GB in bytes
]);

// Gets all servers defined for the KVM
$servers = $service->findAllServers();

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email security@austinkregel.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.