[ 'name' => $strSelectedTemplate, 'icon' => $arrAllTemplates[$strSelectedTemplate]['icon'], 'os' => $arrAllTemplates[$strSelectedTemplate]['os'] ], 'domain' => [ 'name' => $strSelectedTemplate, 'persistent' => 1, 'uuid' => $lv->domain_generate_uuid(), 'clock' => 'localtime', 'arch' => 'x86_64', 'machine' => 'pc', 'mem' => 1024 * 1024, 'maxmem' => 1024 * 1024, 'password' => '', 'cpumode' => 'host-passthrough', 'vcpus' => 1, 'vcpu' => [0], 'hyperv' => 1, 'ovmf' => 1, 'usbmode' => 'usb2' ], 'media' => [ 'cdrom' => '', 'cdrombus' => 'ide', 'drivers' => is_file($domain_cfg['VIRTIOISO']) ? $domain_cfg['VIRTIOISO'] : '', 'driversbus' => 'ide' ], 'disk' => [ [ 'new' => '', 'size' => '', 'driver' => 'raw', 'dev' => 'hda', 'select' => $domain_cfg['VMSTORAGEMODE'], 'bus' => 'virtio' ] ], 'gpu' => [ [ 'id' => 'vnc', 'model' => 'qxl', 'keymap' => 'en-us' ] ], 'audio' => [ [ 'id' => '' ] ], 'pci' => [], 'nic' => [ [ 'network' => $domain_bridge, 'mac' => $lv->generate_random_mac_addr() ] ], 'usb' => [], 'shares' => [ [ 'source' => '', 'target' => '' ] ] ]; // Merge in any default values from the VM template if (!empty($arrAllTemplates[$strSelectedTemplate]) && !empty($arrAllTemplates[$strSelectedTemplate]['overrides'])) { $arrConfigDefaults = array_replace_recursive($arrConfigDefaults, $arrAllTemplates[$strSelectedTemplate]['overrides']); } // If we are editing a existing VM load it's existing configuration details $arrExistingConfig = (!empty($_GET['uuid']) ? domain_to_config($_GET['uuid']) : []); // Active config for this page $arrConfig = array_replace_recursive($arrConfigDefaults, $arrExistingConfig); // Add any custom metadata field defaults (e.g. os) if (empty($arrConfig['template']['os'])) { $arrConfig['template']['os'] = ($arrConfig['domain']['clock'] == 'localtime' ? 'windows' : 'linux'); } $boolNew = empty($arrExistingConfig); $boolRunning = (!empty($arrConfig['domain']['state']) && $arrConfig['domain']['state'] == 'running'); if (array_key_exists('createvm', $_POST)) { //DEBUG file_put_contents('/tmp/debug_libvirt_postparams.txt', print_r($_POST, true)); file_put_contents('/tmp/debug_libvirt_newxml.xml', $lv->config_to_xml($_POST)); $tmp = $lv->domain_new($_POST); if (!$tmp){ $arrResponse = ['error' => $lv->get_last_error()]; } else { $arrResponse = ['success' => true]; // Fire off the vnc popup if available $dom = $lv->get_domain_by_name($_POST['domain']['name']); $vncport = $lv->domain_get_vnc_port($dom); $wsport = $lv->domain_get_ws_port($dom); if ($vncport > 0) { $vnc = '/plugins/dynamix.vm.manager/vnc.html?autoconnect=true&host='.$eth0['IPADDR:0'].'&port='.$wsport; $arrResponse['vncurl'] = $vnc; } } echo json_encode($arrResponse); exit; } if (array_key_exists('updatevm', $_POST)) { //DEBUG file_put_contents('/tmp/debug_libvirt_postparams.txt', print_r($_POST, true)); file_put_contents('/tmp/debug_libvirt_updatexml.xml', $lv->config_to_xml($_POST)); // Backup xml for existing domain in ram $strOldXML = ''; $boolOldAutoStart = false; $dom = $lv->domain_get_domain_by_uuid($_POST['domain']['uuid']); if ($dom) { $strOldXML = $lv->domain_get_xml($dom); $boolOldAutoStart = $lv->domain_get_autostart($dom); $strOldName = $lv->domain_get_name($dom); $strNewName = $_POST['domain']['name']; if (!empty($strOldName) && !empty($strNewName) && is_dir($domain_cfg['DOMAINDIR'].$strOldName.'/') && !is_dir($domain_cfg['DOMAINDIR'].$strNewName.'/')) { // mv domain/vmname folder if (rename($domain_cfg['DOMAINDIR'].$strOldName, $domain_cfg['DOMAINDIR'].$strNewName)) { // replace all disk paths in xml foreach ($_POST['disk'] as &$arrDisk) { if (!empty($arrDisk['new'])) { $arrDisk['new'] = str_replace($domain_cfg['DOMAINDIR'].$strOldName.'/', $domain_cfg['DOMAINDIR'].$strNewName.'/', $arrDisk['new']); } if (!empty($arrDisk['image'])) { $arrDisk['image'] = str_replace($domain_cfg['DOMAINDIR'].$strOldName.'/', $domain_cfg['DOMAINDIR'].$strNewName.'/', $arrDisk['image']); } } } } //DEBUG file_put_contents('/tmp/debug_libvirt_oldxml.xml', $strOldXML); } // Remove existing domain $lv->nvram_backup($_POST['domain']['uuid']); $lv->domain_undefine($dom); $lv->nvram_restore($_POST['domain']['uuid']); // Save new domain $tmp = $lv->domain_new($_POST); if (!$tmp){ $strLastError = $lv->get_last_error(); // Failure -- try to restore existing domain $tmp = $lv->domain_define($strOldXML); if ($tmp) $lv->domain_set_autostart($tmp, $boolOldAutoStart); $arrResponse = ['error' => $strLastError]; } else { $lv->domain_set_autostart($tmp, $_POST['domain']['autostart'] == 1); $arrResponse = ['success' => true]; } echo json_encode($arrResponse); exit; } ?>
Name:

Give the VM a name (e.g. Work, Gaming, Media Player, Firewall, Bitcoin Miner)

Description:

Give the VM a brief description (optional field).

CPU Mode:

There are two CPU modes available to choose:

Host Passthrough
With this mode, the CPU visible to the guest should be exactly the same as the host CPU even in the aspects that libvirt does not understand. For the best possible performance, use this setting.

Emulated
If you are having difficulties with Host Passthrough mode, you can try the emulated mode which doesn't expose the guest to host-based CPU features. This may impact the performance of your VM.

Logical CPUs:

The number of logical CPUs in your system is determined by multiplying the number of CPU cores on your processor(s) by the number of threads.

Select which logical CPUs you wish to allow your VM to use. (minimum 1).

Initial Memory: Max Memory:

Select how much memory to allocate to the VM at boot.

For VMs where no PCI devices are being passed through (GPUs, sound, etc.), you can set different values to initial and max memory to allow for memory ballooning. If you are passing through a PCI device, only the initial memory value is used and the max memory value is ignored. For more information on KVM memory ballooning, see here.

Machine:

The machine type option primarily affects the success some users may have with various hardware and GPU pass through. For more information on the various QEMU machine types, see these links:

http://wiki.qemu.org/Documentation/Platforms/PC
http://wiki.qemu.org/Features/Q35

As a rule of thumb, try to get your configuration working with i440fx first and if that fails, try adjusting to Q35 to see if that changes anything.

BIOS:

SeaBIOS
is the default virtual BIOS used to create virtual machines and is compatible with all guest operating systems (Windows, Linux, etc.).

OVMF
(Open Virtual Machine Firmware) adds support for booting VMs using UEFI, but virtual machine guests must also support UEFI. Assigning graphics devices to a OVMF-based virtual machine requires that the graphics device also support UEFI.

Once a VM is created this setting cannot be adjusted.

Hyper-V:

Exposes the guest to hyper-v extensions for Microsoft operating systems.

OS Install ISO:
OS Install CDRom Bus:

Select the virtual CD-ROM (ISO) that contains the installation media for your operating system. Clicking this field displays a list of ISOs found in the directory specified on the Settings page.

CDRom Bus
Specify what interface this virtual cdrom uses to connect inside the VM.

VirtIO Drivers ISO:
VirtIO Drivers CDRom Bus:

Specify the virtual CD-ROM (ISO) that contains the VirtIO Windows drivers as provided by the Fedora Project. Download the latest ISO from here: https://fedoraproject.org/wiki/Windows_Virtio_Drivers#Direct_download

When installing Windows, you will reach a step where no disk devices will be found. There is an option to browse for drivers on that screen. Click browse and locate the additional CD-ROM in the menu. Inside there will be various folders for the different versions of Windows. Open the folder for the version of Windows you are installing and then select the AMD64 subfolder inside (even if you are on an Intel system, select AMD64). Three drivers will be found. Select them all, click next, and the vDisks you have assigned will appear.

CDRom Bus
Specify what interface this virtual cdrom uses to connect inside the VM.

$arrDisk) { $strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : 'Primary'; ?>
vDisk Location:
vDisk Size:
vDisk Type:
vDisk Bus:

vDisk Location
Specify a path to a user share in which you wish to store the VM or specify an existing vDisk. The primary vDisk will store the operating system for your VM.

vDisk Size
Specify a number followed by a letter. M for megabytes, G for gigabytes.

vDisk Type
Select RAW for best performance. QCOW2 implementation is still in development.

vDisk Bus
Select virtio for best performance.

Additional devices can be added/removed by clicking the symbols to the left.

$arrShare) { $strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : ''; ?>
unRAID Share:
unRAID Mount tag:

unRAID Share
Used to create a VirtFS mapping to a Linux-based guest. Specify the path on the host here.

unRAID Mount tag
Specify the mount tag that you will use for mounting the VirtFS share inside the VM. See this page for how to do this on a Linux-based guest: http://wiki.qemu.org/Documentation/9psetup

Additional devices can be added/removed by clicking the symbols to the left.

$arrGPU) { $strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : ''; ?>
Graphics Card:
VNC Video Driver:
VNC Password:
VNC Keyboard:

Graphics Card
If you wish to assign a graphics card to the VM, select it from this list, otherwise leave it set to VNC.

VNC Video Driver
If you wish to assign a different video driver to use for a VNC connection, specify one here.

VNC Password
If you wish to require a password to connect to the VM over a VNC connection, specify one here.

VNC Keyboard
If you wish to assign a different keyboard layout to use for a VNC connection, specify one here.

Additional devices can be added/removed by clicking the symbols to the left.

$arrAudio) { $strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : ''; ?>
Sound Card:

Select a sound device to assign to your VM. Most modern GPUs have a built-in audio device, but you can also select the on-board audio device(s) if present.

Additional devices can be added/removed by clicking the symbols to the left.

$arrNic) { $strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : ''; ?>
Network MAC:
Network Bridge:

Network MAC
By default, a random MAC address will be assigned here that conforms to the standards for virtual network interface controllers. You can manually adjust this if desired.

Network Bridge
The default libvirt managed network bridge (virbr0) will be used, otherwise you may specify an alternative name for a private network bridge to the host.

Additional devices can be added/removed by clicking the symbols to the left.

USB Devices:
$arrDev) { ?>
None available"; } ?>

If you wish to assign any USB devices to your guest, you can select them from this list.
NOTE: USB hotplug support is not yet implemented, so devices must be attached before the VM is started to use them.

USB Mode:

USB Mode
Select the USB Mode to emulate. Some OSes won't support USB3 (e.g. Windows 7).

Other PCI Devices:
$arrDev) { $extra = ''; if (count(array_filter($arrConfig['pci'], function($arr) use ($arrDev) { return ($arr['id'] == $arrDev['id']); }))) { $extra .= ' checked="checked"'; } else if (!in_array($arrDev['driver'], ['pci-stub', 'vfio-pci'])) { //$extra .= ' disabled="disabled"'; continue; } $intAvailableOtherPCIDevices++; ?>
None available"; } ?>

If you wish to assign any other PCI devices to your guest, you can select them from this list.


Click Create to generate the vDisks and return to the Virtual Machines page where your new VM will be created.