cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sate...@apache.org
Subject git commit: updated refs/heads/master to 664dc17
Date Wed, 10 Jul 2013 12:43:20 GMT
Updated Branches:
  refs/heads/master 033d05fa2 -> 664dc17b0


CLOUDSTACK-3303 Vmware - Put a mechanism to disable hot add vcpu if the number of cores per
socket is not 1 and virtual machine hardware version=7

Following Hotadd memory checks are included now.
1) Check if guest operating system supports memory hotadd
2) Check if virtual machine is using hardware version 7 or later before enabling memory hotadd

Following Hotadd CPU checks are included now.
1) Check if guest operating system supports cpu hotadd
2) Check if virtual machine is using hardware version 8 or later.
3) Check if virtual machine has only 1 core per socket. If hardware version is 7, then only
1 core per socket is supported. Hot adding multi-core vcpus is not allowed if hardware version
is 7.

Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/664dc17b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/664dc17b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/664dc17b

Branch: refs/heads/master
Commit: 664dc17b0b2a07eb0bd6f124a561b47bac03a33e
Parents: 033d05f
Author: Sateesh Chodapuneedi <sateesh@apache.org>
Authored: Wed Jul 10 17:52:15 2013 +0530
Committer: Sateesh Chodapuneedi <sateesh@apache.org>
Committed: Wed Jul 10 17:58:42 2013 +0530

----------------------------------------------------------------------
 .../vmware/resource/VmwareResource.java         | 14 +---
 .../hypervisor/vmware/mo/VirtualMachineMO.java  | 72 ++++++++++++++++++++
 2 files changed, 75 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/664dc17b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 1870736..1f54f9c 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -53,7 +53,6 @@ import com.vmware.vim25.ComputeResourceSummary;
 import com.vmware.vim25.DatastoreSummary;
 import com.vmware.vim25.DynamicProperty;
 import com.vmware.vim25.GuestInfo;
-import com.vmware.vim25.GuestOsDescriptor;
 import com.vmware.vim25.HostCapability;
 import com.vmware.vim25.HostFirewallInfo;
 import com.vmware.vim25.HostFirewallRuleset;
@@ -2575,16 +2574,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
             vmSpec.getMinSpeed(),(int) (vmSpec.getMaxRam()/(1024*1024)), ramMb,
             translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).value(), vmSpec.getLimitCpuUse());
             String guestOsId = translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).value();
-            boolean guestSupportsCpuHotAdd = false;
-            boolean guestSupportsMemoryHotAdd = false;
-            GuestOsDescriptor vmGuestOsDescriptor = vmMo.getGuestOsDescriptor(guestOsId);
-            if (vmGuestOsDescriptor != null) {
-                guestSupportsCpuHotAdd = vmGuestOsDescriptor.isSupportsCpuHotAdd();
-                guestSupportsMemoryHotAdd = vmGuestOsDescriptor.isSupportsMemoryHotAdd();
-            }
-
-            vmConfigSpec.setMemoryHotAddEnabled(guestSupportsMemoryHotAdd);
-            vmConfigSpec.setCpuHotAddEnabled(guestSupportsCpuHotAdd);
+            // Check for hotadd settings
+            vmConfigSpec.setMemoryHotAddEnabled(vmMo.isMemoryHotAddSupported(guestOsId));
+            vmConfigSpec.setCpuHotAddEnabled(vmMo.isCpuHotAddSupported(guestOsId));
 
             if ("true".equals(vmSpec.getDetails().get(VmDetailConstants.NESTED_VIRTUALIZATION_FLAG)))
{
                 s_logger.debug("Nested Virtualization enabled in configuration, checking
hypervisor capability");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/664dc17b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
index de90109..5214f3d 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -71,6 +71,7 @@ import com.vmware.vim25.VirtualDiskSparseVer2BackingInfo;
 import com.vmware.vim25.VirtualDiskType;
 import com.vmware.vim25.VirtualEthernetCard;
 import com.vmware.vim25.VirtualEthernetCardDistributedVirtualPortBackingInfo;
+import com.vmware.vim25.VirtualHardwareOption;
 import com.vmware.vim25.VirtualIDEController;
 import com.vmware.vim25.VirtualLsiLogicController;
 import com.vmware.vim25.VirtualMachineCloneSpec;
@@ -103,6 +104,7 @@ import edu.emory.mathcs.backport.java.util.Arrays;
 
 public class VirtualMachineMO extends BaseMO {
     private static final Logger s_logger = Logger.getLogger(VirtualMachineMO.class);
+    private ManagedObjectReference _vmEnvironmentBrowser = null;
 
 	public VirtualMachineMO(VmwareContext context, ManagedObjectReference morVm) {
 		super(context, morVm);
@@ -2190,4 +2192,74 @@ public class VirtualMachineMO extends BaseMO {
     public long getHotAddMemoryLimitInMb() throws Exception {
         return (Long)_context.getVimClient().getDynamicProperty(_mor, "config.hotPlugMemoryLimit");
     }
+
+    public int getCoresPerSocket() throws Exception {
+        return (Integer)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.numCoresPerSocket");
+    }
+
+    public int getVirtualHardwareVersion() throws Exception {
+        VirtualHardwareOption vhOption = getVirtualHardwareOption();
+        return vhOption.getHwVersion();
+    }
+
+    public VirtualHardwareOption getVirtualHardwareOption() throws Exception {
+        VirtualMachineConfigOption vmConfigOption = _context.getService().queryConfigOption(getEnvironmentBrowser(),
null, null);
+        return vmConfigOption.getHardwareOptions();
+    }
+
+    private ManagedObjectReference getEnvironmentBrowser() throws Exception {
+        if (_vmEnvironmentBrowser == null) {
+            _vmEnvironmentBrowser = _context.getVimClient().getMoRefProp(_mor, "environmentBrowser");
+        }
+        return _vmEnvironmentBrowser;
+    }
+
+    public boolean isCpuHotAddSupported(String guestOsId) throws Exception {
+        boolean guestOsSupportsCpuHotAdd = false;
+        boolean virtualHardwareSupportsCpuHotAdd = false;
+        GuestOsDescriptor guestOsDescriptor;
+        int virtualHardwareVersion;
+        int numCoresPerSocket;
+
+        guestOsDescriptor = getGuestOsDescriptor(guestOsId);
+        virtualHardwareVersion = getVirtualHardwareVersion();
+
+        // Check if guest operating system supports cpu hotadd
+        if (guestOsDescriptor.isSupportsCpuHotAdd()) {
+            guestOsSupportsCpuHotAdd = true;
+        }
+
+        // Check if virtual machine is using hardware version 8 or later.
+        // If hardware version is 7, then only 1 core per socket is supported. Hot adding
multi-core vcpus is not allowed if hardware version is 7.
+        if (virtualHardwareVersion >= 8) {
+            virtualHardwareSupportsCpuHotAdd = true;
+        } else if (virtualHardwareVersion == 7) {
+            // Check if virtual machine has only 1 core per socket.
+            numCoresPerSocket = getCoresPerSocket();
+            if (numCoresPerSocket == 1) {
+                virtualHardwareSupportsCpuHotAdd = true;
+            }
+        }
+        return guestOsSupportsCpuHotAdd && virtualHardwareSupportsCpuHotAdd;
+    }
+
+    public boolean isMemoryHotAddSupported(String guestOsId) throws Exception {
+        boolean guestOsSupportsMemoryHotAdd = false;
+        boolean virtualHardwareSupportsMemoryHotAdd = false;
+        GuestOsDescriptor guestOsDescriptor;
+        int virtualHardwareVersion;
+
+        guestOsDescriptor = getGuestOsDescriptor(guestOsId);
+        virtualHardwareVersion = getVirtualHardwareVersion();
+
+        // Check if guest operating system supports memory hotadd
+        if (guestOsDescriptor.isSupportsMemoryHotAdd()) {
+            guestOsSupportsMemoryHotAdd = true;
+        }
+        // Check if virtual machine is using hardware version 7 or later.
+        if (virtualHardwareVersion >= 7) {
+            virtualHardwareSupportsMemoryHotAdd = true;
+        }
+        return guestOsSupportsMemoryHotAdd && virtualHardwareSupportsMemoryHotAdd;
+    }
 }


Mime
View raw message