You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by hu...@apache.org on 2014/07/28 16:00:00 UTC
[1/2] git commit: updated refs/heads/master to 47bb175
Repository: cloudstack
Updated Branches:
refs/heads/master 67876b215 -> 47bb175bd
Fix a coverity issue about unchecked returns and make the code flow a
litle bit more easy to follow.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/49f60ca7
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/49f60ca7
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/49f60ca7
Branch: refs/heads/master
Commit: 49f60ca744d91c43196633a579c08ff538f171b0
Parents: 67876b2
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Mon Jul 28 10:53:04 2014 +0200
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Mon Jul 28 14:42:42 2014 +0200
----------------------------------------------------------------------
.../cloud/storage/template/IsoProcessor.java | 2 +-
.../cloud/storage/template/OVAProcessor.java | 2 +-
.../com/cloud/storage/template/Processor.java | 3 +-
.../cloud/storage/template/QCOW2Processor.java | 50 ++++++--------------
.../storage/template/RawImageProcessor.java | 2 +-
.../cloud/storage/template/VhdProcessor.java | 20 +-------
.../cloud/storage/template/VmdkProcessor.java | 8 ++--
.../resource/NfsSecondaryStorageResource.java | 7 +--
8 files changed, 28 insertions(+), 66 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49f60ca7/core/src/com/cloud/storage/template/IsoProcessor.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/template/IsoProcessor.java b/core/src/com/cloud/storage/template/IsoProcessor.java
index f706430..4d0a331 100644
--- a/core/src/com/cloud/storage/template/IsoProcessor.java
+++ b/core/src/com/cloud/storage/template/IsoProcessor.java
@@ -61,7 +61,7 @@ public class IsoProcessor extends AdapterBase implements Processor {
}
@Override
- public Long getVirtualSize(File file) {
+ public long getVirtualSize(File file) {
return file.length();
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49f60ca7/core/src/com/cloud/storage/template/OVAProcessor.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/template/OVAProcessor.java b/core/src/com/cloud/storage/template/OVAProcessor.java
index d87ca18..78825ce 100644
--- a/core/src/com/cloud/storage/template/OVAProcessor.java
+++ b/core/src/com/cloud/storage/template/OVAProcessor.java
@@ -86,7 +86,7 @@ public class OVAProcessor extends AdapterBase implements Processor {
}
@Override
- public Long getVirtualSize(File file) {
+ public long getVirtualSize(File file) {
try {
long size = getTemplateVirtualSize(file.getParent(), file.getName());
return size;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49f60ca7/core/src/com/cloud/storage/template/Processor.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/template/Processor.java b/core/src/com/cloud/storage/template/Processor.java
index 7d6f6ce..ba57563 100644
--- a/core/src/com/cloud/storage/template/Processor.java
+++ b/core/src/com/cloud/storage/template/Processor.java
@@ -20,6 +20,7 @@
package com.cloud.storage.template;
import java.io.File;
+import java.io.IOException;
import com.cloud.exception.InternalErrorException;
import com.cloud.storage.Storage.ImageFormat;
@@ -51,6 +52,6 @@ public interface Processor extends Adapter {
public boolean isCorrupted;
}
- Long getVirtualSize(File file);
+ long getVirtualSize(File file) throws IOException;
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49f60ca7/core/src/com/cloud/storage/template/QCOW2Processor.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/template/QCOW2Processor.java b/core/src/com/cloud/storage/template/QCOW2Processor.java
index c387a9b..2c66415 100644
--- a/core/src/com/cloud/storage/template/QCOW2Processor.java
+++ b/core/src/com/cloud/storage/template/QCOW2Processor.java
@@ -37,7 +37,9 @@ import com.cloud.utils.component.AdapterBase;
@Local(value = Processor.class)
public class QCOW2Processor extends AdapterBase implements Processor {
private static final Logger s_logger = Logger.getLogger(QCOW2Processor.class);
- StorageLayer _storage;
+ private static final int VIRTUALSIZE_HEADER_LOCATION = 24;
+
+ private StorageLayer _storage;
@Override
public FormatInfo process(String templatePath, ImageFormat format, String templateName) {
@@ -60,52 +62,30 @@ public class QCOW2Processor extends AdapterBase implements Processor {
File qcow2File = _storage.getFile(qcow2Path);
info.size = _storage.getSize(qcow2Path);
- FileInputStream strm = null;
- byte[] b = new byte[8];
+
try {
- strm = new FileInputStream(qcow2File);
- strm.skip(24);
- strm.read(b);
- } catch (Exception e) {
- s_logger.warn("Unable to read qcow2 file " + qcow2Path, e);
+ info.virtualSize = getVirtualSize(qcow2File);
+ } catch (IOException e) {
+ s_logger.error("Unable to get virtual size from " + qcow2File.getName());
return null;
- } finally {
- if (strm != null) {
- try {
- strm.close();
- } catch (IOException e) {
- }
- }
}
- long templateSize = NumbersUtil.bytesToLong(b);
- info.virtualSize = templateSize;
-
return info;
}
@Override
- public Long getVirtualSize(File file) {
- FileInputStream strm = null;
+ public long getVirtualSize(File file) throws IOException {
byte[] b = new byte[8];
- try {
- strm = new FileInputStream(file);
- strm.skip(24);
- strm.read(b);
- } catch (Exception e) {
- s_logger.warn("Unable to read qcow2 file " + file, e);
- return null;
- } finally {
- if (strm != null) {
- try {
- strm.close();
- } catch (IOException e) {
- }
+ try (FileInputStream strm = new FileInputStream(file)) {
+ if (strm.skip(VIRTUALSIZE_HEADER_LOCATION) != VIRTUALSIZE_HEADER_LOCATION) {
+ throw new IOException("Unable to skip to the virtual size header");
+ }
+ if (strm.read(b) != 8) {
+ throw new IOException("Unable to properly read the size");
}
}
- long templateSize = NumbersUtil.bytesToLong(b);
- return templateSize;
+ return NumbersUtil.bytesToLong(b);
}
@Override
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49f60ca7/core/src/com/cloud/storage/template/RawImageProcessor.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/template/RawImageProcessor.java b/core/src/com/cloud/storage/template/RawImageProcessor.java
index 030c405..820ef19 100644
--- a/core/src/com/cloud/storage/template/RawImageProcessor.java
+++ b/core/src/com/cloud/storage/template/RawImageProcessor.java
@@ -69,7 +69,7 @@ public class RawImageProcessor extends AdapterBase implements Processor {
}
@Override
- public Long getVirtualSize(File file) {
+ public long getVirtualSize(File file) {
return file.length();
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49f60ca7/core/src/com/cloud/storage/template/VhdProcessor.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/template/VhdProcessor.java b/core/src/com/cloud/storage/template/VhdProcessor.java
index ac0fa7e..aff2942 100644
--- a/core/src/com/cloud/storage/template/VhdProcessor.java
+++ b/core/src/com/cloud/storage/template/VhdProcessor.java
@@ -22,7 +22,6 @@ package com.cloud.storage.template;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import java.util.Arrays;
import java.util.Map;
import javax.ejb.Local;
@@ -105,7 +104,7 @@ public class VhdProcessor extends AdapterBase implements Processor {
}
@Override
- public Long getVirtualSize(File file) {
+ public long getVirtualSize(File file) {
FileInputStream strm = null;
byte[] currentSize = new byte[8];
byte[] creatorApp = new byte[4];
@@ -142,21 +141,4 @@ public class VhdProcessor extends AdapterBase implements Processor {
return true;
}
- private void imageSignatureCheck(byte[] creatorApp) throws InternalErrorException {
- boolean findKnownCreator = false;
- for (int i = 0; i < citrixCreatorApp.length; i++) {
- if (Arrays.equals(creatorApp, citrixCreatorApp[i])) {
- findKnownCreator = true;
- break;
- }
- }
- if (!findKnownCreator) {
- /*Only support VHD image created by citrix xenserver, and xenconverter*/
- String readableCreator = "";
- for (int j = 0; j < creatorApp.length; j++) {
- readableCreator += (char)creatorApp[j];
- }
- throw new InternalErrorException("Image creator is:" + readableCreator + ", is not supported");
- }
- }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49f60ca7/core/src/com/cloud/storage/template/VmdkProcessor.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/template/VmdkProcessor.java b/core/src/com/cloud/storage/template/VmdkProcessor.java
index ee4f819..6903b74 100644
--- a/core/src/com/cloud/storage/template/VmdkProcessor.java
+++ b/core/src/com/cloud/storage/template/VmdkProcessor.java
@@ -21,12 +21,12 @@ package com.cloud.storage.template;
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileReader;
import java.io.FileNotFoundException;
+import java.io.FileReader;
import java.io.IOException;
import java.util.Map;
-import java.util.regex.Pattern;
import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.ejb.Local;
import javax.naming.ConfigurationException;
@@ -72,7 +72,7 @@ public class VmdkProcessor extends AdapterBase implements Processor {
}
@Override
- public Long getVirtualSize(File file) {
+ public long getVirtualSize(File file) {
try {
long size = getTemplateVirtualSize(file.getParent(), file.getName());
return size;
@@ -86,8 +86,6 @@ public class VmdkProcessor extends AdapterBase implements Processor {
long virtualSize = 0;
String templateFileFullPath = templatePath.endsWith(File.separator) ? templatePath : templatePath + File.separator;
templateFileFullPath += templateName.endsWith(ImageFormat.VMDK.getFileExtension()) ? templateName : templateName + "." + ImageFormat.VMDK.getFileExtension();
- String vmdkHeader = "";
-
try {
FileReader fileReader = new FileReader(templateFileFullPath);
BufferedReader bufferedReader = new BufferedReader(fileReader);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49f60ca7/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
index b536804..0e625f3 100755
--- a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
+++ b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
@@ -798,7 +798,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
}
- protected Long getVirtualSize(File file, ImageFormat format) {
+ protected long getVirtualSize(File file, ImageFormat format) {
Processor processor = null;
try {
if (format == null) {
@@ -822,9 +822,10 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
processor.configure("template processor", new HashMap<String, Object>());
return processor.getVirtualSize(file);
} catch (Exception e) {
- s_logger.debug("Failed to get virtual size:", e);
+ s_logger.warn("Failed to get virtual size, returning file size instead:", e);
+ return file.length();
}
- return file.length();
+
}
protected Answer copyFromNfsToS3(CopyCommand cmd) {
[2/2] git commit: updated refs/heads/master to 47bb175
Posted by hu...@apache.org.
Partially reverting c61c636ce8a1d74fd22d89026d40ba904fff6cf8. Changing the name if cloud.keystore has bigger impact than just changing the name.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/47bb175b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/47bb175b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/47bb175b
Branch: refs/heads/master
Commit: 47bb175bd4b443f992d8ecc55f0bc795693ba016
Parents: 49f60ca
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Mon Jul 28 14:52:41 2014 +0200
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Mon Jul 28 14:52:41 2014 +0200
----------------------------------------------------------------------
utils/src/com/cloud/utils/nio/Link.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/47bb175b/utils/src/com/cloud/utils/nio/Link.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/nio/Link.java b/utils/src/com/cloud/utils/nio/Link.java
index e0b4d7e..36a8e60 100755
--- a/utils/src/com/cloud/utils/nio/Link.java
+++ b/utils/src/com/cloud/utils/nio/Link.java
@@ -65,7 +65,7 @@ public class Link {
private boolean _gotFollowingPacket;
private SSLEngine _sslEngine;
- public static String keystoreFile = "/cloudmanagementserver.keystore";
+ public static String keystoreFile = "/cloud.keystore";
public Link(InetSocketAddress addr, NioConnection connection) {
_addr = addr;