mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
bug 12898:fix storage related bugs
status 12898: resolved fixed
This commit is contained in:
parent
5aba3913bb
commit
b39d29ef76
@ -996,15 +996,19 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
String volumeName = UUID.randomUUID().toString();
|
||||
|
||||
if (copyToSecondary) {
|
||||
String destVolumeName = volumeName + ".qcow2";
|
||||
KVMPhysicalDisk volume = primaryPool.getPhysicalDisk(cmd.getVolumePath());
|
||||
String volumeDestPath = "/volumes/" + cmd.getVolumeId() + File.separator;
|
||||
secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl);
|
||||
secondaryStoragePool.createFolder(volumeDestPath);
|
||||
secondaryStoragePool.delete();
|
||||
secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl + volumeDestPath);
|
||||
_storagePoolMgr.copyPhysicalDisk(volume, volumeName, secondaryStoragePool);
|
||||
_storagePoolMgr.copyPhysicalDisk(volume, destVolumeName, secondaryStoragePool);
|
||||
return new CopyVolumeAnswer(cmd, true, null, null, volumeName);
|
||||
} else {
|
||||
volumePath = "/volumes/" + cmd.getVolumeId() + File.separator + volumePath;
|
||||
volumePath = "/volumes/" + cmd.getVolumeId() + File.separator;
|
||||
secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl + volumePath);
|
||||
KVMPhysicalDisk volume = secondaryStoragePool.getPhysicalDisk(cmd.getVolumePath());
|
||||
KVMPhysicalDisk volume = secondaryStoragePool.getPhysicalDisk(cmd.getVolumePath() + ".qcow2");
|
||||
_storagePoolMgr.copyPhysicalDisk(volume, volumeName, primaryPool);
|
||||
return new CopyVolumeAnswer(cmd, true, null, null, volumeName);
|
||||
}
|
||||
|
||||
@ -71,6 +71,9 @@ public class LibvirtStorageVolumeDef {
|
||||
}
|
||||
storageVolBuilder.append("<target>\n");
|
||||
storageVolBuilder.append("<format type='" + _volFormat + "'/>\n");
|
||||
storageVolBuilder.append("<permissions>");
|
||||
storageVolBuilder.append("<mode>0744</mode>");
|
||||
storageVolBuilder.append("</permissions>");
|
||||
storageVolBuilder.append("</target>\n");
|
||||
if (_backingPath != null) {
|
||||
storageVolBuilder.append("<backingStore>\n");
|
||||
|
||||
@ -20,4 +20,5 @@ public interface KVMStoragePool {
|
||||
public StoragePoolType getType();
|
||||
public boolean delete();
|
||||
PhysicalDiskFormat getDefaultFormat();
|
||||
public boolean createFolder(String path);
|
||||
}
|
||||
|
||||
@ -74,6 +74,4 @@ public class KVMStoragePoolManager {
|
||||
public KVMPhysicalDisk getPhysicalDiskFromUrl(String url) {
|
||||
return this._storageAdaptor.getPhysicalDiskFromURI(url);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -60,6 +60,15 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
_manageSnapshotPath = Script.findScript("scripts/storage/qcow2/", "managesnapshot.sh");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createFolder(String uuid, String path) {
|
||||
String mountPoint = _mountPoint + File.separator + uuid;
|
||||
File f = new File(mountPoint + path);
|
||||
if (!f.exists()) {
|
||||
f.mkdirs();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public StorageVol getVolume(StoragePool pool, String volName) {
|
||||
StorageVol vol = null;
|
||||
@ -590,7 +599,6 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
String destPath = newDisk.getPath();
|
||||
|
||||
Script.runSimpleBashScript("qemu-img convert -f " + disk.getFormat() + " -O " + newDisk.getFormat() + " " + sourcePath + " " + destPath);
|
||||
|
||||
return newDisk;
|
||||
}
|
||||
|
||||
@ -658,5 +666,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -134,4 +134,9 @@ public class LibvirtStoragePool implements KVMStoragePool {
|
||||
public boolean delete() {
|
||||
return this._storageAdaptor.deleteStoragePool(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createFolder(String path) {
|
||||
return this._storageAdaptor.createFolder(this.uuid, path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,8 @@ package com.cloud.agent.storage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.libvirt.StoragePool;
|
||||
|
||||
import com.cloud.agent.storage.KVMPhysicalDisk.PhysicalDiskFormat;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
|
||||
@ -22,5 +24,6 @@ public interface StorageAdaptor {
|
||||
public KVMPhysicalDisk getPhysicalDiskFromURI(String uri);
|
||||
public boolean refresh(KVMStoragePool pool);
|
||||
public boolean deleteStoragePool(KVMStoragePool pool);
|
||||
public boolean createFolder(String uuid, String path);
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user