[RFC] domain xml validation for source elements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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">
    ...
    <interleave>
      <optional>
        <element name="source">
          <optional>
            <attribute name="file">
              <ref name="absFilePath"/>
            </attribute>
          </optional>
          ...
        </element>
      </optional>
    </interleave>
  </define>

  <define name="absFilePath">
    <data type="string">
<param name="pattern">/[a-zA-Z0-9_\.\+\-\\&amp;&quot;&apos;&lt;&gt;/%,:]+</param>
    </data>
  </define>

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'/>
    </disk>

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 virDomainDiskSourceParse).


--
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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]