[libvirt] [PATCH 2/3] storage: Forbid to shrink the vol's capacity if no --shrink is specified
Michal Privoznik
mprivozn at redhat.com
Tue Jun 4 15:19:39 UTC 2013
On 31.05.2013 07:16, Osier Yang wrote:
> As the document for "virsh-resize" says:
> <...>
> Attempts to shrink the volume will fail unless I<--shrink> is present;
> </...>
>
> This makes sense as it at least prevent the user shrinking the important
> data of volume without a notice.
> ---
> src/storage/storage_driver.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
> index e7516eb..858aeca 100644
> --- a/src/storage/storage_driver.c
> +++ b/src/storage/storage_driver.c
> @@ -1762,7 +1762,8 @@ storageVolResize(virStorageVolPtr obj,
> int ret = -1;
>
> virCheckFlags(VIR_STORAGE_VOL_RESIZE_ALLOCATE |
> - VIR_STORAGE_VOL_RESIZE_DELTA, -1);
> + VIR_STORAGE_VOL_RESIZE_DELTA |
> + VIR_STORAGE_VOL_RESIZE_SHRINK, -1);
>
> storageDriverLock(driver);
> pool = virStoragePoolObjFindByName(&driver->pools, obj->pool);
> @@ -1814,6 +1815,14 @@ storageVolResize(virStorageVolPtr obj,
> goto out;
> }
>
> + if (abs_capacity < vol->capacity &&
> + !(flags & VIR_STORAGE_VOL_RESIZE_SHRINK)) {
> + virReportError(VIR_ERR_INVALID_ARG, "%s",
> + _("Can't shrink capacity below current "
> + "capacity with shrink flag explicitly specified"));
> + goto out;
> + }
> +
> if (abs_capacity > vol->capacity + pool->def->available) {
> virReportError(VIR_ERR_OPERATION_FAILED, "%s",
> _("Not enough space left on storage pool"));
>
ACK
Michal
More information about the libvir-list
mailing list