You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ha...@apache.org on 2025/08/28 04:57:36 UTC
(cloudstack) branch 4.20 updated: Fix live migration of VM with config drive on KVM (#11516)
This is an automated email from the ASF dual-hosted git repository.
harikrishna pushed a commit to branch 4.20
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.20 by this push:
new 0f0155c6530 Fix live migration of VM with config drive on KVM (#11516)
0f0155c6530 is described below
commit 0f0155c65306059f9b1f54aa6f86150b15c3aa98
Author: Suresh Kumar Anaparti <su...@gmail.com>
AuthorDate: Thu Aug 28 10:27:30 2025 +0530
Fix live migration of VM with config drive on KVM (#11516)
---
.../kvm/resource/LibvirtComputingResource.java | 7 +++----
.../resource/wrapper/LibvirtMigrateCommandWrapper.java | 2 +-
.../hypervisor/kvm/storage/KVMStoragePoolManager.java | 18 ++++++++++--------
.../hypervisor/kvm/storage/LibvirtStorageAdaptor.java | 7 +++----
4 files changed, 17 insertions(+), 17 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 5694c23a216..19c6e7145a6 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
@@ -3506,10 +3506,10 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
public synchronized String attachOrDetachISO(final Connect conn, final String vmName, String isoPath, final boolean isAttach, final Integer diskSeq) throws LibvirtException, URISyntaxException,
InternalErrorException {
final DiskDef iso = new DiskDef();
- if (isAttach && StringUtils.isNotBlank(isoPath) && isoPath.lastIndexOf("/") > 0) {
- if (isoPath.startsWith(getConfigPath() + "/" + ConfigDrive.CONFIGDRIVEDIR) && isoPath.contains(vmName)) {
+ if (isAttach && StringUtils.isNotBlank(isoPath)) {
+ if (isoPath.startsWith(getConfigPath() + "/" + ConfigDrive.CONFIGDRIVEDIR) || isoPath.contains(vmName)) {
iso.defISODisk(isoPath, diskSeq, DiskDef.DiskType.FILE);
- } else {
+ } else if (isoPath.lastIndexOf("/") > 0) {
final int index = isoPath.lastIndexOf("/");
final String path = isoPath.substring(0, index);
final String name = isoPath.substring(index + 1);
@@ -3533,7 +3533,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
cleanupDisk(disk);
}
}
-
}
return result;
}
diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
index e15a3287692..2d3b58a809e 100644
--- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
+++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
@@ -899,7 +899,7 @@ public final class LibvirtMigrateCommandWrapper extends CommandWrapper<MigrateCo
Node sourceNode = diskChildNode;
NamedNodeMap sourceNodeAttributes = sourceNode.getAttributes();
Node sourceNodeAttribute = sourceNodeAttributes.getNamedItem("file");
- if ( sourceNodeAttribute.getNodeValue().contains(vmName)) {
+ if (sourceNodeAttribute != null && sourceNodeAttribute.getNodeValue().contains(vmName)) {
diskNode.removeChild(diskChildNode);
Element newChildSourceNode = doc.createElement("source");
newChildSourceNode.setAttribute("file", isoPath);
diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java
index e27547acbb2..710662a3138 100644
--- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java
+++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java
@@ -325,17 +325,19 @@ public class KVMStoragePoolManager {
String uuid = null;
String sourceHost = "";
StoragePoolType protocol = null;
- final String scheme = (storageUri.getScheme() != null) ? storageUri.getScheme().toLowerCase() : "";
List<String> acceptedSchemes = List.of("nfs", "networkfilesystem", "filesystem");
- if (acceptedSchemes.contains(scheme)) {
- sourcePath = storageUri.getPath();
- sourcePath = sourcePath.replace("//", "/");
- sourceHost = storageUri.getHost();
- uuid = UUID.nameUUIDFromBytes(new String(sourceHost + sourcePath).getBytes()).toString();
- protocol = scheme.equals("filesystem") ? StoragePoolType.Filesystem: StoragePoolType.NetworkFilesystem;
+ if (storageUri.getScheme() == null || !acceptedSchemes.contains(storageUri.getScheme().toLowerCase())) {
+ throw new CloudRuntimeException("Empty or unsupported storage pool uri scheme");
}
- // secondary storage registers itself through here
+ final String scheme = storageUri.getScheme().toLowerCase();
+ sourcePath = storageUri.getPath();
+ sourcePath = sourcePath.replace("//", "/");
+ sourceHost = storageUri.getHost();
+ uuid = UUID.nameUUIDFromBytes(new String(sourceHost + sourcePath).getBytes()).toString();
+ protocol = scheme.equals("filesystem") ? StoragePoolType.Filesystem: StoragePoolType.NetworkFilesystem;
+
+ // storage registers itself through here
return createStoragePool(uuid, sourceHost, 0, sourcePath, "", protocol, null, false);
}
diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
index f3731459f89..8be5e9658fa 100644
--- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
+++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
@@ -733,10 +733,9 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
@Override
public KVMStoragePool createStoragePool(String name, String host, int port, String path, String userInfo, StoragePoolType type, Map<String, String> details, boolean isPrimaryStorage) {
- logger.info("Attempting to create storage pool " + name + " (" + type.toString() + ") in libvirt");
-
- StoragePool sp = null;
- Connect conn = null;
+ logger.info("Attempting to create storage pool {} ({}) in libvirt", name, type);
+ StoragePool sp;
+ Connect conn;
try {
conn = LibvirtConnection.getConnection();
} catch (LibvirtException e) {