[libvirt] [PATCH] Implement LVM volume resize via lvresize

Peter Krempa pkrempa at redhat.com
Thu Aug 31 08:14:21 UTC 2017


On Wed, Aug 30, 2017 at 20:23:30 +0300, apolyakov at beget.ru wrote:
> From: Alexander Polyakov <apolyakov at beget.com>

Commit message is missing (and required). Please describe your change.

> 
> Signed-off-by: Alexander Polyakov <apolyakov at beget.com>
> ---
>  m4/virt-storage-lvm.m4                |  4 ++++
>  src/storage/storage_backend_logical.c | 22 ++++++++++++++++++++++
>  2 files changed, 26 insertions(+)

[...]

> diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
> index 67f70e551..810e4ee88 100644
> --- a/src/storage/storage_backend_logical.c
> +++ b/src/storage/storage_backend_logical.c
> @@ -1072,6 +1072,27 @@ virStorageBackendLogicalVolWipe(virConnectPtr conn,
>      return -1;
>  }
>  
> +static int
> +virStorageBackendLogicalResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED,
> +                                   virStoragePoolObjPtr pool,
> +                                   virStorageVolDefPtr vol,
> +                                   unsigned long long capacity,
> +                                   unsigned int flags)
> +{
> +
> +    virCheckFlags(0, -1);

This won't allow shrinking of the volume. Also VIR_STORAGE_VOL_RESIZE_DELTA
looks simple enough to implement.

> +
> +    (void)pool;

Use ATTRIBUTE_UNUSED for the parameter.

> +    virCommandPtr cmd = virCommandNewArgList(LVRESIZE, "-L", NULL);
> +    virCommandAddArgFormat(cmd, "%lluK", VIR_DIV_UP(capacity, 1024));

Why don't you pass this through in bytes?

> +    virCommandAddArgFormat(cmd, "%s", vol->target.path);
> +    int ret = virCommandRun(cmd, NULL);

rest looks fine.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170831/d46c7598/attachment-0001.sig>


More information about the libvir-list mailing list