Roy Golan has uploaded a new change for review.

Change subject: core: block hot unplug CPU
......................................................................

core: block hot unplug CPU

Currently unplug isn't supported due to libvirt's bug[1]

- added canDo action
- exposed config value via engine-confg for
  HotPlugCpuSupported and HotPlugCpuSupported

Change-Id: I32eafdc685198b98005906dc14f6fdc8cc1c7763
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1077515
Signed-off-by: Roy Golan <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HotSetNumberOfCpusCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/HotSetNumerOfCpusParameters.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
M packaging/etc/engine-config/engine-config.properties
11 files changed, 72 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/34/26534/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HotSetNumberOfCpusCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HotSetNumberOfCpusCommand.java
index aeb2732..3a4cd46 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HotSetNumberOfCpusCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HotSetNumberOfCpusCommand.java
@@ -4,7 +4,8 @@
 import org.ovirt.engine.core.bll.validator.LocalizedVmStatus;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.FeatureSupported;
-import org.ovirt.engine.core.common.action.VmManagementParametersBase;
+import org.ovirt.engine.core.common.action.HotSetNumerOfCpusParameters;
+import org.ovirt.engine.core.common.action.PlugAction;
 import org.ovirt.engine.core.common.businessentities.VMStatus;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
 import org.ovirt.engine.core.common.errors.VdcFault;
@@ -20,7 +21,7 @@
  * The execute will never throw an exception. it will rather wrap a return 
value in case of failure.
  */
 @NonTransactiveCommandAttribute
-public class HotSetNumberOfCpusCommand<T extends VmManagementParametersBase> 
extends VmManagementCommandBase<T> {
+public class HotSetNumberOfCpusCommand<T extends HotSetNumerOfCpusParameters> 
extends VmManagementCommandBase<T> {
 
     public static final String LOGABLE_FIELD_NUMBER_OF_CPUS = "numberOfCpus";
     public static final String LOGABLE_FIELD_ERROR_MESSAGE = "ErrorMessage";
@@ -42,8 +43,12 @@
         if (getParameters().getVm().getNumOfCpus() > 
SlaValidator.getEffectiveCpuCores(getVds())) {
             canDo = 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VDS_VM_CPUS);
         }
-        if 
(!FeatureSupported.hotPlugCpu(getVm().getVdsGroupCompatibilityVersion(), 
getVm().getClusterArch())) {
-            canDo = failCanDoAction(VdcBllMessages.HOT_PLUG_IS_NOT_SUPPORTED);
+        if (getParameters().getPlugAction() == PlugAction.PLUG) {
+            if 
(!FeatureSupported.hotPlugCpu(getVm().getVdsGroupCompatibilityVersion(), 
getVm().getClusterArch())) {
+                canDo = 
failCanDoAction(VdcBllMessages.HOT_PLUG_CPU_IS_NOT_SUPPORTED);
+            }
+        } else if 
(!FeatureSupported.hotUnplugCpu(getVm().getVdsGroupCompatibilityVersion(), 
getVm().getClusterArch())) {
+            canDo = 
failCanDoAction(VdcBllMessages.HOT_UNPLUG_CPU_IS_NOT_SUPPORTED);
         }
 
         return canDo;
@@ -90,5 +95,7 @@
     protected void setActionMessageParameters() {
         addCanDoActionMessage(VdcBllMessages.VAR__ACTION__HOT_SET_CPUS);
         addCanDoActionMessage(VdcBllMessages.VAR__TYPE__VM);
+        addCanDoActionMessage(String.format("$clusterVersion %1$s", 
getVm().getVdsGroupCompatibilityVersion() ));
+        addCanDoActionMessage(String.format("$architecture %1$s", 
getVm().getClusterArch()));
     }
 }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
index 2d40b47..a2af896 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
@@ -20,6 +20,8 @@
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.FeatureSupported;
 import org.ovirt.engine.core.common.VdcObjectType;
+import org.ovirt.engine.core.common.action.HotSetNumerOfCpusParameters;
+import org.ovirt.engine.core.common.action.PlugAction;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.action.VdcReturnValueBase;
 import org.ovirt.engine.core.common.action.VmManagementParametersBase;
@@ -108,16 +110,22 @@
         int newSockets = newVmStatic.getNumOfSockets();
 
         if (getVm().getStatus() == VMStatus.Up && currentSockets != 
newSockets) {
-            setNumberOfCpusResult = getBackend().runInternalAction(
-                    VdcActionType.HotSetNumberOfCpus, new 
VmManagementParametersBase(newVmStatic));
+            HotSetNumerOfCpusParameters params =
+                    new HotSetNumerOfCpusParameters(
+                            newVmStatic,
+                            currentSockets < newSockets ? PlugAction.PLUG : 
PlugAction.UNPLUG);
+            setNumberOfCpusResult =
+                    getBackend().runInternalAction(
+                            VdcActionType.HotSetNumberOfCpus,
+                            params);
             newVmStatic.setNumOfSockets(setNumberOfCpusResult.getSucceeded() ? 
newSockets : currentSockets);
-            auditLogHotSetCpusCandos();
+            auditLogHotSetCpusCandos(params);
         }
     }
 
-    private void auditLogHotSetCpusCandos() {
+    private void auditLogHotSetCpusCandos(HotSetNumerOfCpusParameters params) {
         if (!setNumberOfCpusResult.getCanDoAction()) {
-            AuditLogableBase logable = new HotSetNumberOfCpusCommand<>(new 
VmManagementParametersBase(newVmStatic));
+            AuditLogableBase logable = new HotSetNumberOfCpusCommand<>(params);
             List<String> canDos = getBackend().getErrorsTranslator().
                     
TranslateErrorText(setNumberOfCpusResult.getCanDoActionMessages());
             
logable.addCustomValue(HotSetNumberOfCpusCommand.LOGABLE_FIELD_ERROR_MESSAGE, 
StringUtils.join(canDos, ","));
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
index fc531ce..8421252 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
@@ -212,6 +212,10 @@
         return supportedInConfig(ConfigValues.HotPlugCpuSupported, version, 
arch);
     }
 
+    public static boolean hotUnplugCpu(Version version, ArchitectureType arch) 
{
+        return supportedInConfig(ConfigValues.HotUnplugCpuSupported, version, 
arch);
+    }
+
     /**
      * @param version
      *            Compatibility version to check for.
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/HotSetNumerOfCpusParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/HotSetNumerOfCpusParameters.java
new file mode 100644
index 0000000..8d1f435
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/HotSetNumerOfCpusParameters.java
@@ -0,0 +1,22 @@
+package org.ovirt.engine.core.common.action;
+
+import org.ovirt.engine.core.common.businessentities.VmStatic;
+
+public class HotSetNumerOfCpusParameters extends VmManagementParametersBase {
+
+    private static final long serialVersionUID = 3471288629004073208L;
+
+    private PlugAction plugAction;
+
+    public HotSetNumerOfCpusParameters() {
+    }
+
+    public HotSetNumerOfCpusParameters(VmStatic vmStatic, PlugAction 
plugAction) {
+        super(vmStatic);
+        this.plugAction = plugAction;
+    }
+
+    public PlugAction getPlugAction() {
+        return plugAction;
+    }
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
index 0d4fb8b..ef79abf 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
@@ -1627,6 +1627,10 @@
     @DefaultValueAttribute("{\"x86_64\":\"true\",\"ppc64\":\"false\"}")
     HotPlugCpuSupported,
 
+    @TypeConverterAttribute(Map.class)
+    @DefaultValueAttribute("{\"x86_64\":\"false\",\"ppc64\":\"false\"}")
+    HotUnplugCpuSupported,
+
     @TypeConverterAttribute(String.class)
     @DefaultValueAttribute("")
     ChangePasswordMsg,
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
index d43198a..8887d56 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
@@ -715,6 +715,8 @@
     
ACTION_TYPE_FAILED_STORAGE_POOL_WITH_DEFAULT_VDS_GROUP_CANNOT_BE_LOCALFS(ErrorType.CONFLICT),
     DEFAULT_CLUSTER_CANNOT_BE_ON_LOCALFS(ErrorType.CONFLICT),
     HOT_PLUG_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
+    HOT_PLUG_CPU_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
+    HOT_UNPLUG_CPU_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     UNLINKING_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     HOT_PLUG_DISK_SNAPSHOT_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     NULL_NETWORK_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
index 3a43f8d..410158a 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -903,6 +903,8 @@
 USER_CANNOT_BE_ADDED_TO_VM_POOL=User cannot be added to VM-Pool
 ACTION_TYPE_FAILED_DETECTED_PINNED_VMS=Cannot ${action} ${type}. The following 
VMs are set to run specifically only on this Host: ${VmNames}.\nIn order to 
${action} ${type}, you need to remove the association between the VMs and the 
Host (Using Edit VM properties).
 HOT_PLUG_IS_NOT_SUPPORTED=Activate/Deactivate while VM is running, is only 
supported for Clusters of version 3.1 and above.
+HOT_PLUG_CPU_IS_NOT_SUPPORTED=Hot plugging a CPU is not supported for cluster 
version ${clusterVersion} and architecture ${architecture}.
+HOT_UNPLUG_CPU_IS_NOT_SUPPORTED=Hot un-plugging a CPU is not supported for 
cluster version ${clusterVersion} and architecture ${architecture}.
 HOT_PLUG_DISK_SNAPSHOT_IS_NOT_SUPPORTED=Cannot ${action} ${type}. 
Activation/Deactivation of Disk Snapshot is not supported for clusters of 
version ${clusterVersion}.
 UNLINKING_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Link state is set to 
'Down' on the virtual machine's interface, this is not supported for clusters 
of version ${clusterVersion}.
 NULL_NETWORK_IS_NOT_SUPPORTED=Cannot ${action} ${type}. There is no network on 
the virtual machine's interface, this is not supported for clusters of version 
${clusterVersion}.
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
index 9a6ffe9..a22b9cc 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
@@ -2455,6 +2455,12 @@
     @DefaultStringValue("Activate/Deactivate while VM is running, is only 
supported for Clusters of version 3.1 and above.")
     String HOT_PLUG_IS_NOT_SUPPORTED();
 
+    @DefaultStringValue("Hot plugging a CPU is not supported for cluster 
version ${clusterVersion} and architecture ${architecture}.")
+    String HOT_PLUG_CPU_IS_NOT_SUPPORTED();
+
+    @DefaultStringValue("Hot un-plugging a CPU is not supported for cluster 
version ${clusterVersion} and architecture ${architecture}.")
+    String HOT_UNPLUG_CPU_IS_NOT_SUPPORTED();
+
     @DefaultStringValue("Cannot ${action} ${type}. Activation/Deactivation of 
Disk Snapshot is not supported for clusters of version ${clusterVersion}.")
     String HOT_PLUG_DISK_SNAPSHOT_IS_NOT_SUPPORTED();
 
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index b67c734..c29a71b 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -875,6 +875,8 @@
 USER_CANNOT_BE_ADDED_TO_VM_POOL=User cannot be added to VM-Pool
 ACTION_TYPE_FAILED_DETECTED_PINNED_VMS=Cannot ${action} ${type}. The following 
VMs are set to run specifically only on this Host: ${VmNames}.\nIn order to 
${action} ${type}, you need to remove the association between the VMs and the 
Host (Using Edit VM properties).
 HOT_PLUG_IS_NOT_SUPPORTED=Activate/Deactivate while VM is running, is only 
supported for Clusters of version 3.1 and above.
+HOT_PLUG_CPU_IS_NOT_SUPPORTED=Hot plugging a CPU is not supported for cluster 
version ${clusterVersion} and architecture ${architecture}.
+HOT_UNPLUG_CPU_IS_NOT_SUPPORTED=Hot un-plugging a CPU is not supported for 
cluster version ${clusterVersion} and architecture ${architecture}.
 HOT_PLUG_DISK_SNAPSHOT_IS_NOT_SUPPORTED=Cannot ${action} ${type}. 
Activation/Deactivation of Disk Snapshot is not supported for clusters of 
version ${clusterVersion}.
 UNLINKING_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Link state is set to 
'Down' on the virtual machine's interface, this is not supported for clusters 
of version ${clusterVersion}.
 NULL_NETWORK_IS_NOT_SUPPORTED=Cannot ${action} ${type}. There is no network on 
the virtual machine's interface, this is not supported for clusters of version 
${clusterVersion}.
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index a67eb37..4927d9b 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -904,6 +904,8 @@
 USER_CANNOT_BE_ADDED_TO_VM_POOL=User cannot be added to VM-Pool
 ACTION_TYPE_FAILED_DETECTED_PINNED_VMS=Cannot ${action} ${type}. The following 
VMs are set to run specifically only on this Host: ${VmNames}.\nIn order to 
${action} ${type}, you need to remove the association between the VMs and the 
Host (Using Edit VM properties).
 HOT_PLUG_IS_NOT_SUPPORTED=Activate/Deactivate while VM is running, is only 
supported for Clusters of version 3.1 and above.
+HOT_PLUG_CPU_IS_NOT_SUPPORTED=Hot plugging a CPU is not supported for cluster 
version ${clusterVersion} and architecture ${architecture}.
+HOT_UNPLUG_CPU_IS_NOT_SUPPORTED=Hot un-plugging a CPU is not supported for 
cluster version ${clusterVersion} and architecture ${architecture}.
 HOT_PLUG_DISK_SNAPSHOT_IS_NOT_SUPPORTED=Cannot ${action} ${type}. 
Activation/Deactivation of Disk Snapshot is not supported for clusters of 
version ${clusterVersion}.
 UNLINKING_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Link state is set to 
'Down' on the virtual machine's interface, this is not supported for clusters 
of version ${clusterVersion}.
 NULL_NETWORK_IS_NOT_SUPPORTED=Cannot ${action} ${type}. There is no network on 
the virtual machine's interface, this is not supported for clusters of version 
${clusterVersion}.
diff --git a/packaging/etc/engine-config/engine-config.properties 
b/packaging/etc/engine-config/engine-config.properties
index 22cfb13..cdbf2f7 100644
--- a/packaging/etc/engine-config/engine-config.properties
+++ b/packaging/etc/engine-config/engine-config.properties
@@ -372,3 +372,7 @@
 DefaultMaximumMigrationDowntime.description="Maximum number of milliseconds 
the VM can be down during live migration. Value of 0 means that VDSM default 
will be used."
 DefaultMaximumMigrationDowntime.type=Integer
 DefaultMaximumMigrationDowntime.validValues=0..2147483647
+HotPlugCpuSupported.type=String
+HotPlugCpuSupported.description="A support map of hot plug cpu to architecture"
+HotUnplugCpuSupported.type=String
+HotUnplugCpuSupported.description="A support map of hot unplug cpu to 
architecture"


-- 
To view, visit http://gerrit.ovirt.org/26534
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I32eafdc685198b98005906dc14f6fdc8cc1c7763
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Roy Golan <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to