Skip to content

Commit b6b778f

Browse files
author
Daan Hoogland
committed
Merge release branch 4.14 to 4.15
* 4.14: server: select root disk based on user input during vm import (#4591) kvm: Use Q35 chipset for UEFI x86_64 (#4576) server: fix wrong error message when create isolated network without SourceNat (#4624) server: add possibility to scale vm to current customer offerings (#4622) server: keep networks order and ips while move a vm with multiple networks (#4602) server: throw exception when update vm nic on L2 network (#4625) doc: fix typo in install notes (#4633)
2 parents 1bccb95 + 9b45ec2 commit b6b778f

8 files changed

Lines changed: 113 additions & 51 deletions

File tree

INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ To create rpms, install the following extra packages:
136136

137137
# yum -y install rpm-build
138138
# yum -y install ws-commons-util
139-
# yum -y instal gcc
139+
# yum -y install gcc
140140
# yum -y install glibc-devel
141141
# yum -y install MySQL-python
142142

engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void prepare(VirtualMachineProfile profile, DeployDestination dest, ReservationC
129129

130130
void cleanupNics(VirtualMachineProfile vm);
131131

132-
void expungeNics(VirtualMachineProfile vm);
132+
void removeNics(VirtualMachineProfile vm);
133133

134134
List<NicProfile> getNicProfiles(VirtualMachine vm);
135135

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,10 +2301,10 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
23012301
}
23022302

23032303
@Override
2304-
public void expungeNics(final VirtualMachineProfile vm) {
2305-
final List<NicVO> nics = _nicDao.listByVmIdIncludingRemoved(vm.getId());
2304+
public void removeNics(final VirtualMachineProfile vm) {
2305+
final List<NicVO> nics = _nicDao.listByVmId(vm.getId());
23062306
for (final NicVO nic : nics) {
2307-
_nicDao.expunge(nic.getId());
2307+
_nicDao.remove(nic.getId());
23082308
}
23092309
}
23102310

@@ -2545,8 +2545,11 @@ private Network createGuestNetwork(final long networkOfferingId, final String na
25452545
&& (ntwkOff.getGuestType() == GuestType.Shared || (ntwkOff.getGuestType() == GuestType.Isolated
25462546
&& !_networkModel.areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat)));
25472547
if (cidr == null && ip6Cidr == null && cidrRequired) {
2548-
throw new InvalidParameterValueException("StartIp/endIp/gateway/netmask are required when create network of" + " type " + Network.GuestType.Shared
2549-
+ " and network of type " + GuestType.Isolated + " with service " + Service.SourceNat.getName() + " disabled");
2548+
if (ntwkOff.getGuestType() == GuestType.Shared) {
2549+
throw new InvalidParameterValueException("StartIp/endIp/gateway/netmask are required when create network of" + " type " + Network.GuestType.Shared);
2550+
} else {
2551+
throw new InvalidParameterValueException("gateway/netmask are required when create network of" + " type " + GuestType.Isolated + " with service " + Service.SourceNat.getName() + " disabled");
2552+
}
25502553
}
25512554

25522555
checkL2OfferingServices(ntwkOff);

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2247,8 +2247,8 @@ public LibvirtVMDef createVMFromSpec(final VirtualMachineTO vmTO) {
22472247
if (MapUtils.isNotEmpty(customParams) && customParams.containsKey(GuestDef.BootType.UEFI.toString())) {
22482248
guest.setBootType(GuestDef.BootType.UEFI);
22492249
guest.setBootMode(GuestDef.BootMode.LEGACY);
2250+
guest.setMachineType("q35");
22502251
if (StringUtils.isNotBlank(customParams.get(GuestDef.BootType.UEFI.toString())) && "secure".equalsIgnoreCase(customParams.get(GuestDef.BootType.UEFI.toString()))) {
2251-
guest.setMachineType("q35");
22522252
guest.setBootMode(GuestDef.BootMode.SECURE); // setting to secure mode
22532253
}
22542254
}

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2955,7 +2955,9 @@ private Pair<List<ServiceOfferingJoinVO>, Integer> searchForServiceOfferingsInte
29552955
_accountMgr.checkAccess(caller, null, true, vmInstance);
29562956

29572957
currentVmOffering = _srvOfferingDao.findByIdIncludingRemoved(vmInstance.getId(), vmInstance.getServiceOfferingId());
2958-
sc.addAnd("id", SearchCriteria.Op.NEQ, currentVmOffering.getId());
2958+
if (! currentVmOffering.isDynamic()) {
2959+
sc.addAnd("id", SearchCriteria.Op.NEQ, currentVmOffering.getId());
2960+
}
29592961

29602962
// 1. Only return offerings with the same storage type
29612963
sc.addAnd("useLocalStorage", SearchCriteria.Op.EQ, currentVmOffering.isUseLocalStorage());

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 64 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import java.util.Arrays;
2525
import java.util.Date;
2626
import java.util.HashMap;
27-
import java.util.HashSet;
2827
import java.util.LinkedHashMap;
28+
import java.util.LinkedHashSet;
2929
import java.util.List;
3030
import java.util.Map;
3131
import java.util.Map.Entry;
@@ -1736,8 +1736,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
17361736
return null;
17371737
}
17381738
} else {
1739-
s_logger.error("UpdateVmNicIpCmd is not supported in this network...");
1740-
return null;
1739+
throw new InvalidParameterValueException("UpdateVmNicIpCmd is not supported in L2 network");
17411740
}
17421741

17431742
s_logger.debug("Updating IPv4 address of NIC " + nicVO + " to " + ipaddr + "/" + nicVO.getIPv4Netmask() + " with gateway " + nicVO.getIPv4Gateway());
@@ -6454,7 +6453,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
64546453
_securityGroupMgr.removeInstanceFromGroups(cmd.getVmId());
64556454
// cleanup the network for the oldOwner
64566455
_networkMgr.cleanupNics(vmOldProfile);
6457-
_networkMgr.expungeNics(vmOldProfile);
6456+
_networkMgr.removeNics(vmOldProfile);
64586457
// security groups will be recreated for the new account, when the
64596458
// VM is started
64606459
List<NetworkVO> networkList = new ArrayList<NetworkVO>();
@@ -6516,34 +6515,25 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
65166515

65176516
s_logger.debug("AssignVM: Basic zone, adding security groups no " + securityGroupIdList.size() + " to " + vm.getInstanceName());
65186517
} else {
6518+
Set<NetworkVO> applicableNetworks = new LinkedHashSet<>();
6519+
Map<Long, String> requestedIPv4ForNics = new HashMap<>();
6520+
Map<Long, String> requestedIPv6ForNics = new HashMap<>();
65196521
if (zone.isSecurityGroupEnabled()) { // advanced zone with security groups
65206522
// cleanup the old security groups
65216523
_securityGroupMgr.removeInstanceFromGroups(cmd.getVmId());
6522-
6523-
Set<NetworkVO> applicableNetworks = new HashSet<NetworkVO>();
6524-
String requestedIPv4ForDefaultNic = null;
6525-
String requestedIPv6ForDefaultNic = null;
65266524
// if networkIdList is null and the first network of vm is shared network, then keep it if possible
65276525
if (networkIdList == null || networkIdList.isEmpty()) {
65286526
NicVO defaultNicOld = _nicDao.findDefaultNicForVM(vm.getId());
65296527
if (defaultNicOld != null) {
65306528
NetworkVO defaultNetworkOld = _networkDao.findById(defaultNicOld.getNetworkId());
6531-
if (defaultNetworkOld != null && defaultNetworkOld.getGuestType() == Network.GuestType.Shared && defaultNetworkOld.getAclType() == ACLType.Domain) {
6532-
try {
6533-
_networkModel.checkNetworkPermissions(newAccount, defaultNetworkOld);
6534-
applicableNetworks.add(defaultNetworkOld);
6535-
requestedIPv4ForDefaultNic = defaultNicOld.getIPv4Address();
6536-
requestedIPv6ForDefaultNic = defaultNicOld.getIPv6Address();
6537-
s_logger.debug("AssignVM: use old shared network " + defaultNetworkOld.getName() + " with old ip " + requestedIPv4ForDefaultNic + " on default nic of vm:" + vm.getInstanceName());
6538-
} catch (PermissionDeniedException e) {
6539-
s_logger.debug("AssignVM: the shared network on old default nic can not be applied to new account");
6540-
}
6529+
if (canAccountUseNetwork(newAccount, defaultNetworkOld)) {
6530+
applicableNetworks.add(defaultNetworkOld);
6531+
requestedIPv4ForNics.put(defaultNetworkOld.getId(), defaultNicOld.getIPv4Address());
6532+
requestedIPv6ForNics.put(defaultNetworkOld.getId(), defaultNicOld.getIPv6Address());
6533+
s_logger.debug("AssignVM: use old shared network " + defaultNetworkOld.getName() + " with old ip " + defaultNicOld.getIPv4Address() + " on default nic of vm:" + vm.getInstanceName());
65416534
}
65426535
}
65436536
}
6544-
// cleanup the network for the oldOwner
6545-
_networkMgr.cleanupNics(vmOldProfile);
6546-
_networkMgr.expungeNics(vmOldProfile);
65476537

65486538
if (networkIdList != null && !networkIdList.isEmpty()) {
65496539
// add any additional networks
@@ -6566,10 +6556,24 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
65666556
ex.addProxyObject(network.getUuid(), "networkId");
65676557
throw ex;
65686558
}
6559+
6560+
if (network.getGuestType() == Network.GuestType.Shared && network.getAclType() == ACLType.Domain) {
6561+
NicVO nicOld = _nicDao.findByNtwkIdAndInstanceId(network.getId(), vm.getId());
6562+
if (nicOld != null) {
6563+
requestedIPv4ForNics.put(network.getId(), nicOld.getIPv4Address());
6564+
requestedIPv6ForNics.put(network.getId(), nicOld.getIPv6Address());
6565+
s_logger.debug("AssignVM: use old shared network " + network.getName() + " with old ip " + nicOld.getIPv4Address() + " on nic of vm:" + vm.getInstanceName());
6566+
}
6567+
}
6568+
s_logger.debug("AssignVM: Added network " + network.getName() + " to vm " + vm.getId());
65696569
applicableNetworks.add(network);
65706570
}
65716571
}
65726572

6573+
// cleanup the network for the oldOwner
6574+
_networkMgr.cleanupNics(vmOldProfile);
6575+
_networkMgr.removeNics(vmOldProfile);
6576+
65736577
// add the new nics
65746578
LinkedHashMap<Network, List<? extends NicProfile>> networks = new LinkedHashMap<Network, List<? extends NicProfile>>();
65756579
int toggle = 0;
@@ -6578,11 +6582,12 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
65786582
NicProfile defaultNic = new NicProfile();
65796583
if (toggle == 0) {
65806584
defaultNic.setDefaultNic(true);
6581-
defaultNic.setRequestedIPv4(requestedIPv4ForDefaultNic);
6582-
defaultNic.setRequestedIPv6(requestedIPv6ForDefaultNic);
65836585
defaultNetwork = appNet;
65846586
toggle++;
65856587
}
6588+
6589+
defaultNic.setRequestedIPv4(requestedIPv4ForNics.get(appNet.getId()));
6590+
defaultNic.setRequestedIPv6(requestedIPv6ForNics.get(appNet.getId()));
65866591
networks.put(appNet, new ArrayList<NicProfile>(Arrays.asList(defaultNic)));
65876592

65886593
}
@@ -6645,27 +6650,20 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
66456650
if (securityGroupIdList != null && !securityGroupIdList.isEmpty()) {
66466651
throw new InvalidParameterValueException("Can't move vm with security groups; security group feature is not enabled in this zone");
66476652
}
6648-
Set<NetworkVO> applicableNetworks = new HashSet<NetworkVO>();
66496653
// if networkIdList is null and the first network of vm is shared network, then keep it if possible
66506654
if (networkIdList == null || networkIdList.isEmpty()) {
66516655
NicVO defaultNicOld = _nicDao.findDefaultNicForVM(vm.getId());
66526656
if (defaultNicOld != null) {
66536657
NetworkVO defaultNetworkOld = _networkDao.findById(defaultNicOld.getNetworkId());
6654-
if (defaultNetworkOld != null && defaultNetworkOld.getGuestType() == Network.GuestType.Shared && defaultNetworkOld.getAclType() == ACLType.Domain) {
6655-
try {
6656-
_networkModel.checkNetworkPermissions(newAccount, defaultNetworkOld);
6657-
applicableNetworks.add(defaultNetworkOld);
6658-
} catch (PermissionDeniedException e) {
6659-
s_logger.debug("AssignVM: the shared network on old default nic can not be applied to new account");
6660-
}
6658+
if (canAccountUseNetwork(newAccount, defaultNetworkOld)) {
6659+
applicableNetworks.add(defaultNetworkOld);
6660+
requestedIPv4ForNics.put(defaultNetworkOld.getId(), defaultNicOld.getIPv4Address());
6661+
requestedIPv6ForNics.put(defaultNetworkOld.getId(), defaultNicOld.getIPv6Address());
6662+
s_logger.debug("AssignVM: use old shared network " + defaultNetworkOld.getName() + " with old ip " + defaultNicOld.getIPv4Address() + " on default nic of vm:" + vm.getInstanceName());
66616663
}
66626664
}
66636665
}
66646666

6665-
// cleanup the network for the oldOwner
6666-
_networkMgr.cleanupNics(vmOldProfile);
6667-
_networkMgr.expungeNics(vmOldProfile);
6668-
66696667
if (networkIdList != null && !networkIdList.isEmpty()) {
66706668
// add any additional networks
66716669
for (Long networkId : networkIdList) {
@@ -6685,6 +6683,16 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
66856683
ex.addProxyObject(network.getUuid(), "networkId");
66866684
throw ex;
66876685
}
6686+
6687+
if (network.getGuestType() == Network.GuestType.Shared && network.getAclType() == ACLType.Domain) {
6688+
NicVO nicOld = _nicDao.findByNtwkIdAndInstanceId(network.getId(), vm.getId());
6689+
if (nicOld != null) {
6690+
requestedIPv4ForNics.put(network.getId(), nicOld.getIPv4Address());
6691+
requestedIPv6ForNics.put(network.getId(), nicOld.getIPv6Address());
6692+
s_logger.debug("AssignVM: use old shared network " + network.getName() + " with old ip " + nicOld.getIPv4Address() + " on nic of vm:" + vm.getInstanceName());
6693+
}
6694+
}
6695+
s_logger.debug("AssignVM: Added network " + network.getName() + " to vm " + vm.getId());
66886696
applicableNetworks.add(network);
66896697
}
66906698
} else if (applicableNetworks.isEmpty()) {
@@ -6748,6 +6756,10 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
67486756
applicableNetworks.add(defaultNetwork);
67496757
}
67506758

6759+
// cleanup the network for the oldOwner
6760+
_networkMgr.cleanupNics(vmOldProfile);
6761+
_networkMgr.removeNics(vmOldProfile);
6762+
67516763
// add the new nics
67526764
LinkedHashMap<Network, List<? extends NicProfile>> networks = new LinkedHashMap<Network, List<? extends NicProfile>>();
67536765
int toggle = 0;
@@ -6757,6 +6769,8 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
67576769
defaultNic.setDefaultNic(true);
67586770
toggle++;
67596771
}
6772+
defaultNic.setRequestedIPv4(requestedIPv4ForNics.get(appNet.getId()));
6773+
defaultNic.setRequestedIPv6(requestedIPv6ForNics.get(appNet.getId()));
67606774
networks.put(appNet, new ArrayList<NicProfile>(Arrays.asList(defaultNic)));
67616775
}
67626776
VirtualMachine vmi = _itMgr.findById(vm.getId());
@@ -6769,6 +6783,21 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
67696783
return vm;
67706784
}
67716785

6786+
private boolean canAccountUseNetwork(Account newAccount, Network network) {
6787+
if (network != null && network.getAclType() == ACLType.Domain
6788+
&& (network.getGuestType() == Network.GuestType.Shared
6789+
|| network.getGuestType() == Network.GuestType.L2)) {
6790+
try {
6791+
_networkModel.checkNetworkPermissions(newAccount, network);
6792+
return true;
6793+
} catch (PermissionDeniedException e) {
6794+
s_logger.debug(String.format("AssignVM: %s network %s can not be used by new account %s", network.getGuestType(), network.getName(), newAccount.getAccountName()));
6795+
return false;
6796+
}
6797+
}
6798+
return false;
6799+
}
6800+
67726801
@Override
67736802
public UserVm restoreVM(RestoreVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException {
67746803
// Input validation

0 commit comments

Comments
 (0)