Skip to content

Commit 7ce3034

Browse files
author
Marcus Sorensen
committed
CLOUDSTACK-6790: Disable PXE ROM for system vm nics
1 parent 021a604 commit 7ce3034

6 files changed

Lines changed: 35 additions & 1 deletion

File tree

api/src/com/cloud/agent/api/to/NicTO.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class NicTO extends NetworkTO {
2323
Integer networkRateMbps;
2424
Integer networkRateMulticastMbps;
2525
boolean defaultNic;
26+
boolean pxeDisable;
2627
String uuid;
2728
List<String> nicSecIps;
2829

@@ -58,6 +59,14 @@ public void setDefaultNic(boolean defaultNic) {
5859
this.defaultNic = defaultNic;
5960
}
6061

62+
public void setPxeDisable(boolean pxeDisable) {
63+
this.pxeDisable = pxeDisable;
64+
}
65+
66+
public boolean getPxeDisable() {
67+
return pxeDisable;
68+
}
69+
6170
@Override
6271
public String getUuid() {
6372
return uuid;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,9 @@ protected NicTO toNicTO(NicVO nic, NicProfile profile, NetworkVO config) {
904904
} else {
905905
to.setGateway(config.getGateway());
906906
}
907+
if (nic.getVmType() != VirtualMachine.Type.User) {
908+
to.setPxeDisable(true);
909+
}
907910
to.setDefaultNic(nic.isDefaultNic());
908911
to.setBroadcastUri(nic.getBroadcastUri());
909912
to.setIsolationuri(nic.getIsolationUri());

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicA
142142
String storageBrName = nic.getName() == null ? _bridges.get("private") : nic.getName();
143143
intf.defBridgeNet(storageBrName, null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter));
144144
}
145+
if (nic.getPxeDisable() == true) {
146+
intf.setPxeDisable(true);
147+
}
145148
return intf;
146149
}
147150

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3793,6 +3793,14 @@ protected StartAnswer execute(StartCommand cmd) {
37933793
_vms.put(vmName, State.Starting);
37943794
}
37953795

3796+
NicTO[] nics = vmSpec.getNics();
3797+
3798+
for (NicTO nic : nics) {
3799+
if (vmSpec.getType() != VirtualMachine.Type.User) {
3800+
nic.setPxeDisable(true);
3801+
}
3802+
}
3803+
37963804
vm = createVMFromSpec(vmSpec);
37973805

37983806
conn = LibvirtConnection.getConnectionByType(vm.getHvsType());
@@ -3808,7 +3816,6 @@ protected StartAnswer execute(StartCommand cmd) {
38083816
s_logger.debug("starting " + vmName + ": " + vm.toString());
38093817
startVM(conn, vmName, vm.toString());
38103818

3811-
NicTO[] nics = vmSpec.getNics();
38123819
for (NicTO nic : nics) {
38133820
if (nic.isSecurityGroupEnabled() || (nic.getIsolationUri() != null && nic.getIsolationUri().getScheme().equalsIgnoreCase(IsolationType.Ec2.toString()))) {
38143821
if (vmSpec.getType() != VirtualMachine.Type.User) {

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,7 @@ enum hostNicType {
765765
private String _virtualPortType;
766766
private String _virtualPortInterfaceId;
767767
private int _vlanTag = -1;
768+
private boolean _pxeDisable = false;
768769

769770
public void defBridgeNet(String brName, String targetBrName, String macAddr, nicModel model) {
770771
defBridgeNet(brName, targetBrName, macAddr, model, 0);
@@ -832,6 +833,10 @@ public hostNicType getHostNetType() {
832833
return _hostNetType;
833834
}
834835

836+
public void setPxeDisable(boolean pxeDisable) {
837+
_pxeDisable = pxeDisable;
838+
}
839+
835840
public String getBrName() {
836841
return _sourceName;
837842
}
@@ -909,6 +914,9 @@ public String toString() {
909914
if (_scriptPath != null) {
910915
netBuilder.append("<script path='" + _scriptPath + "'/>\n");
911916
}
917+
if (_pxeDisable) {
918+
netBuilder.append("<rom bar='off' file='dummy'/>");
919+
}
912920
if (_virtualPortType != null) {
913921
netBuilder.append("<virtualport type='" + _virtualPortType + "'>\n");
914922
if (_virtualPortInterfaceId != null) {

server/src/com/cloud/hypervisor/HypervisorGuruBase.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ public NicTO toNicTO(NicProfile profile) {
9797
// Workaround to make sure the TO has the UUID we need for Niciri integration
9898
NicVO nicVO = _nicDao.findById(profile.getId());
9999
to.setUuid(nicVO.getUuid());
100+
// disable pxe on system vm nics to speed up boot time
101+
if(nicVO != null && nicVO.getVmType() != VirtualMachine.Type.User){
102+
to.setPxeDisable(true);
103+
}
100104
//check whether the this nic has secondary ip addresses set
101105
//set nic secondary ip address in NicTO which are used for security group
102106
// configuration. Use full when vm stop/start

0 commit comments

Comments
 (0)