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

dahn 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 4d76054377f Fix volume snapshot in VM with attached ISO (#7037)
4d76054377f is described below

commit 4d76054377f4e2fd05787ba2ef1c2c0092fb25ba
Author: Stephan Krug <[email protected]>
AuthorDate: Wed Jan 4 05:24:34 2023 -0300

    Fix volume snapshot in VM with attached ISO (#7037)
    
    Co-authored-by: Stephan Krug <[email protected]>
---
 .../kvm/resource/LibvirtDomainXMLParser.java       |  2 +-
 .../hypervisor/kvm/resource/LibvirtVMDef.java      | 28 ++++++++++++++++------
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git 
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
 
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
index d28ace6d576..cb650e24b2f 100644
--- 
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
+++ 
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
@@ -121,7 +121,7 @@ public class LibvirtDomainXMLParser {
                             }
                             def.defFileBasedDisk(diskFile, diskLabel, 
DiskDef.DiskBus.valueOf(bus.toUpperCase()), fmt);
                         } else if (device.equalsIgnoreCase("cdrom")) {
-                            def.defISODisk(diskFile , i+1);
+                            def.defISODisk(diskFile, i+1, diskLabel);
                         }
                     } else if (type.equalsIgnoreCase("block")) {
                         def.defBlockBasedDisk(diskDev, diskLabel,
diff --git 
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
 
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
index e8af21cc681..17767506445 100644
--- 
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
+++ 
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
@@ -860,17 +860,31 @@ public class LibvirtVMDef {
         }
 
         public void defISODisk(String volPath, Integer devId) {
-            if (devId == null) {
+            defISODisk(volPath, devId, null);
+        }
+
+        public void defISODisk(String volPath, Integer devId, String 
diskLabel) {
+            if (devId == null && StringUtils.isBlank(diskLabel)) {
+                s_logger.debug(String.format("No ID or label informed for 
volume [%s].", volPath));
                 defISODisk(volPath);
+                return;
+            }
+
+            _diskType = DiskType.FILE;
+            _deviceType = DeviceType.CDROM;
+            _sourcePath = volPath;
+
+            if (StringUtils.isNotBlank(diskLabel)) {
+                s_logger.debug(String.format("Using informed label [%s] for 
volume [%s].", diskLabel, volPath));
+                _diskLabel = diskLabel;
             } else {
-                _diskType = DiskType.FILE;
-                _deviceType = DeviceType.CDROM;
-                _sourcePath = volPath;
                 _diskLabel = getDevLabel(devId, DiskBus.IDE, true);
-                _diskFmtType = DiskFmtType.RAW;
-                _diskCacheMode = DiskCacheMode.NONE;
-                _bus = DiskBus.IDE;
+                s_logger.debug(String.format("Using device ID [%s] to define 
the label [%s] for volume [%s].", devId, _diskLabel, volPath));
             }
+
+            _diskFmtType = DiskFmtType.RAW;
+            _diskCacheMode = DiskCacheMode.NONE;
+            _bus = DiskBus.IDE;
         }
 
         public void defISODisk(String volPath, Integer devId,boolean isSecure) 
{

Reply via email to