mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
bug 7317,7013: return error message if creating snapshot from KVM host os that not supported snapshot
status 7317: resolved fixed status 7013: resolved fixed
This commit is contained in:
parent
2f0f78ff73
commit
f48af6ec43
@ -2756,7 +2756,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
}
|
||||
|
||||
private String getVolumePath(VolumeTO volume) throws LibvirtException, URISyntaxException {
|
||||
if (volume.getType() == Volume.VolumeType.ISO) {
|
||||
if (volume.getType() == Volume.VolumeType.ISO && volume.getPath() != null) {
|
||||
StorageVol vol = getVolume(_conn, volume.getPath());
|
||||
return vol.getPath();
|
||||
} else {
|
||||
@ -2772,8 +2772,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
DiskDef.diskBus diskBusType = getGuestDiskModel(vmSpec.getOs());
|
||||
DiskDef disk = new DiskDef();
|
||||
if (volume.getType() == VolumeType.ISO) {
|
||||
foundISO = true;
|
||||
disk.defISODisk(volPath);
|
||||
if (volPath == null) {
|
||||
/*Add iso as placeholder*/
|
||||
disk.defISODisk(null);
|
||||
} else {
|
||||
disk.defISODisk(volPath);
|
||||
}
|
||||
} else {
|
||||
int devId = 0;
|
||||
if (volume.getType() == VolumeType.ROOT) {
|
||||
@ -2794,14 +2798,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
}
|
||||
}
|
||||
|
||||
if (vmSpec.getType() == VirtualMachine.Type.User) {
|
||||
if (!foundISO) {
|
||||
/*Add iso as placeholder*/
|
||||
DiskDef iso = new DiskDef();
|
||||
iso.defISODisk(null);
|
||||
vm.getDevices().addDevice(iso);
|
||||
}
|
||||
} else {
|
||||
if (vmSpec.getType() != VirtualMachine.Type.User) {
|
||||
DiskDef iso = new DiskDef();
|
||||
iso.defISODisk(_sysvmISOPath);
|
||||
vm.getDevices().addDevice(iso);
|
||||
|
||||
@ -51,6 +51,8 @@ import com.cloud.async.AsyncInstanceCreateStatus;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.configuration.ResourceCount.ResourceType;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.ClusterVO;
|
||||
import com.cloud.dc.dao.ClusterDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
@ -61,8 +63,10 @@ import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.DetailsDao;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.Snapshot.Status;
|
||||
import com.cloud.storage.Snapshot.Type;
|
||||
@ -132,6 +136,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
||||
@Inject protected SnapshotScheduler _snapSchedMgr;
|
||||
@Inject protected AsyncJobManager _asyncMgr;
|
||||
@Inject protected AccountManager _accountMgr;
|
||||
@Inject protected ClusterDao _clusterDao;
|
||||
String _name;
|
||||
private int _totalRetries;
|
||||
private int _pauseInterval;
|
||||
@ -328,6 +333,21 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
||||
throw new CloudRuntimeException("Creating snapshot failed due to volume:" + volumeId + " is being used, try it later ");
|
||||
}
|
||||
}
|
||||
if (_volsDao.getHypervisorType(volume.getId()).equals(HypervisorType.KVM)) {
|
||||
/*for kvm, only Fedora supports snapshot, currently*/
|
||||
StoragePoolVO storagePool = _storagePoolDao.findById(volume.getPoolId());
|
||||
ClusterVO cluster = _clusterDao.findById(storagePool.getClusterId());
|
||||
List<HostVO> hosts = _hostDao.listByCluster(cluster.getId());
|
||||
if (hosts != null && !hosts.isEmpty()) {
|
||||
HostVO host = hosts.get(0);
|
||||
_hostDao.loadDetails(host);
|
||||
String hostOS = host.getDetail("Host.OS");
|
||||
String hostOSVersion = host.getDetail("Host.OS.Version");
|
||||
if (! (hostOS != null && hostOS.equalsIgnoreCase("Fedora") && hostOSVersion != null && Integer.parseInt(hostOSVersion) >= 13)) {
|
||||
throw new CloudRuntimeException("KVM Snapshot is not supported on:" + hostOS + ": " + hostOSVersion + ". Please install Fedora 13 and above to enable snapshot");
|
||||
}
|
||||
}
|
||||
}
|
||||
SnapshotVO snapshot = null;
|
||||
boolean backedUp = false;
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user