Skip to content

Allow preserving duplicate MACs during VM import - #13128

Open
andrijapanicsb wants to merge 3 commits into
apache:mainfrom
andrijapanicsb:allow-duplicate-mac-import
Open

andrijapanicsb wants to merge 3 commits into
apache:mainfrom
andrijapanicsb:allow-duplicate-mac-import

Conversation

@andrijapanicsb

@andrijapanicsb andrijapanicsb commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Description

This change adds an explicit import option to preserve duplicate NIC MAC addresses during VM import workflows.

The existing forced option continues to mean: if the imported VM has a NIC MAC address that already exists on the selected CloudStack network, continue the import by generating a new MAC address.

A new allowduplicatemacaddresses API parameter allows the opposite behavior: preserve the imported VM's MAC address even if that same MAC is already present on the selected network. The two options are mutually exclusive.

This is useful for migration cutover workflows where a VMware-sourced VM is imported to KVM while the original VM still exists in CloudStack, but the operator wants the imported instance to keep the same MAC address for guest/network continuity.

The UI import form now labels forced as "Generate new MAC if required" and exposes a separate "Allow duplicate MAC addresses" switch.
These MAC conflicting) options are shown for VM migration/import flows where an existing source VM has NICs to preserve.
They are hidden when creating a brand-new VM from existing QCOW2 files on local/shared storage, because that path creates a new CloudStack NIC instead of importing a source NIC from another VM.

In other words, the MAC options are available when CloudStack has to decide what to do with a MAC address from a source VM: either keep it, generate a replacement, or fail on conflict. They are not shown for QCOW2 disk import, where there is no source VM NIC to preserve.

Types of changes

  • New feature
  • UI change
  • API change

Testing

  • mvn -pl api -am -DskipTests install
  • mvn -pl server -am -DskipTests compile
  • npm run lint -- --no-fix src/views/tools/ImportUnmanagedInstance.vue
  • Parsed ui/public/locales/en.json
  • git diff --check




Allow-dupicate-MAC-due-Import-compressed-under-100MB.mp4

@codecov

codecov Bot commented May 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.88889% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.92%. Comparing base (7ed0cec) to head (0229aa5).

Files with missing lines Patch % Lines
.../apache/cloudstack/vm/UnmanagedVMsManagerImpl.java 75.86% 3 Missing and 4 partials ⚠️
...i/command/admin/vm/ImportUnmanagedInstanceCmd.java 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main   #13128   +/-   ##
=========================================
  Coverage     19.91%   19.92%           
- Complexity    20198    20205    +7     
=========================================
  Files          6373     6374    +1     
  Lines        577230   577281   +51     
  Branches      70696    70702    +6     
=========================================
+ Hits         114936   114998   +62     
+ Misses       449736   449720   -16     
- Partials      12558    12563    +5     
Flag Coverage Δ
uitests 3.73% <ø> (+0.02%) ⬆️
unittests 21.19% <63.88%> (+<0.01%) ⬆️

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.

@andrijapanicsb
andrijapanicsb force-pushed the allow-duplicate-mac-import branch from 4621d57 to e35e8d7 Compare May 7, 2026 19:34
@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
andrijapanicsb force-pushed the allow-duplicate-mac-import branch from e35e8d7 to 8f46ffb Compare May 7, 2026 22:22
@andrijapanicsb

Copy link
Copy Markdown
Contributor Author

@blueorangutan help

@blueorangutan

Copy link
Copy Markdown

@andrijapanicsb [SL] I understand these words: "help", "hello", "thanks", "package", "test"
Test command usage: test [mgmt os] [hypervisor] [keepEnv] [qemuEv] [basicZone|securityGroups]
Mgmt OS options: ['suse15', 'alma10', 'ol10', 'rocky10', 'alma9', 'centos7', 'centos6', 'rocky9', 'alma8', 'ubuntu18', 'ol9', 'ol8', 'ubuntu22', 'debian12', 'ubuntu20', 'rocky8', 'ubuntu24']
Hypervisor options: ['kvm-centos6', 'kvm-centos7', 'kvm-rocky8', 'kvm-rocky9', 'kvm-rocky10', 'kvm-ol8', 'kvm-ol9', 'kvm-ol10', 'kvm-alma8', 'kvm-alma9', 'kvm-alma10', 'kvm-ubuntu18', 'kvm-ubuntu20', 'kvm-ubuntu22', 'kvm-ubuntu24', 'kvm-debian12', 'kvm-suse15', 'vmware-55u3', 'vmware-60u2', 'vmware-65u2', 'vmware-67u3', 'vmware-70u1', 'vmware-70u2', 'vmware-70u3', 'vmware-80', 'vmware-80u1', 'vmware-80u2', 'vmware-80u3', 'vmware-80u3e', 'xenserver-65sp1', 'xenserver-71', 'xenserver-74', 'xenserver-84', 'xcpng74', 'xcpng76', 'xcpng80', 'xcpng81', 'xcpng82', 'xcpng83']
Note: when keepEnv is passed, you need to specify mgmt server os and hypervisor or use the matrix command.
when qemuEv is passed, it will deploy KVM hyperviosr hosts with qemu-kvm-ev, else it will default to stock qemu.
When basicZone and/or securityGroups are passed it will create a zone of the last type specified (default is Advanced)
Package command usage: package [all(default value),kvm,xen,vmware,hyperv,ovm] - a comma separated list can be passed with package command to bundle the required hypervisor's systemVM templates. Not passing any argument will bundle all - kvm,xen and vmware templates.

Blessed contributors for kicking Trillian test jobs: ['rohityadavcloud', 'shwstppr', 'Damans227', 'vishesh92', 'Pearl1594', 'harikrishna-patnala', 'nvazquez', 'DaanHoogland', 'weizhouapache', 'borisstoyanov', 'vladimirpetrov', 'kiranchavala', 'andrijapanicsb', 'NuxRo', 'rajujith', 'alexandremattioli', 'sureshanaparti', 'abh1sar', 'sudo87', 'RosiKyu']

@andrijapanicsb
andrijapanicsb force-pushed the allow-duplicate-mac-import branch from 8f46ffb to b53c760 Compare May 7, 2026 22:24
@blueorangutan

Copy link
Copy Markdown

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

@andrijapanicsb

Copy link
Copy Markdown
Contributor Author

@blueorangutan package kvm

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

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

@apache apache deleted a comment from blueorangutan May 14, 2026
@apache apache deleted a comment from blueorangutan May 14, 2026
@andrijapanicsb

Copy link
Copy Markdown
Contributor Author

@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 17850

@apache apache deleted a comment from blueorangutan May 14, 2026
@apache apache deleted a comment from blueorangutan May 14, 2026
@andrijapanicsb

Copy link
Copy Markdown
Contributor Author

@blueorangutan package kvm,vmware

@blueorangutan

Copy link
Copy Markdown

@andrijapanicsb a [SL] Jenkins job has been kicked to build packages. It will be bundled with kvm,vmware 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 17876

@andrijapanicsb

Copy link
Copy Markdown
Contributor Author

@blueorangutan test

@apache apache deleted a comment from blueorangutan May 25, 2026
@apache apache deleted a comment from blueorangutan May 25, 2026
@blueorangutan

Copy link
Copy Markdown

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

@andrijapanicsb andrijapanicsb added this to the 4.23.0 milestone May 26, 2026

@DaanHoogland DaanHoogland left a comment

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.

clgtm

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-16172)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 50459 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr13128-t16172-kvm-ol8.zip
Smoke tests completed. 151 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

Copilot AI left a comment

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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

@weizhouapache

Copy link
Copy Markdown
Member

@andrijapanicsb @prashanthr2
this PR is highly related to #13414
could you discuss how to proceed ?

@weizhouapache weizhouapache modified the milestones: 4.23.0, 4.24.0 Jul 7, 2026
@weizhouapache

Copy link
Copy Markdown
Member

moving to 4.24.0 milestone

@DaanHoogland DaanHoogland moved this from Backlog to conflict/waiting for author in CloudStack Testing Aug 31, 2026
andrijapanicsb and others added 2 commits October 6, 2026 05:26
Remote KVM imports always generated a replacement MAC on conflict because the import path hardcoded forced=true and duplicate preservation=false.

Preserve the historical replacement default when forced is omitted, while honoring explicit forced=false and allowduplicatemacaddresses=true. Reject incompatible options before import side effects and forward the resolved policy to NIC allocation.

Update the UI to show the remote KVM default, preserve mutual exclusion, and submit forced=false explicitly. Add backend, allocator, and UI coverage for the supported conflict policies.
Declare the checked exceptions raised by importNic Mockito verifications and cover remote KVM duplicate-MAC forwarding when forced is omitted.

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

Status: conflict/waiting

Development

Successfully merging this pull request may close these issues.

5 participants