This is an automated email from the ASF dual-hosted git repository.

RosiKyu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/main by this push:
     new 53a6c0c0529 Identify Guest Agent connection error by the code enum 
instead of message (KBOSS) (#13789)
53a6c0c0529 is described below

commit 53a6c0c052977a36206c9f95c1e745d65256036a
Author: GaOrtiga <[email protected]>
AuthorDate: Thu Nov 12 17:26:48 2026 -0300

    Identify Guest Agent connection error by the code enum instead of message 
(KBOSS) (#13789)
    
    * prevent backup error when guest agent connection fails
    
    * address_copilot
---
 .../hypervisor/kvm/resource/LibvirtComputingResource.java      | 10 +++++++---
 .../resource/wrapper/LibvirtValidateKbossVmCommandWrapper.java |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git 
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
 
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index cbf8d9ee4da..3756567c98b 100644
--- 
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ 
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -144,6 +144,7 @@ import org.libvirt.DomainInfo;
 import org.libvirt.DomainInfo.DomainState;
 import org.libvirt.DomainInterfaceStats;
 import org.libvirt.DomainSnapshot;
+import org.libvirt.Error;
 import org.libvirt.LibvirtException;
 import org.libvirt.MemoryStatistic;
 import org.libvirt.Network;
@@ -647,8 +648,7 @@ public class LibvirtComputingResource extends 
ServerResourceBase implements Serv
 
     public static final String CGROUP_V2 = "cgroup2fs";
 
-    public static final String AGENT_IS_NOT_CONNECTED = "QEMU guest agent is 
not connected";
-
+    public static final org.libvirt.Error.ErrorNumber AGENT_UNRESPONSIVE_ERROR 
= Error.ErrorNumber.VIR_ERR_AGENT_UNRESPONSIVE;
     /**
      * Virsh command to merge (blockcommit) snapshot into the base 
file.<br><br>
      * 1st parameter: VM's name;<br>
@@ -7540,7 +7540,7 @@ public class LibvirtComputingResource extends 
ServerResourceBase implements Serv
         } catch (LibvirtException e) {
             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 (isGuestAgentUnresponsive(e)) {
                 errorMsg = "QEMU guest agent is not connected. If the VM has 
been recently started, it might connect soon. Otherwise the VM does not have 
the" +
                         " guest agent installed; thus the QuiesceVM parameter 
is not supported.";
                 isVmConsistent = true;
@@ -7558,6 +7558,10 @@ public class LibvirtComputingResource extends 
ServerResourceBase implements Serv
         }
     }
 
+    public static boolean isGuestAgentUnresponsive(LibvirtException e) {
+        return AGENT_UNRESPONSIVE_ERROR.equals(e.getError().getCode());
+    }
+
     public Map<String, Long> 
createDiskOnlyVMSnapshotOfStoppedVm(List<Pair<VolumeObjectTO, String>> 
volumeTosAndNewPaths, String vmName) {
         logger.info("Creating volume deltas for stopped VM [{}].", vmName);
 
diff --git 
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtValidateKbossVmCommandWrapper.java
 
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtValidateKbossVmCommandWrapper.java
index eec68cd464e..f27e2b9ae4b 100644
--- 
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtValidateKbossVmCommandWrapper.java
+++ 
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtValidateKbossVmCommandWrapper.java
@@ -92,7 +92,7 @@ public class LibvirtValidateKbossVmCommandWrapper extends 
CommandWrapper<Validat
                     return true;
                 }
             } catch (LibvirtException ex) {
-                if 
(!ex.getMessage().contains(LibvirtComputingResource.AGENT_IS_NOT_CONNECTED)) {
+                if (!LibvirtComputingResource.isGuestAgentUnresponsive(ex)) {
                     logger.error("Got an unexpected Libvirt Exception, giving 
up on validating VM [{}].", vm.getName(), ex);
                     throw ex;
                 }

Reply via email to