Skip to content

Identify Guest Agent connection error by the ordinal instead of message (KBOSS) - #13789

Open
GaOrtiga wants to merge 1 commit into
apache:mainfrom
scclouds:preventBackupErrorGuestAgentConnectionFail
Open

Identify Guest Agent connection error by the ordinal instead of message (KBOSS)#13789
GaOrtiga wants to merge 1 commit into
apache:mainfrom
scclouds:preventBackupErrorGuestAgentConnectionFail

Conversation

@GaOrtiga

@GaOrtiga GaOrtiga commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Description

When a backup fails because connection with the VM's guest agent failed, the VM remains consistent, therefore, there is no need to place it in the BackupError state. This validation, however is done by verifying the error message sent by Libvirt, which can be different on older versions. It also does not cover every case of Guest Agent connection failures, as Libvirt's code contains multiple places where this error is thrown, with different messages.

This PR changes this validation to use the errors # (ordinal) instead of the message, to avoid these issues.

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?

I disabled the Guest Agent on the VM and tried creating a backup, and verified that the backup failed but the VM was no placed in the BackupError state.

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.65%. Comparing base (4f11707) to head (4a4dd5d).

Files with missing lines Patch % Lines
...ervisor/kvm/resource/LibvirtComputingResource.java 50.00% 1 Missing ⚠️
.../wrapper/LibvirtValidateKbossVmCommandWrapper.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #13789      +/-   ##
============================================
- Coverage     19.65%   19.65%   -0.01%     
+ Complexity    19792    19791       -1     
============================================
  Files          6368     6368              
  Lines        574881   574882       +1     
  Branches      70351    70351              
============================================
- Hits         112970   112969       -1     
- Misses       449639   449641       +2     
  Partials      12272    12272              
Flag Coverage Δ
uitests 3.41% <ø> (ø)
unittests 20.92% <33.33%> (-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.

@DaanHoogland
DaanHoogland requested a lite review from Copilot August 5, 2026 07:28

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.

Pull request overview

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.

Updates Guest Agent connection-failure detection during KBOSS VM validation/backup so the VM isn’t incorrectly marked BackupError when the guest agent is unreachable, by matching on libvirt error identity rather than message text.

Changes:

  • Replace libvirt exception message matching with an error “ordinal” comparison in KBOSS VM validation.
  • Replace snapshot/backup consistency detection message matching with the same ordinal-based check.
  • Introduce a constant for the guest-agent-unresponsive error ordinal.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtValidateKbossVmCommandWrapper.java Switches Guest Agent failure detection from message matching to ordinal-based comparison.
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java Adds ordinal constant and uses it to mark VM consistent on guest-agent connection failures during snapshot creation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
} catch (LibvirtException ex) {
if (!ex.getMessage().contains(LibvirtComputingResource.AGENT_IS_NOT_CONNECTED)) {
if (!LibvirtComputingResource.AGENT_UNRESPONSIVE_ERROR_ORDINAL.equals(ex.getError().getCode().ordinal())) {
public static final String CGROUP_V2 = "cgroup2fs";

public static final String AGENT_IS_NOT_CONNECTED = "QEMU guest agent is not connected";
public static final Integer AGENT_UNRESPONSIVE_ERROR_ORDINAL = 86;
String errorMsg = String.format("Creation of disk-only VM snapshot for VM [%s] failed due to %s.", vmName, e.getMessage());
boolean isVmConsistent = false;
if (e.getMessage().contains(AGENT_IS_NOT_CONNECTED)) {
if (AGENT_UNRESPONSIVE_ERROR_ORDINAL.equals(e.getError().getCode().ordinal())) {
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.

3 participants