Re: [PATCH 05/10] virDomainBlockResize: Introduce VIR_DOMAIN_BLOCK_RESIZE_CAPACITY

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Dec 14, 2023 at 10:19:40AM +0100, Peter Krempa wrote:
> Allow users to easily resize 'raw' images on block devices to the full
> capacity of the block device. Obviously this won't work on file-backed
> storage (filling the remaining capacity is most likely wrong) or for
> formats with metadata due to the overhead.
> 
> Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
> ---
>  docs/manpages/virsh.rst          |  6 +++++-
>  include/libvirt/libvirt-domain.h |  1 +
>  src/libvirt-domain.c             |  5 +++++
>  tools/virsh-domain.c             | 10 +++++++++-
>  4 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
> index 3e7a4c6c22..ed1027e133 100644
> --- a/docs/manpages/virsh.rst
> +++ b/docs/manpages/virsh.rst
> @@ -1421,7 +1421,7 @@ blockresize
> 
>  ::
> 
> -   blockresize domain path size
> +   blockresize domain path ([size] | [--capacity])
> 
>  Resize a block device of domain while the domain is running, *path*
>  specifies the absolute path of the block device; it corresponds
> @@ -1429,6 +1429,10 @@ to a unique target name (<target dev='name'/>) or source file (<source
>  file='name'/>) for one of the disk devices attached to *domain* (see
>  also ``domblklist`` for listing these names).
> 
> +For image formats without metadata (raw) stored inside fixed-size storage (e.g.
> +block devices) the --capacity flag can be used to resize the device to the
> +full size of the backing device.
> +
>  *size* is a scaled integer (see ``NOTES`` above) which defaults to KiB
>  (blocks of 1024 bytes) if there is no suffix.  You must use a suffix of
>  "B" to get bytes (note that for historical reasons, this differs from
> diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
> index a1902546bb..30cce85b29 100644
> --- a/include/libvirt/libvirt-domain.h
> +++ b/include/libvirt/libvirt-domain.h
> @@ -2172,6 +2172,7 @@ int                     virDomainBlockPeek (virDomainPtr dom,
>   */
>  typedef enum {
>      VIR_DOMAIN_BLOCK_RESIZE_BYTES = 1 << 0, /* size in bytes instead of KiB (Since: 0.9.11) */
> +    VIR_DOMAIN_BLOCK_RESIZE_CAPACITY = 1 << 1, /* resize to full the capacity of the source (Since: 10.0.0) */
>  } virDomainBlockResizeFlags;
> 
>  int                     virDomainBlockResize (virDomainPtr dom,
> diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
> index 77a9682ecb..94e5672ed8 100644
> --- a/src/libvirt-domain.c
> +++ b/src/libvirt-domain.c
> @@ -6388,6 +6388,11 @@ virDomainBlockPeek(virDomainPtr dom,
>   * size.  Depending on the file format, the hypervisor may round up
>   * to the next alignment boundary.
>   *
> + * If @flag contains VIR_DOMAIN_BLOCK_RESIZE_CAPACITY (since 10.0.0) the
> + * hypervisor will resize the guest block device to fully fill the source,
> + * ignoring @size. This is possible only for image formats with no metadata
> + * ('raw') and for source devices with limited capacity such as block devices.
> + *

I think we should declare that @size *must* be set to either
0, or the underlying block device size, when VIR_DOMAIN_BLOCK_RESIZE_CAPACITY.

If set to 0 then auto-discover the size.

If set to non-zero then validate that it is an *exact* match for
the block dev capacity, as a means of error checking.


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux