Skip to content

Kvm vm migration log refactor - #14224

Open
erikbocks wants to merge 2 commits into
apache:mainfrom
scclouds:kvm-vm-migration-log-refactor
Open

erikbocks wants to merge 2 commits into
apache:mainfrom
scclouds:kvm-vm-migration-log-refactor

Conversation

@erikbocks

Copy link
Copy Markdown
Collaborator

Description

This PR focuses on improving the consistency and clarity of logging of the KVM VM migration process. The changes aim to improve the traceability of the process, by adding more context for the logs, helping future troubleshooting processes. It also standardizes log messages to use parametrized logging, instead of string concatenation.

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):

How Has This Been Tested?

The code was compiled with Maven and installed to my local environment. Then, I migrated a VM from one of my hosts to another and verified that the new logs were displayed correctly.

@codecov

codecov Bot commented Sep 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 16.66667% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.91%. Comparing base (602d9ec) to head (d49e548).

Files with missing lines Patch % Lines
...resource/wrapper/LibvirtMigrateCommandWrapper.java 18.18% 18 Missing ⚠️
...n/java/com/cloud/vm/VirtualMachineManagerImpl.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #14224      +/-   ##
============================================
- Coverage     19.91%   19.91%   -0.01%     
+ Complexity    20200    20196       -4     
============================================
  Files          6373     6373              
  Lines        577230   577220      -10     
  Branches      70696    70687       -9     
============================================
- Hits         114974   114945      -29     
- Misses       449690   449716      +26     
+ Partials      12566    12559       -7     
Flag Coverage Δ
uitests 3.71% <ø> (ø)
unittests 21.18% <16.66%> (-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.

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 7 Medium severity · 3 Low severity

Open (10)
What changed in this PR

Refactors KVM VM migration logging to be more consistent and contextual, primarily by switching to parameterized logging and standardizing messages for troubleshooting.

Changes:

  • Replaced String.format/string concatenation with parameterized logging across KVM migration flow.
  • Expanded log context (destination host, XML retrieval flag, job stats) for better traceability.
  • Tweaked log levels/messages around migration timeouts and exception handling.
File Description
plugins/​hypervisors/​kvm/​src/​main/​java/​com/​cloud/​hypervisor/​kvm/​resource/​wrapper/​LibvirtMigrateCommandWrapper.java Standardizes and enriches migration logs; adjusts log levels and message structure.
engine/​orchestration/​src/​main/​java/​com/​cloud/​vm/​VirtualMachineManagerImpl.java Fixes/standardizes config-drive detach logging and improves message quality.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

if (logger.isDebugEnabled()) {
logger.debug("VM {} with XML configuration {} will be migrated to host {}.", vmName, maskSensitiveInfoInXML(xmlDesc), target);
}
logger.debug("VM {} will be migrated to host {} with the following XML configuration retrieved with flag [{}]: {} .", vmName, target, xmlFlag, maskSensitiveInfoInXML(xmlDesc));
if (logger.isDebugEnabled()) {
logger.debug("Replaced disk mount point {} with {} in Instance {} XML configuration. New XML configuration is {}.", oldIsoVolumePath, newIsoVolumePath, vmName, maskSensitiveInfoInXML(xmlDesc));
}
logger.debug("Replaced disk mount point {} with {} in Instance {} XML configuration. New XML configuration is {}.", oldIsoVolumePath, newIsoVolumePath, vmName, maskSensitiveInfoInXML(xmlDesc));
if (logger.isDebugEnabled()) {
logger.debug("Changed VM {} XML configuration of used storage. New XML configuration is {}.", vmName, maskSensitiveInfoInXML(xmlDesc));
}
logger.debug("Changed VM {} XML configuration of used storage. New XML configuration is {}.", vmName, maskSensitiveInfoInXML(xmlDesc));
if (logger.isDebugEnabled()) {
logger.debug("Changed VM {} XML configuration of DPDK interfaces. New XML configuration is {}.", vmName, maskSensitiveInfoInXML(xmlDesc));
}
logger.debug("Changed VM {} XML configuration of DPDK interfaces. New XML configuration is {}.", vmName, maskSensitiveInfoInXML(xmlDesc));
}
} catch (final LibvirtException e) {
logger.debug("Failed to set max downtime for migration, perhaps migration completed? Error: " + e.getMessage());
logger.warn("Failed to set max downtime for migration. It might happen if the migration has already completed. Error: {}", e.getMessage());
logger.info("VM domain state when trying to abort migration : {}", state);
} catch (final LibvirtException e) {
logger.info("Couldn't get VM domain state after " + sleeptime + "ms: " + e.getMessage());
logger.warn("Could not get VM domain state after {}ms: {}", sleeptime, e.getMessage());
} catch (final LibvirtException e) {
// pause could be racy if it attempts to pause right when vm is finished, simply warn
logger.info("Failed to pause vm " + vmName + " : " + e.getMessage());
logger.warn("Failed to pause vm {} : {}", vmName, e.getMessage());
if (logger.isDebugEnabled()) {
logger.debug("VM {} with XML configuration {} will be migrated to host {}.", vmName, maskSensitiveInfoInXML(xmlDesc), target);
}
logger.debug("VM {} will be migrated to host {} with the following XML configuration retrieved with flag [{}]: {} .", vmName, target, xmlFlag, maskSensitiveInfoInXML(xmlDesc));
if (setDowntime == 0 ) {
isMigrateDowntimeSet = true;
logger.debug("Set max downtime for migration of " + vmName + " to " + String.valueOf(migrateDowntime) + "ms");
logger.debug("Set max downtime for migration of {} to {}ms", vmName, String.valueOf(migrateDowntime));
logger.info("VM domain state when trying to pause VM for migration: {}", state);
} catch (final LibvirtException e) {
logger.info("Couldn't get VM domain state after " + sleeptime + "ms: " + e.getMessage());
logger.info("Could not get VM domain state after {}ms: {}",sleeptime, e.getMessage());

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.

2 participants