From a2265ef9dcadeb2dfb8aec2d612cf6c01a0dea8a Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Mon, 19 Sep 2022 16:39:07 +0100 Subject: [PATCH] Add startupPolicy to Custom.form --- plugins/dynamix.vm.manager/include/libvirt.php | 7 ++++++- plugins/dynamix.vm.manager/templates/Custom.form.php | 9 ++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/dynamix.vm.manager/include/libvirt.php b/plugins/dynamix.vm.manager/include/libvirt.php index 6143cd7c0..63b55b0db 100644 --- a/plugins/dynamix.vm.manager/include/libvirt.php +++ b/plugins/dynamix.vm.manager/include/libvirt.php @@ -262,6 +262,7 @@ $nics = $config['nic']; $disks = $config['disk']; $usb = $config['usb']; + $usbopt = $config['usbopt']; $shares = $config['shares']; $gpus = $config['gpu']; $pcis = $config['pci']; @@ -447,8 +448,12 @@ if (!empty($usb)) { foreach($usb as $i => $v){ $usbx = explode(':', $v); + $startupPolicy = '' ; + if (isset($usbopt[$i])) { + if (strpos($usbopt[$i], "#remove") == false) $startupPolicy = 'startupPolicy="optional"' ; else $startupPolicy = '' ; + } $usbstr .= " - + diff --git a/plugins/dynamix.vm.manager/templates/Custom.form.php b/plugins/dynamix.vm.manager/templates/Custom.form.php index 79ff7a6bd..b2bd85cb4 100644 --- a/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -1114,6 +1114,8 @@ + +
_(Select)_  _(Optional)_
_(USB Devices)_: @@ -1122,7 +1124,8 @@ if (!empty($arrVMUSBs)) { foreach($arrVMUSBs as $i => $arrDev) { ?> -
+
// signal devices to be added or removed - form.find('input[name="usb[]"],input[name="pci[]"]').each(function(){ + 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'); }); // remove unused graphic cards @@ -1533,7 +1536,7 @@ $(function() { var postdata = form.find('input,select').serialize().replace(/'/g,"%27"); // keep checkbox visually unchecked - form.find('input[name="usb[]"],input[name="pci[]"]').each(function(){ + form.find('input[name="usb[]"],input[name="usbopt[]"],input[name="pci[]"]').each(function(){ if ($(this).val().indexOf('#remove')>0) $(this).prop('checked',false); });