Skip to content

A package using the basement-common interface to manage virtual machines via Libvirt

License

Notifications You must be signed in to change notification settings

The-Basement-Club/basement-libvirt

Repository files navigation

basement-libvirt

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 [email protected] instead of using the issue tracker.

Credits

License

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

About

A package using the basement-common interface to manage virtual machines via Libvirt

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages