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 <rgo...@redhat.com>
---
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, 74 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/99/25899/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 4bbd0b8..b6c6069 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
@@ -1,10 +1,10 @@
 package org.ovirt.engine.core.bll;
 
-import org.ovirt.engine.core.bll.scheduling.SlaValidator;
 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 +20,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";
@@ -39,8 +39,12 @@
             canDo = 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_STATUS_ILLEGAL,
                     LocalizedVmStatus.from(getVm().getStatus()));
         }
-        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;
@@ -87,5 +91,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 9cfa278..bfc4b53 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 22422a5..e4a3b49 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 185bad1..d59ae16 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
@@ -1626,6 +1626,11 @@
     @TypeConverterAttribute(Map.class)
     @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 e72d0eb..26663d4 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
@@ -714,6 +714,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 1882b92..8db54e3 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 5962a3f..8b9a56f 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
@@ -2449,9 +2449,15 @@
     @DefaultStringValue("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).")
     String ACTION_TYPE_FAILED_DETECTED_PINNED_VMS();
 
-    @DefaultStringValue("Activate/Deactivate while VM is running, is only 
supported for Clusters of version 3.1 and above.")
+    @DefaultStringValue("Hot plugging a CPU is not supported for cluster 
version ${clusterVersion} and architecture ${architecture}.")
     String HOT_PLUG_IS_NOT_SUPPORTED();
 
+    @DefaultStringValue("Hot un-plugging a CPU is not supported for cluster 
version ${clusterVersion} and architecture ${architecture}.")
+    String HOT_PLUG_CPU_IS_NOT_SUPPORTED();
+
+    @DefaultStringValue("Activate/Deactivate while VM is running, is only 
supported for Clusters of version 3.1 and above.")
+    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 73f6d66..4853be6 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 b3c51dd..18f55e2 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
@@ -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/packaging/etc/engine-config/engine-config.properties 
b/packaging/etc/engine-config/engine-config.properties
index d8a4e5b..813473b 100644
--- a/packaging/etc/engine-config/engine-config.properties
+++ b/packaging/etc/engine-config/engine-config.properties
@@ -373,3 +373,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/25899
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I32eafdc685198b98005906dc14f6fdc8cc1c7763
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Roy Golan <rgo...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to