Skip to content

Allow selecting guest OS for KVM imports#13158

Open
andrijapanicsb wants to merge 4 commits into
apache:mainfrom
andrijapanicsb:import-qcow2-guest-os-options
Open

Allow selecting guest OS for KVM imports#13158
andrijapanicsb wants to merge 4 commits into
apache:mainfrom
andrijapanicsb:import-qcow2-guest-os-options

Conversation

@andrijapanicsb
Copy link
Copy Markdown
Contributor

@andrijapanicsb andrijapanicsb commented May 13, 2026

Description

This PR improves the KVM VM import flows by allowing operators to select the guest OS type instead of relying only on the default import template guest OS - it's an extension of #12802 by @nvazquez

The change covers:

  • Import Instance from Remote KVM host (importsource=external)
  • KVM unmanaged instance imports through importUnmanagedInstance
  • KVM local/shared storage QCOW2 imports through importVm

For remote and unmanaged KVM VM imports, CloudStack now parses libvirt metadata when available and exposes the detected source OS information to the UI. The UI uses this information to filter and preselect the Guest OS list where possible:

  • Prefer libosinfo:os id, for example http://ubuntu.com/ubuntu/24.04 or http://redhat.com/rhel/8.0
  • Fall back to the libvirt domain description, for example Debian GNU/Linux 12 (64-bit) (typical for CloudStack KVM VMs)
  • Show the full Guest OS list when no useful match is found

For QCOW2 imports from local/shared storage there is no source VM metadata, so the UI shows the full Guest OS list.

This PR also allows optional macaddress and ipaddress parameters for KVM local/shared storage imports, so a caller can explicitly request the NIC MAC and IPv4 address when creating the imported VM from an existing disk. to make this import UI a bit closer to the UI of creating a brand new VM Instance.

Testing

  • mvn -pl api,server -am -DskipTests compile
  • mvn -pl server -am -Dtest=UnmanagedVMsManagerImplTest#importFromLocalDisk+importFromsharedStorage+testImportFromExternalTest -Dsurefire.failIfNoSpecifiedTests=false test
  • mvn -pl plugins/hypervisors/kvm -am -Dtest=LibvirtDomainXMLParserTest -Dsurefire.failIfNoSpecifiedTests=false test
  • git diff --check

@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

❌ Patch coverage is 51.11111% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.09%. Comparing base (4425ee4) to head (d2963a6).
⚠️ Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
...e/cloudstack/api/command/admin/vm/ImportVmCmd.java 0.00% 6 Missing ⚠️
.../apache/cloudstack/vm/UnmanagedVMsManagerImpl.java 61.53% 2 Missing and 3 partials ⚠️
...ypervisor/kvm/resource/LibvirtDomainXMLParser.java 78.94% 1 Missing and 3 partials ⚠️
...i/command/admin/vm/ImportUnmanagedInstanceCmd.java 0.00% 3 Missing ⚠️
...rce/wrapper/LibvirtGetRemoteVmsCommandWrapper.java 0.00% 2 Missing ⚠️
...er/LibvirtGetUnmanagedInstancesCommandWrapper.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               main   #13158    +/-   ##
==========================================
  Coverage     18.09%   18.09%            
- Complexity    16717    16726     +9     
==========================================
  Files          6037     6037            
  Lines        542543   542663   +120     
  Branches      66430    66448    +18     
==========================================
+ Hits          98149    98174    +25     
- Misses       433375   433459    +84     
- Partials      11019    11030    +11     
Flag Coverage Δ
uitests 3.51% <ø> (-0.01%) ⬇️
unittests 19.25% <51.11%> (+<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.

@andrijapanicsb
Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@andrijapanicsb 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.

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.

minor comments, did not test functionality

Comment thread api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ImportVmCmd.java Outdated
Comment thread ui/src/views/tools/ImportUnmanagedInstance.vue Outdated
@blueorangutan
Copy link
Copy Markdown

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

andrijapanicsb and others added 2 commits May 14, 2026 02:11
…mportUnmanagedInstanceCmd.java

Co-authored-by: Pearl Dsilva <pearl1594@gmail.com>
…mportVmCmd.java

Co-authored-by: Pearl Dsilva <pearl1594@gmail.com>
@andrijapanicsb
Copy link
Copy Markdown
Contributor Author

minor comments, did not test functionality

Neither did I - yet to test it after package build (again) :)

Thx my favourite colleague @Pearl1594

@andrijapanicsb
Copy link
Copy Markdown
Contributor Author

@blueorangutan package kvm

Co-authored-by: Pearl Dsilva <pearl1594@gmail.com>
@andrijapanicsb
Copy link
Copy Markdown
Contributor Author

damn it, @blueorangutan package kvm

@blueorangutan
Copy link
Copy Markdown

@andrijapanicsb a [SL] Jenkins job has been kicked to build packages. It will be bundled with kvm SystemVM template(s). I'll keep you posted as I make progress.

@blueorangutan
Copy link
Copy Markdown

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

@andrijapanicsb
Copy link
Copy Markdown
Contributor Author

@bueorangutan test ol8 kvm-ol8

@andrijapanicsb
Copy link
Copy Markdown
Contributor Author

@blueorangutan test ol8 kvm-ol8

@blueorangutan
Copy link
Copy Markdown

@andrijapanicsb a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@andrijapanicsb
Copy link
Copy Markdown
Contributor Author

@blueorangutan help

@blueorangutan
Copy link
Copy Markdown

[SL] Blueorangutan Help

Supported commands

  • help
  • hello
  • thanks
  • package
  • test

Test command

@blueorangutan test [mgmt os] [hypervisor] [keepEnv] [qemuEv] [basicZone|securityGroups]

Supported Management Server OS

alma10, alma8, alma9, centos6, centos7, debian12, ol10, ol8, ol9, rocky10, rocky8, rocky9, suse15, ubuntu18, ubuntu20, ubuntu22, ubuntu24

Supported Hypervisors

kvm-alma10, kvm-alma8, kvm-alma9, kvm-centos6, kvm-centos7, kvm-debian12, kvm-ol10, kvm-ol8, kvm-ol9, kvm-rocky10, kvm-rocky8, kvm-rocky9, kvm-suse15, kvm-ubuntu18, kvm-ubuntu20, kvm-ubuntu22, kvm-ubuntu24, vmware-55u3, vmware-60u2, vmware-65u2, vmware-67u3, vmware-70u1, vmware-70u2, vmware-70u3, vmware-80, vmware-80u1, vmware-80u2, vmware-80u3, vmware-80u3e, xcpng74, xcpng76, xcpng80, xcpng81, xcpng82, xcpng83, xenserver-65sp1, xenserver-71, xenserver-74, xenserver-84

Notes

  • keepEnv keeps the environment after test completion.

    • Requires explicit mgmt OS + hypervisor, or use matrix.
  • qemuEv deploys KVM hosts with qemu-kvm-ev.

    • Otherwise stock qemu is used.
  • basicZone creates a Basic zone.

  • securityGroups creates an Advanced zone with Security Groups.


Matrix test examples

@blueorangutan test matrix
@blueorangutan test matrix keepEnv

Package command

@blueorangutan package [all(default),kvm,xen,vmware,hyperv,ovm]

Package examples

@blueorangutan package
@blueorangutan package kvm
@blueorangutan package kvm,vmware
@blueorangutan package all
@blueorangutan package none

Package notes

  • No argument defaults to bundling SystemVM templates when required by the PR branch.
  • all bundles KVM, XenServer and VMware SystemVM templates.
  • kvm bundles KVM SystemVM template(s).
  • none builds packages without SystemVM templates.

Blessed contributors for Trillian test jobs

DaanHoogland, Damans227, NuxRo, Pearl1594, RosiKyu, abh1sar, andrijapanicsb, borisstoyanov, harikrishna-patnala, kiranchavala, nvazquez, rajujith, rohityadavcloud, shwstppr, sudo87, sureshanaparti, vishesh92, vladimirpetrov, weizhouapache

@andrijapanicsb
Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@andrijapanicsb 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.

@andrijapanicsb
Copy link
Copy Markdown
Contributor Author

@blueorangutan package

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.

3 participants