From 8c387f9de6d76cfa983b6fa7f39b2e9df4be4266 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Fri, 31 May 2019 10:27:36 +0530 Subject: [PATCH 1/3] vmware: fix potential NPE when memory hotplug capability is checked (#3362) This fixes potential NPE case when memory hotpluggability is checked based on the guest OS descriptor. Signed-off-by: Rohit Yadav --- .../src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b700b6d8f63..1ab325be14c 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java @@ -3281,7 +3281,7 @@ public class VirtualMachineMO extends BaseMO { virtualHardwareVersion = getVirtualHardwareVersion(); // Check if guest operating system supports memory hotadd - if (guestOsDescriptor.isSupportsMemoryHotAdd()) { + if (guestOsDescriptor != null && guestOsDescriptor.isSupportsMemoryHotAdd()) { guestOsSupportsMemoryHotAdd = true; } // Check if virtual machine is using hardware version 7 or later. From bd780303853132c696cf8e2ab20d9e1641fd5a25 Mon Sep 17 00:00:00 2001 From: ustcweizhou Date: Fri, 31 May 2019 08:53:55 +0200 Subject: [PATCH 2/3] server: update dhcp configurations in vrs while update default nic of running vms (#3205) In virtual routers, there are different dnsmasq settings for default nic and non-default nic on vm. We need to update dhcp informations on network vrs when default nic is changed. For example, if 172.16.1.135 is non-default nic of vm VPC1-001-001, then root@r-22-VM:~# cat /etc/dhcphosts.txt 02:00:1d:15:00:05,set:172_16_1_135,172.16.1.135,VPC1-001-001,710h root@r-22-VM:~# cat /etc/dhcpopts.txt 172_16_1_135,3 172_16_1_135,6 172_16_1_135,15 If it is default nic,then root@r-22-VM:~# cat /etc/dhcpopts.txt root@r-22-VM:~# cat /etc/dhcphosts.txt 02:00:1d:15:00:05,172.16.1.135,VPC1-001-001,757h Fixes #3201 --- server/src/com/cloud/vm/UserVmManagerImpl.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 7ba282f4b18..8857fe91ee1 100644 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -1448,6 +1448,19 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir newNetworkOfferingId, null, 0L, VirtualMachine.class.getName(), vmInstance.getUuid(), vmInstance.isDisplay()); UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NETWORK_OFFERING_ASSIGN, vmInstance.getAccountId(), vmInstance.getDataCenterId(), vmInstance.getId(), oldNicIdString, oldNetworkOfferingId, null, 0L, VirtualMachine.class.getName(), vmInstance.getUuid(), vmInstance.isDisplay()); + + if (vmInstance.getState() != State.Stopped) { + try { + VirtualMachineProfile vmProfile = new VirtualMachineProfileImpl(vmInstance); + User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId()); + ReservationContext context = new ReservationContextImpl(null, null, callerUser, caller); + DeployDestination dest = new DeployDestination(dc, null, null, null); + _networkMgr.prepare(vmProfile, dest, context); + } catch (final Exception e) { + s_logger.info("Got exception: ", e); + } + } + return _vmDao.findById(vmInstance.getId()); } From b8522c97cb9204e16a9dd4c138bdbf0046992820 Mon Sep 17 00:00:00 2001 From: ustcweizhou Date: Fri, 31 May 2019 08:54:33 +0200 Subject: [PATCH 3/3] server: allow dedicate ip range to a domain if ips are used by an accout in the domain (#3206) when we dedicate public ip range to a domain but some ips are used by an account in the domain, the operation should be allowed but actually fails for now. It is because cloudstack check if ips are used by same account by account name, However, accountName is null when dedicate public ip range to a domain. Modify the code to check account id only when dedicate ip range to account. --- .../configuration/ConfigurationManagerImpl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 9075ee903a5..d0230755d47 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -3601,9 +3601,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } boolean isDomainSpecific = false; - List domainVln = _domainVlanMapDao.listDomainVlanMapsByVlan(vlanRange.getId()); + List domainVlan = _domainVlanMapDao.listDomainVlanMapsByVlan(vlanRange.getId()); // Check for domain wide pool. It will have an entry for domain_vlan_map. - if (domainVln != null && !domainVln.isEmpty()) { + if (domainVlan != null && !domainVlan.isEmpty()) { isDomainSpecific = true; } @@ -3760,10 +3760,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati forSystemVms = ip.isForSystemVms(); final Long allocatedToAccountId = ip.getAllocatedToAccountId(); if (allocatedToAccountId != null) { - final Account accountAllocatedTo = _accountMgr.getActiveAccountById(allocatedToAccountId); - if (!accountAllocatedTo.getAccountName().equalsIgnoreCase(accountName)) { + if (vlanOwner != null && allocatedToAccountId != vlanOwner.getId()) { throw new InvalidParameterValueException(ip.getAddress() + " Public IP address in range is allocated to another account "); } + final Account accountAllocatedTo = _accountMgr.getActiveAccountById(allocatedToAccountId); if (vlanOwner == null && domain != null && domain.getId() != accountAllocatedTo.getDomainId()){ throw new InvalidParameterValueException(ip.getAddress() + " Public IP address in range is allocated to another domain/account "); @@ -3824,9 +3824,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } boolean isDomainSpecific = false; - final List domainVln = _domainVlanMapDao.listDomainVlanMapsByVlan(vlanDbId); + final List domainVlan = _domainVlanMapDao.listDomainVlanMapsByVlan(vlanDbId); // Check for domain wide pool. It will have an entry for domain_vlan_map. - if (domainVln != null && !domainVln.isEmpty()) { + if (domainVlan != null && !domainVlan.isEmpty()) { isDomainSpecific = true; } @@ -3879,7 +3879,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati // decrement resource count for dedicated public ip's _resourceLimitMgr.decrementResourceCount(acctVln.get(0).getAccountId(), ResourceType.public_ip, new Long(ips.size())); return true; - } else if (isDomainSpecific && _domainVlanMapDao.remove(domainVln.get(0).getId())) { + } else if (isDomainSpecific && _domainVlanMapDao.remove(domainVlan.get(0).getId())) { s_logger.debug("Remove the vlan from domain_vlan_map successfully."); return true; } else {