qemublocktest: Extract printing of nodename list

There will be multiple places where we'll need to print nodenames from a
GSList of virStorageSource for testing purposes. Extract the code into a
function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Peter Krempa 2020-06-02 09:11:36 +02:00
parent 5aa423c52d
commit 69cacbe506

View File

@ -647,6 +647,23 @@ testQemuDetectBitmaps(const void *opaque)
}
static void
testQemuBitmapListPrint(const char *title,
GSList *next,
virBufferPtr buf)
{
if (!next)
return;
virBufferAsprintf(buf, "%s\n", title);
for (; next; next = next->next) {
virStorageSourcePtr src = next->data;
virBufferAsprintf(buf, "%s\n", src->nodeformat);
}
}
static virStorageSourcePtr
testQemuBackupIncrementalBitmapCalculateGetFakeImage(size_t idx)
{
@ -829,7 +846,6 @@ testQemuCheckpointDeleteMerge(const void *opaque)
g_autoptr(virHashTable) nodedata = NULL;
g_autoptr(GSList) reopenimages = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
GSList *tmp;
expectpath = g_strdup_printf("%s/%s%s-out.json", abs_srcdir,
checkpointDeletePrefix, data->name);
@ -858,14 +874,7 @@ testQemuCheckpointDeleteMerge(const void *opaque)
virBufferAddLit(&buf, "NULL\n");
}
if (reopenimages) {
virBufferAddLit(&buf, "reopen nodes:\n");
for (tmp = reopenimages; tmp; tmp = tmp->next) {
virStorageSourcePtr src = tmp->data;
virBufferAsprintf(&buf, "%s\n", src->nodeformat);
}
}
testQemuBitmapListPrint("reopen nodes:", reopenimages, &buf);
actual = virBufferContentAndReset(&buf);