]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Exercise the ABI stability check code in test suite
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 10 Jan 2014 17:18:03 +0000 (17:18 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 10 Jan 2014 20:32:48 +0000 (20:32 +0000)
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>
src/conf/domain_conf.c
tests/lxcxml2xmltest.c
tests/qemuargv2xmltest.c
tests/qemuxml2argvtest.c
tests/qemuxml2xmltest.c
tests/qemuxmlnstest.c
tests/sexpr2xmltest.c
tests/vmx2xmltest.c
tests/xmconfigtest.c
tests/xml2sexprtest.c
tests/xml2vmxtest.c

index 416d96e66815ab107c61b797e85bf2d66c56ec75..c1dd5987d4b128597c42f26d152ed5204ee60a84 100644 (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);
index c6bb70615793c0f4178bb9ae32de224bd65e1c22..af50dc5ebf8e6988a8af6daaa1324e9ef2148718 100644 (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;
 
index 0bf4c37d96b2238a137562cc721dc2112a795afe..1b13fcc8db353e6aa9d5606d1043f7433c469960 100644 (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;
 
index b90f0e79c2c527a582735a0a874dd4a889697c89..b0cfa608c0833a99c3b3c582a58b8efddc679a39 100644 (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
index 89de0c951c0906b992580db988334bd74b4b9e20..41d19047d0ff5507034c7b2d5644a3509b0d3392 100644 (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;
 
index 2093e1e1b21f2d791b4191715c56e6df71a8210e..9426bf757141914a63ac00a355842d48ae0dc1b5 100644 (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
index f8b06613647f275c1950efb08adff8b87c634d2a..c2710c27d78a1253fabe0a17264bfab84a924d0d 100644 (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;
 
index 13515f08836f0242c2d1264b1f7baa48274f5d60..5c3b60e22d5d0605935ec493f1c5cb60a09b9ef5 100644 (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;
 
index c8014e1d8eb1390abb0119dd33b087b1692e943e..05903333bd0cba5688174f4825e8cc676d7ac3fe 100644 (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;
 
index a4d2b14218857e1afd165382f485133a3b69c36a..deb2fced3b416d878f66f7da03e58f4981f111f0 100644 (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;
 
index 2f2db6070e6da1c6768ad6d47049e5e3d5ad46c6..242b8541301c95c90cec4651fe2d97357aec51eb 100644 (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) {