public StorageVol createVolume(Connect conn, StoragePool pool, String uuid, long size, VolumeFormat format) throws LibvirtException { LibvirtStorageVolumeDef volDef = new LibvirtStorageVolumeDef(UUID.randomUUID().toString(), size, format, null, null); s_logger.debug(volDef.toString()); return pool.storageVolCreateXML(volDef.toString(), 0); }
public StorageVol copyVolume(StoragePool destPool, LibvirtStorageVolumeDef destVol, StorageVol srcVol, int timeout) throws LibvirtException { StorageVol vol = destPool.storageVolCreateXML(destVol.toString(), 0); String srcPath = srcVol.getKey(); String destPath = vol.getKey(); Script.runSimpleBashScript("cp " + srcPath + " " + destPath, timeout); return vol; }
private KVMPhysicalDisk createPhysicalDiskByLibVirt(String name, KVMStoragePool pool, PhysicalDiskFormat format, Storage.ProvisioningType provisioningType, long size) { LibvirtStoragePool libvirtPool = (LibvirtStoragePool) pool; StoragePool virtPool = libvirtPool.getPool(); LibvirtStorageVolumeDef.VolumeFormat libvirtformat = LibvirtStorageVolumeDef.VolumeFormat.getFormat(format); String volPath = null; String volName = null; long volAllocation = 0; long volCapacity = 0; LibvirtStorageVolumeDef volDef = new LibvirtStorageVolumeDef(name, size, libvirtformat, null, null); s_logger.debug(volDef.toString()); try { StorageVol vol = virtPool.storageVolCreateXML(volDef.toString(), 0); volPath = vol.getPath(); volName = vol.getName(); volAllocation = vol.getInfo().allocation; volCapacity = vol.getInfo().capacity; } catch (LibvirtException e) { throw new CloudRuntimeException(e.toString()); } KVMPhysicalDisk disk = new KVMPhysicalDisk(volPath, volName, pool); disk.setFormat(format); disk.setSize(volAllocation); disk.setVirtualSize(volCapacity); return disk; }
s_logger.debug(volDef.toString()); vol = virtPool.storageVolCreateXML(volDef.toString(), 0);
public StorageVol createCloneWithBackingStore(String name) { try { String volumeXml = DiskXml.cloneVolumeXml(this, name); log.debug("Creating volume with xml={}", volumeXml); StorageVol vol = getStoragePool().storageVolCreateXML(volumeXml, 0); return vol; } catch (LibvirtException e) { throw new LibvirtRuntimeException(e); } catch (IOException e) { throw new LibvirtRuntimeException(e); } }