JoaoJandre commented on code in PR #13286:
URL: https://github.com/apache/cloudstack/pull/13286#discussion_r3397949741


##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java:
##########
@@ -507,6 +507,12 @@ public LibvirtStoragePoolDef getStoragePoolDef(Connect 
conn, StoragePool pool) t
         return parser.parseStoragePoolXML(poolDefXML);
     }
 
+    public String getBackingFileOfVolumeIfExists(StorageVol vol) throws 
LibvirtException {

Review Comment:
   This method could be private



##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java:
##########
@@ -657,6 +663,16 @@ public KVMStoragePool getStoragePool(String uuid, boolean 
refreshInfo) {
         }
     }
 
+    public Long getBackingFileSizes(StoragePool pool, StorageVol vol) throws 
LibvirtException {

Review Comment:
   This method could be private



##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtStorageVolumeXMLParser.java:
##########
@@ -35,6 +35,35 @@
 public class LibvirtStorageVolumeXMLParser {
     protected Logger logger = LogManager.getLogger(getClass());
 
+    public String getBackingFileNameIfExists(String volXML) {
+        try {
+            DocumentBuilder builder = 
ParserUtils.getSaferDocumentBuilderFactory().newDocumentBuilder();
+
+            InputSource is = new InputSource();
+            is.setCharacterStream(new StringReader(volXML));
+            Document doc = builder.parse(is);
+
+            Element rootElement = doc.getDocumentElement();
+            NodeList backingStores = 
rootElement.getElementsByTagName("backingStore");
+            if (backingStores.getLength() > 0) {
+                Element backingStore = (Element) backingStores.item(0);
+                NodeList pathNodes = backingStore.getElementsByTagName("path");
+                if (pathNodes.getLength() > 0) {
+                    String path = pathNodes.item(0).getTextContent();
+                    if (path == null || path.trim().isEmpty()) {

Review Comment:
   We could use StringUtils.isEmpty here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to