mirror of https://github.com/apache/cloudstack.git
cloudstack-4235
This commit is contained in:
parent
a6c6f4851b
commit
798d8f1e4b
|
|
@ -6462,11 +6462,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
}
|
||||
}
|
||||
|
||||
// for about 1 GiB of physical size, about 4 MiB seems to be used for metadata
|
||||
private long getMetadata(long physicalSize) {
|
||||
return (long)(physicalSize * 0.00390625); // 1 GiB / 4 MiB = 0.00390625
|
||||
}
|
||||
|
||||
protected VDI handleSrAndVdiAttach(String iqn, String storageHostName,
|
||||
String chapInitiatorName, String chapInitiatorPassword) throws Types.XenAPIException, XmlRpcException {
|
||||
VDI vdi = null;
|
||||
|
|
@ -6486,13 +6481,32 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
vdir.nameLabel = iqn;
|
||||
vdir.SR = sr;
|
||||
vdir.type = Types.VdiType.USER;
|
||||
vdir.virtualSize = sr.getPhysicalSize(conn) - sr.getPhysicalUtilisation(conn) - getMetadata(sr.getPhysicalSize(conn));
|
||||
|
||||
long totalSpace = sr.getPhysicalSize(conn);
|
||||
long unavailableSpace = sr.getPhysicalUtilisation(conn);
|
||||
|
||||
vdir.virtualSize = totalSpace - unavailableSpace;
|
||||
|
||||
if (vdir.virtualSize < 0) {
|
||||
throw new CloudRuntimeException("VDI virtual size cannot be less than 0.");
|
||||
}
|
||||
|
||||
vdi = VDI.create(conn, vdir);
|
||||
long maxNumberOfTries = (totalSpace / unavailableSpace >= 1) ? (totalSpace / unavailableSpace) : 1;
|
||||
long tryNumber = 0;
|
||||
|
||||
while (tryNumber <= maxNumberOfTries) {
|
||||
try {
|
||||
vdi = VDI.create(conn, vdir);
|
||||
|
||||
break;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
tryNumber++;
|
||||
|
||||
vdir.virtualSize -= unavailableSpace;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
vdi = sr.getVDIs(conn).iterator().next();
|
||||
|
|
|
|||
Loading…
Reference in New Issue