rhtyd closed pull request #2696: Fix LibvirtStorageAdaptor.java
URL: https://github.com/apache/cloudstack/pull/2696
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 64d2a0421b0..24cf0312046 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
@@ -147,44 +147,24 @@ private StoragePool createNetfsStoragePool(PoolType 
fsType, Connect conn, String
         StoragePool sp = null;
         try {
             s_logger.debug(spd.toString());
-            sp = conn.storagePoolCreateXML(spd.toString(), 0);
-            return sp;
-        } catch (LibvirtException e) {
-            s_logger.error(e.toString());
-            // if error is that pool is mounted, try to handle it
-            if (e.toString().contains("already mounted")) {
-                s_logger.error("Attempting to unmount old mount libvirt is 
unaware of at " + targetPath);
+            // check whether the pool is already mounted
+            int mountpointResult = 
Script.runSimpleBashScriptForExitValue("mountpoint -q " + targetPath);
+            // if the pool is mounted, try to unmount it
+            if(mountpointResult == 0) {
+                s_logger.info("Attempting to unmount old mount at " + 
targetPath);
                 String result = Script.runSimpleBashScript("umount -l " + 
targetPath);
                 if (result == null) {
-                    s_logger.error("Succeeded in unmounting " + targetPath);
-                    try {
-                        sp = conn.storagePoolCreateXML(spd.toString(), 0);
-                        s_logger.error("Succeeded in redefining storage");
-                        return sp;
-                    } catch (LibvirtException l) {
-                        s_logger.error("Target was already mounted, unmounted 
it but failed to redefine storage:" + l);
-                    }
+                    s_logger.info("Succeeded in unmounting " + targetPath);
                 } else {
-                    s_logger.error("Failed in unmounting and redefining 
storage");
+                    s_logger.error("Failed in unmounting storage");
                 }
-            } else {
-                s_logger.error("Internal error occurred when attempting to 
mount: specified path may be invalid");
-                throw e;
             }
-            if (sp != null) {
-                try {
-                    if (sp.isPersistent() == 1) {
-                        sp.destroy();
-                        sp.undefine();
-                    } else {
-                        sp.destroy();
-                    }
-                    sp.free();
-                } catch (LibvirtException l) {
-                    s_logger.debug("Failed to undefine " + fsType.toString() + 
" storage pool with: " + l.toString());
-                }
-            }
-            return null;
+
+            sp = conn.storagePoolCreateXML(spd.toString(), 0);
+            return sp;
+        } catch (LibvirtException e) {
+            s_logger.error(e.toString());
+            throw e;
         }
     }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to