[Kimchi-devel] [PATCH v4] On Ubuntu, current libvirt library requires <os><type arch=

thierry at linux.vnet.ibm.com thierry at linux.vnet.ibm.com
Mon Feb 2 09:37:19 UTC 2015


From: Thierry Fauck <thierry at linux.vnet.ibm.com>

 On Ubuntu, current libvirt library requires <os><type arch=
 specification to avoid a failure in virDomainDefineXML() and messages like
 - libvirtError: internal error: no supported architecture for os type 'hvm'  on
 x86_64 arch
 - libvirtError: XML error: No PCI buses available on ppc64el arch

Signed-off-by: Thierry Fauck <thierry at linux.vnet.ibm.com>


	modified:   src/kimchi/kvmusertests.py
	modified:   src/kimchi/model/featuretests.py
---
 src/kimchi/kvmusertests.py       | 16 +++++++++++-----
 src/kimchi/model/featuretests.py | 15 +++++++++++----
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/src/kimchi/kvmusertests.py b/src/kimchi/kvmusertests.py
index 2326727..fe7388a 100644
--- a/src/kimchi/kvmusertests.py
+++ b/src/kimchi/kvmusertests.py
@@ -16,24 +16,25 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
+import platform
 import psutil
 import uuid
 
-
 import libvirt
 
 
 from kimchi.rollbackcontext import RollbackContext
+from kimchi.utils import kimchi_log
 
 
 class UserTests(object):
     SIMPLE_VM_XML = """
     <domain type='kvm'>
-      <name>%s</name>
-      <uuid>%s</uuid>
+      <name>%(vm_name)s</name>
+      <uuid>%(vm_uuid)s</uuid>
       <memory unit='KiB'>262144</memory>
       <os>
-        <type>hvm</type>
+        <type arch='%(arch)s'>hvm</type>
         <boot dev='hd'/>
       </os>
     </domain>"""
@@ -46,8 +47,12 @@ class UserTests(object):
 
         vm_uuid = uuid.uuid1()
         vm_name = "kimchi_test_%s" % vm_uuid
+        arch = 'ppc64' if platform.machine() == 'ppc64le' \
+            else platform.machine()
+
+        xml = cls.SIMPLE_VM_XML % {'vm_name': vm_name, 'vm_uuid': vm_uuid,
+                                   'arch': arch}
 
-        xml = cls.SIMPLE_VM_XML % (vm_name, vm_uuid)
         with RollbackContext() as rollback:
             conn = libvirt.open(None)
             rollback.prependDefer(conn.close)
diff --git a/src/kimchi/model/featuretests.py b/src/kimchi/model/featuretests.py
index c187f86..bbd741d 100644
--- a/src/kimchi/model/featuretests.py
+++ b/src/kimchi/model/featuretests.py
@@ -20,6 +20,7 @@
 import cherrypy
 import libvirt
 import lxml.etree as ET
+import platform
 import socket
 import subprocess
 import threading
@@ -37,7 +38,7 @@ ISO_STREAM_XML = """
   <name>ISO_STREAMING</name>
   <memory unit='KiB'>1048576</memory>
   <os>
-    <type>hvm</type>
+    <type arch='%(arch)s'>hvm</type>
     <boot dev='cdrom'/>
   </os>
   <devices>
@@ -59,7 +60,7 @@ SIMPLE_VM_XML = """
   <name>A_SIMPLE_VM</name>
   <memory unit='KiB'>10240</memory>
   <os>
-    <type>hvm</type>
+    <type arch='%(arch)s'>hvm</type>
     <boot dev='hd'/>
   </os>
 </domain>"""
@@ -102,7 +103,10 @@ class FeatureTests(object):
     @staticmethod
     def libvirt_supports_iso_stream(conn, protocol):
         domain_type = 'test' if conn.getType().lower() == 'test' else 'kvm'
-        xml = ISO_STREAM_XML % {'domain': domain_type, 'protocol': protocol}
+        arch = 'ppc64' if platform.machine() == 'ppc64le' \
+            else platform.machine()
+        xml = ISO_STREAM_XML % {'domain': domain_type, 'protocol': protocol,
+                                'arch': arch}
         try:
             FeatureTests.disable_libvirt_error_logging()
             dom = conn.defineXML(xml)
@@ -190,7 +194,10 @@ class FeatureTests(object):
             FeatureTests.disable_libvirt_error_logging()
             rollback.prependDefer(FeatureTests.enable_libvirt_error_logging)
             domain_type = 'test' if conn.getType().lower() == 'test' else 'kvm'
-            dom = conn.defineXML(SIMPLE_VM_XML % {'domain': domain_type})
+            arch = 'ppc64' if platform.machine() == 'ppc64le' \
+                else platform.machine()
+            dom = conn.defineXML(SIMPLE_VM_XML % {'domain': domain_type,
+                                                  'arch': arch})
             rollback.prependDefer(dom.undefine)
             try:
                 dom.setMetadata(libvirt.VIR_DOMAIN_METADATA_ELEMENT,




More information about the Kimchi-devel mailing list