]> xenbits.xensource.com Git - libvirt.git/commitdiff
xenconfig: xm: check for driver on disk format
authorJoao Martins <joao.m.martins@oracle.com>
Tue, 24 May 2016 10:56:08 +0000 (11:56 +0100)
committerJim Fehlig <jfehlig@suse.com>
Wed, 25 May 2016 01:19:50 +0000 (19:19 -0600)
When reviewing libxl vif typename series[0] I found a bug
on xen-xm formatter where "virsh domxml-to-native xen-xm file.xml"
can lead to a NULL dereference if the disk driver isn't specified.
Fix this by checking for driver before writing/testing it down.

[0] https://www.redhat.com/archives/libvir-list/2016-April/msg01434.html

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
src/xenconfig/xen_xm.c

index 34d57de1d07cc8916d474a7b95a5514fb9b84430..3658c59797fc0d462ea8ccb37499f10ded4001ba 100644 (file)
@@ -297,9 +297,12 @@ xenFormatXMDisk(virConfValuePtr list,
                 type = "aio";
             else
                 type = virStorageFileFormatTypeToString(format);
-            virBufferAsprintf(&buf, "%s:", driver);
-            if (STREQ(driver, "tap"))
-                virBufferAsprintf(&buf, "%s:", type);
+
+            if (driver) {
+                virBufferAsprintf(&buf, "%s:", driver);
+                if (STREQ(driver, "tap"))
+                    virBufferAsprintf(&buf, "%s:", type);
+            }
         } else {
             switch (virDomainDiskGetType(disk)) {
             case VIR_STORAGE_TYPE_FILE: