Skip to content

kvm: dedicated live migration network with TLS, parallel streams and cluster CPU baseline - #14347

Open
rootnomad wants to merge 6 commits into
apache:mainfrom
rootnomad:pr/live-migration-enhancements
Open

rootnomad wants to merge 6 commits into
apache:mainfrom
rootnomad:pr/live-migration-enhancements

Conversation

@rootnomad

Copy link
Copy Markdown
Collaborator

Description

KVM live migration runs over the management network and in cleartext. This moves it onto a dedicated network, lets it be encrypted and parallelised, and adds a cluster CPU baseline so VMs stay migratable across mixed CPU generations.

The dedicated network is a new Migration traffic type on the zone's physical network, configured once with a per hypervisor label, exactly like the Storage traffic type. Each KVM host resolves its own IP on the labelled NIC and reports it to the management server, and the libvirt data stream is pinned to it only when both the source and destination host have one, otherwise migration behaves exactly as it does today, so it can be enabled one host at a time. CloudStack does not allocate the IPs: the operator gives the migration NIC its address the same way the management NIC gets one, and CloudStack reads it from the labelled interface. listHosts returns each host's migration IP, shown on the host detail view, so an operator can confirm the dedicated network is in use. Removing the Migration traffic type clears the recorded IPs so migration stops targeting a decommissioned network.

Native TLS encryption and multiple file descriptor parallel streams sit on top, both opt-in. TLS sets the libvirt TLS flag; parallel streams set a configurable connection count for high latency links. Both are gated on the host libvirt version and fail closed with a clear error when the host is too old, rather than silently downgrading to an unencrypted or single stream migration.

cluster.cpu.baseline.model (cluster scoped) pins every user VM in the cluster to a chosen custom CPU model, so the guest sees the same CPU on every host and keeps migrating across mixed generations. The model is validated against every host in the cluster when it is set; a host that cannot run it is reported back instead of the migration failing later. The baseline guest is pinned with match='exact', so a host that cannot provide the model's features refuses the VM rather than the guest quietly receiving a different CPU, and with fallback='forbid' so libvirt will not substitute a near match model. This is scoped to the baseline; a VM with its own explicit CPU mode or model is left untouched. Setting the baseline to 'auto' computes the common denominator model of the cluster's reachable hosts and persists it; it does not recompute as hosts change, so the committed baseline stays stable. The baseline is set from a Configure CPU baseline action on the cluster, with a model picker that includes auto.

No existing behaviour changes unless an operator configures a migration network, enables TLS or parallel streams, or sets a cluster baseline. No database schema change is required.

Types of changes

  • New feature (non-breaking change which adds functionality)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major

How Has This Been Tested?

Unit tests, all green:

NetworkServiceImplTest                          Tests run: 73
NetworkOrchestratorTest                         Tests run: 66
LibvirtComputingResourceTest                    Tests run: 324
VirtualMachineManagerImplMigrationIpTest        Tests run: 8
VirtualMachineManagerImplCpuCompatTest          Tests run: 6
VirtualMachineManagerImplCpuBaselineTest        Tests run: 5
MigrateKVMAsyncTest                             Tests run: 15
LibvirtMigrateCommandWrapperTest                Tests run: 39
LibvirtCheckNetworkCommandWrapperTest           Tests run: 2
LibvirtCheckCpuCompatibilityCommandWrapperTest  Tests run: 10
LibvirtBaselineCpuCommandWrapperTest            Tests run: 3
LibvirtGetHostCpuModelCommandWrapperTest        Tests run: 2

They cover the Migration label delivery to the host and the agent resolving it to a local IP, the host detail being recorded on connect and cleared when the traffic type is removed, the both ends gate on the migration IP (non KVM skipped, blank rejected, resolved only when both hosts have one), the libvirt flag and typed parameter construction for TLS and parallel streams including the version gate, the CPU baseline injection at VM start (user instances only), the forbid fallback emission and its scoping, the auto compute and model parsing, and the host compatibility check including the fail closed path on an unknown model.

Verified end to end on a two host KVM cluster. A Migration traffic type was added to the physical network with the dedicated NIC as its label; each host resolved its own IP on that NIC and listHosts showed it. Migrating a running VM then moved the guest RAM over the migration interface (about 54 MB of pages captured on that NIC during the migration), while the management interface carried no migration traffic. The CPU baseline was set to a custom model and the running VM's definition was hard pinned (custom, match=exact, fallback=forbid) and migrated across both hosts; 'auto' computed the common model of the two hosts and stored it; an unsupported model was rejected at config time with the list of hosts that could not run it.

A Marvin smoke test (test/integration/smoke/test_migration_network.py) exercises adding the Migration traffic type and the cluster CPU baseline setting.

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

  • Migration IP on only one of the two hosts: migration falls back to the management path (both ends gate), confirmed by unit test and on the cluster.
  • TLS and parallel streams enabled on a host whose libvirt is too old: migration fails closed with a clear error instead of downgrading.
  • A bogus and a well formed but unsupported baseline model: config is rejected, the value is not stored, and the unknown model path fails closed rather than passing an unchecked string to the hypervisor.
  • Removing the Migration traffic type after it was in use: the recorded host migration IPs are cleared so later migrations do not target the decommissioned network.
  • A transient failure recording the migration IP during host connect: it is logged and the host still connects, rather than the informational detail failing the connection.
migration-traffic-type-dropdown cpu-baseline-dialog migration-dropdown-cropped

@github-actions

Copy link
Copy Markdown

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

…cluster CPU baseline

Carry KVM live migration traffic on a dedicated network instead of the
management network. A Migration traffic type is added to the zone's physical
network with a per hypervisor label; each KVM host resolves its own IP on the
labelled NIC and reports it, and the libvirt data stream is routed to it only
when both the source and the destination host have one, otherwise migration
falls back to the existing behaviour unchanged. listHosts returns each host's
migration IP, shown on the host detail view, so an operator can confirm the
dedicated network is in use.

Migrations can be encrypted with libvirt native TLS and parallelised with
multiple file-descriptor streams. Both are opt-in and gated on the host
libvirt version, failing closed with a clear error when the host is too old
rather than silently downgrading.

Add a cluster-scoped CPU baseline model so a mixed cluster can present a
uniform guest CPU, keeping a VM's CPU definition stable as it migrates across
hosts. The baseline guest is pinned with fallback=forbid so it refuses a host
that cannot provide the exact model rather than silently degrading the CPU the
guest sees; the forbid is scoped to the baseline and leaves a VM with its own
explicit CPU mode or model untouched. The baseline is validated against every
host in the cluster before it is accepted, and hosts that cannot run the model
are reported back instead of failing the migration later.

Setting the baseline to "auto" computes the common-denominator model of the
cluster's reachable hosts, by collecting each host's CPU and running
cpu-baseline, and persists the computed model; it does not re-compute as hosts
change, so the committed baseline stays stable.

Unit tests cover the IP resolver (both-ends gating, non-KVM skip, blank
values), the libvirt flag and typed-parameter construction, the version gate,
the CPU baseline injection, the forbid fallback emission and scoping, the
auto-compute and model parsing, and the host compatibility check including the
fail-closed path on an unknown model. A Marvin smoke test exercises the
migration traffic type API.
@github-actions

Copy link
Copy Markdown

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

# Conflicts:
#	plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java
#	server/src/test/java/com/cloud/configuration/ConfigurationManagerImplTest.java
@rootnomad
rootnomad force-pushed the pr/live-migration-enhancements branch from 9fabba3 to 02020f6 Compare December 2, 2026 16:12
@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.93617% with 193 lines in your changes missing coverage. Please review.
✅ Project coverage is 21.20%. Comparing base (85ca17a) to head (02020f6).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
...resource/wrapper/LibvirtMigrateCommandWrapper.java 49.09% 48 Missing and 8 partials ⚠️
...n/java/com/cloud/vm/VirtualMachineManagerImpl.java 68.03% 22 Missing and 17 partials ⚠️
...n/java/com/cloud/resource/ResourceManagerImpl.java 0.00% 21 Missing ⚠️
.../wrapper/LibvirtGetHostCpuModelCommandWrapper.java 47.36% 8 Missing and 2 partials ⚠️
.../cloud/configuration/ConfigurationManagerImpl.java 52.38% 9 Missing and 1 partial ⚠️
...tack/engine/orchestration/NetworkOrchestrator.java 43.75% 9 Missing ⚠️
...urce/wrapper/LibvirtBaselineCpuCommandWrapper.java 66.66% 5 Missing and 3 partials ⚠️
...er/LibvirtCheckCpuCompatibilityCommandWrapper.java 73.33% 5 Missing and 3 partials ⚠️
...ain/java/com/cloud/network/NetworkServiceImpl.java 46.15% 6 Missing and 1 partial ⚠️
...g/apache/cloudstack/api/response/HostResponse.java 0.00% 6 Missing ⚠️
... and 11 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #14347      +/-   ##
============================================
+ Coverage     20.92%   21.20%   +0.28%     
- Complexity    21142    21662     +520     
============================================
  Files          6057     6087      +30     
  Lines        549556   552243    +2687     
  Branches      73477    74031     +554     
============================================
+ Hits         114991   117100    +2109     
- Misses       421116   421308     +192     
- Partials      13449    13835     +386     
Flag Coverage Δ
uitests 3.87% <ø> (+<0.01%) ⬆️
unittests 22.67% <58.93%> (+0.30%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

computeHostId is set exactly when the first host CPU definition is collected, so
checking it alone is equivalent to also checking that the list is empty.
Cover the migrate command carrying the dedicated migration IP and the encryption
policy, the preflight and resolve guards, VM start applying the cluster CPU
baseline, the baseline pin keeping other VM details, the CPU compatibility check
skipping down, non-KVM and unreachable hosts, the baseline computation failure
paths, and the host connect recording the migration IP.
Cover rejecting an unsafe or unsupported cluster CPU baseline model on update, the
non-blocking alert for newly added hosts that cannot run the baseline, adding,
deduplicating and removing the Migration traffic type, and the migration IP in the
host response and physical network info.
Cover the CPU precheck rejecting, allowing, skipping and failing open, the migrate
fail-fast on an incompatible destination, the data stream on the dedicated migration
IP with an unreadable job, a failed abort and a guest left paused, a running guest
left alone, source network teardown, the temp file and virsh failures of the CPU
wrappers, the requested CPU model fallback, and the libvirt version gates.
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

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

This branch has not been deployed

No deployments
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.

1 participant