]> code.ossystems Code Review - openembedded-core.git/commitdiff
runqemu: try and guess qemu-system binary when MACHINE isn't set
authorJoshua Lock <joshua.g.lock@intel.com>
Wed, 21 Sep 2016 19:35:37 +0000 (20:35 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 21 Sep 2016 20:59:14 +0000 (21:59 +0100)
Emulate some logic from the prior, shell based, version of runqemu
to try and infer the correct setting for MACHINE from the kernel
and rootfs filenames.

Signed-off-by: Joshua Lock <joshua.g.lock@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/runqemu

index 5170d8757073c38753ff45e26fdc49ef8638a2cd..591746f65705140959c265146b1dbc93da275a67 100755 (executable)
@@ -846,8 +846,44 @@ class BaseConfig(object):
 
         self.set('ROOTFS_OPTIONS', self.rootfs_options)
 
+    def guess_qb_system(self):
+        """attempt to determine the appropriate qemu-system binary"""
+        mach = self.get('MACHINE')
+        if not mach:
+            search = '.*(qemux86-64|qemux86|qemuarm64|qemuarm|qemumips64|qemumips|qemuppc).*'
+            if self.rootfs:
+                match = re.match(search, self.rootfs)
+                if match:
+                    mach = match.group(1)
+            elif self.kernel:
+                match = re.match(search, self.kernel)
+                if match:
+                    mach = match.group(1)
+
+        if not mach:
+            return None
+
+        if mach == 'qemuarm':
+            qbsys = 'arm'
+        elif mach == 'qemuarm64':
+            qbsys = 'aarch64'
+        elif mach == 'qemux86':
+            qbsys = 'i386'
+        elif mach == 'qemux86-64':
+            qbsys = 'x86_64'
+        elif mach == 'qemuppc':
+            qbsys = 'ppc'
+        elif mach == 'qemumips':
+            qbsys = 'mips'
+        elif mach == 'qemumips64':
+            qbsys = 'mips64'
+
+        return 'qemu-system-%s' % qbsys
+
     def setup_final(self):
         qemu_system = self.get('QB_SYSTEM_NAME')
+        if not qemu_system:
+            qemu_system = self.guess_qb_system()
         if not qemu_system:
             raise Exception("Failed to boot, QB_SYSTEM_NAME is NULL!")