[Kimchi-devel] [PATCH] 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

thierry at linux.vnet.ibm.com thierry at linux.vnet.ibm.com
Thu Jan 29 09:21:12 UTC 2015


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

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       | 14 +++++++++-----
 src/kimchi/model/featuretests.py | 14 ++++++++++----
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/src/kimchi/kvmusertests.py b/src/kimchi/kvmusertests.py
index 2326727..be858f5 100644
--- a/src/kimchi/kvmusertests.py
+++ b/src/kimchi/kvmusertests.py
@@ -18,22 +18,23 @@
 
 import psutil
 import uuid
-
+import platform
 
 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,11 @@ 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_uuid)
+        xml = cls.SIMPLE_VM_XML % {'vm_name':vm_name, 'vm_uuid':vm_uuid, 'arch': arch }
+        kimchi_log.warning("DEBUG XML %s",xml)
+        
         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..7798142 100644
--- a/src/kimchi/model/featuretests.py
+++ b/src/kimchi/model/featuretests.py
@@ -23,6 +23,7 @@ import lxml.etree as ET
 import socket
 import subprocess
 import threading
+import platform
 
 
 from lxml.builder import E
@@ -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,9 @@ 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 +193,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,
-- 
2.1.0




More information about the Kimchi-devel mailing list