Procházet zdrojové kódy

disable cpu downgrade on running VM

andre před 4 roky
rodič
revize
9e4d9af53b
1 změnil soubory, kde provedl 18 přidání a 3 odebrání
  1. 18 3
      app/UI/VmUpdate/Sections/Qemu/GeneralSection.php

+ 18 - 3
app/UI/VmUpdate/Sections/Qemu/GeneralSection.php

@@ -93,9 +93,24 @@ class GeneralSection extends BaseSection
         }
         }
         //vcpus
         //vcpus
         if($this->configuration()->isPermissionVcpus() || $this->configuration()->isCalculateSocketsAndCores()){
         if($this->configuration()->isPermissionVcpus() || $this->configuration()->isCalculateSocketsAndCores()){
-            $field = new Range('vcpus',$this->resourceManager->vcpus()->getMin(), $this->resourceManager->vcpus()->free());
-            $field->addValidator(new NumberValidator($this->resourceManager->vcpus()->getMin(), $this->resourceManager->vcpus()->free(),true));
-            $field->setDescription('description');
+
+            logModuleCall(
+                'proxmoxCloud',
+                __FUNCTION__,
+                $vm->config(),
+                'Debug',
+                $this->configuration()
+            );
+
+            if(!$vm->isRunning()) {
+                $field = new Range('vcpus',$this->resourceManager->vcpus()->getMin(), $this->resourceManager->vcpus()->free());
+                $field->addValidator(new NumberValidator($this->resourceManager->vcpus()->getMin(), $this->resourceManager->vcpus()->free(),true));
+                $field->setDescription('description');
+            } else {
+                $field = new Range('vcpus',$this->resourceManager->vcpus()->getMin(), $this->resourceManager->vcpus()->free());
+                $field->addValidator(new NumberValidator($this->resourceManager->vcpus()->getMin(), $this->resourceManager->vcpus()->free(),true));
+                $field->setDescription('description');
+            }
             $this->addField($field);
             $this->addField($field);
         }
         }
         //cpu priority
         //cpu priority