Skip to content

Multiple CD-ROM / ISO Support Per VM#13101

Draft
Damans227 wants to merge 35 commits into
apache:mainfrom
Damans227:fr283-multi-cdrom
Draft

Multiple CD-ROM / ISO Support Per VM#13101
Damans227 wants to merge 35 commits into
apache:mainfrom
Damans227:fr283-multi-cdrom

Conversation

@Damans227
Copy link
Copy Markdown
Collaborator

@Damans227 Damans227 commented May 4, 2026

Description

Adds multiple CD-ROM support per VM on KVM. Today CloudStack allows only one ISO per VM, forcing a manual ISO-swap workflow to install Windows on KVM (Windows installer + VirtIO drivers). After this PR each VM can hold up to vm.cdrom.max.count ISOs simultaneously, each appearing as its own CD-ROM inside the guest.

What changes:

  • detachIso takes an optional id (required when multiple ISOs are attached).
  • listVirtualMachines returns isos[] and cdrommaxcount; legacy isoid still reflects the bootable ISO.
  • New cluster-scoped config vm.cdrom.max.count (default 1). Values above the host-advertised cap fail loudly instead of silent clamping.
  • KVM agent advertises its supported CD-ROM count via the host.cdrom.max.count host detail; management reads from host_details, no hardcoded hypervisor numbers in management code.
  • New vm_iso_map table holds extra slots; user_vm.iso_id is kept as the bootable pointer. ISO deletion is gated by both tables.

Scope: KVM only.

Design doc: https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=421957739

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Screenshots (if appropriate):

Screen.Recording.2026-05-04.at.5.20.18.PM.mov
image

How Has This Been Tested?

  • End-to-end on a KVM lab across cap=1/2/5, plus the UI manually.
  • Unit tests added in TemplateManagerImplTest for slot allocation, the duplicate-attach check, and the detach-id resolution helper.

How did you try to break this feature and the system with this change?

  • Set vm.cdrom.max.count above the host's advertised cap to confirm the validate-and-throw fires on attach/deploy
  • Tried to re-attach an already-attached ISO
  • Detached the bootable and non-bootable ISO in turn to confirm user_vm.iso_id and vm_iso_map stay in sync
  • Stopped and restarted a multi-ISO VM to confirm boot-time persistence
  • Confirmed legacy single-ISO API consumers (isoid in listVirtualMachines) see no functional change

@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 41.28440% with 192 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.10%. Comparing base (5893ba5) to head (68ac686).

Files with missing lines Patch % Lines
...n/java/com/cloud/template/TemplateManagerImpl.java 39.54% 92 Missing and 15 partials ⚠️
...rc/main/java/com/cloud/vm/dao/VmIsoMapDaoImpl.java 0.00% 44 Missing ⚠️
...ava/com/cloud/api/query/dao/UserVmJoinDaoImpl.java 51.28% 13 Missing and 6 partials ⚠️
...apache/cloudstack/api/response/UserVmResponse.java 33.33% 8 Missing ⚠️
...ud/hypervisor/kvm/storage/KVMStorageProcessor.java 0.00% 7 Missing ⚠️
.../schema/src/main/java/com/cloud/vm/VmIsoMapVO.java 83.33% 3 Missing and 1 partial ⚠️
.../cloudstack/api/command/user/iso/DetachIsoCmd.java 0.00% 1 Missing ⚠️
...e/cloudstack/api/response/AttachedIsoResponse.java 95.23% 0 Missing and 1 partial ⚠️
...ervisor/kvm/resource/LibvirtComputingResource.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #13101      +/-   ##
============================================
+ Coverage     18.09%   18.10%   +0.01%     
- Complexity    16723    16770      +47     
============================================
  Files          6037     6041       +4     
  Lines        542580   542928     +348     
  Branches      66427    66489      +62     
============================================
+ Hits          98155    98307     +152     
- Misses       433399   433570     +171     
- Partials      11026    11051      +25     
Flag Coverage Δ
uitests 3.52% <ø> (+<0.01%) ⬆️
unittests 19.27% <41.28%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Damans227
Copy link
Copy Markdown
Collaborator Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@Damans227 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link
Copy Markdown

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 17708

@Damans227
Copy link
Copy Markdown
Collaborator Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@Damans227 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17709

@Damans227
Copy link
Copy Markdown
Collaborator Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@Damans227 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17720

Comment thread server/src/main/java/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
Comment thread server/src/main/java/com/cloud/template/TemplateManagerImpl.java Outdated
Comment thread server/src/main/java/com/cloud/template/TemplateManagerImpl.java
Comment on lines +1477 to +1478
VmIsoMapVO highest = highestCdromMapEntry(vmId);
return highest == null ? CDROM_PRIMARY_DEVICE_SEQ + 1 : highest.getDeviceSeq() + 1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is we aren't using highestCdromMapEntry() elsewhere I was wondering if we could just do:

Suggested change
VmIsoMapVO highest = highestCdromMapEntry(vmId);
return highest == null ? CDROM_PRIMARY_DEVICE_SEQ + 1 : highest.getDeviceSeq() + 1;
return _vmIsoMapDao.listByVmId(vmId).stream()
.mapToInt(VmIsoMapVO::getDeviceSeq)
.max()
.orElse(CDROM_PRIMARY_DEVICE_SEQ) + 1;

feel free to ignore.

Copy link
Copy Markdown
Contributor

@Pearl1594 Pearl1594 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm. Left a few minor comments.

Copy link
Copy Markdown
Member

@harikrishna-patnala harikrishna-patnala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code LGTM

@Damans227
Copy link
Copy Markdown
Collaborator Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@Damans227 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17740

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@Damans227
Copy link
Copy Markdown
Collaborator Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@Damans227 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link
Copy Markdown

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 17862

@Damans227
Copy link
Copy Markdown
Collaborator Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@Damans227 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17863

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants