提交 53a699a0 编写于 作者: D Daniel P. Berrange

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: NDaniel P. Berrange <berrange@redhat.com>
上级 dd0dda2e
...@@ -13761,7 +13761,7 @@ virDomainDefCheckABIStability(virDomainDefPtr src, ...@@ -13761,7 +13761,7 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
* don't get silently re-named through the backdoor when passing * don't get silently re-named through the backdoor when passing
* custom XML into various APIs, since this would create havoc * 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, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target domain name '%s' does not match source '%s'"), _("Target domain name '%s' does not match source '%s'"),
dst->name, src->name); dst->name, src->name);
......
...@@ -41,6 +41,11 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live) ...@@ -41,6 +41,11 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live)
live ? 0 : VIR_DOMAIN_XML_INACTIVE))) live ? 0 : VIR_DOMAIN_XML_INACTIVE)))
goto fail; 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))) if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE)))
goto fail; goto fail;
......
...@@ -61,6 +61,11 @@ static int testCompareXMLToArgvFiles(const char *xml, ...@@ -61,6 +61,11 @@ static int testCompareXMLToArgvFiles(const char *xml,
} }
VIR_FREE(log); VIR_FREE(log);
if (!virDomainDefCheckABIStability(vmdef, vmdef)) {
fprintf(stderr, "ABI stability check failed on %s", xml);
goto fail;
}
if (!(actualxml = virDomainDefFormat(vmdef, 0))) if (!(actualxml = virDomainDefFormat(vmdef, 0)))
goto fail; goto fail;
......
...@@ -289,6 +289,11 @@ static int testCompareXMLToArgvFiles(const char *xml, ...@@ -289,6 +289,11 @@ static int testCompareXMLToArgvFiles(const char *xml,
goto out; goto out;
} }
if (!virDomainDefCheckABIStability(vmdef, vmdef)) {
fprintf(stderr, "ABI stability check failed on %s", xml);
goto out;
}
if (virQEMUCapsGet(extraFlags, QEMU_CAPS_DOMID)) if (virQEMUCapsGet(extraFlags, QEMU_CAPS_DOMID))
vmdef->id = 6; vmdef->id = 6;
else else
......
...@@ -41,6 +41,11 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live) ...@@ -41,6 +41,11 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live)
QEMU_EXPECTED_VIRT_TYPES, flags))) QEMU_EXPECTED_VIRT_TYPES, flags)))
goto fail; 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))) if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE | flags)))
goto fail; goto fail;
......
...@@ -59,6 +59,11 @@ static int testCompareXMLToArgvFiles(const char *xml, ...@@ -59,6 +59,11 @@ static int testCompareXMLToArgvFiles(const char *xml,
VIR_DOMAIN_XML_INACTIVE))) VIR_DOMAIN_XML_INACTIVE)))
goto fail; 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 * 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 * our own script instead of a real emulator. For this to work we need to
......
...@@ -60,6 +60,11 @@ testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion) ...@@ -60,6 +60,11 @@ testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion)
if (!(def = xenParseSxprString(sexprData, xendConfigVersion, tty, vncport))) if (!(def = xenParseSxprString(sexprData, xendConfigVersion, tty, vncport)))
goto fail; goto fail;
if (!virDomainDefCheckABIStability(def, def)) {
fprintf(stderr, "ABI stability check failed on %s", xml);
goto fail;
}
if (!(gotxml = virDomainDefFormat(def, 0))) if (!(gotxml = virDomainDefFormat(def, 0)))
goto fail; goto fail;
......
...@@ -88,6 +88,11 @@ testCompareFiles(const char *vmx, const char *xml) ...@@ -88,6 +88,11 @@ testCompareFiles(const char *vmx, const char *xml)
if (!(def = virVMXParseConfig(&ctx, xmlopt, vmxData))) if (!(def = virVMXParseConfig(&ctx, xmlopt, vmxData)))
goto cleanup; 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))) if (!(formatted = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE)))
goto cleanup; goto cleanup;
......
...@@ -77,6 +77,11 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion) ...@@ -77,6 +77,11 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion)
VIR_DOMAIN_XML_INACTIVE))) VIR_DOMAIN_XML_INACTIVE)))
goto fail; goto fail;
if (!virDomainDefCheckABIStability(def, def)) {
fprintf(stderr, "ABI stability check failed on %s", xml);
goto fail;
}
if (!(conf = xenFormatXM(conn, def, xendConfigVersion))) if (!(conf = xenFormatXM(conn, def, xendConfigVersion)))
goto fail; goto fail;
......
...@@ -41,6 +41,11 @@ testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion) ...@@ -41,6 +41,11 @@ testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion)
VIR_DOMAIN_XML_INACTIVE))) VIR_DOMAIN_XML_INACTIVE)))
goto fail; goto fail;
if (!virDomainDefCheckABIStability(def, def)) {
fprintf(stderr, "ABI stability check failed on %s", xml);
goto fail;
}
if (!(gotsexpr = xenFormatSxpr(NULL, def, xendConfigVersion))) if (!(gotsexpr = xenFormatSxpr(NULL, def, xendConfigVersion)))
goto fail; goto fail;
......
...@@ -97,6 +97,11 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version) ...@@ -97,6 +97,11 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
goto failure; goto failure;
} }
if (!virDomainDefCheckABIStability(def, def)) {
fprintf(stderr, "ABI stability check failed on %s", xml);
goto failure;
}
formatted = virVMXFormatConfig(&ctx, xmlopt, def, virtualHW_version); formatted = virVMXFormatConfig(&ctx, xmlopt, def, virtualHW_version);
if (formatted == NULL) { if (formatted == NULL) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册