mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-26 06:25:19 +00:00
virStorageVolDefFormat: Extract formatting of source extents
Move the extent formatting code into virStorageVolDefFormatSourceExtents. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
104db1951d
commit
80d9ef8068
@ -1643,6 +1643,35 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
virStorageVolDefFormatSourceExtents(virBufferPtr buf,
|
||||||
|
virStorageVolDefPtr def)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
const char *thispath = NULL;
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
virStorageVolDefFormat(virStoragePoolDefPtr pool,
|
virStorageVolDefFormat(virStoragePoolDefPtr pool,
|
||||||
virStorageVolDefPtr def)
|
virStorageVolDefPtr def)
|
||||||
@ -1663,29 +1692,8 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
|
|||||||
virBufferAddLit(&buf, "<source>\n");
|
virBufferAddLit(&buf, "<source>\n");
|
||||||
virBufferAdjustIndent(&buf, 2);
|
virBufferAdjustIndent(&buf, 2);
|
||||||
|
|
||||||
if (def->source.nextent) {
|
if (def->source.nextent)
|
||||||
size_t i;
|
virStorageVolDefFormatSourceExtents(&buf, def);
|
||||||
const char *thispath = NULL;
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
virBufferAdjustIndent(&buf, -2);
|
virBufferAdjustIndent(&buf, -2);
|
||||||
virBufferAddLit(&buf, "</source>\n");
|
virBufferAddLit(&buf, "</source>\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user