diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php
index 77cc43e41..03d3a4df9 100644
--- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php
+++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php
@@ -1,6 +1,6 @@
-$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
-require_once "$docroot/webGui/include/Helpers.php";
-require_once "$docroot/webGui/include/Custom.php";
-require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
+ $docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
+ require_once "$docroot/webGui/include/Helpers.php";
+ require_once "$docroot/webGui/include/Custom.php";
+ require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
-// add translations
-if (substr($_SERVER['REQUEST_URI'],0,4) != '/VMs') {
- $_SERVER['REQUEST_URI'] = 'vms';
- require_once "$docroot/webGui/include/Translations.php";
-}
-
-$arrValidMachineTypes = getValidMachineTypes();
-$arrValidPCIDevices = getValidPCIDevices();
-$arrValidGPUDevices = getValidGPUDevices();
-$arrValidAudioDevices = getValidAudioDevices();
-$arrValidOtherDevices = getValidOtherDevices();
-$arrValidUSBDevices = getValidUSBDevices();
-$arrValidDiskDrivers = getValidDiskDrivers();
-$arrValidDiskBuses = getValidDiskBuses();
-$arrValidDiskDiscard = getValidDiskDiscard();
-$arrValidCdromBuses = getValidCdromBuses();
-$arrValidVNCModels = getValidVNCModels();
-$arrValidProtocols = getValidVMRCProtocols();
-$arrValidKeyMaps = getValidKeyMaps();
-$arrValidNetworks = getValidNetworks();
-$strCPUModel = getHostCPUModel();
-$templateslocation = "/boot/config/plugins/dynamix.vm.manager/savedtemplates.json";
-
-if (is_file($templateslocation)){
- $arrAllTemplates["User-templates"] = "";
- $ut = json_decode(file_get_contents($templateslocation),true);
- $arrAllTemplates = array_merge($arrAllTemplates, $ut);
-}
-
-$arrConfigDefaults = [
- 'template' => [
- 'name' => $strSelectedTemplate,
- 'icon' => $arrAllTemplates[$strSelectedTemplate]['icon'],
- 'os' => $arrAllTemplates[$strSelectedTemplate]['os'],
- 'storage' => "default"
- ],
- 'domain' => [
- 'name' => $strSelectedTemplate,
- 'persistent' => 1,
- 'uuid' => $lv->domain_generate_uuid(),
- 'clock' => 'localtime',
- 'arch' => 'x86_64',
- 'machine' => 'pc-i440fx',
- 'mem' => 1024 * 1024,
- 'maxmem' => 1024 * 1024,
- 'password' => '',
- 'cpumode' => 'host-passthrough',
- 'cpumigrate' => 'on',
- 'vcpus' => 1,
- 'vcpu' => [0],
- 'hyperv' => 1,
- 'ovmf' => 1,
- 'usbmode' => 'usb2',
- 'memoryBacking' => '{"nosharepages":{}}'
- ],
- 'media' => [
- 'cdrom' => '',
- 'cdrombus' => 'ide',
- 'drivers' => is_file($domain_cfg['VIRTIOISO']) ? $domain_cfg['VIRTIOISO'] : '',
- 'driversbus' => 'ide' ,
- 'cdromboot' => 2
- ],
- 'disk' => [
- [
- 'new' => '',
- 'size' => '',
- 'driver' => 'raw',
- 'dev' => 'hda',
- 'select' => $domain_cfg['VMSTORAGEMODE'],
- 'bus' => 'virtio' ,
- 'boot' => 1,
- 'serial' => 'vdisk1',
- 'discard' => 'unmap'
- ]
- ],
- 'gpu' => [
- [
- 'id' => 'virtual',
- 'protocol' => 'vnc',
- 'autoport' => 'yes',
- 'model' => 'qxl',
- 'keymap' => 'none',
- 'port' => -1 ,
- 'wsport' => -1,
- 'copypaste' => 'no',
- 'render' => 'auto',
- 'DisplayOptions' => ""
- ]
- ],
- 'audio' => [
- [
- 'id' => ''
- ]
- ],
- 'pci' => [],
- 'nic' => [
- [
- 'network' => $domain_bridge,
- 'mac' => $lv->generate_random_mac_addr(),
- 'model' => 'virtio-net'
- ]
- ],
- 'usb' => [],
- 'shares' => [
- [
- 'source' => '',
- 'target' => '',
- 'mode' => ''
- ]
- ]
-];
-$hdrXML = "\n"; // XML encoding declaration
-
-// Merge in any default values from the VM template
-if ($arrAllTemplates[$strSelectedTemplate] && $arrAllTemplates[$strSelectedTemplate]['overrides']) {
- $arrConfigDefaults = array_replace_recursive($arrConfigDefaults, $arrAllTemplates[$strSelectedTemplate]['overrides']);
-}
-// create new VM
-if (isset($_POST['createvm'])) {
- if (isset($_POST['xmldesc'])) {
- // XML view
- $new = $lv->domain_define($_POST['xmldesc'], $_POST['domain']['xmlstartnow']==1);
- if ($new){
- $lv->domain_set_autostart($new, $_POST['domain']['autostart']==1);
- $reply = ['success' => true];
- } else {
- $reply = ['error' => $lv->get_last_error()];
- }
- } else {
- // form view
- if ($lv->domain_new($_POST)) {
- // Fire off the vnc/spice popup if available
- $dom = $lv->get_domain_by_name($_POST['domain']['name']);
- $vmrcport = $lv->domain_get_vnc_port($dom);
- $wsport = $lv->domain_get_ws_port($dom);
- $protocol = $lv->domain_get_vmrc_protocol($dom);
- $reply = ['success' => true];
- if ($vmrcport > 0) {
- if ($protocol == "vnc") $vmrcscale = "&resize=scale"; else $vmrcscale = "";
- $reply['vmrcurl'] = autov('/plugins/dynamix.vm.manager/'.$protocol.'.html',true).'&autoconnect=true'.$vmrcscale.'&host='.$_SERVER['HTTP_HOST'];
- if ($protocol == "spice") $reply['vmrcurl'] .= '&port=/wsproxy/'.$vmrcport.'/'; else $reply['vmrcurl'] .= '&port=&path=/wsproxy/'.$wsport.'/';
- }
- } else {
- $reply = ['error' => $lv->get_last_error()];
- }
+ // add translations
+ if (substr($_SERVER['REQUEST_URI'],0,4) != '/VMs') {
+ $_SERVER['REQUEST_URI'] = 'vms';
+ require_once "$docroot/webGui/include/Translations.php";
}
- echo json_encode($reply);
- exit;
-}
-// create new VM template
-if (isset($_POST['createvmtemplate'])) {
- $reply = addtemplatexml($_POST);
- echo json_encode($reply);
- exit;
-}
+ $arrValidMachineTypes = getValidMachineTypes();
+ $arrValidPCIDevices = getValidPCIDevices();
+ $arrValidGPUDevices = getValidGPUDevices();
+ $arrValidAudioDevices = getValidAudioDevices();
+ $arrValidOtherDevices = getValidOtherDevices();
+ $arrValidUSBDevices = getValidUSBDevices();
+ $arrValidDiskDrivers = getValidDiskDrivers();
+ $arrValidDiskBuses = getValidDiskBuses();
+ $arrValidDiskDiscard = getValidDiskDiscard();
+ $arrValidCdromBuses = getValidCdromBuses();
+ $arrValidVNCModels = getValidVNCModels();
+ $arrValidProtocols = getValidVMRCProtocols();
+ $arrValidKeyMaps = getValidKeyMaps();
+ $arrValidNetworks = getValidNetworks();
+ $strCPUModel = getHostCPUModel();
-// update existing VM
-if (isset($_POST['updatevm'])) {
- $uuid = $_POST['domain']['uuid'];
- $dom = $lv->domain_get_domain_by_uuid($uuid);
- $oldAutoStart = $lv->domain_get_autostart($dom)==1;
- $newAutoStart = $_POST['domain']['autostart']==1;
- $strXML = $lv->domain_get_xml($dom);
+ $templateslocation = "/boot/config/plugins/dynamix.vm.manager/savedtemplates.json";
- if ($lv->domain_get_state($dom)=='running') {
- $arrErrors = [];
- $arrExistingConfig = domain_to_config($uuid);
- $arrNewUSBIDs = $_POST['usb'];
+ if (is_file($templateslocation)){
+ $arrAllTemplates["User-templates"] = "";
+ $ut = json_decode(file_get_contents($templateslocation),true) ;
+ $arrAllTemplates = array_merge($arrAllTemplates, $ut);
+ }
- // hot-attach any new usb devices
- foreach ($arrNewUSBIDs as $strNewUSBID) {
- if (strpos($strNewUSBID,"#remove")) continue;
- $remove = explode('#', $strNewUSBID);
- $strNewUSBID2 = $remove[0];
- foreach ($arrExistingConfig['usb'] as $arrExistingUSB) {
- if ($strNewUSBID2 == $arrExistingUSB['id']) continue 2;
+ $arrConfigDefaults = [
+ 'template' => [
+ 'name' => $strSelectedTemplate,
+ 'icon' => $arrAllTemplates[$strSelectedTemplate]['icon'],
+ 'os' => $arrAllTemplates[$strSelectedTemplate]['os'],
+ 'storage' => "default"
+ ],
+ 'domain' => [
+ 'name' => $strSelectedTemplate,
+ 'persistent' => 1,
+ 'uuid' => $lv->domain_generate_uuid(),
+ 'clock' => 'localtime',
+ 'arch' => 'x86_64',
+ 'machine' => 'pc-i440fx',
+ 'mem' => 1024 * 1024,
+ 'maxmem' => 1024 * 1024,
+ 'password' => '',
+ 'cpumode' => 'host-passthrough',
+ 'cpumigrate' => 'on',
+ 'vcpus' => 1,
+ 'vcpu' => [0],
+ 'hyperv' => 1,
+ 'ovmf' => 1,
+ 'usbmode' => 'usb2',
+ 'memoryBacking' => '{"nosharepages":{}}'
+ ],
+ 'media' => [
+ 'cdrom' => '',
+ 'cdrombus' => 'ide',
+ 'drivers' => is_file($domain_cfg['VIRTIOISO']) ? $domain_cfg['VIRTIOISO'] : '',
+ 'driversbus' => 'ide' ,
+ 'cdromboot' => 2
+ ],
+ 'disk' => [
+ [
+ 'new' => '',
+ 'size' => '',
+ 'driver' => 'raw',
+ 'dev' => 'hda',
+ 'select' => $domain_cfg['VMSTORAGEMODE'],
+ 'bus' => 'virtio' ,
+ 'boot' => 1,
+ 'serial' => 'vdisk1',
+ 'discard' => 'unmap'
+ ]
+ ],
+ 'gpu' => [
+ [
+ 'id' => 'virtual',
+ 'protocol' => 'vnc',
+ 'autoport' => 'yes',
+ 'model' => 'qxl',
+ 'keymap' => 'none',
+ 'port' => -1 ,
+ 'wsport' => -1,
+ 'copypaste' => 'no',
+ 'render' => 'auto',
+ 'DisplayOptions' => ""
+ ]
+ ],
+ 'audio' => [
+ [
+ 'id' => ''
+ ]
+ ],
+ 'pci' => [],
+ 'nic' => [
+ [
+ 'network' => $domain_bridge,
+ 'mac' => $lv->generate_random_mac_addr(),
+ 'model' => 'virtio-net'
+ ]
+ ],
+ 'usb' => [],
+ 'shares' => [
+ [
+ 'source' => '',
+ 'target' => '',
+ 'mode' => ''
+ ]
+ ]
+ ];
+ $hdrXML = "\n"; // XML encoding declaration
+
+ // Merge in any default values from the VM template
+ if ($arrAllTemplates[$strSelectedTemplate] && $arrAllTemplates[$strSelectedTemplate]['overrides']) {
+ $arrConfigDefaults = array_replace_recursive($arrConfigDefaults, $arrAllTemplates[$strSelectedTemplate]['overrides']);
+ }
+ // create new VM
+ if (isset($_POST['createvm'])) {
+ if (isset($_POST['xmldesc'])) {
+ // XML view
+ $new = $lv->domain_define($_POST['xmldesc'], $_POST['domain']['xmlstartnow']==1);
+ if ($new){
+ $lv->domain_set_autostart($new, $_POST['domain']['autostart']==1);
+ $reply = ['success' => true];
+ } else {
+ $reply = ['error' => $lv->get_last_error()];
}
- [$strVendor,$strProduct] = my_explode(':', $strNewUSBID2);
- // hot-attach usb
- file_put_contents('/tmp/hotattach.tmp', " ");
- exec("virsh attach-device ".escapeshellarg($uuid)." /tmp/hotattach.tmp --live 2>&1", $arrOutput, $intReturnCode);
- unlink('/tmp/hotattach.tmp');
- if ($intReturnCode != 0) {
- $arrErrors[] = implode(' ', $arrOutput);
+ } else {
+ // form view
+ if ($lv->domain_new($_POST)) {
+ // Fire off the vnc/spice popup if available
+ $dom = $lv->get_domain_by_name($_POST['domain']['name']);
+ $vmrcport = $lv->domain_get_vnc_port($dom);
+ $wsport = $lv->domain_get_ws_port($dom);
+ $protocol = $lv->domain_get_vmrc_protocol($dom);
+ $reply = ['success' => true];
+ if ($vmrcport > 0) {
+ if ($protocol == "vnc") $vmrcscale = "&resize=scale"; else $vmrcscale = "";
+ $reply['vmrcurl'] = autov('/plugins/dynamix.vm.manager/'.$protocol.'.html',true).'&autoconnect=true'.$vmrcscale.'&host=' . $_SERVER['HTTP_HOST'] ;
+ if ($protocol == "spice") $reply['vmrcurl'] .= '&port=/wsproxy/'.$vmrcport.'/'; else $reply['vmrcurl'] .= '&port=&path=/wsproxy/' . $wsport . '/';
+ }
+ } else {
+ $reply = ['error' => $lv->get_last_error()];
}
}
-
- // hot-detach any old usb devices
- foreach ($arrExistingConfig['usb'] as $arrExistingUSB) {
- if (!in_array($arrExistingUSB['id'], $arrNewUSBIDs)) {
- [$strVendor, $strProduct] = my_explode(':', $arrExistingUSB['id']);
- file_put_contents('/tmp/hotdetach.tmp', " ");
- exec("virsh detach-device ".escapeshellarg($uuid)." /tmp/hotdetach.tmp --live 2>&1", $arrOutput, $intReturnCode);
- unlink('/tmp/hotdetach.tmp');
- if ($intReturnCode != 0) $arrErrors[] = implode(' ',$arrOutput);
- }
- }
- $reply = !$arrErrors ? ['success' => true] : ['error' => implode(', ',$arrErrors)];
echo json_encode($reply);
exit;
}
- // backup xml for existing domain in ram
- if ($dom && empty($_POST['xmldesc'])) {
- $oldName = $lv->domain_get_name($dom);
- $newName = $_POST['domain']['name'];
- $oldDir = $domain_cfg['DOMAINDIR'].$oldName;
- $newDir = $domain_cfg['DOMAINDIR'].$newName;
- if ($oldName && $newName && is_dir($oldDir) && !is_dir($newDir)) {
- // mv domain/vmname folder
- if (rename($oldDir, $newDir)) {
- // replace all disk paths in xml
- foreach ($_POST['disk'] as &$arrDisk) {
- if ($arrDisk['new']) $arrDisk['new'] = str_replace($oldDir, $newDir, $arrDisk['new']);
- if ($arrDisk['image']) $arrDisk['image'] = str_replace($oldDir, $newDir, $arrDisk['image']);
+ // create new VM template
+ if (isset($_POST['createvmtemplate'])) {
+ $reply = addtemplatexml($_POST);
+ echo json_encode($reply);
+ exit;
+ }
+
+ // update existing VM
+ if (isset($_POST['updatevm'])) {
+ $uuid = $_POST['domain']['uuid'];
+ $dom = $lv->domain_get_domain_by_uuid($uuid);
+ $oldAutoStart = $lv->domain_get_autostart($dom)==1;
+ $newAutoStart = $_POST['domain']['autostart']==1;
+ $strXML = $lv->domain_get_xml($dom);
+
+ if ($lv->domain_get_state($dom)=='running') {
+ $arrErrors = [];
+ $arrExistingConfig = domain_to_config($uuid);
+ $arrNewUSBIDs = $_POST['usb'];
+
+ // hot-attach any new usb devices
+ foreach ($arrNewUSBIDs as $strNewUSBID) {
+ if (strpos($strNewUSBID,"#remove")) continue ;
+ $remove = explode('#', $strNewUSBID) ;
+ $strNewUSBID2 = $remove[0] ;
+ foreach ($arrExistingConfig['usb'] as $arrExistingUSB) {
+ if ($strNewUSBID2 == $arrExistingUSB['id']) continue 2;
+ }
+ [$strVendor,$strProduct] = my_explode(':', $strNewUSBID2);
+ // hot-attach usb
+ file_put_contents('/tmp/hotattach.tmp', " ");
+ exec("virsh attach-device ".escapeshellarg($uuid)." /tmp/hotattach.tmp --live 2>&1", $arrOutput, $intReturnCode);
+ unlink('/tmp/hotattach.tmp');
+ if ($intReturnCode != 0) {
+ $arrErrors[] = implode(' ', $arrOutput);
+ }
+ }
+
+ // hot-detach any old usb devices
+ foreach ($arrExistingConfig['usb'] as $arrExistingUSB) {
+ if (!in_array($arrExistingUSB['id'], $arrNewUSBIDs)) {
+ [$strVendor, $strProduct] = my_explode(':', $arrExistingUSB['id']);
+ file_put_contents('/tmp/hotdetach.tmp', " ");
+ exec("virsh detach-device ".escapeshellarg($uuid)." /tmp/hotdetach.tmp --live 2>&1", $arrOutput, $intReturnCode);
+ unlink('/tmp/hotdetach.tmp');
+ if ($intReturnCode != 0) $arrErrors[] = implode(' ',$arrOutput);
+ }
+ }
+ $reply = !$arrErrors ? ['success' => true] : ['error' => implode(', ',$arrErrors)];
+ echo json_encode($reply);
+ exit;
+ }
+
+ // backup xml for existing domain in ram
+ if ($dom && empty($_POST['xmldesc'])) {
+ $oldName = $lv->domain_get_name($dom);
+ $newName = $_POST['domain']['name'];
+ $oldDir = $domain_cfg['DOMAINDIR'].$oldName;
+ $newDir = $domain_cfg['DOMAINDIR'].$newName;
+ if ($oldName && $newName && is_dir($oldDir) && !is_dir($newDir)) {
+ // mv domain/vmname folder
+ if (rename($oldDir, $newDir)) {
+ // replace all disk paths in xml
+ foreach ($_POST['disk'] as &$arrDisk) {
+ if ($arrDisk['new']) $arrDisk['new'] = str_replace($oldDir, $newDir, $arrDisk['new']);
+ if ($arrDisk['image']) $arrDisk['image'] = str_replace($oldDir, $newDir, $arrDisk['image']);
+ }
}
}
}
- }
- $newuuid = $uuid;
- $olduuid = $uuid;
- // construct updated config
- if (isset($_POST['xmldesc'])) {
- // XML view
- $xml = $_POST['xmldesc'];
- $arrExistingConfig = custom::createArray('domain',$xml);
- $newuuid = $arrExistingConfig['uuid'];
- $xml = str_replace($olduuid,$newuuid,$xml);
- } else {
- // form view
- if ($error = create_vdisk($_POST) === false) {
- $arrExistingConfig = custom::createArray('domain',$strXML);
- $arrUpdatedConfig = custom::createArray('domain',$lv->config_to_xml($_POST));
- array_update_recursive($arrExistingConfig, $arrUpdatedConfig);
- $arrConfig = array_replace_recursive($arrExistingConfig, $arrUpdatedConfig);
- $xml = custom::createXML('domain',$arrConfig)->saveXML();
- $xml = $lv->appendqemucmdline($xml,$_POST["qemucmdline"]);
+ $newuuid = $uuid;
+ $olduuid = $uuid;
+ // construct updated config
+ if (isset($_POST['xmldesc'])) {
+ // XML view
+ $xml = $_POST['xmldesc'];
+ $arrExistingConfig = custom::createArray('domain',$xml);
+ $newuuid = $arrExistingConfig['uuid'] ;
+ $xml = str_replace($olduuid,$newuuid,$xml);
} else {
- echo json_encode(['error' => $error]);
- exit;
+ // form view
+ if ($error = create_vdisk($_POST) === false) {
+ $arrExistingConfig = custom::createArray('domain',$strXML);
+ $arrUpdatedConfig = custom::createArray('domain',$lv->config_to_xml($_POST));
+ array_update_recursive($arrExistingConfig, $arrUpdatedConfig);
+ $arrConfig = array_replace_recursive($arrExistingConfig, $arrUpdatedConfig);
+ $xml = custom::createXML('domain',$arrConfig)->saveXML();
+ $xml = $lv->appendqemucmdline($xml,$_POST["qemucmdline"]) ;
+ } else {
+ echo json_encode(['error' => $error]);
+ exit;
+ }
}
+ // delete and create the VM
+ $lv->nvram_backup($uuid);
+ $lv->domain_undefine($dom);
+ $lv->nvram_restore($uuid);
+ if ($newuuid != $olduuid) $lv->nvram_rename($olduuid,$newuuid);
+ $new = $lv->domain_define($xml);
+ if ($new) {
+ $lv->domain_set_autostart($new, $newAutoStart);
+ $reply = ['success' => true];
+ } else {
+ // Failure -- try to restore existing VM
+ $reply = ['error' => $lv->get_last_error()];
+ $old = $lv->domain_define($strXML);
+ if ($old) $lv->domain_set_autostart($old, $oldAutoStart);
+ }
+ echo json_encode($reply);
+ exit;
}
- // delete and create the VM
- $lv->nvram_backup($uuid);
- $lv->domain_undefine($dom);
- $lv->nvram_restore($uuid);
- if ($newuuid != $olduuid) $lv->nvram_rename($olduuid,$newuuid);
- $new = $lv->domain_define($xml);
- if ($new) {
- $lv->domain_set_autostart($new, $newAutoStart);
- $reply = ['success' => true];
+
+ if (isset($_GET['uuid'])) {
+ // edit an existing VM
+ $uuid = unscript($_GET['uuid']);
+ $dom = $lv->domain_get_domain_by_uuid($uuid);
+ $boolRunning = $lv->domain_get_state($dom)=='running';
+ $strXML = $lv->domain_get_xml($dom);
+ $boolNew = false;
+ $arrConfig = array_replace_recursive($arrConfigDefaults, domain_to_config($uuid));
+ $arrVMUSBs = getVMUSBs($strXML) ;
} else {
- // Failure -- try to restore existing VM
- $reply = ['error' => $lv->get_last_error()];
- $old = $lv->domain_define($strXML);
- if ($old) $lv->domain_set_autostart($old, $oldAutoStart);
+ // edit new VM
+ $boolRunning = false;
+ $strXML = '';
+ $boolNew = true;
+ $arrConfig = $arrConfigDefaults;
+ $arrVMUSBs = getVMUSBs($strXML) ;
+ $strXML = $lv->config_to_xml($arrConfig);
+ $domXML = new DOMDocument();
+ $domXML->preserveWhiteSpace = false;
+ $domXML->formatOutput = true;
+ $domXML->loadXML($strXML);
+ $strXML= $domXML->saveXML();
+ }
+ // Add any custom metadata field defaults (e.g. os)
+ if (!$arrConfig['template']['os']) {
+ $arrConfig['template']['os'] = ($arrConfig['domain']['clock']=='localtime' ? 'windows' : 'linux');
+ }
+ $os_type = ((empty($arrConfig['template']['os']) || stripos($arrConfig['template']['os'], 'windows') === false) ? 'other' : 'windows');
+ if (isset($arrConfig['clocks'])) $arrClocks = json_decode($arrConfig['clocks'],true) ; else {
+ if ($os_type == "windows") {
+ if ($arrConfig['domain']['hyperv'] == 1) $arrClocks = $arrDefaultClocks['hyperv'] ; else $arrClocks = $arrDefaultClocks['windows'] ;
+ } else $arrClocks = $arrDefaultClocks['other'] ;
}
- echo json_encode($reply);
- exit;
-}
-if (isset($_GET['uuid'])) {
- // edit an existing VM
- $uuid = unscript($_GET['uuid']);
- $dom = $lv->domain_get_domain_by_uuid($uuid);
- $boolRunning = $lv->domain_get_state($dom)=='running';
- $strXML = $lv->domain_get_xml($dom);
- $boolNew = false;
- $arrConfig = array_replace_recursive($arrConfigDefaults, domain_to_config($uuid));
- $arrVMUSBs = getVMUSBs($strXML);
-} else {
- // edit new VM
- $boolRunning = false;
- $strXML = '';
- $boolNew = true;
- $arrConfig = $arrConfigDefaults;
- $arrVMUSBs = getVMUSBs($strXML);
- $strXML = $lv->config_to_xml($arrConfig);
- $domXML = new DOMDocument();
- $domXML->preserveWhiteSpace = false;
- $domXML->formatOutput = true;
- $domXML->loadXML($strXML);
- $strXML= $domXML->saveXML();
-}
-
-// Add any custom metadata field defaults (e.g. os)
-if (!$arrConfig['template']['os']) {
- $arrConfig['template']['os'] = ($arrConfig['domain']['clock']=='localtime' ? 'windows' : 'linux');
-}
-
-$os_type = ((empty($arrConfig['template']['os']) || stripos($arrConfig['template']['os'], 'windows') === false) ? 'other' : 'windows');
-if (isset($arrConfig['clocks'])) $arrClocks = json_decode($arrConfig['clocks'],true); else {
- if ($os_type == "windows") {
- if ($arrConfig['domain']['hyperv'] == 1) $arrClocks = $arrDefaultClocks['hyperv']; else $arrClocks = $arrDefaultClocks['windows'];
- } else $arrClocks = $arrDefaultClocks['other'];
-}
-
-if (strpos($arrConfig['template']['name'],"User-") !== false) {
- $arrConfig['template']['name'] = str_replace("User-","",$arrConfig['template']['name']);
- unset($arrConfig['domain']['uuid']);
-}
-
-if ($usertemplate == 1) unset($arrConfig['domain']['uuid']);
-$xml2 = build_xml_templates($strXML);
-#disable rename if snapshots exist
-$snapshots = getvmsnapshots($arrConfig['domain']['name']);
-if ($snapshots != null && count($snapshots) && !$boolNew) {
- $snaprenamehidden = "";
- $namedisable = "disabled";
- $snapcount = count($snapshots);
-} else {
- $snaprenamehidden = "hidden";
- $namedisable = "";
- $snapcount = "0";
-};
+ if (strpos($arrConfig['template']['name'],"User-") !== false) {
+ $arrConfig['template']['name'] = str_replace("User-","",$arrConfig['template']['name']);
+ unset($arrConfig['domain']['uuid']);
+ }
+ if ($usertemplate == 1) unset($arrConfig['domain']['uuid']);
+ $xml2 = build_xml_templates($strXML);
+ #disable rename if snapshots exist
+ $snapshots = getvmsnapshots($arrConfig['domain']['name']) ;
+ if ($snapshots != null && count($snapshots) && !$boolNew)
+ {
+ $snaprenamehidden = "";
+ $namedisable = "disabled";
+ $snapcount = count($snapshots);
+ } else {
+ $snaprenamehidden = "hidden";
+ $namedisable = "";
+ $snapcount = "0";
+ };
?>
@@ -351,511 +350,85 @@ if ($snapshots != null && count($snapshots) && !$boolNew) {
-
-
-
- Give the VM a name (e.g. Work, Gaming, Media Player, Firewall, Bitcoin Miner)
-
-
-
-
-
+
- Give the VM a brief description (optional field).
+ Give the VM a name (e.g. Work, Gaming, Media Player, Firewall, Bitcoin Miner)
-
-
-
-
-
- Specify a URL that for menu to start. Substitution variables are
- [IP] IP address, this will take the first IP on the VM. Guest Agent must be installed for this to work.
- [PORT:XX] Port Number in XX.
- [VMNAME] VM Name will have spaces replaced with -
-
-
-
-
-
-
-
- _(Override Storage Location)_:
-
- name="template[storage]" onchange="get_storage_fstype(this)" class="disk_select narrow" id="storage_location" title="_(Location of virtual machine files)_">
-
- $default_storage=htmlspecialchars($arrConfig['template']['storage']);
- echo mk_option($default_storage, 'default', _('Default'));
-
- $strShareUserLocalInclude = '';
- $strShareUserLocalExclude = '';
- $strShareUserLocalUseCache = 'no';
-
- // Get the share name and its configuration
- $arrDomainDirParts = explode('/', $domain_cfg['DOMAINDIR']);
- $strShareName = $arrDomainDirParts[3];
- if (!empty($strShareName) && is_file('/boot/config/shares/'.$strShareName.'.cfg')) {
- $arrShareCfg = parse_ini_file('/boot/config/shares/'.$strShareName.'.cfg');
- if (!empty($arrShareCfg['shareInclude'])) {
- $strShareUserLocalInclude = $arrShareCfg['shareInclude'];
- }
- if (!empty($arrShareCfg['shareExclude'])) {
- $strShareUserLocalExclude = $arrShareCfg['shareExclude'];
- }
- if (!empty($arrShareCfg['shareUseCache'])) {
- $strShareUserLocalUseCache = $arrShareCfg['shareUseCache'];
- }
- }
-
- // Available cache pools
- foreach ($pools as $pool) {
- if (isSubpool($pool)) continue;
- $strLabel = $pool.' - '.my_scale($disks[$pool]['fsFree']*1024, $strUnit).' '.$strUnit.' '._('free');
- echo mk_option($default_storage, $pool, $strLabel);
- }
-
- // Determine which disks from the array are available for this share:
- foreach ($disks as $name => $disk) {
- if ((strpos($name, 'disk') === 0) && (!empty($disk['device']))) {
- if ((!empty($strShareUserLocalInclude) && (strpos($strShareUserLocalInclude.',', $name.',') === false)) ||
- (!empty($strShareUserLocalExclude) && (strpos($strShareUserLocalExclude.',', $name.',') !== false)) ||
- (!empty($var['shareUserInclude']) && (strpos($var['shareUserInclude'].',', $name.',') === false)) ||
- (!empty($var['shareUserExclude']) && (strpos($var['shareUserExclude'].',', $name.',') !== false))) {
- // skip this disk based on local and global share settings
- continue;
- }
- $strLabel = _(my_disk($name),3).' - '.my_scale($disk['fsFree']*1024, $strUnit).' '.$strUnit.' '._('free');
- echo mk_option($default_storage, $name, $strLabel);
- }
- }
-?>
-
-
-
-
-
- Specify the overide storage pool for VM. This option allows you to specify the physical pool/disk used to store the disk images and snapshot data.
- Default will follow standard processing and store images in the default location for the share defined in the settings.
- A pool/disk(Volume) will be the location for images if the default is overridden.
-
-
-
-
-
-$migratehidden = "disabled hidden";
-if ($arrConfig['domain']['cpumode'] == 'host-passthrough') $migratehidden = "";
-?>
-
-
-
- _(CPU)_ _(Mode)_:
-
-
- _('Host Passthrough').' ('.$strCPUModel.')', 'custom' => _('Emulated').' ('._('QEMU64').')'], $arrConfig['domain']['cpumode']);?>
-
- >_(Migratable)_:
- hidden class="narrow" title="_(define if migratable)_">
-
- echo mk_option($arrConfig['domain']['cpumigrate'], 'on', 'On');
- echo mk_option($arrConfig['domain']['cpumigrate'], 'off', 'Off');
-?>
-
-
-
-
-
-
-
-
- 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.
-
-
- Migratable
- Migratable attribute may be used to explicitly request such features to be removed from (on) or kept in (off) the virtual CPU. Off will not remove any host features when using Host Passthrough. Not support on emulated.
-
-
-
-
-
-
-
-
- There are two CPU modes available to choose:
-
- vCPUs Allocated
- Set the number of vCPUs allocated to the VM when not using pinning. The host will dynamically allocate workload for the VM across the whole system.
-
-
-
-
-
-
-
- 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)_:
-
-
-
- echo mk_option($arrConfig['domain']['mem'], 128 * 1024, '128 MB');
- echo mk_option($arrConfig['domain']['mem'], 256 * 1024, '256 MB');
- for ($i = 1; $i <= ($maxmem*2); $i++) {
- $label = ($i * 512).' MB';
- $value = $i * 512 * 1024;
- echo mk_option($arrConfig['domain']['mem'], $value, $label);
- }
-?>
-
- _(Max)_ _(Memory)_:
-
-
- echo mk_option($arrConfig['domain']['maxmem'], 128 * 1024, '128 MB');
- echo mk_option($arrConfig['domain']['maxmem'], 256 * 1024, '256 MB');
- for ($i = 1; $i <= ($maxmem*2); $i++) {
- $label = ($i * 512).' MB';
- $value = $i * 512 * 1024;
- echo mk_option($arrConfig['domain']['maxmem'], $value, $label);
- }
-?>
-
-
-
-
-
-
-
-
- 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 .
-
-
-
-
-if (!isset($arrValidMachineTypes[$arrConfig['domain']['machine']])) {
- $arrConfig['domain']['machine'] = ValidateMachineType($arrConfig['domain']['machine']);
-}
-?>
-
-
-
- _(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)_:
-
-
-
- echo mk_option($arrConfig['domain']['ovmf'], '0', _('SeaBIOS'));
- if (file_exists('/usr/share/qemu/ovmf-x64/OVMF_CODE-pure-efi.fd')) {
- echo mk_option($arrConfig['domain']['ovmf'], '1', _('OVMF'));
- } else {
- echo mk_option('', '0', _('OVMF').' ('._('Not Available').')', 'disabled');
- }
- if (file_exists('/usr/share/qemu/ovmf-x64/OVMF_CODE-pure-efi-tpm.fd')) {
- echo mk_option($arrConfig['domain']['ovmf'], '2', _('OVMF TPM'));
- } else {
- echo mk_option('', '0', _('OVMF TPM').' ('._('Not Available').')', 'disabled');
- }
-?>
-
-
- $usbboothidden = "hidden";
- if ($arrConfig['domain']['ovmf'] != '0') $usbboothidden = "";
-?>
- >_(Enable USB boot)_:
- onchange="USBBootChange(this)">
-
- echo mk_option($arrConfig['domain']['usbboot'], 'No', 'No');
- echo mk_option($arrConfig['domain']['usbboot'], 'Yes', 'Yes');
-?>
-
-
-
-
-
-
-
-
- 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.
-
-
- OVMF TPM
- (Open Virtual Machine Firmware) adds support for booting VMs using UEFI with TPM and Secure Boot available, 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.
-
-
- USB Boot
- Adds support for booting from USB devices using UEFI. No device boot orders can be specified at the same time as this option.
-
-
-
-
-
-
- _(Hyper-V)_:
-
- onchange="HypervChgNew(this)" >
-
-
-
-
-
-
-
+
- Exposes the guest to hyper-v extensions for Microsoft operating systems.
+ Give the VM a brief description (optional field).
-
-
-
- _(USB Controller)_:
-
-
-
- echo mk_option($arrConfig['domain']['usbmode'], 'usb2', _('2.0 (EHCI)'));
- echo mk_option($arrConfig['domain']['usbmode'], 'usb3', _('3.0 (nec XHCI)'));
- echo mk_option($arrConfig['domain']['usbmode'], 'usb3-qemu', _('3.0 (qemu XHCI)'));
-?>
-
-
-
-
-
-
-
-
- USB Controller
- Select the USB Controller to emulate. Some OSes won't support USB3 (e.g. Windows 7). Qemu XHCI is the same code base as Nec XHCI but without several hacks applied over the years. Recommended to try qemu XHCI before resorting to nec XHCI.
-
-
-
-
-
-
-
- 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.
-
-
-
-
-
-
+
- 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://docs.fedoraproject.org/en-US/quick-docs/creating-windows-virtual-machines-using-virtio-drivers/index.html#virtio-win-direct-downloads
- 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.
+
Specify a URL that for menu to start. Substitution variables are
+ [IP] IP address, this will take the first IP on the VM. Guest Agent must be installed for this to work.
+ [PORT:XX] Port Number in XX.
+ [VMNAME] VM Name will have spaces replaced with -
-
- $arrDisk) {
- $strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : _('Primary');
-?>
+
+
+
+ _(Override Storage Location)_:
+ name="template[storage]" onchange="get_storage_fstype(this)" class="disk_select narrow" id="storage_location" title="_(Location of virtual machine files)_">
+
+ $default_storage=htmlspecialchars($arrConfig['template']['storage']);
+ echo mk_option($default_storage, 'default', _('Default'));
+
+ $strShareUserLocalInclude = '';
+ $strShareUserLocalExclude = '';
+ $strShareUserLocalUseCache = 'no';
-
-
- _(vDisk Location)_:
-
-
-
- if ($i == 0) {
- echo ''._('None').' ';
- }
- $default_option = $arrDisk['select'];
- if (!empty($domain_cfg['DOMAINDIR']) && file_exists($domain_cfg['DOMAINDIR'])) {
- $boolShowAllDisks = (strpos($domain_cfg['DOMAINDIR'], '/mnt/user/') === 0);
- if (!empty($arrDisk['new'])) {
- if (strpos($domain_cfg['DOMAINDIR'], dirname(dirname($arrDisk['new']))) === false ||
- basename(dirname($arrDisk['new'])) != $arrConfig['domain']['name'] || (
- basename($arrDisk['new']) != 'vdisk'.($i+1).'.img') && basename($arrDisk['new']) != 'vdisk'.($i+1).'.qcow2') {
- $default_option = 'manual';
+ // Get the share name and its configuration
+ $arrDomainDirParts = explode('/', $domain_cfg['DOMAINDIR']);
+ $strShareName = $arrDomainDirParts[3];
+ if (!empty($strShareName) && is_file('/boot/config/shares/'.$strShareName.'.cfg')) {
+ $arrShareCfg = parse_ini_file('/boot/config/shares/'.$strShareName.'.cfg');
+ if (!empty($arrShareCfg['shareInclude'])) {
+ $strShareUserLocalInclude = $arrShareCfg['shareInclude'];
+ }
+ if (!empty($arrShareCfg['shareExclude'])) {
+ $strShareUserLocalExclude = $arrShareCfg['shareExclude'];
+ }
+ if (!empty($arrShareCfg['shareUseCache'])) {
+ $strShareUserLocalUseCache = $arrShareCfg['shareUseCache'];
+ }
}
- if (file_exists(dirname(dirname($arrDisk['new'])).'/'.$arrConfig['domain']['name'].'/vdisk'.($i+1).'.img') || file_exists(dirname(dirname($arrDisk['new'])).'/'.$arrConfig['domain']['name'].'/vdisk'.($i+1).'.qcow2')) {
- // hide all the disks because the auto disk already has been created
- $boolShowAllDisks = false;
- }
- }
- echo mk_option($default_option, 'auto', _('Auto'));
- if ($boolShowAllDisks) {
- $strShareUserLocalInclude = '';
- $strShareUserLocalExclude = '';
- $strShareUserLocalUseCache = 'no';
- // Get the share name and its configuration
- $arrDomainDirParts = explode('/', $domain_cfg['DOMAINDIR']);
- $strShareName = $arrDomainDirParts[3];
- if (!empty($strShareName) && is_file('/boot/config/shares/'.$strShareName.'.cfg')) {
- $arrShareCfg = parse_ini_file('/boot/config/shares/'.$strShareName.'.cfg');
- if (!empty($arrShareCfg['shareInclude'])) {
- $strShareUserLocalInclude = $arrShareCfg['shareInclude'];
- }
- if (!empty($arrShareCfg['shareExclude'])) {
- $strShareUserLocalExclude = $arrShareCfg['shareExclude'];
- }
- if (!empty($arrShareCfg['shareUseCache'])) {
- $strShareUserLocalUseCache = $arrShareCfg['shareUseCache'];
- }
- }
- // Available cache pools
- foreach ($pools as $pool) {
- if (isSubpool($pool)) continue;
+
+ // Available cache pools
+ foreach ($pools as $pool) {
+ if (isSubpool($pool)) continue;
$strLabel = $pool.' - '.my_scale($disks[$pool]['fsFree']*1024, $strUnit).' '.$strUnit.' '._('free');
- echo mk_option($default_option, $pool, $strLabel);
+ echo mk_option($default_storage, $pool, $strLabel);
}
+
// Determine which disks from the array are available for this share:
foreach ($disks as $name => $disk) {
if ((strpos($name, 'disk') === 0) && (!empty($disk['device']))) {
@@ -867,1051 +440,1525 @@ if (!isset($arrValidMachineTypes[$arrConfig['domain']['machine']])) {
continue;
}
$strLabel = _(my_disk($name),3).' - '.my_scale($disk['fsFree']*1024, $strUnit).' '.$strUnit.' '._('free');
- echo mk_option($default_option, $name, $strLabel);
+ echo mk_option($default_storage, $name, $strLabel);
}
- }
- }
- }
- echo mk_option($default_option, 'manual', _('Manual'));
-?>
-
-
-
-
-
-
- _(vDisk Size)_:
-
-
-
-
-
- _(vDisk Type)_:
-
-
-
-
-
-
-
- _(vDisk Bus)_:
-
-
-
-
- _(Boot Order)_:
-
- _(Discard)_:
-
-
-
- if ($arrDisk['bus'] == "virtio" || $arrDisk['bus'] == "usb") $ssddisabled = "hidden "; else $ssddisabled = " ";?>
- >_(SSD)_:
- =$arrDisk['rotation'] ? "checked ":"";?> title="_(Set SDD flag)_" value="=$arrDisk['rotation']?>" >
-
-
-
- _(Serial)_:
-
-
-
-
-
+ }
+ ?>
+
+
+
+ Specify the overide storage pool for VM. This option allows you to specify the physical pool/disk used to store the disk images and snapshot data.
+ Default will follow standard processing and store images in the default location for the share defined in the settings.
+ A pool/disk(Volume) will be the location for images if the default is overridden.
+
+
-
-
-
- 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.
-
-
- NOTE : Unraid will automatically "dereference" vdisk paths when starting a VM.
- That is, if a vdisk path is specified as being on a user share, we use the SYSTEM.LOCATION extended attribute to find out what physical disk the image exists on.
- We then pass this path when starting a VM via qemu. This ensures that VM I/O bypasses shfs (FUSE user share file system) for better performance.
- It also means that a vdisk image file can be moved from one physical device to another without changing the VM XML file.
-
-
- Example: /mnt/user/domains/Windows/vdisk1.img will be dereferenced to /mnt/cache/domains/Windows/vdisk1.img (for vdisk1.img physically located in the "cache" volume).
-
-
- 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.
-
-
- vDisk Boot Order
- Specify the order the devices are used for booting.
-
-
- vDisk Discard
- Specify if unmap(Trim) requests are sent to underlaying filesystem.
-
-
- vDisk SSD Flag
- Specify the vdisk shows as SSD within the guest, only supported on SCSI, SATA and IDE bus types.
-
-
- vDisk Serial
- Set the device serial number presented to the VM.
-
- Additional devices can be added/removed by clicking the symbols to the left.
-
-}?>
-}?>
-
-
-
-$arrUnraidShares = getUnraidShares();
-foreach ($arrConfig['shares'] as $i => $arrShare) {
-$strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : '';
-?>
-
+
+
+
+ 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.
+
+
+ Migratable
+ Migratable attribute may be used to explicitly request such features to be removed from (on) or kept in (off) the virtual CPU. Off will not remove any host features when using Host Passthrough. Not support on emulated.
+
+
+
-
-
+
+
+
+ There are two CPU modes available to choose:
+
+ vCPUs Allocated
+ Set the number of vCPUs allocated to the VM when not using pinning. The host will dynamically allocate workload for the VM across the whole system.
+
+
+
+
+
+ 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)_:
+
+
+
+ echo mk_option($arrConfig['domain']['mem'], 128 * 1024, '128 MB');
+ echo mk_option($arrConfig['domain']['mem'], 256 * 1024, '256 MB');
+ for ($i = 1; $i <= ($maxmem*2); $i++) {
+ $label = ($i * 512) . ' MB';
+ $value = $i * 512 * 1024;
+ echo mk_option($arrConfig['domain']['mem'], $value, $label);
+ }
+ ?>
+
+
+ _(Max)_ _(Memory)_:
+
+
+ echo mk_option($arrConfig['domain']['maxmem'], 128 * 1024, '128 MB');
+ echo mk_option($arrConfig['domain']['maxmem'], 256 * 1024, '256 MB');
+ for ($i = 1; $i <= ($maxmem*2); $i++) {
+ $label = ($i * 512) . ' MB';
+ $value = $i * 512 * 1024;
+ echo mk_option($arrConfig['domain']['maxmem'], $value, $label);
+ }
+ ?>
+
+
+
+
+
+
+
+ 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 .
+
+
+
+
+ if (!isset($arrValidMachineTypes[$arrConfig['domain']['machine']])) {
+ $arrConfig['domain']['machine'] = ValidateMachineType($arrConfig['domain']['machine']);
+ }
+ ?>
+
+
+
+ _(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)_:
+
+
+
+ echo mk_option($arrConfig['domain']['ovmf'], '0', _('SeaBIOS'));
+
+ if (file_exists('/usr/share/qemu/ovmf-x64/OVMF_CODE-pure-efi.fd')) {
+ echo mk_option($arrConfig['domain']['ovmf'], '1', _('OVMF'));
+ } else {
+ echo mk_option('', '0', _('OVMF').' ('._('Not Available').')', 'disabled');
+ }
+ if (file_exists('/usr/share/qemu/ovmf-x64/OVMF_CODE-pure-efi-tpm.fd')) {
+ echo mk_option($arrConfig['domain']['ovmf'], '2', _('OVMF TPM'));
+ } else {
+ echo mk_option('', '0', _('OVMF TPM').' ('._('Not Available').')', 'disabled');
+ }
+ ?>
+
+
+
+ $usbboothidden = "hidden" ;
+ if ($arrConfig['domain']['ovmf'] != '0') $usbboothidden = "" ;
+ ?>
+ >_(Enable USB boot)_:
+
+ onchange="USBBootChange(this)">
+
+ echo mk_option($arrConfig['domain']['usbboot'], 'No', 'No');
+ echo mk_option($arrConfig['domain']['usbboot'], 'Yes', 'Yes');
+ ?>
+
+
+
+
- Unraid Share Mode
- Used to create a VirtFS mapping to a Linux-based guest. Specify the mode you want to use either 9p or Virtiofs.
+ SeaBIOS
+ is the default virtual BIOS used to create virtual machines and is compatible with all guest operating systems (Windows, Linux, etc.).
- Unraid Share
- Set tag and path to match the selected Unraid share.
+ 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.
- Unraid Source Path
- Specify the path on the host here.
+ OVMF TPM
+ (Open Virtual Machine Firmware) adds support for booting VMs using UEFI with TPM and Secure Boot available, 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.
- 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
+ Once a VM is created this setting cannot be adjusted.
- For Windows additional software needs to be installed: https://virtio-fs.gitlab.io/howto-windows.html
+ USB Boot
+ Adds support for booting from USB devices using UEFI. No device boot orders can be specified at the same time as this option.
- Additional devices can be added/removed by clicking the symbols to the left.
-
-}?>
-}?>
-
-
- $arrGPU) {
-$strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : '';
-$bootgpuhidden = " hidden ";
-?>
-
-
- _(Graphics Card)_:
-
-
-
-
-
- _(Multifunction)_:
- >
-
-
-
-
-
-
- } else {?>
-
- }?>
-
-
-
- _(VM Console Protocol)_:
-
-
-
-
-
+
-
-
-
-
- Graphics Card
- If you wish to assign a graphics card to the VM, select it from this list, otherwise leave it set to virtual.
-
-
- Virtual video protocol VNC/SPICE
- If you wish to assign a protocol type, specify one here.
-
-
- Virtual enable copy paste for VNC/SPICE
- If you enable copy paste you need to install additional software on the client in addition to the QEMU agent if that has been installed. https://www.spice-space.org/download.html is the location for spice-vdagent for both window and linux. Note copy paste function will not work with web spice viewer you need to use virt-viewer.
-
-
- Virtual auto port
- Set it you want to specify a manual port for VNC or Spice. VNC needs two ports where Spice only requires one. Leave as auto yes for the system to set.
-
-
- Virtual Video Driver
- If you wish to assign a different video driver to use for a VM Console connection, specify one here.
- QXL has an option of setting number of screens and vram.
- Virtio3d allows render device to be specified or auto.(This allow GPU to be used in a VM without passthru for 3D acceleration no screen output)
-
-
- Virtual Password
- If you wish to require a password to connect to the VM over a VM Console connection, specify one here.
-
-
- Virtual Keyboard
- If you wish to assign a different keyboard layout to use for a VM Console connection, specify one here.
-
-
- Graphics ROM BIOS
- If you wish to use a custom ROM BIOS for a Graphics card, 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)_:
-
-
-
- echo mk_option($arrAudio['id'], '', _('None'));
- foreach($arrValidAudioDevices as $arrDev) {
- echo mk_option($arrAudio['id'], $arrDev['id'], $arrDev['name'].' ('.$arrDev['id'].')');
- }
- ?>
-
-
-
-
-
-
-
-
- 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.
-
-}?>
-}?>
-
-
-
- $domain_bridge,
- 'mac' => "",
- 'model' => 'virtio-net'
- ];
-}
-foreach ($arrConfig['nic'] as $i => $arrNic) {
-$strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : '';
-?>
-
-
-
- _(Network MAC)_:
-
-
-
-
-
-
- _(Network Source)_:
-
-
-
- foreach (array_keys($arrValidNetworks) as $key) {
- echo mk_option("", $key, "- "._($key)." -", "disabled");
- foreach ($arrValidNetworks[$key] as $strNetwork) {
- echo mk_option($arrNic['network'], $strNetwork, $strNetwork);
- }
- }
- ?>
-
-
-
-
- _(Network Model)_:
-
-
-
- echo mk_option($arrNic['model'], 'virtio-net', 'virtio-net');
- echo mk_option($arrNic['model'], 'virtio', 'virtio');
- echo mk_option($arrNic['model'], 'e1000', 'e1000');
- echo mk_option($arrNic['model'], 'rtl8139', 'rtl8139');
- echo mk_option($arrNic['model'], 'vmxnet3', 'vmxnet3');
- ?>
-
-
-
-
- _(Boot Order)_:
-
- style="width: 50px;" name="nic[=$i?>][boot]" title="_(Boot order)_" value="=$arrNic['boot']?>" >
-
-
-
-
-
-
-
-
- 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 Source
- The default libvirt managed network bridge (virbr0) will be used, otherwise you may specify an alternative name for a private network to the host.
-
-
- Network Model
- Default and recommended is 'virtio-net', which gives improved stability. To improve performance 'virtio' can be selected, but this may lead to stability issues.
-
- Use boot order to set device as bootable and boot sequence.
- Additional devices can be added/removed by clicking the symbols to the left.
-
-
-}?>
-}?>
-
-
-
-
+
+
+
+ Exposes the guest to hyper-v extensions for Microsoft operating systems.
+
-
-
-
+
-
- If you wish to assign any USB devices to your guest, you can select them from this list.
- Use boot order to set device as bootable and boot sequence.
- Select optional if you want device to be ignored when VM starts if not present.
-
+
+
+ _(USB Controller)_:
+
+
+
+ echo mk_option($arrConfig['domain']['usbmode'], 'usb2', _('2.0 (EHCI)'));
+ echo mk_option($arrConfig['domain']['usbmode'], 'usb3', _('3.0 (nec XHCI)'));
+ echo mk_option($arrConfig['domain']['usbmode'], 'usb3-qemu', _('3.0 (qemu XHCI)'));
+ ?>
+
+
+
+
+
+
+
+ USB Controller
+ Select the USB Controller to emulate. Some OSes won't support USB3 (e.g. Windows 7). Qemu XHCI is the same code base as Nec XHCI but without several hacks applied over the years. Recommended to try qemu XHCI before resorting to nec XHCI.
+
+
+
-
-
-If you wish to assign any other PCI devices to your guest, you can select them from this list.
-Use boot order to set device as bootable and boot sequence. Only NVMe and Network devices (PCI types 0108 and 02xx) supported for boot order.
-
-
-
-
-
-
- Click Create to generate the vDisks and return to the Virtual Machines page where your new VM will be created.
-
-}?>
-
-
-
-
- _(Advanced tuning options)_
-
-
- _(QEMU Command Line)_:
-
- if ($arrConfig['qemucmdline'] == "") $qemurows = 2; else $qemurows = 15;
- ?>
-
-
-
-
-
-
-
- If you need to add QEMU arguments to the XML
- Examples can be found on the Libvirt page => https://libvirt.org/kbase/qemu-passthrough-security.html
-
-
-
-
-
-
- _(Clocks)_
-
-
- _(Clocks Offset)_:
-
- $clockdisabled = "";?>
- id="clockoffset" class="narrow" title="_(Clock Offset)_" =$arrConfig["domain"]['clock']?>>
-
- echo mk_option($arrConfig['domain']['clock'], 'localtime', 'Localtime');
- echo mk_option($arrConfig['domain']['clock'], 'utc', "UTC");
- ?>
-
-
-
-
-
-
-
-
-
- $clockcount = 0;
- if (!empty($arrClocks)) {
- foreach($arrClocks as $i => $arrTimer) {
- if ($i =="offset") continue;
- if ($clockcount == 0) $clocksourcetext = _("Timer Source").":"; else $clocksourcetext = "";
- ?>
-
- =$clocksourcetext?>
- =ucfirst($i)?>:
-
- _(Present)_:
- id="clock[=$i?>][present]" class="narrow" title="_(Clock Offset)_" =$arrTimer["present"]?>>
-
- echo mk_option($arrTimer["present"], 'yes', 'Yes');
- echo mk_option($arrTimer["present"], 'no', "No");
- ?>
-
-
-
- _(Tickpolicy)_:
- id="clock[=$i?>][tickpolicy]" class="narrow" title="_(Clock Offset)_" =$arrTimer["tickpolicy"]?>>
-
- echo mk_option($arrTimer["tickpolicy"], 'delay', 'Delay');
- echo mk_option($arrTimer["tickpolicy"], 'catchup', 'Catchup');
- echo mk_option($arrTimer["tickpolicy"], 'merge', "Merge");
- echo mk_option($arrTimer["tickpolicy"], 'discard', "Discard");
- ?>
-
-
-
-
- $clockcount++;
- }
- }
- ?>
-
-
-
- Allows setting of timers and offset into the XML You should not need to modify these values.
- Windows tuning details can be found here https://forums.unraid.net/topic/134041-guide-optimizing-windows-vms-in-unraid/
- Details can be found on the Libvirt XML page => https://libvirt.org/formatdomain.html#time-keeping
- Defaults are:
- linux Hpet:no Hypervclock: no Pit yes rtc yes tickpolicy catchup.
- Windows Hpet:no Hypervclock: yes Pit yes rtc yes tickpolicy catchup.
- Windows and Hyperv Hpet:no Hypervclock: yes Pit no rtc no.
-
-
-
-if (!isset($arrConfig['evdev'])) $arrConfig['evdev'][0] = ['dev'=>"",'grab'=>"",'repeat'=>"",'grabToggle'=>""];
-foreach ($arrConfig['evdev'] as $i => $arrEvdev) {
-$strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : '';
-?>
-
-
- _(Evdev Device)_:
-
-
-
- echo mk_option($arrEvdev['dev'], '', _('None'));
- foreach(getValidevDev() as $line) echo mk_option($arrEvdev['dev'], $line , $line);
- ?>
-
-
-
-
-
-
-
-
-
- _(Grab)_:
-
-
-
- echo mk_option($arrEvdev['grab'], '', _('None'));
- foreach(["all"] as $line) echo mk_option($arrEvdev['grab'],$line,ucfirst($line));
- ?>
-
-
-
-
- _(Repeat)_:
-
-
-
- echo mk_option($arrEvdev['repeat'], '', _('None'));
- foreach(["on","off"] as $line) echo mk_option($arrEvdev['repeat'],$line,ucfirst($line));
- ?>
-
-
-
-
- _(Grab Toggle)_:
-
-
-
- echo mk_option($arrEvdev['grabToggle'], '', _('None'));
- foreach(["ctrl-ctrl", "alt-alt", "shift-shift", "meta-meta", "scrolllock" , "ctrl-scrolllock"] as $line) echo mk_option($arrEvdev['grabToggle'],$line,$line);
- ?>
-
-
-
-
-
-
-
+
-
- Event Devices
- Evdev is an input interface built into the Linux kernel. QEMU’s evdev passthrough support allows a user to redirect evdev events to a guest. These events can include mouse movements and key presses. By hitting both Ctrl keys at the same time, QEMU can toggle the input recipient. QEMU’s evdev passthrough also features almost no latency, making it perfect for gaming. The main downside to evdev passthrough is the lack of button rebinding – and in some cases, macro keys won’t even work at all.
- Optional items are normally only used for keyboards.
+
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.
-
- Device
- Host device to passthrough to guest.
-
-
- Grab
- All grabs all input devices instead of just one
-
-
- Repeat
- Repeat with value 'on'/'off' to enable/disable auto-repeat events
-
-
- GrabToggle
- GrabToggle with values ctrl-ctrl, alt-alt, shift-shift, meta-meta, scrolllock or ctrl-scrolllock to change the grab key combination
-
- Additional devices can be added/removed by clicking the symbols to the left.
-
-}?>
-}?>
-
+
+
+
+
+ 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://docs.fedoraproject.org/en-US/quick-docs/creating-windows-virtual-machines-using-virtio-drivers/index.html#virtio-win-direct-downloads
+ 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.
+
+
+
+
-
-
-
-
-
-
-
- } else {?>
-
-
+ $arrDisk) {
+ $strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : _('Primary');
+
+ ?>
+
+
+ _(vDisk Location)_:
+
+
+
+ if ($i == 0) {
+ echo ''._('None').' ';
+ }
+
+ $default_option = $arrDisk['select'];
+
+ if (!empty($domain_cfg['DOMAINDIR']) && file_exists($domain_cfg['DOMAINDIR'])) {
+
+ $boolShowAllDisks = (strpos($domain_cfg['DOMAINDIR'], '/mnt/user/') === 0);
+
+ if (!empty($arrDisk['new'])) {
+ if (strpos($domain_cfg['DOMAINDIR'], dirname(dirname($arrDisk['new']))) === false ||
+ basename(dirname($arrDisk['new'])) != $arrConfig['domain']['name'] || (
+ basename($arrDisk['new']) != 'vdisk'.($i+1).'.img') && basename($arrDisk['new']) != 'vdisk'.($i+1).'.qcow2') {
+ $default_option = 'manual';
+ }
+ if (file_exists(dirname(dirname($arrDisk['new'])).'/'.$arrConfig['domain']['name'].'/vdisk'.($i+1).'.img') || file_exists(dirname(dirname($arrDisk['new'])).'/'.$arrConfig['domain']['name'].'/vdisk'.($i+1).'.qcow2')) {
+ // hide all the disks because the auto disk already has been created
+ $boolShowAllDisks = false;
+ }
+ }
+
+ echo mk_option($default_option, 'auto', _('Auto'));
+
+ if ($boolShowAllDisks) {
+ $strShareUserLocalInclude = '';
+ $strShareUserLocalExclude = '';
+ $strShareUserLocalUseCache = 'no';
+
+ // Get the share name and its configuration
+ $arrDomainDirParts = explode('/', $domain_cfg['DOMAINDIR']);
+ $strShareName = $arrDomainDirParts[3];
+ if (!empty($strShareName) && is_file('/boot/config/shares/'.$strShareName.'.cfg')) {
+ $arrShareCfg = parse_ini_file('/boot/config/shares/'.$strShareName.'.cfg');
+ if (!empty($arrShareCfg['shareInclude'])) {
+ $strShareUserLocalInclude = $arrShareCfg['shareInclude'];
+ }
+ if (!empty($arrShareCfg['shareExclude'])) {
+ $strShareUserLocalExclude = $arrShareCfg['shareExclude'];
+ }
+ if (!empty($arrShareCfg['shareUseCache'])) {
+ $strShareUserLocalUseCache = $arrShareCfg['shareUseCache'];
+ }
+ }
+
+ // Available cache pools
+ foreach ($pools as $pool) {
+ if (isSubpool($pool)) continue;
+ $strLabel = $pool.' - '.my_scale($disks[$pool]['fsFree']*1024, $strUnit).' '.$strUnit.' '._('free');
+ echo mk_option($default_option, $pool, $strLabel);
+ }
+
+ // Determine which disks from the array are available for this share:
+ foreach ($disks as $name => $disk) {
+ if ((strpos($name, 'disk') === 0) && (!empty($disk['device']))) {
+ if ((!empty($strShareUserLocalInclude) && (strpos($strShareUserLocalInclude.',', $name.',') === false)) ||
+ (!empty($strShareUserLocalExclude) && (strpos($strShareUserLocalExclude.',', $name.',') !== false)) ||
+ (!empty($var['shareUserInclude']) && (strpos($var['shareUserInclude'].',', $name.',') === false)) ||
+ (!empty($var['shareUserExclude']) && (strpos($var['shareUserExclude'].',', $name.',') !== false))) {
+ // skip this disk based on local and global share settings
+ continue;
+ }
+ $strLabel = _(my_disk($name),3).' - '.my_scale($disk['fsFree']*1024, $strUnit).' '.$strUnit.' '._('free');
+ echo mk_option($default_option, $name, $strLabel);
+ }
+ }
+ }
+
+ }
+
+ echo mk_option($default_option, 'manual', _('Manual'));
+ ?>
+
+
+
+
+
+
+
+
+ _(vDisk Size)_:
+
+
+
+
+
+
+ _(vDisk Type)_:
+
+
+
+
+
+
+
+
+ _(vDisk Bus)_:
+
+
+
+
+ _(Boot Order)_:
+
+ _(Discard)_:
+
+
+
+ if ($arrDisk['bus'] == "virtio" || $arrDisk['bus'] == "usb") $ssddisabled = "hidden "; else $ssddisabled = " ";?>
+ >_(SSD)_:
+ =$arrDisk['rotation'] ? "checked ":"";?> title="_(Set SDD flag)_" value="=$arrDisk['rotation']?>" >
+
+
+
+ _(Serial)_:
+
+
+
+
+
+
+
+
+ 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.
+
+
+
+ NOTE : Unraid will automatically "dereference" vdisk paths when starting a VM.
+ That is, if a vdisk path is specified as being on a user share, we use the SYSTEM.LOCATION extended attribute to find out what physical disk the image exists on.
+ We then pass this path when starting a VM via qemu. This ensures that VM I/O bypasses shfs (FUSE user share file system) for better performance.
+ It also means that a vdisk image file can be moved from one physical device to another without changing the VM XML file.
+
+
+
+ Example: /mnt/user/domains/Windows/vdisk1.img will be dereferenced to /mnt/cache/domains/Windows/vdisk1.img (for vdisk1.img physically located in the "cache" volume).
+
+
+
+ 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.
+
+
+
+ vDisk Boot Order
+ Specify the order the devices are used for booting.
+
+
+
+ vDisk Discard
+ Specify if unmap(Trim) requests are sent to underlaying filesystem.
+
+
+
+ vDisk SSD Flag
+ Specify the vdisk shows as SSD within the guest, only supported on SCSI, SATA and IDE bus types.
+
+
+
+ vDisk Serial
+ Set the device serial number presented to the VM.
+
+
+ Additional devices can be added/removed by clicking the symbols to the left.
+
}?>
-
-
-
-
-
+ }?>
+
+
+
+ $arrUnraidShares = getUnraidShares() ;
+ foreach ($arrConfig['shares'] as $i => $arrShare) {
+ $strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : '';
+
+ ?>
+
+
+
+
+
+
+ Unraid Share Mode
+ Used to create a VirtFS mapping to a Linux-based guest. Specify the mode you want to use either 9p or Virtiofs.
+
+
+
+
+ Unraid Share
+ Set tag and path to match the selected Unraid share.
+
+
+
+ Unraid Source Path
+ 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
+
+
+ For Windows additional software needs to be installed: https://virtio-fs.gitlab.io/howto-windows.html
+
+
+ Additional devices can be added/removed by clicking the symbols to the left.
+
+
+
+ }?>
+ }?>
+
+
+ $arrGPU) {
+ $strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : '';
+ $bootgpuhidden = " hidden ";
+?>
+
+
+ _(Graphics Card)_:
+
+
+
+ if ($i == 0) {
+ // Only the first video card can be VNC or SPICE
+ echo mk_option($arrGPU['id'], 'virtual', _('Virtual'));
+
+ } else {
+ echo mk_option($arrGPU['id'], '', _('None'));
+ }
+ echo mk_option($arrGPU['id'], 'nogpu', _('No GPU'));
+ foreach($arrValidGPUDevices as $arrDev) {
+ echo mk_option($arrGPU['id'], $arrDev['id'], $arrDev['name'].' ('.$arrDev['id'].')');
+ }
+ ?>
+
+
+ if ($arrGPU['id'] != 'virtual' && $arrGPU['id'] != 'nogpu') $multifunction = "" ; else $multifunction = " disabled " ;
+ ?>
+ _(Multifunction)_:
+
+ >
+
+ echo mk_option($arrGPU['guest']['multi'], 'off', 'Off');
+ echo mk_option($arrGPU['guest']['multi'], 'on', 'On');
+ ?>
+
+
+
+ if ($arrGPU['id'] == 'virtual') {
+ ?>
+
+ } else {?>
+
+ }?>
+
+
+
+
+ _(VM Console Protocol)_:
+
+
+
+
+
+
+
+ _(VM Console enable Copy/paste)_:
+
+
+
+ echo mk_option($arrGPU['copypaste'], 'no', _('No'));
+ echo mk_option($arrGPU['copypaste'], 'yes', _('Yes'));
+ ?>
+
+
+
+ _(VM Console AutoPort)_:
+
+
+
+ echo mk_option($arrGPU['autoport'], 'yes', _('Yes'));
+ echo mk_option($arrGPU['autoport'], 'no', _('No'));
+ ?>
+
+
+ >_(VM Console Port)_:
+
+ >
+
+ >_(VM Console WS Port)_:
+
+ >
+
+
+
+
+ _(VM Console Video Driver)_:
+
+
+
+
+
+ >_(Render GPU)_:
+
+
+ echo mk_option($arrGPU['render'], 'auto', _('Auto'));
+ foreach($arrValidGPUDevices as $arrDev) {
+ echo mk_option($arrGPU['render'], $arrDev['id'], $arrDev['name'].' ('.$arrDev['id'].')');
+ }
+ ?>
+
+ $arrGPU['DisplayOptions'] = htmlentities($arrDisplayOptions[$arrGPU['DisplayOptions']]['qxlxml'],ENT_QUOTES);
+ if ($arrGPU['model'] == "qxl") $vncdspopt = "" ; else $vncdspopt = " hidden ";?>
+ >_(Display(s) and RAM)_:
+
+
+ foreach($arrDisplayOptions as $key => $value) {
+ echo mk_option($arrGPU['DisplayOptions'], htmlentities($value['qxlxml'],ENT_QUOTES), _($value['text']));
+ }?>
+
+
+
+
+
+ _(VM Console Password)_:
+
+
+
+ _(VM Console Keyboard)_:
+
+
+
+
+
+
+ }?>
+
+ _(Graphics ROM BIOS)_:
+
+
+
+
+
+ if ($arrValidGPUDevices[$arrGPU['id']]['bootvga'] == "1") $bootgpuhidden = "";
+ ?>
+ >_(Graphics ROM Needed?)_: _(GPU is primary adapater, vbios may be required.)_
+
+
+
+
+ Graphics Card
+ If you wish to assign a graphics card to the VM, select it from this list, otherwise leave it set to virtual.
+
+
+
+ Virtual video protocol VNC/SPICE
+ If you wish to assign a protocol type, specify one here.
+
+
+
+ Virtual enable copy paste for VNC/SPICE
+ If you enable copy paste you need to install additional software on the client in addition to the QEMU agent if that has been installed. https://www.spice-space.org/download.html is the location for spice-vdagent for both window and linux. Note copy paste function will not work with web spice viewer you need to use virt-viewer.
+
+
+
+ Virtual auto port
+ Set it you want to specify a manual port for VNC or Spice. VNC needs two ports where Spice only requires one. Leave as auto yes for the system to set.
+
+
+
+ Virtual Video Driver
+ If you wish to assign a different video driver to use for a VM Console connection, specify one here.
+ QXL has an option of setting number of screens and vram.
+ Virtio3d allows render device to be specified or auto.(This allow GPU to be used in a VM without passthru for 3D acceleration no screen output)
+
+
+
+ Virtual Password
+ If you wish to require a password to connect to the VM over a VM Console connection, specify one here.
+
+
+
+ Virtual Keyboard
+ If you wish to assign a different keyboard layout to use for a VM Console connection, specify one here.
+
+
+
+ Graphics ROM BIOS
+ If you wish to use a custom ROM BIOS for a Graphics card, 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)_:
+
+
+
+ echo mk_option($arrAudio['id'], '', _('None'));
+
+ foreach($arrValidAudioDevices as $arrDev) {
+ echo mk_option($arrAudio['id'], $arrDev['id'], $arrDev['name'].' ('.$arrDev['id'].')');
+ }
+ ?>
+
+
+
+
+
+
+
+ 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.
+
+ }?>
+ }?>
+
+
+ if ( $arrConfig['nic'] == false) {
+ $arrConfig['nic']['0'] =
+ [
+ 'network' => $domain_bridge,
+ 'mac' => "",
+ 'model' => 'virtio-net'
+ ] ;
+ }
+ foreach ($arrConfig['nic'] as $i => $arrNic) {
+ $strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : '';
+
+ ?>
+
+
+ _(Network MAC)_:
+
+
+
+
+
+
+ _(Network Source)_:
+
+
+
+ foreach (array_keys($arrValidNetworks) as $key) {
+ echo mk_option("", $key, "- "._($key)." -", "disabled");
+ foreach ($arrValidNetworks[$key] as $strNetwork) {
+ echo mk_option($arrNic['network'], $strNetwork, $strNetwork);
+ }
+ }
+ ?>
+
+
+
+
+ _(Network Model)_:
+
+
+
+ echo mk_option($arrNic['model'], 'virtio-net', 'virtio-net');
+ echo mk_option($arrNic['model'], 'virtio', 'virtio');
+ echo mk_option($arrNic['model'], 'e1000', 'e1000');
+ echo mk_option($arrNic['model'], 'rtl8139', 'rtl8139');
+ echo mk_option($arrNic['model'], 'vmxnet3', 'vmxnet3');
+ ?>
+
+
+
+
+ _(Boot Order)_:
+
+ style="width: 50px;" name="nic[=$i?>][boot]" title="_(Boot order)_" value="=$arrNic['boot']?>" >
+
+
+
+
+
+
+
+ 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 Source
+ The default libvirt managed network bridge (virbr0) will be used, otherwise you may specify an alternative name for a private network to the host.
+
+
+
+ Network Model
+ Default and recommended is 'virtio-net', which gives improved stability. To improve performance 'virtio' can be selected, but this may lead to stability issues.
+
+
+ Use boot order to set device as bootable and boot sequence.
+
+ Additional devices can be added/removed by clicking the symbols to the left.
+
+
+ }?>
+ }?>
+
+
+
+
+ If you wish to assign any USB devices to your guest, you can select them from this list.
+ Use boot order to set device as bootable and boot sequence.
+ Select optional if you want device to be ignored when VM starts if not present.
+
+
+
+
+ If you wish to assign any other PCI devices to your guest, you can select them from this list.
+ Use boot order to set device as bootable and boot sequence. Only NVMe and Network devices (PCI types 0108 and 02xx) supported for boot order.
+
+
+
+
+
+
+
+ Click Create to generate the vDisks and return to the Virtual Machines page where your new VM will be created.
+
+ }?>
+
+
- _(Other XML)_:
-
+ _(Advanced tuning options)_
+
+ _(QEMU Command Line)_:
+
+ if ($arrConfig['qemucmdline'] == "") $qemurows = 2 ; else $qemurows = 15 ;
+ ?>
+
+
+
+
+
+
+ If you need to add QEMU arguments to the XML
+ Examples can be found on the Libvirt page => https://libvirt.org/kbase/qemu-passthrough-security.html
+
+
+
+
+ _(Clocks)_
+ _(Clocks Offset)_:
+ $clockdisabled = "" ;?>
+ id="clockoffset" class="narrow" title="_(Clock Offset)_" =$arrConfig["domain"]['clock']?>>
+
+ echo mk_option($arrConfig['domain']['clock'], 'localtime', 'Localtime');
+ echo mk_option($arrConfig['domain']['clock'], 'utc', "UTC");
+ ?>
+
+
+
+
+ $clockcount = 0 ;
+ if (!empty($arrClocks)) {
+ foreach($arrClocks as $i => $arrTimer) {
+ if ($i =="offset") continue ;
+ if ($clockcount == 0) $clocksourcetext = _("Timer Source").":" ;else $clocksourcetext = "" ;
+ ?>
+ =$clocksourcetext?>
+
+ =ucfirst($i)?>:
+
+ _(Present)_:
+ id="clock[=$i?>][present]" class="narrow" title="_(Clock Offset)_" =$arrTimer["present"]?>>
+
+ echo mk_option($arrTimer["present"], 'yes', 'Yes');
+ echo mk_option($arrTimer["present"], 'no', "No");
+ ?>
+
+
+ _(Tickpolicy)_:
+ id="clock[=$i?>][tickpolicy]" class="narrow" title="_(Clock Offset)_" =$arrTimer["tickpolicy"]?>>
+
+ echo mk_option($arrTimer["tickpolicy"], 'delay', 'Delay');
+ echo mk_option($arrTimer["tickpolicy"], 'catchup', 'Catchup');
+ echo mk_option($arrTimer["tickpolicy"], 'merge', "Merge");
+ echo mk_option($arrTimer["tickpolicy"], 'discard', "Discard");
+ ?>
+
+
+
+ $clockcount++ ;
+ }
+ }
+ ?>
+
+
+
+
+ Allows setting of timers and offset into the XML You should not need to modify these values.
+ Windows tuning details can be found here https://forums.unraid.net/topic/134041-guide-optimizing-windows-vms-in-unraid/
+ Details can be found on the Libvirt XML page => https://libvirt.org/formatdomain.html#time-keeping
+ Defaults are:
+ linux Hpet:no Hypervclock: no Pit yes rtc yes tickpolicy catchup.
+ Windows Hpet:no Hypervclock: yes Pit yes rtc yes tickpolicy catchup.
+ Windows and Hyperv Hpet:no Hypervclock: yes Pit no rtc no.
+
+
+
+ if (!isset($arrConfig['evdev'])) $arrConfig['evdev'][0] = ['dev'=>"",'grab'=>"",'repeat'=>"",'grabToggle'=>""];
+ foreach ($arrConfig['evdev'] as $i => $arrEvdev) {
+ $strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : '';
+ ?>
+
+
+ _(Evdev Device)_:
+
+
+
+ echo mk_option($arrEvdev['dev'], '', _('None'));
+ foreach(getValidevDev() as $line) echo mk_option($arrEvdev['dev'], $line , $line);
+ ?>
+
+
+
+
+
+
+ _(Grab)_:
+
+
+
+
+
+
+
+
+ _(Repeat)_:
+
+
+
+
+
+
+
+
+ _(Grab Toggle)_:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Event Devices
+ Evdev is an input interface built into the Linux kernel. QEMU’s evdev passthrough support allows a user to redirect evdev events to a guest. These events can include mouse movements and key presses. By hitting both Ctrl keys at the same time, QEMU can toggle the input recipient. QEMU’s evdev passthrough also features almost no latency, making it perfect for gaming. The main downside to evdev passthrough is the lack of button rebinding – and in some cases, macro keys won’t even work at all.
+ Optional items are normally only used for keyboards.
+
+
+ Device
+ Host device to passthrough to guest.
+
+
+
+ Grab
+ All grabs all input devices instead of just one
+
+
+
+ Repeat
+ Repeat with value 'on'/'off' to enable/disable auto-repeat events
+
+
+
+ GrabToggle
+ GrabToggle with values ctrl-ctrl, alt-alt, shift-shift, meta-meta, scrolllock or ctrl-scrolllock to change the grab key combination
+
+ Additional devices can be added/removed by clicking the symbols to the left.
+
+
+ }?>
+ }?>
+
+
+
+
+
+
+ Click Create to generate the vDisks and return to the Virtual Machines page where your new VM will be created.
+
+ }?>
+
+
+
+
+ _(Other XML)_:
+
+ if ($arrConfig['qemucmdline'] == "") $qemurows = 2 ; else $qemurows = 15 ;
+ ?>
+
-
-
-
+
+
+
+
@@ -1926,107 +1973,108 @@ var storageType = "=get_storage_fstype($arrConfig['template']['storage']);?>";
var storageLoc = "=$arrConfig['template']['storage']?>";
function ShareChange(share) {
- var value = share.value;
- var text = share.options[share.selectedIndex].text;
- var strArray = text.split(":");
- var index = share.name.indexOf("]") + 1;
- var name = share.name.substr(0,index);
- if (strArray[0] === "User") {
- var path = "/mnt/user/" + strArray[1];
- } else {
- var path = "/mnt/" + strArray[1];
- }
- if (strArray[0] != "Manual") {
- document.getElementById(name+"[target]").value = strArray[1];
- document.getElementById(name+"[source]").value = path;
+ var value = share.value;
+ var text = share.options[share.selectedIndex].text;
+ var strArray = text.split(":");
+ var index = share.name.indexOf("]") + 1;
+ var name = share.name.substr(0,index) ;
+ if (strArray[0] === "User") {
+ var path = "/mnt/user/" + strArray[1] ;
+ } else {
+ var path = "/mnt/" + strArray[1] ;
+ }
+ if (strArray[0] != "Manual") {
+ document.getElementById(name+"[target]").value = strArray[1] ;
+ document.getElementById(name+"[source]").value = path ;
document.getElementById(name+"[target]").setAttribute("disabled","disabled");
document.getElementById(name+"[source]").setAttribute("disabled","disabled");
- } else {
- document.getElementById(name+"[target]").removeAttribute("disabled");
- document.getElementById(name+"[source]").removeAttribute("disabled");
- }
+ } else {
+ document.getElementById(name+"[target]").removeAttribute("disabled");
+ document.getElementById(name+"[source]").removeAttribute("disabled");
+ }
}
function BusChange(bus) {
- var value = bus.value;
- var index = bus.name.indexOf("]") + 1;
- var name = bus.name.substr(0,index);
- if (value == "virtio" || value == "usb" ) {
+ var value = bus.value;
+ var index = bus.name.indexOf("]") + 1;
+ var name = bus.name.substr(0,index) ;
+ if (value == "virtio" || value == "usb" ) {
document.getElementById(name+"[rotatetext]").style.visibility="hidden";
document.getElementById(name+"[rotation]").style.visibility="hidden";
- } else {
- document.getElementById(name+"[rotation]").style.display="inline";
- document.getElementById(name+"[rotation]").style.visibility="visible";
- document.getElementById(name+"[rotatetext]").style.display="inline";
- document.getElementById(name+"[rotatetext]").style.visibility="visible";
- }
+ } else {
+ document.getElementById(name+"[rotation]").style.display="inline";
+ document.getElementById(name+"[rotation]").style.visibility="visible";
+ document.getElementById(name+"[rotatetext]").style.display="inline";
+ document.getElementById(name+"[rotatetext]").style.visibility="visible";
+ }
}
function updateSSDCheck(ssd) {
- var value = ssd.value;
- var index = ssd.name.indexOf("]") + 1;
- var name = ssd.name.substr(0,index);
- if (document.getElementById(name+"[rotation]").checked) ssd.value = "1"; else ssd.value = "0";
+ var value = ssd.value;
+ var index = ssd.name.indexOf("]") + 1;
+ var name = ssd.name.substr(0,index) ;
+ if (document.getElementById(name+"[rotation]").checked) ssd.value = "1"; else ssd.value = "0";
}
function BIOSChange(bios) {
- var value = bios.value;
- if (value == "0") {
- document.getElementById("USBBoottext").style.visibility="hidden";
- document.getElementById("domain_usbboot").style.visibility="hidden";
- } else {
- document.getElementById("USBBoottext").style.display="inline";
- document.getElementById("USBBoottext").style.visibility="visible";
- document.getElementById("domain_usbboot").style.display="inline";
- document.getElementById("domain_usbboot").style.visibility="visible";
- }
+ var value = bios.value;
+ if (value == "0") {
+ document.getElementById("USBBoottext").style.visibility="hidden";
+ document.getElementById("domain_usbboot").style.visibility="hidden";
+ } else {
+ document.getElementById("USBBoottext").style.display="inline";
+ document.getElementById("USBBoottext").style.visibility="visible";
+ document.getElementById("domain_usbboot").style.display="inline";
+ document.getElementById("domain_usbboot").style.visibility="visible";
+ }
}
function QEMUChgCmd(qemu) {
- var value = qemu.value;
- if (value != "") {
- document.getElementById("qemucmdline").setAttribute("rows","15");
- } else {
- document.getElementById("qemucmdline").setAttribute("rows","2");
- }
+ var value = qemu.value;
+ if (value != "") {
+ document.getElementById("qemucmdline").setAttribute("rows","15");
+ } else {
+ document.getElementById("qemucmdline").setAttribute("rows","2");
+ }
}
function HypervChgNew(hyperv) {
- var value = hyperv.value;
- if (value == "0") {
- var clockdefault = "windows";
- document.getElementById("clock[rtc][present]").value = "=$arrDefaultClocks['windows']['rtc']['present']?>";
- document.getElementById("clock[pit][present]").value = "=$arrDefaultClocks['windows']['pit']['present']?>";
- } else {
- var clockdefault = "hyperv";
- document.getElementById("clock[rtc][present]").value = "=$arrDefaultClocks['hyperv']['rtc']['present']?>";
- document.getElementById("clock[pit][present]").value = "=$arrDefaultClocks['hyperv']['pit']['present']?>";
- }
+ var value = hyperv.value;
+ if (value == "0") {
+ var clockdefault = "windows" ;
+ document.getElementById("clock[rtc][present]").value = "=$arrDefaultClocks['windows']['rtc']['present']?>" ;
+ document.getElementById("clock[pit][present]").value = "=$arrDefaultClocks['windows']['pit']['present']?>" ;
+ } else {
+ var clockdefault = "hyperv" ;
+ document.getElementById("clock[rtc][present]").value = "=$arrDefaultClocks['hyperv']['rtc']['present']?>" ;
+ document.getElementById("clock[pit][present]").value = "=$arrDefaultClocks['hyperv']['pit']['present']?>";
+ }
}
function SetBootorderfields(usbbootvalue) {
var bootelements = document.getElementsByClassName("bootorder");
for(var i = 0; i < bootelements.length; i++) {
if (usbbootvalue == "Yes") {
- bootelements[i].value = "";
- bootelements[i].setAttribute("disabled","disabled");
+ bootelements[i].value = "";
+ bootelements[i].setAttribute("disabled","disabled");
} else bootelements[i].removeAttribute("disabled");
}
var bootelements = document.getElementsByClassName("pcibootorder");
- const bootpcidevs =
-
- $devlist = [];
- foreach($arrValidOtherDevices as $i => $arrDev) {
- if ($arrDev["typeid"] != "0108" && substr($arrDev["typeid"],0,2) != "02") $devlist[$arrDev['id']] = "N"; else $devlist[$arrDev['id']] = "Y";
- }
- echo json_encode($devlist);
-?>;
+ const bootpcidevs =
+ $devlist = [] ;
+ foreach($arrValidOtherDevices as $i => $arrDev) {
+ if ($arrDev["typeid"] != "0108" && substr($arrDev["typeid"],0,2) != "02") $devlist[$arrDev['id']] = "N" ; else $devlist[$arrDev['id']] = "Y" ;
+ }
+ echo json_encode($devlist) ;
+ ?>
+
for(var i = 0; i < bootelements.length; i++) {
- let bootpciid = bootelements[i].name.split('[');
- bootpciid= bootpciid[1].replace(']', '');
+ let bootpciid = bootelements[i].name.split('[') ;
+ bootpciid= bootpciid[1].replace(']', '') ;
+
if (usbbootvalue == "Yes") {
- bootelements[i].value = "";
- bootelements[i].setAttribute("disabled","disabled");
+ bootelements[i].value = "";
+ bootelements[i].setAttribute("disabled","disabled");
} else {
// Put check for PCI Type 0108 & 02xx and only remove disable if 0108 or 02xx.
if (bootpcidevs[bootpciid] === "Y") bootelements[i].removeAttribute("disabled");
@@ -2034,6 +2082,7 @@ function SetBootorderfields(usbbootvalue) {
}
}
+
/* Remove characters not allowed in share name. */
function checkName(name) {
/* Declare variables at the function scope */
@@ -2043,11 +2092,9 @@ function checkName(name) {
if (isValidName) {
$('#btnSubmit').prop("disabled", false);
} else {
- if (storageType == "zfs") {
- $('#btnSubmit').prop("disabled", true); $('#zfs-name').show();
- } else {
- $('#btnSubmit').prop("disabled", false);
- }
+ if (storageType == "zfs")
+ { $('#btnSubmit').prop("disabled", true); $('#zfs-name').show(); }
+ else $('#btnSubmit').prop("disabled", false);
}
}
@@ -2058,41 +2105,42 @@ function get_storage_fstype(item) {
if (data.fstype) {
storageType=data.fstype;
checkName(document.getElementById("domain_name").value);
- }
+ }}
+
+ if (data.error) {
}
- if (data.error) {}
}, "json");
}
function USBBootChange(usbboot) {
// Remove all boot orders if changed to Yes
- var value = usbboot.value;
- SetBootorderfields(value);
+ var value = usbboot.value ;
+ SetBootorderfields(value) ;
}
function AutoportChange(autoport) {
- if (autoport.value == "yes") {
- document.getElementById("port").style.visibility="hidden";
- document.getElementById("Porttext").style.visibility="hidden";
- document.getElementById("wsport").style.visibility="hidden";
- document.getElementById("WSPorttext").style.visibility="hidden";
- } else {
- var protocol = document.getElementById("protocol").value;
- document.getElementById("port").style.display="inline";
- document.getElementById("port").style.visibility="visible";
- document.getElementById("Porttext").style.display="inline";
- document.getElementById("Porttext").style.visibility="visible";
- if (protocol == "vnc") {
- document.getElementById("wsport").style.display="inline";
- document.getElementById("wsport").style.visibility="visible";
- document.getElementById("WSPorttext").style.display="inline";
- document.getElementById("WSPorttext").style.visibility="visible";
- } else {
+ if (autoport.value == "yes") {
+ document.getElementById("port").style.visibility="hidden";
+ document.getElementById("Porttext").style.visibility="hidden";
document.getElementById("wsport").style.visibility="hidden";
document.getElementById("WSPorttext").style.visibility="hidden";
+ } else {
+ var protocol = document.getElementById("protocol").value ;
+ document.getElementById("port").style.display="inline";
+ document.getElementById("port").style.visibility="visible";
+ document.getElementById("Porttext").style.display="inline";
+ document.getElementById("Porttext").style.visibility="visible";
+ if (protocol == "vnc") {
+ document.getElementById("wsport").style.display="inline";
+ document.getElementById("wsport").style.visibility="visible";
+ document.getElementById("WSPorttext").style.display="inline";
+ document.getElementById("WSPorttext").style.visibility="visible";
+ } else {
+ document.getElementById("wsport").style.visibility="hidden";
+ document.getElementById("WSPorttext").style.visibility="hidden";
+ }
}
}
-}
function VMConsoleDriverChange(driver) {
if (driver.value != "virtio3d") {
@@ -2100,6 +2148,7 @@ function VMConsoleDriverChange(driver) {
document.getElementById("vncrendertext").style.visibility="hidden";
document.getElementById("vncrender").style.display="none";
document.getElementById("vncrendertext").style.display="none";
+
} else {
document.getElementById("vncrender").style.display="inline";
document.getElementById("vncrender").style.visibility="visible";
@@ -2109,6 +2158,7 @@ function VMConsoleDriverChange(driver) {
if (driver.value != "qxl") {
document.getElementById("vncdspopt").style.visibility="hidden";
document.getElementById("vncdspopttext").style.visibility="hidden";
+
} else {
document.getElementById("vncdspopt").style.display="inline";
document.getElementById("vncdspopt").style.visibility="visible";
@@ -2118,28 +2168,32 @@ function VMConsoleDriverChange(driver) {
}
function ProtocolChange(protocol) {
- var autoport = document.getElementById("autoport").value;
- if (autoport == "yes") {
- document.getElementById("port").style.visibility="hidden";
- document.getElementById("Porttext").style.visibility="hidden";
- document.getElementById("wsport").style.visibility="hidden";
- document.getElementById("WSPorttext").style.visibility="hidden";
- } else {
- document.getElementById("port").style.display="inline";
- document.getElementById("port").style.visibility="visible";
- document.getElementById("Porttext").style.display="inline";
- document.getElementById("Porttext").style.visibility="visible";
- if (protocol.value == "vnc") {
- document.getElementById("wsport").style.display="inline";
- document.getElementById("wsport").style.visibility="visible";
- document.getElementById("WSPorttext").style.display="inline";
- document.getElementById("WSPorttext").style.visibility="visible";
- } else {
+ var autoport = document.getElementById("autoport").value ;
+ if (autoport == "yes") {
+ document.getElementById("port").style.visibility="hidden";
+ document.getElementById("Porttext").style.visibility="hidden";
document.getElementById("wsport").style.visibility="hidden";
document.getElementById("WSPorttext").style.visibility="hidden";
+ } else {
+ document.getElementById("port").style.display="inline";
+ document.getElementById("port").style.visibility="visible";
+ document.getElementById("Porttext").style.display="inline";
+ document.getElementById("Porttext").style.visibility="visible";
+ if (protocol.value == "vnc") {
+ document.getElementById("wsport").style.display="inline";
+ document.getElementById("wsport").style.visibility="visible";
+ document.getElementById("WSPorttext").style.display="inline";
+ document.getElementById("WSPorttext").style.visibility="visible";
+ } else {
+ document.getElementById("wsport").style.visibility="hidden";
+ document.getElementById("WSPorttext").style.visibility="hidden";
+ }
}
}
-}
+
+
+
+
$(function() {
function completeAfter(cm, pred) {
@@ -2167,6 +2221,7 @@ $(function() {
});
}
+
var editor = CodeMirror.fromTextArea(document.getElementById("addcode"), {
mode: "xml",
lineNumbers: true,
@@ -2182,7 +2237,7 @@ $(function() {
hintOptions: {schemaInfo: getLibvirtSchema()}
});
- SetBootorderfields("=$arrConfig['domain']['usbboot']?>");
+ SetBootorderfields("=$arrConfig['domain']['usbboot']?>") ;
function resetForm() {
$("#vmform .domain_vcpu").change(); // restore the cpu checkbox disabled states
@@ -2195,7 +2250,7 @@ $(function() {
}
- $('.advancedview').change(function() {
+ $('.advancedview').change(function () {
if ($(this).is(':checked')) {
setTimeout(function() {
var xmlPanelHeight = window.outerHeight;
@@ -2206,14 +2261,18 @@ $(function() {
}
});
- var regenerateDiskPreview = function(disk_index) {
+
+ var regenerateDiskPreview = function (disk_index) {
var domaindir = '=$domain_cfg['DOMAINDIR']?>' + $('#domain_oldname').val();
var tl_args = arguments.length;
- $("#vmform .disk").closest('table').each(function(index) {
+
+ $("#vmform .disk").closest('table').each(function (index) {
var $table = $(this);
+
if (tl_args && disk_index != $table.data('index')) {
return;
}
+
var disk_select = $table.find(".disk_select option:selected").val();
var $disk_file_sections = $table.find('.disk_file_options');
var $disk_bus_sections = $table.find('.disk_bus_options');
@@ -2222,28 +2281,36 @@ $(function() {
var $disk_serial = $table.find('.disk_serial');
var $disk_driver = $table.find('.disk_driver').val();
var $disk_ext = "img";
- if ($disk_driver == "raw") $disk_ext = "img";
- else if(disk_select != 'manual') $disk_ext = $disk_driver;
+ if ($disk_driver == "raw") $disk_ext = "img";
+ else if(disk_select != 'manual') $disk_ext = $disk_driver;
+
if (disk_select == 'manual') {
+
// Manual disk
$disk_preview.fadeOut('fast', function() {
$disk_input.fadeIn('fast');
});
+
$disk_bus_sections.filter('.wasadvanced').removeClass('wasadvanced').addClass('advanced');
slideDownRows($disk_bus_sections.not(isVMAdvancedMode() ? '.basic' : '.advanced'));
+
$.getJSON("/plugins/dynamix.vm.manager/include/VMajax.php?action=file-info&file=" + encodeURIComponent($disk_input.val()), function( info ) {
if (info.isfile || info.isblock) {
slideUpRows($disk_file_sections);
$disk_file_sections.filter('.advanced').removeClass('advanced').addClass('wasadvanced');
+
$disk_input.attr('name', $disk_input.attr('name').replace('new', 'image'));
if (info.isfile) $table.find('.disk_driver').val(info.format);
} else {
$disk_file_sections.filter('.wasadvanced').removeClass('wasadvanced').addClass('advanced');
slideDownRows($disk_file_sections.not(isVMAdvancedMode() ? '.basic' : '.advanced'));
+
$disk_input.attr('name', $disk_input.attr('name').replace('image', 'new'));
}
});
+
} else if (disk_select !== '') {
+
// Auto disk
var auto_disk_path = domaindir + '/vdisk' + (index+1) + '.' + $disk_ext;
$disk_preview.html(auto_disk_path);
@@ -2258,50 +2325,63 @@ $(function() {
if (info.isfile || info.isblock) {
slideUpRows($disk_file_sections);
$disk_file_sections.filter('.advanced').removeClass('advanced').addClass('wasadvanced');
+
$disk_input.attr('name', $disk_input.attr('name').replace('new', 'image'));
} else {
$disk_file_sections.filter('.wasadvanced').removeClass('wasadvanced').addClass('advanced');
slideDownRows($disk_file_sections.not(isVMAdvancedMode() ? '.basic' : '.advanced'));
+
$disk_input.attr('name', $disk_input.attr('name').replace('image', 'new'));
}
});
+
} else {
+
// No disk
var $hide_el = $table.find('.disk_bus_options,.disk_file_options,.disk_preview,.disk');
$disk_preview.html('');
slideUpRows($hide_el);
$hide_el.filter('.advanced').removeClass('advanced').addClass('wasadvanced');
+
}
});
};
- var setDiskserial = function(disk_index) {
+ var setDiskserial = function (disk_index) {
var domaindir = '=$domain_cfg['DOMAINDIR']?>' + $('#domain_oldname').val();
var tl_args = arguments.length;
- $("#vmform .disk").closest('table').each(function(index) {
+
+ $("#vmform .disk").closest('table').each(function (index) {
var $table = $(this);
+
if (tl_args && disk_index != $table.data('index')) {
return;
}
+
var disk_select = $table.find(".disk_select option:selected").val();
var $disk_serial = $table.find('.disk_serial');
- if (disk_select !== '') {
+
+ if (disk_select !== '') {
+
// Auto disk serial
- var auto_serial = 'vdisk' + (index+1);
+ var auto_serial = 'vdisk' + (index+1) ;
$disk_serial.val(auto_serial);
+
}
+
});
};
-
+
$("#vmform #domain_name").on("input change", function changeNameEvent() {
$('#vmform #domain_oldname').val($(this).val());
regenerateDiskPreview();
});
-
+
$("#vmform .domain_vcpu").change(function changeVCPUEvent() {
var $cores = $("#vmform .domain_vcpu:checked");
+
if ($cores.length < 1) {
$("#vmform .domain_vcpus").prop("disabled", false);
$("#vmform .domain_vcpu").prop("disabled", false);
@@ -2343,7 +2423,7 @@ $(function() {
$("#vmform").on("spawn_section", function spawnSectionEvent(evt, section, sectiondata) {
if (sectiondata.category == 'vDisk') {
regenerateDiskPreview(sectiondata.index);
- setDiskserial(sectiondata.index);
+ setDiskserial(sectiondata.index) ;
}
if (sectiondata.category == 'Graphics_Card') {
$(section).find(".gpu").change();
@@ -2375,6 +2455,7 @@ $(function() {
$("#vmform").on("input change", ".disk", function changeDiskEvent() {
var $input = $(this);
var config = $input.data();
+
if (config.hasOwnProperty('pickfilter')) {
regenerateDiskPreview($input.closest('table').data('index'));
}
@@ -2383,8 +2464,8 @@ $(function() {
$("#vmform").on("change", ".cpu", function changeCPUEvent() {
var myvalue = $(this).val();
var mylabel = $(this).children('option:selected').text();
- var cpumigrate = document.getElementById("domain_cpumigrate_text");
- var cpumigrate_text = document.getElementById("domain_cpumigrate");
+ var cpumigrate = document.getElementById("domain_cpumigrate_text") ;
+ var cpumigrate_text = document.getElementById("domain_cpumigrate") ;
if (myvalue == "custom") {
document.getElementById("domain_cpumigrate_text").style.visibility="hidden";
document.getElementById("domain_cpumigrate").style.visibility="hidden";
@@ -2394,53 +2475,57 @@ $(function() {
document.getElementById("domain_cpumigrate").style.display="inline";
document.getElementById("domain_cpumigrate").style.visibility="visible";
}
- });
+
+ }) ;
$("#vmform").on("change", ".gpu", function changeGPUEvent() {
const ValidGPUs = =json_encode($arrValidGPUDevices);?>;
var myvalue = $(this).val();
var mylabel = $(this).children('option:selected').text();
var myindex = $(this).closest('table').data('index');
+
if (myindex == 0) {
$vnc_sections = $('.autoportline,.protocol,.vncmodel,.vncpassword,.vnckeymap,.copypaste');
if (myvalue == 'virtual') {
$vnc_sections.filter('.wasadvanced').removeClass('wasadvanced').addClass('advanced');
slideDownRows($vnc_sections.not(isVMAdvancedMode() ? '.basic' : '.advanced'));
- var MultiSel = document.getElementById("GPUMultiSel0");
- MultiSel.disabled = true;
+ var MultiSel = document.getElementById("GPUMultiSel0") ;
+ MultiSel.disabled = true ;
if (document.getElementById("vncmodel").value == "virtio3d") {
$("#vncrender").show();
$("#vncrendertext").show();
- } else {
+ } else {
$("#vncrender").hide();
$("#vncrendertext").hide();
document.getElementById("vncrender").style.display="none";
document.getElementById("vncrendertext").style.display="none";
- }
- if (document.getElementById("vncmodel").value == "qxl") {
+ }
+ if (document.getElementById("vncmodel").value == "qxl") {
$("#vncdspopt").show();
$("#vncdspopttext").show();
document.getElementById("vncdspopt").style.display="inline";
document.getElementById("vncdspopt").style.visibility="visible";
document.getElementById("vncdspopttext").style.display="inline";
document.getElementById("vncdspopttext").style.visibility="visible";
- } else {
+ } else {
$("#vncdspopt").hide();
$("#vncdspopttext").hide();
document.getElementById("vncdspopt").style.display="none";
- document.getElementById("vncdspopttext").style.display="none";
- }
+ document.getElementById("vncdspopttext").style.display="none";
+ }
} else {
slideUpRows($vnc_sections);
$vnc_sections.filter('.advanced').removeClass('advanced').addClass('wasadvanced');
- var MultiSel = document.getElementById("GPUMultiSel0");
- if (myvalue=="nogpu") MultiSel.disabled = true; else MultiSel.disabled = false;
+ var MultiSel = document.getElementById("GPUMultiSel0") ;
+ if (myvalue=="nogpu") MultiSel.disabled = true ; else MultiSel.disabled = false ;
}
}
+
if (mylabel == "_(None)_") $("#gpubootvga"+myindex).hide();
if (myvalue != "_(virtual)_" && myvalue != '' && myvalue != "_(nogpu)_") {
if (ValidGPUs[myvalue].bootvga == "1") $("#gpubootvga"+myindex).show(); else $("#gpubootvga"+myindex).hide();
}
+
$romfile = $(this).closest('table').find('.romfile');
if (myvalue == '_(virtual)_' || myvalue == '' || myvalue =="_(nogpu)_") {
slideUpRows($romfile.not(isVMAdvancedMode() ? '.basic' : '.advanced'));
@@ -2448,6 +2533,7 @@ $(function() {
} else {
$romfile.filter('.wasadvanced').removeClass('wasadvanced').addClass('advanced');
slideDownRows($romfile.not(isVMAdvancedMode() ? '.basic' : '.advanced'));
+
$("#vmform .gpu").not(this).each(function () {
if (myvalue == $(this).val()) {
$(this).prop("selectedIndex", 0).change();
@@ -2458,6 +2544,7 @@ $(function() {
$("#vmform").on("click", ".mac_generate", function generateMac() {
var $input = $(this).prev('input');
+
$.getJSON("/plugins/dynamix.vm.manager/include/VMajax.php?action=generate-mac", function( data ) {
if (data.mac) {
$input.val(data.mac);
@@ -2466,7 +2553,7 @@ $(function() {
});
$("#vmform .formview #btnvCPUSelect").click(function selectcpus() {
- if (this.value == "_(Select All)_") {
+ if (this.value == "_(Select All)_"){
$('.domain_vcpu').prop('checked', true);
var $cores = $("#vmform .domain_vcpu:checked");
$("#vmform .domain_vcpus").prop("disabled", true).prop("value", $cores.length);
@@ -2474,7 +2561,7 @@ $(function() {
} else {
$('.domain_vcpu').prop('checked', false);
var $cores = $("#vmform .domain_vcpu:checked");
- $("#vmform .domain_vcpus").prop("disabled", false).prop("value", 1);
+ $("#vmform .domain_vcpus").prop("disabled", false).prop("value", 1);
this.value = "_(Select All)_";
}
});
@@ -2483,12 +2570,15 @@ $(function() {
var $button = $(this);
var $panel = $('.formview');
var form = $button.closest('form');
+
$("#vmform .disk_select option:selected").not("[value='manual']").closest('table').each(function () {
var v = $(this).find('.disk_preview').html();
$(this).find('.disk').val(v);
});
+
$panel.find('input').prop('disabled', false); // enable all inputs otherwise they wont post
-
+
+
// signal devices to be added or removed
form.find('input[name="usb[]"],input[name="pci[]"],input[name="usbopt[]"]').each(function(){
if (!$(this).prop('checked')) $(this).prop('checked',true).val($(this).val()+'#remove');
@@ -2513,16 +2603,18 @@ $(function() {
var audio = $(this).val();
if (audio && !sound.includes(audio)) form.append(' ');
});
-
+
var postdata = form.find('input,select,textarea[name="qemucmdline"]').serialize().replace(/'/g,"%27");
-
+
// keep checkbox visually unchecked
form.find('input[name="usb[]"],input[name="usbopt[]"],input[name="pci[]"]').each(function(){
if ($(this).val().indexOf('#remove')>0) $(this).prop('checked',false);
});
-
+
+
$panel.find('input').prop('disabled', true);
$button.val($button.attr('busyvalue'));
+
$.post("/plugins/dynamix.vm.manager/templates/Custom.form.php", postdata, function( data ) {
if (data.success) {
if (data.vmrcurl) {
@@ -2552,12 +2644,16 @@ $(function() {
form.append(' ');
var createVmInput = form.find('input[name="createvm"],input[name="updatevm"]');
createVmInput.remove();
+
+
$("#vmform .disk_select option:selected").not("[value='manual']").closest('table').each(function () {
var v = $(this).find('.disk_preview').html();
$(this).find('.disk').val(v);
});
+
$panel.find('input').prop('disabled', false); // enable all inputs otherwise they wont post
-
+
+
// signal devices to be added or removed
form.find('input[name="usb[]"],input[name="pci[]"],input[name="usbopt[]"]').each(function(){
if (!$(this).prop('checked')) $(this).prop('checked',true).val($(this).val()+'#remove');
@@ -2582,16 +2678,18 @@ $(function() {
var audio = $(this).val();
if (audio && !sound.includes(audio)) form.append(' ');
});
-
+
var postdata = form.find('input,select,textarea[name="qemucmdline"]').serialize().replace(/'/g,"%27");
-
+
// keep checkbox visually unchecked
form.find('input[name="usb[]"],input[name="usbopt[]"],input[name="pci[]"]').each(function(){
if ($(this).val().indexOf('#remove')>0) $(this).prop('checked',false);
});
-
+
+
$panel.find('input').prop('disabled', true);
$button.val($button.attr('busyvalue'));
+
swal({
title: '_(Template Name)_',
text: "_(Enter name:\nIf name already exists it will be replaced.)_",
@@ -2600,40 +2698,48 @@ $(function() {
closeOnConfirm: false,
//animation: "slide-from-top",
inputPlaceholder: "_(Leaving blank will use OS name.)_"
- },
- function(inputValue){
- postdata=postdata+"&templatename="+inputValue;
- $.post("/plugins/dynamix.vm.manager/templates/Custom.form.php", postdata, function(data){
- if (data.success) {
- if (data.vmrcurl) {
- var vmrc_window=window.open(data.vmrcurl, '_blank', 'scrollbars=yes,resizable=yes');
- try {
- vmrc_window.focus();
- } catch (e) {
- swal({title:"_(Browser error)_",text:"_(Pop-up Blocker is enabled! Please add this site to your exception list)_",type:"warning",confirmButtonText:"_(Ok)_"},function(){ done() });
- return;
- }
+ },
+ function(inputValue){
+
+
+ postdata=postdata+"&templatename="+inputValue;
+
+ $.post("/plugins/dynamix.vm.manager/templates/Custom.form.php", postdata, function( data ) {
+ if (data.success) {
+ if (data.vmrcurl) {
+ var vmrc_window=window.open(data.vmrcurl, '_blank', 'scrollbars=yes,resizable=yes');
+ try {
+ vmrc_window.focus();
+ } catch (e) {
+ swal({title:"_(Browser error)_",text:"_(Pop-up Blocker is enabled! Please add this site to your exception list)_",type:"warning",confirmButtonText:"_(Ok)_"},function(){ done() });
+ return;
}
- done();
}
- if (data.error) {
- swal({title:"_(VM creation error)_",text:data.error,type:"error",confirmButtonText:"_(Ok)_"});
- $panel.find('input').prop('disabled', false);
- $button.val($button.attr('readyvalue'));
- resetForm();
- }
- }, "json");
- });
+ done();
+ }
+ if (data.error) {
+ swal({title:"_(VM creation error)_",text:data.error,type:"error",confirmButtonText:"_(Ok)_"});
+ $panel.find('input').prop('disabled', false);
+ $button.val($button.attr('readyvalue'));
+ resetForm();
+ }
+ }, "json");
});
+});
$("#vmform .xmlview #btnSubmit").click(function frmSubmit() {
var $button = $(this);
var $panel = $('.xmlview');
+
editor.save();
+
$panel.find('input').prop('disabled', false); // enable all inputs otherwise they wont post
+
var postdata = $panel.closest('form').serialize().replace(/'/g,"%27");
+
$panel.find('input').prop('disabled', true);
$button.val($button.attr('busyvalue'));
+
$.post("/plugins/dynamix.vm.manager/templates/Custom.form.php", postdata, function( data ) {
if (data.success) {
done();
@@ -2650,15 +2756,21 @@ $(function() {
$("#vmform .xmlview #btnTemplateSubmit").click(function frmSubmit() {
var $button = $(this);
var $panel = $('.xmlview');
+
+
editor.save();
+
$panel.find('input').prop('disabled', false); // enable all inputs otherwise they wont post
var form = $button.closest('form');
form.append(' ');
var createVmInput = form.find('input[name="createvm"],input[name="updatevm"]');
createVmInput.remove();
+
var postdata = $panel.closest('form').serialize().replace(/'/g,"%27");
+
$panel.find('input').prop('disabled', true);
$button.val($button.attr('busyvalue'));
+
swal({
title: "_(Template Name)_",
text: "_(Enter name:\nIf name already exists it will be replaced.)_",
@@ -2667,21 +2779,24 @@ $(function() {
closeOnConfirm: false,
//animation: "slide-from-top",
inputPlaceholder: "_(Leaving blank will use OS name.)_"
- },
- function(inputValue){
- postdata=postdata+"&templatename="+inputValue;
- $.post("/plugins/dynamix.vm.manager/templates/Custom.form.php", postdata, function( data ) {
- if (data.success) {
- done();
- }
- if (data.error) {
- swal({title:"_(VM creation error)_",text:data.error,type:"error",confirmButtonText:"_(Ok)_"});
- $panel.find('input').prop('disabled', false);
- $button.val($button.attr('readyvalue'));
- resetForm();
- }
- }, "json");
- });
+ },
+ function(inputValue){
+
+
+ postdata=postdata+"&templatename="+inputValue;
+
+ $.post("/plugins/dynamix.vm.manager/templates/Custom.form.php", postdata, function( data ) {
+ if (data.success) {
+ done();
+ }
+ if (data.error) {
+ swal({title:"_(VM creation error)_",text:data.error,type:"error",confirmButtonText:"_(Ok)_"});
+ $panel.find('input').prop('disabled', false);
+ $button.val($button.attr('readyvalue'));
+ resetForm();
+ }
+ }, "json");
+ });
});
// Fire events below once upon showing page
@@ -2691,7 +2806,7 @@ $(function() {
$('#vmform .domain_os').not($('.' + os_casted)).hide();
$('#vmform .domain_os.' + os_casted).not(isVMAdvancedMode() ? '.basic' : '.advanced').show();
-
+
if (os_casted == 'windows') {
$('#vmform #domain_clock').val('localtime');
$("#vmform #domain_machine option").each(function(){
@@ -2712,7 +2827,7 @@ $(function() {
}
});
}
-
+
// disable usb3 option for windows7 / xp / server 2003 / server 2008
var noUSB3 = (os == 'windows7' || os == 'windows2008' || os == 'windowsxp' || os == 'windows2003');
@@ -2720,9 +2835,13 @@ $(function() {
$("#vmform #usbmode").val('usb2');
}
$("#vmform #usbmode option[value^='usb3']").prop('disabled', noUSB3);
+
$("#vmform .gpu").change();
+
$('#vmform .cdrom').change();
+
regenerateDiskPreview();
+
resetForm();
});