From 51d050d39faee17098b08d41381fe5a3784d7912 Mon Sep 17 00:00:00 2001 From: Rene Peinthor Date: Tue, 19 Mar 2024 15:47:42 +0100 Subject: [PATCH] linstor: Only set allow-two-primaries if resource is already in use For live migrate we need the allow-two-primaries option, but we don't know exactly if we are called for a migration operation. Now also check if at least any of the resources is in use somewhere and only then set the option. --- .../kvm/storage/LinstorStorageAdaptor.java | 20 ++++++++++--------- .../storage/datastore/util/LinstorUtil.java | 14 +++++++++++++ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java b/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java index 87746447188d..ca49f5f4da16 100644 --- a/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java +++ b/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java @@ -285,15 +285,17 @@ public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map rscs = api.resourceList(rscName, null, null); + return rscs.stream().anyMatch(rsc -> rsc.getState() != null ? rsc.getState().isInUse() : false); + } }