File 8126d870-libxl-cdrom-config-fix.patch of Package libvirt.6159

commit 8126d870783e69cfa9e9f8b366f21548c1abe3fa
Author: C├ędric Bosdonnat <cbosdonnat@suse.com>
Date:   Mon Oct 17 09:57:22 2016 +0200

    xl: don't output (null) target in domxml-to-native
    
    When converting a domain xml containing a CDROM device without
    any attached source, don't add a target=(null) to the libxl config
    disk definition: xen doesn't like it at all and would fail to start
    the domain.

Index: libvirt-2.0.0/src/xenconfig/xen_xl.c
===================================================================
--- libvirt-2.0.0.orig/src/xenconfig/xen_xl.c
+++ libvirt-2.0.0/src/xenconfig/xen_xl.c
@@ -976,7 +976,7 @@ xenFormatXLDisk(virConfValuePtr list, vi
 
     /* devtype */
     if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
-        virBufferAddLit(&buf, "devtype=cdrom,");
+        virBufferAddLit(&buf, "devtype=cdrom");
 
     /*
      * target
@@ -989,7 +989,8 @@ xenFormatXLDisk(virConfValuePtr list, vi
     if (xenFormatXLDiskSrc(disk->src, &target) < 0)
         goto cleanup;
 
-    virBufferAsprintf(&buf, "target=%s", target);
+    if (target)
+        virBufferAsprintf(&buf, ",target=%s", target);
 
     if (virBufferCheckError(&buf) < 0)
         goto cleanup;