Exercise the ABI stability check code in test suite

Any test suite which involves a virDomainDefPtr should
call virDomainDefCheckABIStability with itself just as
a basic sanity check that the identity-comparison always
succeeds. This would have caught the recent NULL pointer
access crash.

Make sure we cope with def->name being NULL since the
VMWare config parser produces NULL names.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2014-01-10 17:18:03 +00:00
parent dd0dda2e4a
commit 53a699a07b
11 changed files with 51 additions and 1 deletions

View File

@ -13761,7 +13761,7 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
* don't get silently re-named through the backdoor when passing
* custom XML into various APIs, since this would create havoc
*/
if (STRNEQ(src->name, dst->name)) {
if (STRNEQ_NULLABLE(src->name, dst->name)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target domain name '%s' does not match source '%s'"),
dst->name, src->name);

View File

@ -41,6 +41,11 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live)
live ? 0 : VIR_DOMAIN_XML_INACTIVE)))
goto fail;
if (!virDomainDefCheckABIStability(def, def)) {
fprintf(stderr, "ABI stability check failed on %s", inxml);
goto fail;
}
if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE)))
goto fail;

View File

@ -61,6 +61,11 @@ static int testCompareXMLToArgvFiles(const char *xml,
}
VIR_FREE(log);
if (!virDomainDefCheckABIStability(vmdef, vmdef)) {
fprintf(stderr, "ABI stability check failed on %s", xml);
goto fail;
}
if (!(actualxml = virDomainDefFormat(vmdef, 0)))
goto fail;

View File

@ -289,6 +289,11 @@ static int testCompareXMLToArgvFiles(const char *xml,
goto out;
}
if (!virDomainDefCheckABIStability(vmdef, vmdef)) {
fprintf(stderr, "ABI stability check failed on %s", xml);
goto out;
}
if (virQEMUCapsGet(extraFlags, QEMU_CAPS_DOMID))
vmdef->id = 6;
else

View File

@ -41,6 +41,11 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live)
QEMU_EXPECTED_VIRT_TYPES, flags)))
goto fail;
if (!virDomainDefCheckABIStability(def, def)) {
fprintf(stderr, "ABI stability check failed on %s", inxml);
goto fail;
}
if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE | flags)))
goto fail;

View File

@ -59,6 +59,11 @@ static int testCompareXMLToArgvFiles(const char *xml,
VIR_DOMAIN_XML_INACTIVE)))
goto fail;
if (!virDomainDefCheckABIStability(vmdef, vmdef)) {
fprintf(stderr, "ABI stability check failed on %s", xml);
goto fail;
}
/*
* For test purposes, we may want to fake emulator's output by providing
* our own script instead of a real emulator. For this to work we need to

View File

@ -60,6 +60,11 @@ testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion)
if (!(def = xenParseSxprString(sexprData, xendConfigVersion, tty, vncport)))
goto fail;
if (!virDomainDefCheckABIStability(def, def)) {
fprintf(stderr, "ABI stability check failed on %s", xml);
goto fail;
}
if (!(gotxml = virDomainDefFormat(def, 0)))
goto fail;

View File

@ -88,6 +88,11 @@ testCompareFiles(const char *vmx, const char *xml)
if (!(def = virVMXParseConfig(&ctx, xmlopt, vmxData)))
goto cleanup;
if (!virDomainDefCheckABIStability(def, def)) {
fprintf(stderr, "ABI stability check failed on %s", vmx);
goto cleanup;
}
if (!(formatted = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE)))
goto cleanup;

View File

@ -77,6 +77,11 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion)
VIR_DOMAIN_XML_INACTIVE)))
goto fail;
if (!virDomainDefCheckABIStability(def, def)) {
fprintf(stderr, "ABI stability check failed on %s", xml);
goto fail;
}
if (!(conf = xenFormatXM(conn, def, xendConfigVersion)))
goto fail;

View File

@ -41,6 +41,11 @@ testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion)
VIR_DOMAIN_XML_INACTIVE)))
goto fail;
if (!virDomainDefCheckABIStability(def, def)) {
fprintf(stderr, "ABI stability check failed on %s", xml);
goto fail;
}
if (!(gotsexpr = xenFormatSxpr(NULL, def, xendConfigVersion)))
goto fail;

View File

@ -97,6 +97,11 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
goto failure;
}
if (!virDomainDefCheckABIStability(def, def)) {
fprintf(stderr, "ABI stability check failed on %s", xml);
goto failure;
}
formatted = virVMXFormatConfig(&ctx, xmlopt, def, virtualHW_version);
if (formatted == NULL) {