[PATCH 3/4] virStorageVolDefFormat: Extract formatting of source extents
Michal Privoznik
mprivozn at redhat.com
Mon Mar 1 13:31:35 UTC 2021
On 2/25/21 2:26 PM, Peter Krempa wrote:
> Move the extent formatting code into
> virStorageVolDefFormatSourceExtents.
>
> Signed-off-by: Peter Krempa <pkrempa at redhat.com>
> ---
> src/conf/storage_conf.c | 53 +++++++++++++++++++++++------------------
> 1 file changed, 30 insertions(+), 23 deletions(-)
>
> diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
> index 0f515c7cbb..1bc27ff194 100644
> --- a/src/conf/storage_conf.c
> +++ b/src/conf/storage_conf.c
> @@ -1643,6 +1643,34 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
> }
>
>
> +static void
> +virStorageVolDefFormatSourceExtents(virBufferPtr buf,
> + virStorageVolDefPtr def)
> +{
> + size_t i;
> + const char *thispath = NULL;
Insert an empty line here, please.
> + for (i = 0; i < def->source.nextent; i++) {
> + if (thispath == NULL ||
> + STRNEQ(thispath, def->source.extents[i].path)) {
> + if (thispath != NULL)
> + virBufferAddLit(buf, "</device>\n");
> +
> + virBufferEscapeString(buf, "<device path='%s'>\n",
> + def->source.extents[i].path);
> + }
> +
> + virBufferAdjustIndent(buf, 2);
> + virBufferAsprintf(buf, "<extent start='%llu' end='%llu'/>\n",
> + def->source.extents[i].start,
> + def->source.extents[i].end);
> + virBufferAdjustIndent(buf, -2);
> + thispath = def->source.extents[i].path;
> + }
> + if (thispath != NULL)
> + virBufferAddLit(buf, "</device>\n");
> +}
> +
Michal
More information about the libvir-list
mailing list