Conversation
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
Open (10)
maskSensitiveInfoInXML(xmlDesc)is evaluated eagerly even when DEBUG is disabled, which can be… · NewmaskSensitiveInfoInXML(xmlDesc)is evaluated eagerly even when DEBUG is disabled, which can be… · NewmaskSensitiveInfoInXML(xmlDesc)is evaluated eagerly even when DEBUG is disabled, which can be… · NewmaskSensitiveInfoInXML(xmlDesc)is evaluated eagerly even when DEBUG is disabled, which can be… · New These exception logs only includee.getMessage()and drop the stack trace, which makes… · New These exception logs only includee.getMessage()and drop the stack trace, which makes… · New These exception logs only includee.getMessage()and drop the stack trace, which makes… · New There are a couple of formatting issues that reduce readability/consistency in logs: (1) line 161… · NewString.valueOf(migrateDowntime)is unnecessary for parameterized logging (it will be converted… · New There are a couple of formatting issues that reduce readability/consistency in logs: (1) line 161… · New
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()); |


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
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
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.