Change in vdsm[ovirt-3.6]: caps: more precise emulated machines selection

fromani at redhat.com fromani at redhat.com
Tue Sep 8 11:24:54 UTC 2015


Hello Dan Kenigsberg, Martin Polednik,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/45850

to review the following change.

Change subject: caps: more precise emulated machines selection
......................................................................

caps: more precise emulated machines selection

Current VDSM code fetches emulated machines from the section which matches
first the required architecture.
This works in the simplest (and the only recommended) case, but doesn't
if, for any reason, there is more than one valid emulatore for a given
architecture.

The only known case is if the user managed to install qemu-kvm alongside
plain qemu.

This patch implements more robust capabilities fetching to deal with
this corner case.

Change-Id: I4deebbc90bf1cec53fc40bc6a35c6ada933296c3
Bug-Url: https://bugzilla.redhat.com/1239258
Signed-off-by: Francesco Romani <fromani at redhat.com>
Reviewed-on: https://gerrit.ovirt.org/45257
Continuous-Integration: Jenkins CI
Reviewed-by: Martin Polednik <mpolednik at redhat.com>
Reviewed-by: Dan Kenigsberg <danken at redhat.com>
---
M tests/Makefile.am
M tests/capsTests.py
A tests/caps_libvirt_multiqemu.out
M vdsm.spec.in
M vdsm/caps.py
5 files changed, 606 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/50/45850/1

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 174982c..e247551 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -154,6 +154,7 @@
 	caps_libvirt_intel_E5606.out \
 	caps_libvirt_intel_i73770.out \
 	caps_libvirt_intel_i73770_nosnap.out \
+	caps_libvirt_multiqemu.out \
 	cpu_map.xml \
 	caps_numactl_4_nodes.out \
 	glusterGeoRepStatus.xml \
diff --git a/tests/capsTests.py b/tests/capsTests.py
index 1bdccce..a70de5f 100644
--- a/tests/capsTests.py
+++ b/tests/capsTests.py
@@ -317,6 +317,24 @@
                     'pc-i440fx-rhel7.0.0']
         self.assertEqual(expected, result)
 
+    def test_getEmulatedMachinesWithTwoQEMUInstalled(self):
+        capsData = self._readCaps("caps_libvirt_multiqemu.out")
+        result = caps._getEmulatedMachines('x86_64', capsData)
+        expected = ['pc-i440fx-rhel7.1.0',
+                    'rhel6.3.0',
+                    'pc-q35-rhel7.0.0',
+                    'rhel6.1.0',
+                    'rhel6.6.0',
+                    'rhel6.2.0',
+                    'pc',
+                    'pc-q35-rhel7.1.0',
+                    'q35',
+                    'rhel6.4.0',
+                    'rhel6.0.0',
+                    'rhel6.5.0',
+                    'pc-i440fx-rhel7.0.0']
+        self.assertEqual(expected, result)
+
     def test_getNumaTopology(self):
         capsData = self._readCaps("caps_libvirt_intel_i73770_nosnap.out")
         result = caps.getNumaTopology(capsData)
diff --git a/tests/caps_libvirt_multiqemu.out b/tests/caps_libvirt_multiqemu.out
new file mode 100644
index 0000000..38e962f
--- /dev/null
+++ b/tests/caps_libvirt_multiqemu.out
@@ -0,0 +1,547 @@
+<capabilities>
+
+  <host>
+    <uuid>8760ad12-e4e8-43ca-8a11-93c59fbf148d</uuid>
+    <cpu>
+      <arch>x86_64</arch>
+      <model>SandyBridge</model>
+      <vendor>Intel</vendor>
+      <topology sockets='1' cores='6' threads='2'/>
+      <feature name='invtsc'/>
+      <feature name='invpcid'/>
+      <feature name='erms'/>
+      <feature name='bmi2'/>
+      <feature name='smep'/>
+      <feature name='avx2'/>
+      <feature name='bmi1'/>
+      <feature name='fsgsbase'/>
+      <feature name='abm'/>
+      <feature name='pdpe1gb'/>
+      <feature name='rdrand'/>
+      <feature name='f16c'/>
+      <feature name='osxsave'/>
+      <feature name='movbe'/>
+      <feature name='dca'/>
+      <feature name='pcid'/>
+      <feature name='pdcm'/>
+      <feature name='xtpr'/>
+      <feature name='fma'/>
+      <feature name='tm2'/>
+      <feature name='est'/>
+      <feature name='smx'/>
+      <feature name='vmx'/>
+      <feature name='ds_cpl'/>
+      <feature name='monitor'/>
+      <feature name='dtes64'/>
+      <feature name='pbe'/>
+      <feature name='tm'/>
+      <feature name='ht'/>
+      <feature name='ss'/>
+      <feature name='acpi'/>
+      <feature name='ds'/>
+      <feature name='vme'/>
+      <pages unit='KiB' size='4'/>
+      <pages unit='KiB' size='2048'/>
+    </cpu>
+    <power_management>
+      <suspend_mem/>
+    </power_management>
+    <migration_features>
+      <live/>
+      <uri_transports>
+        <uri_transport>tcp</uri_transport>
+        <uri_transport>rdma</uri_transport>
+      </uri_transports>
+    </migration_features>
+    <topology>
+      <cells num='2'>
+        <cell id='0'>
+          <memory unit='KiB'>33444704</memory>
+          <pages unit='KiB' size='4'>8361176</pages>
+          <pages unit='KiB' size='2048'>0</pages>
+          <distances>
+            <sibling id='0' value='10'/>
+            <sibling id='1' value='21'/>
+          </distances>
+          <cpus num='12'>
+            <cpu id='0' socket_id='0' core_id='0' siblings='0,12'/>
+            <cpu id='1' socket_id='0' core_id='1' siblings='1,13'/>
+            <cpu id='2' socket_id='0' core_id='2' siblings='2,14'/>
+            <cpu id='3' socket_id='0' core_id='3' siblings='3,15'/>
+            <cpu id='4' socket_id='0' core_id='4' siblings='4,16'/>
+            <cpu id='5' socket_id='0' core_id='5' siblings='5,17'/>
+            <cpu id='12' socket_id='0' core_id='0' siblings='0,12'/>
+            <cpu id='13' socket_id='0' core_id='1' siblings='1,13'/>
+            <cpu id='14' socket_id='0' core_id='2' siblings='2,14'/>
+            <cpu id='15' socket_id='0' core_id='3' siblings='3,15'/>
+            <cpu id='16' socket_id='0' core_id='4' siblings='4,16'/>
+            <cpu id='17' socket_id='0' core_id='5' siblings='5,17'/>
+          </cpus>
+        </cell>
+        <cell id='1'>
+          <memory unit='KiB'>33554432</memory>
+          <pages unit='KiB' size='4'>8388608</pages>
+          <pages unit='KiB' size='2048'>0</pages>
+          <distances>
+            <sibling id='0' value='21'/>
+            <sibling id='1' value='10'/>
+          </distances>
+          <cpus num='12'>
+            <cpu id='6' socket_id='1' core_id='0' siblings='6,18'/>
+            <cpu id='7' socket_id='1' core_id='1' siblings='7,19'/>
+            <cpu id='8' socket_id='1' core_id='2' siblings='8,20'/>
+            <cpu id='9' socket_id='1' core_id='3' siblings='9,21'/>
+            <cpu id='10' socket_id='1' core_id='4' siblings='10,22'/>
+            <cpu id='11' socket_id='1' core_id='5' siblings='11,23'/>
+            <cpu id='18' socket_id='1' core_id='0' siblings='6,18'/>
+            <cpu id='19' socket_id='1' core_id='1' siblings='7,19'/>
+            <cpu id='20' socket_id='1' core_id='2' siblings='8,20'/>
+            <cpu id='21' socket_id='1' core_id='3' siblings='9,21'/>
+            <cpu id='22' socket_id='1' core_id='4' siblings='10,22'/>
+            <cpu id='23' socket_id='1' core_id='5' siblings='11,23'/>
+          </cpus>
+        </cell>
+      </cells>
+    </topology>
+    <secmodel>
+      <model>selinux</model>
+      <doi>0</doi>
+      <baselabel type='kvm'>system_u:system_r:svirt_t:s0</baselabel>
+      <baselabel type='qemu'>system_u:system_r:svirt_tcg_t:s0</baselabel>
+    </secmodel>
+    <secmodel>
+      <model>dac</model>
+      <doi>0</doi>
+      <baselabel type='kvm'>+107:+107</baselabel>
+      <baselabel type='qemu'>+107:+107</baselabel>
+    </secmodel>
+  </host>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='alpha'>
+      <wordsize>64</wordsize>
+      <emulator>/usr/bin/qemu-system-alpha</emulator>
+      <machine maxCpus='4'>clipper</machine>
+      <domain type='qemu'>
+      </domain>
+    </arch>
+    <features>
+      <deviceboot/>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='armv7l'>
+      <wordsize>32</wordsize>
+      <emulator>/usr/bin/qemu-system-arm</emulator>
+      <machine maxCpus='1'>borzoi</machine>
+      <machine maxCpus='4'>virt</machine>
+      <machine maxCpus='4'>midway</machine>
+      <machine maxCpus='1'>tosa</machine>
+      <machine maxCpus='1'>cheetah</machine>
+      <machine maxCpus='1'>realview-pb-a8</machine>
+      <machine maxCpus='1'>collie</machine>
+      <machine maxCpus='1'>n800</machine>
+      <machine maxCpus='4'>highbank</machine>
+      <machine maxCpus='1'>kzm</machine>
+      <machine maxCpus='1'>integratorcp</machine>
+      <machine maxCpus='1'>sx1-v1</machine>
+      <machine maxCpus='2'>smdkc210</machine>
+      <machine maxCpus='1'>akita</machine>
+      <machine maxCpus='1'>canon-a1100</machine>
+      <machine maxCpus='1'>spitz</machine>
+      <machine maxCpus='1'>verdex</machine>
+      <machine maxCpus='1'>xilinx-zynq-a9</machine>
+      <machine maxCpus='4'>realview-eb-mpcore</machine>
+      <machine maxCpus='2'>nuri</machine>
+      <machine maxCpus='4'>vexpress-a15</machine>
+      <machine maxCpus='1'>n810</machine>
+      <machine maxCpus='1'>terrier</machine>
+      <machine maxCpus='1'>mainstone</machine>
+      <machine maxCpus='1'>musicpal</machine>
+      <machine maxCpus='4'>realview-pbx-a9</machine>
+      <machine maxCpus='1'>lm3s6965evb</machine>
+      <machine maxCpus='4'>vexpress-a9</machine>
+      <machine maxCpus='1'>cubieboard</machine>
+      <machine maxCpus='1'>realview-eb</machine>
+      <machine maxCpus='1'>sx1</machine>
+      <machine maxCpus='1'>connex</machine>
+      <machine maxCpus='1'>z2</machine>
+      <machine maxCpus='1'>lm3s811evb</machine>
+      <machine maxCpus='1'>versatilepb</machine>
+      <machine maxCpus='1'>versatileab</machine>
+      <domain type='qemu'>
+      </domain>
+    </arch>
+    <features>
+      <cpuselection/>
+      <deviceboot/>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='cris'>
+      <wordsize>32</wordsize>
+      <emulator>/usr/bin/qemu-system-cris</emulator>
+      <machine maxCpus='1'>axis-dev88</machine>
+      <domain type='qemu'>
+      </domain>
+    </arch>
+    <features>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='i686'>
+      <wordsize>32</wordsize>
+      <emulator>/usr/bin/qemu-system-i386</emulator>
+      <machine canonical='pc-i440fx-2.0' maxCpus='255'>pc</machine>
+      <machine maxCpus='255'>pc-0.12</machine>
+      <machine maxCpus='255'>pc-1.3</machine>
+      <machine maxCpus='255'>pc-q35-1.6</machine>
+      <machine maxCpus='255'>pc-q35-1.5</machine>
+      <machine maxCpus='255'>pc-i440fx-1.6</machine>
+      <machine maxCpus='255'>pc-i440fx-1.7</machine>
+      <machine maxCpus='255'>pc-0.11</machine>
+      <machine maxCpus='255'>pc-0.10</machine>
+      <machine maxCpus='255'>pc-1.2</machine>
+      <machine maxCpus='1'>isapc</machine>
+      <machine maxCpus='255'>pc-q35-1.4</machine>
+      <machine maxCpus='255'>pc-0.15</machine>
+      <machine maxCpus='255'>pc-0.14</machine>
+      <machine maxCpus='255'>pc-i440fx-1.5</machine>
+      <machine canonical='pc-q35-2.0' maxCpus='255'>q35</machine>
+      <machine maxCpus='255'>pc-i440fx-1.4</machine>
+      <machine maxCpus='255'>pc-1.1</machine>
+      <machine maxCpus='255'>pc-q35-1.7</machine>
+      <machine maxCpus='255'>pc-1.0</machine>
+      <machine maxCpus='255'>pc-0.13</machine>
+      <domain type='qemu'>
+      </domain>
+      <domain type='kvm'>
+        <emulator>/usr/libexec/qemu-kvm</emulator>
+        <machine canonical='pc-i440fx-rhel7.1.0' maxCpus='240'>pc</machine>
+        <machine maxCpus='240'>rhel6.6.0</machine>
+        <machine maxCpus='240'>pc-q35-rhel7.0.0</machine>
+        <machine maxCpus='240'>rhel6.4.0</machine>
+        <machine canonical='pc-q35-rhel7.1.0' maxCpus='240'>q35</machine>
+        <machine maxCpus='240'>pc-i440fx-rhel7.0.0</machine>
+        <machine maxCpus='240'>rhel6.2.0</machine>
+        <machine maxCpus='240'>rhel6.1.0</machine>
+        <machine maxCpus='240'>rhel6.5.0</machine>
+        <machine maxCpus='240'>rhel6.0.0</machine>
+        <machine maxCpus='240'>rhel6.3.0</machine>
+      </domain>
+    </arch>
+    <features>
+      <cpuselection/>
+      <deviceboot/>
+      <disksnapshot default='on' toggle='no'/>
+      <acpi default='on' toggle='yes'/>
+      <apic default='on' toggle='no'/>
+      <pae/>
+      <nonpae/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='lm32'>
+      <wordsize>32</wordsize>
+      <emulator>/usr/bin/qemu-system-lm32</emulator>
+      <machine maxCpus='1'>lm32-evr</machine>
+      <machine maxCpus='1'>milkymist</machine>
+      <machine maxCpus='1'>lm32-uclinux</machine>
+      <domain type='qemu'>
+      </domain>
+    </arch>
+    <features>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='m68k'>
+      <wordsize>32</wordsize>
+      <emulator>/usr/bin/qemu-system-m68k</emulator>
+      <machine maxCpus='1'>mcf5208evb</machine>
+      <machine maxCpus='1'>dummy</machine>
+      <machine maxCpus='1'>an5206</machine>
+      <domain type='qemu'>
+      </domain>
+    </arch>
+    <features>
+      <deviceboot/>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='microblaze'>
+      <wordsize>32</wordsize>
+      <emulator>/usr/bin/qemu-system-microblaze</emulator>
+      <machine maxCpus='1'>petalogix-s3adsp1800</machine>
+      <machine maxCpus='1'>petalogix-ml605</machine>
+      <domain type='qemu'>
+      </domain>
+    </arch>
+    <features>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='microblazeel'>
+      <wordsize>32</wordsize>
+      <emulator>/usr/bin/qemu-system-microblazeel</emulator>
+      <machine maxCpus='1'>petalogix-s3adsp1800</machine>
+      <machine maxCpus='1'>petalogix-ml605</machine>
+      <domain type='qemu'>
+      </domain>
+    </arch>
+    <features>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='mips'>
+      <wordsize>32</wordsize>
+      <emulator>/usr/bin/qemu-system-mips</emulator>
+      <machine maxCpus='16'>malta</machine>
+      <machine maxCpus='1'>mipssim</machine>
+      <machine maxCpus='1'>magnum</machine>
+      <machine maxCpus='1'>pica61</machine>
+      <machine maxCpus='1'>mips</machine>
+      <domain type='qemu'>
+      </domain>
+    </arch>
+    <features>
+      <deviceboot/>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='mipsel'>
+      <wordsize>32</wordsize>
+      <emulator>/usr/bin/qemu-system-mipsel</emulator>
+      <machine maxCpus='16'>malta</machine>
+      <machine maxCpus='1'>mipssim</machine>
+      <machine maxCpus='1'>magnum</machine>
+      <machine maxCpus='1'>pica61</machine>
+      <machine maxCpus='1'>mips</machine>
+      <domain type='qemu'>
+      </domain>
+    </arch>
+    <features>
+      <deviceboot/>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='mips64'>
+      <wordsize>64</wordsize>
+      <emulator>/usr/bin/qemu-system-mips64</emulator>
+      <machine maxCpus='16'>malta</machine>
+      <machine maxCpus='1'>mipssim</machine>
+      <machine maxCpus='1'>magnum</machine>
+      <machine maxCpus='1'>mips</machine>
+      <machine maxCpus='1'>pica61</machine>
+      <domain type='qemu'>
+      </domain>
+    </arch>
+    <features>
+      <deviceboot/>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='mips64el'>
+      <wordsize>64</wordsize>
+      <emulator>/usr/bin/qemu-system-mips64el</emulator>
+      <machine maxCpus='16'>malta</machine>
+      <machine maxCpus='1'>fulong2e</machine>
+      <machine maxCpus='1'>magnum</machine>
+      <machine maxCpus='1'>mipssim</machine>
+      <machine maxCpus='1'>mips</machine>
+      <machine maxCpus='1'>pica61</machine>
+      <domain type='qemu'>
+      </domain>
+    </arch>
+    <features>
+      <deviceboot/>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='s390x'>
+      <wordsize>64</wordsize>
+      <emulator>/usr/bin/qemu-system-s390x</emulator>
+      <machine canonical='s390-virtio' maxCpus='255'>s390</machine>
+      <machine canonical='s390-ccw-virtio' maxCpus='255'>s390-ccw</machine>
+      <domain type='qemu'>
+      </domain>
+    </arch>
+    <features>
+      <cpuselection/>
+      <deviceboot/>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='sh4'>
+      <wordsize>32</wordsize>
+      <emulator>/usr/bin/qemu-system-sh4</emulator>
+      <machine maxCpus='1'>shix</machine>
+      <machine maxCpus='1'>r2d</machine>
+      <domain type='qemu'>
+      </domain>
+    </arch>
+    <features>
+      <deviceboot/>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='sh4eb'>
+      <wordsize>64</wordsize>
+      <emulator>/usr/bin/qemu-system-sh4eb</emulator>
+      <machine maxCpus='1'>shix</machine>
+      <machine maxCpus='1'>r2d</machine>
+      <domain type='qemu'>
+      </domain>
+    </arch>
+    <features>
+      <deviceboot/>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='unicore32'>
+      <wordsize>32</wordsize>
+      <emulator>/usr/bin/qemu-system-unicore32</emulator>
+      <machine maxCpus='1'>puv3</machine>
+      <domain type='qemu'>
+      </domain>
+    </arch>
+    <features>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='x86_64'>
+      <wordsize>64</wordsize>
+      <emulator>/usr/bin/qemu-system-x86_64</emulator>
+      <machine canonical='pc-i440fx-2.0' maxCpus='255'>pc</machine>
+      <machine maxCpus='255'>pc-1.3</machine>
+      <machine maxCpus='255'>pc-0.12</machine>
+      <machine maxCpus='255'>pc-q35-1.6</machine>
+      <machine maxCpus='255'>pc-q35-1.5</machine>
+      <machine maxCpus='255'>pc-i440fx-1.6</machine>
+      <machine maxCpus='255'>pc-i440fx-1.7</machine>
+      <machine maxCpus='255'>pc-0.11</machine>
+      <machine maxCpus='255'>pc-1.2</machine>
+      <machine maxCpus='255'>pc-0.10</machine>
+      <machine maxCpus='1'>isapc</machine>
+      <machine maxCpus='255'>pc-q35-1.4</machine>
+      <machine maxCpus='255'>pc-0.15</machine>
+      <machine maxCpus='255'>pc-0.14</machine>
+      <machine maxCpus='255'>pc-i440fx-1.5</machine>
+      <machine maxCpus='255'>pc-i440fx-1.4</machine>
+      <machine canonical='pc-q35-2.0' maxCpus='255'>q35</machine>
+      <machine maxCpus='255'>pc-1.1</machine>
+      <machine maxCpus='255'>pc-q35-1.7</machine>
+      <machine maxCpus='255'>pc-1.0</machine>
+      <machine maxCpus='255'>pc-0.13</machine>
+      <domain type='qemu'>
+      </domain>
+      <domain type='kvm'>
+        <emulator>/usr/libexec/qemu-kvm</emulator>
+        <machine canonical='pc-i440fx-rhel7.1.0' maxCpus='240'>pc</machine>
+        <machine maxCpus='240'>rhel6.6.0</machine>
+        <machine maxCpus='240'>pc-q35-rhel7.0.0</machine>
+        <machine maxCpus='240'>rhel6.4.0</machine>
+        <machine canonical='pc-q35-rhel7.1.0' maxCpus='240'>q35</machine>
+        <machine maxCpus='240'>pc-i440fx-rhel7.0.0</machine>
+        <machine maxCpus='240'>rhel6.2.0</machine>
+        <machine maxCpus='240'>rhel6.1.0</machine>
+        <machine maxCpus='240'>rhel6.5.0</machine>
+        <machine maxCpus='240'>rhel6.0.0</machine>
+        <machine maxCpus='240'>rhel6.3.0</machine>
+      </domain>
+    </arch>
+    <features>
+      <cpuselection/>
+      <deviceboot/>
+      <disksnapshot default='on' toggle='no'/>
+      <acpi default='on' toggle='yes'/>
+      <apic default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='xtensa'>
+      <wordsize>32</wordsize>
+      <emulator>/usr/bin/qemu-system-xtensa</emulator>
+      <machine maxCpus='4'>sim</machine>
+      <machine maxCpus='4'>lx60</machine>
+      <machine maxCpus='4'>kc705</machine>
+      <machine maxCpus='4'>ml605</machine>
+      <machine maxCpus='4'>lx200</machine>
+      <domain type='qemu'>
+      </domain>
+    </arch>
+    <features>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='xtensaeb'>
+      <wordsize>32</wordsize>
+      <emulator>/usr/bin/qemu-system-xtensaeb</emulator>
+      <machine maxCpus='4'>sim</machine>
+      <machine maxCpus='4'>kc705</machine>
+      <machine maxCpus='4'>ml605</machine>
+      <machine maxCpus='4'>lx200</machine>
+      <machine maxCpus='4'>lx60</machine>
+      <domain type='qemu'>
+      </domain>
+    </arch>
+    <features>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+</capabilities>
+
+
diff --git a/vdsm.spec.in b/vdsm.spec.in
index f0e061e..9a38359 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1101,6 +1101,7 @@
 %{_datadir}/%{vdsm_name}/tests/caps_libvirt_intel_E5606.out
 %{_datadir}/%{vdsm_name}/tests/caps_libvirt_intel_i73770.out
 %{_datadir}/%{vdsm_name}/tests/caps_libvirt_intel_i73770_nosnap.out
+%{_datadir}/%{vdsm_name}/tests/caps_libvirt_multiqemu.out
 %{_datadir}/%{vdsm_name}/tests/caps_numactl_4_nodes.out
 %{_datadir}/%{vdsm_name}/tests/cpu_map.xml
 %{_datadir}/%{vdsm_name}/tests/devices/*.py*
diff --git a/vdsm/caps.py b/vdsm/caps.py
index 89c96ba..c0cb2f6 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -381,25 +381,51 @@
         return AutoNumaBalancingStatus.UNKNOWN
 
 
+def _get_emulated_machines_from_node(node):
+    # We have to make sure to inspect 'canonical' attribute where
+    # libvirt puts the real machine name. Relevant bug:
+    # https://bugzilla.redhat.com/show_bug.cgi?id=1229666
+    return list(set((itertools.chain.from_iterable(
+        (
+            (m.text, m.get('canonical'))
+            if m.get('canonical') else
+            (m.text,)
+        )
+        for m in node.iterfind('machine')))))
+
+
+def _get_emulated_machines_from_arch(arch, caps):
+    arch_tag = caps.find('.//guest/arch[@name="%s"]' % arch)
+    if not arch_tag:
+        logging.error('Error while looking for architecture '
+                      '"%s" in libvirt capabilities', arch)
+        return []
+
+    return _get_emulated_machines_from_node(arch_tag)
+
+
+def _get_emulated_machines_from_domain(arch, caps):
+    domain_tag = caps.find(
+        './/guest/arch[@name="%s"]/domain[@type="kvm"]' % arch)
+    if not domain_tag:
+        logging.error('Error while looking for kvm domain (%s) '
+                      'libvirt capabilities', arch)
+        return []
+
+    return _get_emulated_machines_from_node(domain_tag)
+
+
 @utils.memoized
 def _getEmulatedMachines(arch, capabilities=None):
     if capabilities is None:
         capabilities = _getCapsXMLStr()
     caps = ET.fromstring(capabilities)
 
-    for archTag in caps.iter(tag='arch'):
-        if archTag.get('name') == arch:
-            # We have to make sure to inspect 'canonical' attribute where
-            # libvirt puts the real machine name. Relevant bug:
-            # https://bugzilla.redhat.com/show_bug.cgi?id=1229666
-            return list(set((itertools.chain.from_iterable(
-                (
-                    (m.text, m.get('canonical')) if
-                    m.get('canonical') else (m.text,)
-                )
-                for m in archTag.iterfind('machine')))))
-
-    return []
+    # machine list from domain can legally be empty
+    # (e.g. only qemu-kvm installed)
+    # in that case it is fine to use machines list from arch
+    return (_get_emulated_machines_from_domain(arch, caps) or
+            _get_emulated_machines_from_arch(arch, caps))
 
 
 def _getAllCpuModels(capfile=CPU_MAP_FILE, arch=None):


-- 
To view, visit https://gerrit.ovirt.org/45850
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4deebbc90bf1cec53fc40bc6a35c6ada933296c3
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Martin Polednik <mpolednik at redhat.com>


More information about the vdsm-patches mailing list