Skip to content

Commit 7821838

Browse files
author
Brady Wilkin
committed
Completed config option to allow nested virtualization
1 parent fd74895 commit 7821838

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4846,6 +4846,8 @@ protected long getMemoryFreeInKBs(Domain dm) throws LibvirtException {
48464846
}
48474847

48484848
private boolean canBridgeFirewall(final String prvNic) {
4849+
if (getAllowNestedVMAccess())
4850+
return true; // If nested VM is allowed, then we skip call to security group and allow bypassing firewall
48494851
final Script cmd = new Script(securityGroupPath, timeout, LOGGER);
48504852
cmd.add("can_bridge_firewall");
48514853
cmd.add("--privnic", prvNic);

server/src/main/java/com/cloud/network/IpAddressManagerImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
329329

330330
public static final ConfigKey<Integer> PUBLIC_IP_ADDRESS_QUARANTINE_DURATION = new ConfigKey<>("Network", Integer.class, "public.ip.address.quarantine.duration",
331331
"0", "The duration (in minutes) for the public IP address to be quarantined when it is disassociated.", true, ConfigKey.Scope.Domain);
332+
333+
public static final ConfigKey<Boolean> AllowNestedVMAccess = new ConfigKey<>("Advanced", Boolean.class, "allow.nested.vm.access",
334+
"false", "Allows nested VM access by bypassing security group restrictions. Use with caution.", true, ConfigKey.Scope.Global);
332335

333336
private Random rand = new Random(System.currentTimeMillis());
334337

@@ -2453,6 +2456,10 @@ public static ConfigKey<Boolean> getSystemvmpublicipreservationmodestrictness()
24532456
return SystemVmPublicIpReservationModeStrictness;
24542457
}
24552458

2459+
public static ConfigKey<Boolean> getAllowNestedVMAccess() {
2460+
return AllowNestedVMAccess;
2461+
}
2462+
24562463
@Override
24572464
public boolean canPublicIpAddressBeAllocated(IpAddress ip, Account newOwner) {
24582465
PublicIpQuarantineVO publicIpQuarantineVO = publicIpQuarantineDao.findByPublicIpAddressId(ip.getId());

server/src/test/java/com/cloud/network/IpAddressManagerTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,4 +491,14 @@ public void checkIfIpResourceCountShouldBeUpdatedTestIpIsAssociatedToVpcAndNotDe
491491

492492
Assert.assertTrue(result);
493493
}
494+
495+
@Test
496+
public void testCanBridgeFirewallWithNestedVMAccessEnabled() {
497+
// Force config to return true for AllowNestedVMAccess
498+
Mockito.doReturn(true).when(ipAddressManager).getAllowNestedVMAccessConfig();
499+
500+
boolean result = ipAddressManager.canBridgeFirewall("eth0");
501+
502+
Assert.assertTrue("Should return true when AllowNestedVMAccess is enabled", result);
503+
}
494504
}

0 commit comments

Comments
 (0)