This package is a basic QEMU management interface using the interfaces from the-basement/common.
Via Composer
$ composer require the-basement/libvirt
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();
Please see CHANGELOG for more information on what has changed recently.
$ composer test
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.