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@xxxxxxxxxx> --- src/conf/domain_conf.c | 2 +- tests/lxcxml2xmltest.c | 5 +++++ tests/qemuargv2xmltest.c | 5 +++++ tests/qemuxml2argvtest.c | 5 +++++ tests/qemuxml2xmltest.c | 5 +++++ tests/qemuxmlnstest.c | 5 +++++ tests/sexpr2xmltest.c | 5 +++++ tests/vmx2xmltest.c | 5 +++++ tests/xmconfigtest.c | 5 +++++ tests/xml2sexprtest.c | 5 +++++ tests/xml2vmxtest.c | 5 +++++ 11 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 416d96e..c1dd598 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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); diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c index a028e39..b7d35c1 100644 --- a/tests/lxcxml2xmltest.c +++ b/tests/lxcxml2xmltest.c @@ -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; diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index 0bf4c37..1b13fcc 100644 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -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; diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index b90f0e7..b0cfa60 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -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 diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 89de0c9..41d1904 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -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; diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c index 2093e1e..9426bf7 100644 --- a/tests/qemuxmlnstest.c +++ b/tests/qemuxmlnstest.c @@ -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 diff --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c index f8b0661..c2710c2 100644 --- a/tests/sexpr2xmltest.c +++ b/tests/sexpr2xmltest.c @@ -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; diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 13515f0..5c3b60e 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -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; diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index c8014e1..0590333 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -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; diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c index a4d2b14..deb2fce 100644 --- a/tests/xml2sexprtest.c +++ b/tests/xml2sexprtest.c @@ -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; diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 2f2db60..242b854 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -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) { -- 1.8.4.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list