[libvirt] [RFC] domain xml validation for source elements

Boris Fiuczynski fiuczy at linux.vnet.ibm.com
Wed Jul 22 11:43:12 UTC 2015

I ran into a problem that was caused by a missing leading slash (/) in 
the value of the file attribute of a disks source element.
Defining the domain worked without a problem.
Editing the domain and trying to save it resulted in a very generic 
error message:

error: XML document failed to validate against schema: Unable to 
validate doc against /usr/share/libvirt/schemas/domain.rng
Extra element devices in interleave
Element domain failed to validate content

Failed. Try again? [y,n,i,f,?]:

It took me some time to find out that the schema defines in absFilePath 
a leading slash as required for a fully qualified file path but the C 
code parsing does not require/validate it.

   <define name="diskSourceFile">
         <element name="source">
             <attribute name="file">
               <ref name="absFilePath"/>

   <define name="absFilePath">
     <data type="string">

I tried to fix the behavior by implementing additional validation code 
in method virDomainDiskSourceParse checking for the leading slash on the 
absolute file path.
This resulted in breaking the VMware tests (xml2vmxtest), e.g.
8) VMware XML-2-VMX cdrom-scsi-file -> cdrom-scsi-file

When looking at the related test data I found:
     <disk type='file' device='cdrom'>
       <source file='[testing] isos/cdrom.iso'/>
       <target dev='sda' bus='scsi'/>

Besides the fact that the file path string also contains the characters 
space, opening and closing square brackets which are not specified as 
valid characters the file path string does not have a leading slash but 
instead some kind of 'datastore' specific name.

What is the way to approach this since I am not a VMware user?
1) Change the schema to include the missing characters and removing the 
requirement for the leading slash and include additional schema aligned 
validation in the parsing code (method virDomainDiskSourceParse) or
2) fix the VMware tests to use absolute paths only and include 
additional schema aligned validation in the parsing code (method 

Mit freundlichen Grüßen/Kind regards
    Boris Fiuczynski

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martina Köderitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

More information about the libvir-list mailing list