Ejemplo n.º 1
0
func (v *VirStorageVol) Resize(capacity uint64, flags uint32) error {
	result := C.virStorageVolResize(v.ptr, C.ulonglong(capacity), C.uint(flags))
	if result == -1 {
		return GetLastError()
	}
	return nil
}
Ejemplo n.º 2
0
// Resize changes the capacity of the storage volume to "capacity". The
// operation will fail if the new capacity requires allocation that would exceed
// the remaining free space in the parent pool. The contents of the new capacity
// will appear as all zero bytes. The capacity value will be rounded to the
// granularity supported by the hypervisor.
// Normally, the operation will attempt to affect capacity with a minimum impact
// on allocation (that is, the default operation favors a sparse resize). If
// "flags" contains VolResizeAllocate, then the operation will ensure that
// allocation is sufficient for the new capacity; this may make the operation
// take noticeably longer.
// Normally, the operation treats "capacity" as the new size in bytes; but if
// "flags" contains VolResizeDelta, then "capacity" represents the size
// difference to add to the current size. It is up to the storage pool
// implementation whether unaligned requests are rounded up to the next valid
// boundary, or rejected.
// Normally, this operation should only be used to enlarge capacity; but if
// "flags" contains VolResizeShrink, it is possible to attempt a reduction in
// capacity even though it might cause data loss. If VolResizeDelta is also
// present, then "capacity" is subtracted from the current size; without it,
// "capacity" represents the absolute new size regardless of whether it is
// larger or smaller than the current size.
func (vol StorageVolume) Resize(capacity uint64, flags StorageVolumeResizeFlag) error {
	vol.log.Printf("resizing storage volume to %v bytes (flags = %v)...\n", capacity, flags)
	cRet := C.virStorageVolResize(vol.virStorageVol, C.ulonglong(capacity), C.uint(flags))
	ret := int32(cRet)

	if ret == -1 {
		err := LastError()
		vol.log.Printf("an error occurred: %v\n", err)
		return err
	}

	vol.log.Println("volume resized")

	return nil
}