Browse Source

try disable memory downgrade on running VMs

andre 4 years ago
parent
commit
fa4980c703
1 changed files with 10 additions and 13 deletions
  1. 10 13
      app/UI/VmUpdate/Sections/Qemu/GeneralSection.php

+ 10 - 13
app/UI/VmUpdate/Sections/Qemu/GeneralSection.php

@@ -125,19 +125,16 @@ class GeneralSection extends BaseSection
             $this->addField($field);
         }
         //memory
-
-        logModuleCall(
-            'proxmoxCloud',
-            __FUNCTION__,
-            $vm->isRunning(),
-            'Debug',
-            $vm->config()['memory']
-        );
-
-        $field = new Range('memory', $this->resourceManager->memory()->getMin(), $this->resourceManager->memory()->free());
-        $field->addValidator(new NumberValidator($this->resourceManager->memory()->getMin(), $this->resourceManager->memory()->free(),true));
-        $field->setDefaultValue($this->configuration()->serverMemory->min);
-        $field->setDescription('description');
+        if($vm->isStopped()) {
+            $field = new Range('memory', $this->resourceManager->memory()->getMin(), $this->resourceManager->memory()->free());
+            $field->addValidator(new NumberValidator($this->resourceManager->memory()->getMin(), $this->resourceManager->memory()->free(),true));
+            $field->setDescription('description');
+        } else {
+            $field = new Range('memory', $vm->config()['memory'], $this->resourceManager->memory()->free());
+            $field->addValidator(new NumberValidator($vm->config()['memory'], $this->resourceManager->memory()->free(),true));
+            $field->setDescription('Zur Speicherreduzierung muß die VM heruntergefahren sein!');
+        }
+        $field->setDefaultValue($vm->config()['memory']);
         $this->addField($field);
         /**
          * @deprecated