qemumigrationcookiexmltest: Don't crash when parsing of status XML fails

Some sub-tests dereference 'data->vm' even when it is NULL.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2023-11-09 14:31:43 +01:00
parent 85f5871186
commit f0643a5759

View File

@ -137,9 +137,17 @@ static int
testQemuMigrationCookieParse(const void *opaque)
{
struct testQemuMigrationCookieData *data = (struct testQemuMigrationCookieData *) opaque;
qemuDomainObjPrivate *priv = data->vm->privateData;
qemuDomainObjPrivate *priv;
g_auto(virBuffer) actual = VIR_BUFFER_INITIALIZER;
/* if the VM object parsing step failed there's nothing this test can do */
if (!data->vm) {
VIR_TEST_DEBUG("\nmissing VM object\n");
return -1;
}
priv = data->vm->privateData;
if (!(data->cookie = qemuMigrationCookieParse(&driver,
data->vm,
data->vm->def,
@ -314,6 +322,12 @@ testQemuMigrationCookieBlockDirtyBitmaps(const void *opaque)
return -1;
}
/* if the VM object parsing step failed there's nothing this test can do */
if (!data->vm) {
VIR_TEST_DEBUG("\nmissing VM object\n");
return -1;
}
if (qemuMigrationCookieBlockDirtyBitmapsMatchDisks(data->vm->def,
data->cookie->blockDirtyBitmaps) < 0)
return -1;