Skip to content

KVM: remove dead command wrappers, unused classes and unused storage scripts - #14236

Open
wido wants to merge 3 commits into
apache:mainfrom
wido:kvm-remove-dead-command-wrappers
Open

wido wants to merge 3 commits into
apache:mainfrom
wido:kvm-remove-dead-command-wrappers

Conversation

@wido

@wido wido commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Description

This PR removes code from the KVM agent plugin that nothing calls any more. It is the first of three cleanup PRs; the other two build on this one or are independent of it.

Command wrappers for commands the management server no longer sends (13 wrappers plus the shared console proxy base class). These belong to the pre-4.2 storage model. Nothing in the management server creates or subclasses these commands, so the wrappers could never be reached:

AttachIsoCommand, BackupSnapshotCommand, CheckConsoleProxyLoadCommand, WatchConsoleProxyLoadCommand, CheckStorageAvailabilityCommand, CreateCommand, CreatePrivateTemplateFromSnapshotCommand, CreatePrivateTemplateFromVolumeCommand, CreateVolumeFromSnapshotCommand, ManageSnapshotCommand, PrimaryStorageDownloadCommand, RebootRouterCommand, UpgradeSnapshotCommand.

With them go the things only they used: the createtmplt.sh and createvm.sh lookups in LibvirtComputingResource (the storage processor has its own createtmplt.sh lookup, createvm.sh was located at startup but never executed), three helpers in LibvirtUtilitiesHelper, a handful of fields that were declared but never read, and the 27 unit tests that exercised the wrappers. The Command classes themselves stay in core in this PR because XenServer, VMware and the simulator still reference them; that is handled in a follow-up PR.

Unused scripts in scripts/storage/qcow2 (12 files). Nine have no callers anywhere in the tree. Three (createvolume.sh, listvmtmplt.sh, listvolume.sh) are stale copies of scripts in scripts/storage/secondary; the secondary storage code resolves them from that directory only. createtmplt.sh, managesnapshot.sh and resizevolume.sh remain, the agent still uses them.

Classes with no references anywhere (7 files):

  • IvsVifDriver: VIF driver for Big Switch IVS. It could only be activated by naming it in libvirt.vif.driver in agent.properties, and the Big Switch plugin never refers to it. Anyone still pointing agent.properties at it will get a class-not-found at agent start, so this deserves a release note.
  • ManagedNfsStorageAdaptor: picked up by the storage adaptor reflection scan, but the management server never creates a pool of type ManagedNFS, so the adaptor was never selected. The enum value is removed in the follow-up PR.
  • LibvirtNetworkDef, KVMGuestOsMapper, KVMStorageResource, StorageAdaptorInfo, KVMVirtualDisk.

No functional behaviour changes for any supported configuration. Packaging needs no changes: both the RPM spec and the Debian rules copy the scripts directory wholesale.

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

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

Every removed class, method and script was checked for references across the whole tree (Java main and test sources, Spring XML, properties, Python and shell), including reflection-based loading (the storage adaptor scan, the libvirt.vif.driver property) and libvirt callback interfaces.

The KVM plugin compiles with JDK 17 and its unit tests pass (862 tests, 0 failures). A full-tree mvn -T 1C -Dsimulator test on the combined cleanup branches passes: 147 modules, 13,188 tests, 0 failures.

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

Searched for every removed symbol across all file types, not only Java, so that reflection strings, Spring bean definitions and script names would show up. Classes that are loaded by reflection but do have a real pool type behind them (FiberChannelAdapter) and libvirt callback methods (LibvirtDomainListener.onLifecycleChange) were identified as false positives and kept.

…nger sends

The KVM agent still registered wrappers for a set of commands that date
back to the pre-4.2 storage model. None of these commands is created or
subclassed anywhere in the management server any more, so the wrappers
could never be reached:

  AttachIsoCommand, BackupSnapshotCommand, CheckConsoleProxyLoadCommand,
  WatchConsoleProxyLoadCommand, CheckStorageAvailabilityCommand,
  CreateCommand, CreatePrivateTemplateFromSnapshotCommand,
  CreatePrivateTemplateFromVolumeCommand, CreateVolumeFromSnapshotCommand,
  ManageSnapshotCommand, PrimaryStorageDownloadCommand,
  RebootRouterCommand, UpgradeSnapshotCommand

Along with the wrappers and their shared console proxy base class, this
removes what only they used:

  - the createtmplt.sh and createvm.sh lookups in
    LibvirtComputingResource. The storage processor has its own
    createtmplt.sh lookup; createvm.sh was looked up at startup but never
    executed.
  - the buildTemplateLocation, buildQCOW2Processor and
    retrieveBashScriptPath helpers in LibvirtUtilitiesHelper and the
    BASH_SCRIPT_PATH constant.
  - fields that were declared but never read: heartBeatPath,
    hostOsVersion, javaTempDir, and an unused local in
    getMacAddressToNicNumPair.
  - the 27 unit tests that exercised the removed wrappers.

The Command classes themselves stay in core because the XenServer,
VMware and simulator resources still reference them.
Nothing in the tree references these scripts any more. Nine of them have
no callers at all:

  create_private_template.sh, createvm.sh, delvm.sh, get_domr_kernel.sh,
  get_iqn.sh, importmpl.sh, listvmdisk.sh, listvmdisksize.sh,
  managevolume.sh

createvm.sh was still located at agent startup until the previous
commit, but was never executed.

The other three are stale copies of scripts that live in
scripts/storage/secondary. The secondary storage code resolves them
from that directory only, so the qcow2 copies were never run:

  createvolume.sh, listvmtmplt.sh, listvolume.sh

createtmplt.sh, managesnapshot.sh and resizevolume.sh stay, the KVM
agent still uses them.
  - IvsVifDriver: VIF driver for Big Switch IVS. It could only be
    activated by naming it in libvirt.vif.driver in agent.properties,
    and the Big Switch plugin itself never refers to it.
  - ManagedNfsStorageAdaptor: picked up by the storage adaptor
    reflection scan, but the management server never creates a pool of
    type ManagedNFS, so the adaptor was never selected. The enum value
    is left in place.
  - LibvirtNetworkDef: builder for libvirt <network> XML, never used.
  - KVMGuestOsMapper, KVMStorageResource, StorageAdaptorInfo,
    KVMVirtualDisk: no references anywhere in the tree.
@codecov

codecov Bot commented Sep 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 3.71%. Comparing base (602d9ec) to head (cc2fd2d).

❗ There is a different number of reports uploaded between BASE (602d9ec) and HEAD (cc2fd2d). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (602d9ec) HEAD (cc2fd2d)
unittests 1 0
Additional details and impacted files
@@              Coverage Diff              @@
##               main   #14236       +/-   ##
=============================================
- Coverage     19.91%    3.71%   -16.21%     
=============================================
  Files          6373      487     -5886     
  Lines        577230    41992   -535238     
  Branches      70696     7942    -62754     
=============================================
- Hits         114974     1558   -113416     
+ Misses       449690    40208   -409482     
+ Partials      12566      226    -12340     
Flag Coverage Δ
uitests 3.71% <ø> (ø)
unittests ?

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.

@wido wido added this to the 24.0 milestone Sep 24, 2026

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