From 3b65a5928b7c50ab5eef5789371df0acdb7a3463 Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Fri, 10 Oct 2014 00:57:21 +0200 Subject: [PATCH] kvm: Add better logging when fetching a volume from libvirt Clearly show if a volume is found and if not, that the pool is being refreshed and the fetch is tried again. Due to my commit b53a9dcc9f3ee95d40761b9c2c860f821595a661 the chance of a volume not being found is slightly bigger, but the performance gain is enormous on larger deployments. This is why we clearly have to log that we are refreshing the pool information when a volume is not found. It could be that a volume is created on host A and a few seconds later host B tries to access the volume. In that case host B's libvirt doesn't know about the volume yet and has to refresh the pool before it does. (cherry picked from commit 4ee82f1f40f6a384619323698d3f59e3cdda3c9c) --- .../kvm/storage/LibvirtStorageAdaptor.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java index 26237ba69b2..ea3e1d6016d 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java @@ -94,21 +94,30 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { try { vol = pool.storageVolLookupByName(volName); } catch (LibvirtException e) { - s_logger.debug("Can't find volume: " + e.toString()); + s_logger.debug("Could not find volume " + volName + ": " + e.getMessage()); } + + /** + * The volume was not found in the storage pool + * This can happen when a volume has just been created on a different host and + * since then the libvirt storage pool has not been refreshed. + */ if (vol == null) { try { + s_logger.debug("Refreshing storage pool " + pool.getName()); refreshPool(pool); } catch (LibvirtException e) { - s_logger.debug("failed to refresh pool: " + e.toString()); + s_logger.debug("Failed to refresh storage pool: " + e.getMessage()); } try { vol = pool.storageVolLookupByName(volName); + s_logger.debug("Found volume " + volName + " in storage pool " + pool.getName() + " after refreshing the pool"); } catch (LibvirtException e) { - throw new CloudRuntimeException(e.toString()); + throw new CloudRuntimeException("Could not find volume " + volName + ": " + e.getMessage()); } } + return vol; }