Unable to create VM with some RAW data

Hello.

We upgraded our OpenNebula to 5.12.1 successfully (with minor documentation issues #4998 and #4999).

There is a regression in the hanling of RAW data.

We build some template with several devices RAW data like:

RAW=[
  DATA="	<devices>
		<controller type='scsi' index='0' model='virtio-scsi'>
			<driver queues='2'/>
		</controller>
	</devices>
	<devices>
		<video>
			<model type='vga' vram='16384' heads='1'/>
		</video>
	</devices>",
  TYPE="kvm" ]

it was working fine with 5.10.1 but fails with 5.12:

Mon Jul 27 12:14:24 2020 [Z0][ONE][E]: Invalid RAW section: cannot validate DATA with domain.rng schema
Mon Jul 27 12:14:24 2020 [Z0][ReM][E]: Req:2304 UID:4 one.vm.allocate result FAILURE [one.vm.allocate] Invalid RAW section: cannot validate DATA with domain.rng schema

When I remove one <devices /> element, it’s working.

Having several <devices /> entries is not a problem for libvirt since OpenNebula generate itself deployment.0 files containing several ones:

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
	<name>one-388035</name>
	<title>etb1.horus</title>
	<vcpu><![CDATA[4]]></vcpu>
	<cputune>
		<shares>205</shares>
	</cputune>
	<memory>3145728</memory>
	<os>
		<type arch='x86_64'>hvm</type>
	</os>
	<devices>
		<emulator><![CDATA[/usr/bin/qemu-system-x86_64]]></emulator>
		<disk type='file' device='disk'>
			<source file='/var/lib/one//datastores/0/388035/disk.0'/>
			<target dev='sda'/>
			<boot order='1'/>
			<driver name='qemu' type='qcow2' cache='none' discard='unmap'/>
			<address type='drive' controller='0' bus='0' target='0' unit='0'/>
		</disk>
		<disk type='file' device='disk'>
			<source file='/var/lib/one//datastores/0/388035/disk.1'/>
			<target dev='sdb'/>
			<driver name='qemu' type='qcow2' cache='none' discard='unmap'/>
			<address type='drive' controller='0' bus='0' target='1' unit='0'/>
		</disk>
		<disk type='file' device='cdrom'>
			<source file='/var/lib/one//datastores/0/388035/disk.2'/>
			<target dev='hda' bus='ide'/>
			<readonly/>
			<driver name='qemu' type='raw'/>
		</disk>
		<interface type='bridge'>
			<virtualport type='openvswitch'/>
			<source bridge='nebula'/>
			<mac address='02:00:0a:01:01:65'/>
			<target dev='one-388035-0'/>
			<model type='virtio'/>
		</interface>
		<graphics type='vnc' listen='vnc.localdomain' port='36125' keymap='fr'/>
		<input type='tablet' bus='usb'/>
	</devices>
	<features>
		<acpi/>
	</features>
	<devices>
		<controller type='scsi' index='0' model='virtio-scsi'>
			<driver queues='2'/>
		</controller>
	</devices>

Is there a way to switch off the check since we can’t rework the way we generate our template to merge entries before 3 weeks (thanks to hollydays ;-))?

Regards

I found my answer: there is a libvirt schema, I added a ZeroOrMore

@@ -4960,57 +4960,59 @@
     </element>
   </define>
   <define name="devices">
-    <element name="devices">
-      <interleave>
-        <optional>
-          <ref name="emulator"/>
-        </optional>
-        <zeroOrMore>
-          <choice>
-            <ref name="disk"/>
-            <ref name="controller"/>
-            <ref name="lease"/>
-            <ref name="filesystem"/>
-            <ref name="interface"/>
-            <ref name="input"/>
-            <ref name="sound"/>
-            <ref name="hostdev"/>
-            <ref name="graphic"/>
-            <ref name="video"/>
-            <ref name="console"/>
-            <ref name="parallel"/>
-            <ref name="serial"/>
-            <ref name="channel"/>
-            <ref name="smartcard"/>
-            <ref name="hub"/>
-            <ref name="redirdev"/>
-            <ref name="redirfilter"/>
-            <ref name="rng"/>
-            <ref name="tpm"/>
-            <ref name="shmem"/>
-            <ref name="memorydev"/>
-          </choice>
-        </zeroOrMore>
-        <optional>
-          <ref name="watchdog"/>
-        </optional>
-        <optional>
-          <ref name="memballoon"/>
-        </optional>
-        <optional>
-          <ref name="nvram"/>
-        </optional>
-        <zeroOrMore>
-          <ref name="panic"/>
-        </zeroOrMore>
-        <optional>
-          <ref name="iommu"/>
-        </optional>
-        <optional>
-          <ref name="vsock"/>
-        </optional>
-      </interleave>
-    </element>
+    <zeroOrMore>
+      <element name="devices">
+	<interleave>
+          <optional>
+            <ref name="emulator"/>
+          </optional>
+          <zeroOrMore>
+            <choice>
+              <ref name="disk"/>
+              <ref name="controller"/>
+              <ref name="lease"/>
+              <ref name="filesystem"/>
+              <ref name="interface"/>
+              <ref name="input"/>
+              <ref name="sound"/>
+              <ref name="hostdev"/>
+              <ref name="graphic"/>
+              <ref name="video"/>
+              <ref name="console"/>
+              <ref name="parallel"/>
+              <ref name="serial"/>
+              <ref name="channel"/>
+              <ref name="smartcard"/>
+              <ref name="hub"/>
+              <ref name="redirdev"/>
+              <ref name="redirfilter"/>
+              <ref name="rng"/>
+              <ref name="tpm"/>
+              <ref name="shmem"/>
+              <ref name="memorydev"/>
+            </choice>
+          </zeroOrMore>
+          <optional>
+            <ref name="watchdog"/>
+          </optional>
+          <optional>
+            <ref name="memballoon"/>
+          </optional>
+          <optional>
+            <ref name="nvram"/>
+          </optional>
+          <zeroOrMore>
+            <ref name="panic"/>
+          </zeroOrMore>
+          <optional>
+            <ref name="iommu"/>
+          </optional>
+          <optional>
+            <ref name="vsock"/>
+          </optional>
+	</interleave>
+      </element>
+    </zeroOrMore>
   </define>
   <!--
       A set of optional features: PAE, APIC, ACPI, GIC,

I’ll proposed a pull request.

Thanks.

1 Like

Or better:

diff --git a/share/schemas/libvirt/domaincommon.rng b/share/schemas/libvirt/domaincommon.rng
index a83c9ae7a..b76e2569b 100644
--- a/share/schemas/libvirt/domaincommon.rng
+++ b/share/schemas/libvirt/domaincommon.rng
@@ -63,9 +63,9 @@
         <optional>
           <ref name="idmap"/>
         </optional>
-        <optional>
+        <zeroOrMore>
           <ref name="devices"/>
-        </optional>
+        </zeroOrMore>
         <zeroOrMore>
           <ref name="seclabel"/>
         </zeroOrMore>

This is not the only problem. I can no longer add

<os><smbios mode=‘sysinfo’/></os>

This used to work in previous versions to add smbios information. Any idea how this could be fixed as well?

tino via OpenNebula Community opennebula@discoursemail.com writes:

This is not the only problem. I can no longer add

<os><smbios mode=‘sysinfo’/></os>

This used to work in previous versions to add smbios information. Any idea how this could be fixed as well?

I may badly read the RNG schema but it’s probably because it’s not listed here:

https://github.com/OpenNebula/one/blob/master/share/schemas/libvirt/domaincommon.rng#L52

but it should according to the documentation :

https://libvirt.org/formatdomain.html#elementsSysinfo

Regards.

I think there is a section starting at 5323, which should be the correct element. However it does not work. I tried a few things with little success. Is there a way to debug this is better error messages?

Hi,

This change was introduced to address https://github.com/OpenNebula/one/issues/3953. So an incorrect RAW section is detected prior to deployment. I can only think of adding a switch to disable validation, also as a work around you can try to replace the schema for a catch any document (something in the line of https://stackoverflow.com/questions/13424960/how-to-write-anything-goes-in-relax-ng).

I’ve filled an issue to address this https://github.com/OpenNebula/one/issues/5015 Please feel free to add any additional comment to the proposed strategy there.

THANKS!

Hi,

disabling strict checking is a good option (also for edge cases).
I think that the change to verify the RAW data is a good default. I had various deployment errors due to incorrect RAW sections in the past.
For this specific problem, I do not really understand why the check fails because I believe that everything is in the domaincommon.ng or so I think…

What am I missing?