mirror of https://github.com/apache/cloudstack.git
Merge remote-tracking branch 'origin/4.15'
This commit is contained in:
commit
def65ec873
|
|
@ -4302,8 +4302,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
QemuImg qemu = new QemuImg(timeout);
|
||||
try{
|
||||
Map<String, String> info = qemu.info(file);
|
||||
String backingFilePath = info.get(new String("backing_file"));
|
||||
String backingFileFormat = info.get(new String("backing_file_format"));
|
||||
String backingFilePath = info.get(QemuImg.BACKING_FILE);
|
||||
String backingFileFormat = info.get(QemuImg.BACKING_FILE_FORMAT);
|
||||
if (org.apache.commons.lang.StringUtils.isNotBlank(backingFilePath)
|
||||
&& org.apache.commons.lang.StringUtils.isBlank(backingFileFormat)) {
|
||||
// VMs which are created in CloudStack 4.14 and before cannot be started or migrated
|
||||
|
|
@ -4312,7 +4312,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
s_logger.info("Setting backing file format of " + volPath);
|
||||
QemuImgFile backingFile = new QemuImgFile(backingFilePath);
|
||||
Map<String, String> backingFileinfo = qemu.info(backingFile);
|
||||
String backingFileFmt = backingFileinfo.get(new String("file_format"));
|
||||
String backingFileFmt = backingFileinfo.get(QemuImg.FILE_FORMAT);
|
||||
qemu.rebase(file, backingFile, backingFileFmt, false);
|
||||
}
|
||||
} catch (QemuImgException | LibvirtException e) {
|
||||
|
|
|
|||
|
|
@ -808,7 +808,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
try{
|
||||
qemu.create(destFile, options);
|
||||
Map<String, String> info = qemu.info(destFile);
|
||||
virtualSize = Long.parseLong(info.get(new String("virtual_size")));
|
||||
virtualSize = Long.parseLong(info.get(QemuImg.VIRTUAL_SIZE));
|
||||
actualSize = new File(destFile.getFileName()).length();
|
||||
} catch (QemuImgException | LibvirtException e) {
|
||||
s_logger.error("Failed to create " + volPath +
|
||||
|
|
@ -1285,7 +1285,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
srcFile = new QemuImgFile(sourcePath, sourceFormat);
|
||||
try {
|
||||
Map<String, String> info = qemu.info(srcFile);
|
||||
String backingFile = info.get(new String("backing_file"));
|
||||
String backingFile = info.get(QemuImg.BACKING_FILE);
|
||||
// qcow2 templates can just be copied into place
|
||||
if (sourceFormat.equals(destFormat) && backingFile == null && sourcePath.endsWith(".qcow2")) {
|
||||
String result = Script.runSimpleBashScript("cp -f " + sourcePath + " " + destPath, timeout);
|
||||
|
|
@ -1297,7 +1297,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
try {
|
||||
qemu.convert(srcFile, destFile);
|
||||
Map<String, String> destInfo = qemu.info(destFile);
|
||||
Long virtualSize = Long.parseLong(destInfo.get(new String("virtual_size")));
|
||||
Long virtualSize = Long.parseLong(destInfo.get(QemuImg.VIRTUAL_SIZE));
|
||||
newDisk.setVirtualSize(virtualSize);
|
||||
newDisk.setSize(virtualSize);
|
||||
} catch (QemuImgException | LibvirtException e) {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,12 @@ import org.apache.commons.lang.NotImplementedException;
|
|||
import org.libvirt.LibvirtException;
|
||||
|
||||
public class QemuImg {
|
||||
public final static String BACKING_FILE = "backing_file";
|
||||
public final static String BACKING_FILE_FORMAT = "backing_file_format";
|
||||
public final static String CLUSTER_SIZE = "cluster_size";
|
||||
public final static String FILE_FORMAT = "file_format";
|
||||
public final static String IMAGE = "image";
|
||||
public final static String VIRTUAL_SIZE = "virtual_size";
|
||||
|
||||
/* The qemu-img binary. We expect this to be in $PATH */
|
||||
public String _qemuImgPath = "qemu-img";
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ public class QemuImgTest {
|
|||
fail("We didn't get any information back from qemu-img");
|
||||
}
|
||||
|
||||
Long infoSize = Long.parseLong(info.get(new String("virtual_size")));
|
||||
Long infoSize = Long.parseLong(info.get(QemuImg.VIRTUAL_SIZE));
|
||||
assertEquals(Long.valueOf(size), Long.valueOf(infoSize));
|
||||
|
||||
String infoPath = info.get(new String("image"));
|
||||
String infoPath = info.get(QemuImg.IMAGE);
|
||||
assertEquals(filename, infoPath);
|
||||
|
||||
File f = new File(filename);
|
||||
|
|
@ -79,13 +79,13 @@ public class QemuImgTest {
|
|||
qemu.create(file, options);
|
||||
Map<String, String> info = qemu.info(file);
|
||||
|
||||
Long infoSize = Long.parseLong(info.get(new String("virtual_size")));
|
||||
Long infoSize = Long.parseLong(info.get(QemuImg.VIRTUAL_SIZE));
|
||||
assertEquals(Long.valueOf(size), Long.valueOf(infoSize));
|
||||
|
||||
String infoPath = info.get(new String("image"));
|
||||
String infoPath = info.get(QemuImg.IMAGE);
|
||||
assertEquals(filename, infoPath);
|
||||
|
||||
String infoClusterSize = info.get(new String("cluster_size"));
|
||||
String infoClusterSize = info.get(QemuImg.CLUSTER_SIZE);
|
||||
assertEquals(clusterSize, infoClusterSize);
|
||||
|
||||
File f = new File(filename);
|
||||
|
|
@ -136,7 +136,7 @@ public class QemuImgTest {
|
|||
fail("We didn't get any information back from qemu-img");
|
||||
}
|
||||
|
||||
Long infoSize = Long.parseLong(info.get(new String("virtual_size")));
|
||||
Long infoSize = Long.parseLong(info.get(QemuImg.VIRTUAL_SIZE));
|
||||
assertEquals(Long.valueOf(endSize), Long.valueOf(infoSize));
|
||||
} catch (QemuImgException e) {
|
||||
fail(e.getMessage());
|
||||
|
|
@ -165,7 +165,7 @@ public class QemuImgTest {
|
|||
fail("We didn't get any information back from qemu-img");
|
||||
}
|
||||
|
||||
Long infoSize = Long.parseLong(info.get(new String("virtual_size")));
|
||||
Long infoSize = Long.parseLong(info.get(QemuImg.VIRTUAL_SIZE));
|
||||
assertEquals(Long.valueOf(startSize + increment), Long.valueOf(infoSize));
|
||||
} catch (QemuImgException e) {
|
||||
fail(e.getMessage());
|
||||
|
|
@ -193,7 +193,7 @@ public class QemuImgTest {
|
|||
fail("We didn't get any information back from qemu-img");
|
||||
}
|
||||
|
||||
Long infoSize = Long.parseLong(info.get(new String("virtual_size")));
|
||||
Long infoSize = Long.parseLong(info.get(QemuImg.VIRTUAL_SIZE));
|
||||
assertEquals(Long.valueOf(startSize + increment), Long.valueOf(infoSize));
|
||||
} catch (QemuImgException e) {
|
||||
fail(e.getMessage());
|
||||
|
|
@ -256,7 +256,7 @@ public class QemuImgTest {
|
|||
fail("We didn't get any information back from qemu-img");
|
||||
}
|
||||
|
||||
String backingFile = info.get(new String("backing_file"));
|
||||
String backingFile = info.get(QemuImg.BACKING_FILE);
|
||||
if (backingFile == null) {
|
||||
fail("The second file does not have a property backing_file! Create failed?");
|
||||
}
|
||||
|
|
@ -304,10 +304,10 @@ public class QemuImgTest {
|
|||
|
||||
Map<String, String> info = qemu.info(destFile);
|
||||
|
||||
PhysicalDiskFormat infoFormat = PhysicalDiskFormat.valueOf(info.get(new String("format")).toUpperCase());
|
||||
PhysicalDiskFormat infoFormat = PhysicalDiskFormat.valueOf(info.get(QemuImg.FILE_FORMAT).toUpperCase());
|
||||
assertEquals(destFormat, infoFormat);
|
||||
|
||||
Long infoSize = Long.parseLong(info.get(new String("virtual_size")));
|
||||
Long infoSize = Long.parseLong(info.get(QemuImg.VIRTUAL_SIZE));
|
||||
assertEquals(Long.valueOf(srcSize), Long.valueOf(infoSize));
|
||||
|
||||
File sf = new File(srcFileName);
|
||||
|
|
@ -317,4 +317,4 @@ public class QemuImgTest {
|
|||
df.delete();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue