@@ -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 ()), slotsNeededFor (slotToIsoId ));
697+ int totalSlots = Math .max (effectiveMaxCdroms (vm , dest .getHost ().getId (), false ), 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,6 +1557,10 @@ 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 ) {
15601564 HostVO host = hostId != null ? _hostDao .findById (hostId ) : null ;
15611565 Long clusterId = host != null ? host .getClusterId () : null ;
15621566 int configuredCap = VmIsoMaxCount .valueIn (clusterId );
@@ -1565,8 +1569,14 @@ int effectiveMaxCdroms(VirtualMachine vm, Long hostId) {
15651569 String message = String .format (
15661570 "%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." ,
15671571 VmIsoMaxCount .key (), configuredCap , hypervisorCap , VmIsoMaxCount .key (), hypervisorCap );
1568- logger .error (message );
1569- throw new InvalidParameterValueException (message );
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 );
1579+ return hypervisorCap ;
15701580 }
15711581 return configuredCap ;
15721582 }
0 commit comments