mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-07 04:07:17 +00:00
qemublocktest: Add tests for handling of bitmaps during block-commit
Add code for testing the two necessary steps of handling bitmaps during block commit and exercise the code on the test data which we have for bitmap handling. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
1753f60550
commit
77b9d574b4
@ -669,6 +669,21 @@ testQemuBackupIncrementalBitmapCalculateGetFakeChain(void)
|
||||
}
|
||||
|
||||
|
||||
static virStorageSourcePtr
|
||||
testQemuBitmapGetFakeChainEntry(virStorageSourcePtr src,
|
||||
size_t idx)
|
||||
{
|
||||
virStorageSourcePtr n;
|
||||
|
||||
for (n = src; n; n = n->backingStore) {
|
||||
if (n->id == idx)
|
||||
return n;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
typedef virDomainMomentDefPtr testMomentList;
|
||||
|
||||
static void
|
||||
@ -923,6 +938,68 @@ testQemuBlockBitmapBlockcopy(const void *opaque)
|
||||
return virTestCompareToFile(actual, expectpath);
|
||||
}
|
||||
|
||||
static const char *blockcommitPrefix = "qemublocktestdata/bitmapblockcommit/";
|
||||
|
||||
struct testQemuBlockBitmapBlockcommitData {
|
||||
const char *name;
|
||||
virStorageSourcePtr top;
|
||||
virStorageSourcePtr base;
|
||||
virStorageSourcePtr chain;
|
||||
const char *nodedatafile;
|
||||
};
|
||||
|
||||
|
||||
static int
|
||||
testQemuBlockBitmapBlockcommit(const void *opaque)
|
||||
{
|
||||
const struct testQemuBlockBitmapBlockcommitData *data = opaque;
|
||||
|
||||
g_autofree char *actual = NULL;
|
||||
g_autofree char *expectpath = NULL;
|
||||
g_autoptr(virJSONValue) actionsDisable = NULL;
|
||||
g_autoptr(virJSONValue) actionsMerge = NULL;
|
||||
g_autoptr(virJSONValue) nodedatajson = NULL;
|
||||
g_autoptr(virHashTable) nodedata = NULL;
|
||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||
VIR_AUTOSTRINGLIST bitmapsDisable = NULL;
|
||||
|
||||
expectpath = g_strdup_printf("%s/%s%s", abs_srcdir,
|
||||
blockcommitPrefix, data->name);
|
||||
|
||||
if (!(nodedatajson = virTestLoadFileJSON(bitmapDetectPrefix, data->nodedatafile,
|
||||
".json", NULL)))
|
||||
return -1;
|
||||
|
||||
if (!(nodedata = qemuMonitorJSONBlockGetNamedNodeDataJSON(nodedatajson))) {
|
||||
VIR_TEST_VERBOSE("failed to load nodedata JSON\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (qemuBlockBitmapsHandleCommitStart(data->top, data->base, nodedata,
|
||||
&actionsDisable, &bitmapsDisable) < 0)
|
||||
return -1;
|
||||
|
||||
virBufferAddLit(&buf, "pre job bitmap disable:\n");
|
||||
|
||||
if (actionsDisable &&
|
||||
virJSONValueToBuffer(actionsDisable, &buf, true) < 0)
|
||||
return -1;
|
||||
|
||||
virBufferAddLit(&buf, "merge bitmpas:\n");
|
||||
|
||||
if (qemuBlockBitmapsHandleCommitFinish(data->top, data->base, nodedata,
|
||||
&actionsMerge, bitmapsDisable) < 0)
|
||||
return -1;
|
||||
|
||||
if (actionsMerge &&
|
||||
virJSONValueToBuffer(actionsMerge, &buf, true) < 0)
|
||||
return -1;
|
||||
|
||||
actual = virBufferContentAndReset(&buf);
|
||||
|
||||
return virTestCompareToFile(actual, expectpath);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
mymain(void)
|
||||
@ -937,6 +1014,7 @@ mymain(void)
|
||||
struct testQemuCheckpointDeleteMergeData checkpointdeletedata;
|
||||
struct testQemuBlockBitmapValidateData blockbitmapvalidatedata;
|
||||
struct testQemuBlockBitmapBlockcopyData blockbitmapblockcopydata;
|
||||
struct testQemuBlockBitmapBlockcommitData blockbitmapblockcommitdata;
|
||||
char *capslatest_x86_64 = NULL;
|
||||
virQEMUCapsPtr caps_x86_64 = NULL;
|
||||
g_autoptr(virHashTable) qmp_schema_x86_64 = NULL;
|
||||
@ -1301,6 +1379,23 @@ mymain(void)
|
||||
TEST_BITMAP_BLOCKCOPY("snapshots-shallow", true, "snapshots");
|
||||
TEST_BITMAP_BLOCKCOPY("snapshots-deep", false, "snapshots");
|
||||
|
||||
|
||||
#define TEST_BITMAP_BLOCKCOMMIT(testname, topimg, baseimg, ndf) \
|
||||
do {\
|
||||
blockbitmapblockcommitdata.name = testname; \
|
||||
blockbitmapblockcommitdata.top = testQemuBitmapGetFakeChainEntry(bitmapSourceChain, topimg); \
|
||||
blockbitmapblockcommitdata.base = testQemuBitmapGetFakeChainEntry(bitmapSourceChain, baseimg); \
|
||||
blockbitmapblockcommitdata.nodedatafile = ndf; \
|
||||
if (virTestRun("bitmap block commit " testname, \
|
||||
testQemuBlockBitmapBlockcommit, \
|
||||
&blockbitmapblockcommitdata) < 0) \
|
||||
ret = -1; \
|
||||
} while (0)
|
||||
|
||||
TEST_BITMAP_BLOCKCOMMIT("basic-1-2", 1, 2, "basic");
|
||||
TEST_BITMAP_BLOCKCOMMIT("basic-1-3", 1, 3, "basic");
|
||||
TEST_BITMAP_BLOCKCOMMIT("basic-2-3", 2, 3, "basic");
|
||||
|
||||
cleanup:
|
||||
qemuTestDriverFree(&driver);
|
||||
VIR_FREE(capslatest_x86_64);
|
||||
|
119
tests/qemublocktestdata/bitmapblockcommit/basic-1-2
Normal file
119
tests/qemublocktestdata/bitmapblockcommit/basic-1-2
Normal file
@ -0,0 +1,119 @@
|
||||
pre job bitmap disable:
|
||||
merge bitmpas:
|
||||
[
|
||||
{
|
||||
"type": "block-dirty-bitmap-add",
|
||||
"data": {
|
||||
"node": "libvirt-2-format",
|
||||
"name": "a",
|
||||
"persistent": true,
|
||||
"disabled": true,
|
||||
"granularity": 65536
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block-dirty-bitmap-merge",
|
||||
"data": {
|
||||
"node": "libvirt-2-format",
|
||||
"target": "a",
|
||||
"bitmaps": [
|
||||
{
|
||||
"node": "libvirt-1-format",
|
||||
"name": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block-dirty-bitmap-add",
|
||||
"data": {
|
||||
"node": "libvirt-2-format",
|
||||
"name": "b",
|
||||
"persistent": true,
|
||||
"disabled": true,
|
||||
"granularity": 65536
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block-dirty-bitmap-merge",
|
||||
"data": {
|
||||
"node": "libvirt-2-format",
|
||||
"target": "b",
|
||||
"bitmaps": [
|
||||
{
|
||||
"node": "libvirt-1-format",
|
||||
"name": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block-dirty-bitmap-add",
|
||||
"data": {
|
||||
"node": "libvirt-2-format",
|
||||
"name": "current",
|
||||
"persistent": true,
|
||||
"disabled": false,
|
||||
"granularity": 65536
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block-dirty-bitmap-merge",
|
||||
"data": {
|
||||
"node": "libvirt-2-format",
|
||||
"target": "current",
|
||||
"bitmaps": [
|
||||
{
|
||||
"node": "libvirt-1-format",
|
||||
"name": "current"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block-dirty-bitmap-add",
|
||||
"data": {
|
||||
"node": "libvirt-2-format",
|
||||
"name": "c",
|
||||
"persistent": true,
|
||||
"disabled": true,
|
||||
"granularity": 65536
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block-dirty-bitmap-merge",
|
||||
"data": {
|
||||
"node": "libvirt-2-format",
|
||||
"target": "c",
|
||||
"bitmaps": [
|
||||
{
|
||||
"node": "libvirt-1-format",
|
||||
"name": "c"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block-dirty-bitmap-add",
|
||||
"data": {
|
||||
"node": "libvirt-2-format",
|
||||
"name": "d",
|
||||
"persistent": true,
|
||||
"disabled": true,
|
||||
"granularity": 65536
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block-dirty-bitmap-merge",
|
||||
"data": {
|
||||
"node": "libvirt-2-format",
|
||||
"target": "d",
|
||||
"bitmaps": [
|
||||
{
|
||||
"node": "libvirt-1-format",
|
||||
"name": "d"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
119
tests/qemublocktestdata/bitmapblockcommit/basic-1-3
Normal file
119
tests/qemublocktestdata/bitmapblockcommit/basic-1-3
Normal file
@ -0,0 +1,119 @@
|
||||
pre job bitmap disable:
|
||||
merge bitmpas:
|
||||
[
|
||||
{
|
||||
"type": "block-dirty-bitmap-add",
|
||||
"data": {
|
||||
"node": "libvirt-3-format",
|
||||
"name": "a",
|
||||
"persistent": true,
|
||||
"disabled": true,
|
||||
"granularity": 65536
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block-dirty-bitmap-merge",
|
||||
"data": {
|
||||
"node": "libvirt-3-format",
|
||||
"target": "a",
|
||||
"bitmaps": [
|
||||
{
|
||||
"node": "libvirt-1-format",
|
||||
"name": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block-dirty-bitmap-add",
|
||||
"data": {
|
||||
"node": "libvirt-3-format",
|
||||
"name": "b",
|
||||
"persistent": true,
|
||||
"disabled": true,
|
||||
"granularity": 65536
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block-dirty-bitmap-merge",
|
||||
"data": {
|
||||
"node": "libvirt-3-format",
|
||||
"target": "b",
|
||||
"bitmaps": [
|
||||
{
|
||||
"node": "libvirt-1-format",
|
||||
"name": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block-dirty-bitmap-add",
|
||||
"data": {
|
||||
"node": "libvirt-3-format",
|
||||
"name": "current",
|
||||
"persistent": true,
|
||||
"disabled": false,
|
||||
"granularity": 65536
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block-dirty-bitmap-merge",
|
||||
"data": {
|
||||
"node": "libvirt-3-format",
|
||||
"target": "current",
|
||||
"bitmaps": [
|
||||
{
|
||||
"node": "libvirt-1-format",
|
||||
"name": "current"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block-dirty-bitmap-add",
|
||||
"data": {
|
||||
"node": "libvirt-3-format",
|
||||
"name": "c",
|
||||
"persistent": true,
|
||||
"disabled": true,
|
||||
"granularity": 65536
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block-dirty-bitmap-merge",
|
||||
"data": {
|
||||
"node": "libvirt-3-format",
|
||||
"target": "c",
|
||||
"bitmaps": [
|
||||
{
|
||||
"node": "libvirt-1-format",
|
||||
"name": "c"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block-dirty-bitmap-add",
|
||||
"data": {
|
||||
"node": "libvirt-3-format",
|
||||
"name": "d",
|
||||
"persistent": true,
|
||||
"disabled": true,
|
||||
"granularity": 65536
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block-dirty-bitmap-merge",
|
||||
"data": {
|
||||
"node": "libvirt-3-format",
|
||||
"target": "d",
|
||||
"bitmaps": [
|
||||
{
|
||||
"node": "libvirt-1-format",
|
||||
"name": "d"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
2
tests/qemublocktestdata/bitmapblockcommit/basic-2-3
Normal file
2
tests/qemublocktestdata/bitmapblockcommit/basic-2-3
Normal file
@ -0,0 +1,2 @@
|
||||
pre job bitmap disable:
|
||||
merge bitmpas:
|
Loading…
x
Reference in New Issue
Block a user