提交 69daa2ea 编写于 作者: M Michal Privoznik

testCompareXMLToArgvValidateSchema: Construct @vm from scratch

Currently, the @vm is passed in as an argument and
testCompareXMLToArgvCreateArgs() is called over it which means
under the hood qemuProcessPrepareDomain() is called. But at the
point where ValidateSchema() is called, the domain object is
already 'prepared', i.e. all device aliases are assigned and so
on. But our code is not prepared to 'prepare' a domain twice - it
simply overwrites all the pointers leading to a memory leak.

Fortunately, this is only the problem of this test.

Resolve this by constructing the domain object from scratch.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NPeter Krempa <pkrempa@redhat.com>
上级 d265171b
......@@ -482,16 +482,17 @@ testCompareXMLToArgvCreateArgs(virQEMUDriverPtr drv,
static int
testCompareXMLToArgvValidateSchema(virQEMUDriverPtr drv,
virDomainObjPtr vm,
const char *migrateURI,
struct testQemuInfo *info,
unsigned int flags)
{
VIR_AUTOSTRINGLIST args = NULL;
g_autoptr(virDomainObj) vm = NULL;
size_t nargs = 0;
size_t i;
g_autoptr(virHashTable) schema = NULL;
g_autoptr(virCommand) cmd = NULL;
unsigned int parseFlags = info->parseFlags;
if (info->schemafile)
schema = testQEMUSchemaLoad(info->schemafile);
......@@ -504,6 +505,15 @@ testCompareXMLToArgvValidateSchema(virQEMUDriverPtr drv,
if (!schema)
return 0;
if (!(vm = virDomainObjNew(driver.xmlopt)))
return -1;
parseFlags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
if (!(vm->def = virDomainDefParseFile(info->infile,
driver.xmlopt,
NULL, parseFlags)))
return -1;
if (!(cmd = testCompareXMLToArgvCreateArgs(drv, vm, migrateURI, info, flags,
true)))
return -1;
......@@ -651,7 +661,7 @@ testCompareXMLToArgv(const void *data)
goto cleanup;
}
if (testCompareXMLToArgvValidateSchema(&driver, vm, migrateURI, info, flags) < 0)
if (testCompareXMLToArgvValidateSchema(&driver, migrateURI, info, flags) < 0)
goto cleanup;
if (!(actualargv = virCommandToString(cmd, false)))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册