Skip to content

Commit e8ece3b

Browse files
committed
refactor: simplify effectiveMaxCdroms method and improve logging for CD-ROM capacity
1 parent 489bf98 commit e8ece3b

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

server/src/main/java/com/cloud/template/TemplateManagerImpl.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ public void prepareIsoForVmProfile(VirtualMachineProfile profile, DeployDestinat
694694

695695
// Pre-allocate every cdrom slot at boot. QEMU/IDE refuses to hot-add new cdrom drives, so
696696
// runtime attachIso can only media-swap into a slot the domain already owns.
697-
int totalSlots = Math.max(effectiveMaxCdroms(vm, dest.getHost().getId(), false), slotsNeededFor(slotToIsoId));
697+
int totalSlots = Math.max(effectiveMaxCdroms(vm, dest.getHost().getId()), slotsNeededFor(slotToIsoId));
698698
for (int i = 0; i < totalSlots; i++) {
699699
int diskSeq = CDROM_PRIMARY_DEVICE_SEQ + i;
700700
Long isoId = slotToIsoId.get(diskSeq);
@@ -1557,25 +1557,13 @@ void enforceCdromAttachLimits(long vmId, UserVm vm, long isoId) {
15571557
}
15581558

15591559
int effectiveMaxCdroms(VirtualMachine vm, Long hostId) {
1560-
return effectiveMaxCdroms(vm, hostId, true);
1561-
}
1562-
1563-
int effectiveMaxCdroms(VirtualMachine vm, Long hostId, boolean failOnMisconfig) {
15641560
HostVO host = hostId != null ? _hostDao.findById(hostId) : null;
15651561
Long clusterId = host != null ? host.getClusterId() : null;
15661562
int configuredCap = VmIsoMaxCount.valueIn(clusterId);
15671563
int hypervisorCap = advertisedCdromCap(hostId);
15681564
if (configuredCap > hypervisorCap) {
1569-
String message = String.format(
1570-
"%s is set to %d but the placement host supports a maximum of %d CD-ROM(s) per Instance; lower %s to %d or less.",
1571-
VmIsoMaxCount.key(), configuredCap, hypervisorCap, VmIsoMaxCount.key(), hypervisorCap);
1572-
if (failOnMisconfig) {
1573-
logger.error(message);
1574-
throw new InvalidParameterValueException(message);
1575-
}
1576-
// VM start path: don't block the Instance from booting just because the cap was misconfigured.
1577-
// The next attach attempt will surface the misconfig loudly via the strict variant.
1578-
logger.warn("{} Clamping to {} for VM start.", message, hypervisorCap);
1565+
logger.warn("{} is set to {} but the placement host supports a maximum of {} CD-ROM(s) per Instance. Clamping to {}.",
1566+
VmIsoMaxCount.key(), configuredCap, hypervisorCap, hypervisorCap);
15791567
return hypervisorCap;
15801568
}
15811569
return configuredCap;

0 commit comments

Comments
 (0)