mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 12:05:17 +00:00
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:
parent
dd0dda2e4a
commit
53a699a07b
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user