Skip to contentSkip to conversation

runqemu fixes for toolchain and sdk uses

PATCH New Joshua Lock 1 participant 5 messages Sep 21, 2016

lore
Share & tools
lore
#0 lore raw

cover runqemu fixes for toolchain and sdk uses

Another round of fixes for runqemu to support common usage models such as being called via the Eclipse plugin.

* don't immediately bail out if QB_SYSTEM_NAME isn't set (this variable is only set in a qemuboot.conf file), instead attempt to infer the correct qemu-system binary based on the machine name, rootfs name or kernel name
* always attempt to infer paths which aren't explicitly set, rather than only trying to infer them when the values in a qemuboot.conf aren't validate
* don't try and determine whether a MACHINE setting is correct when called From an sdk environment, bitbake isn't available in this context

[YOCTO #10309]

The following changes since commit b2771e17a5f301423f65be9f93c9c1b1e7f8ab93:

oeqa/selftest/lic-checksum: don't report the expected failure to errors.yp (2016-09-20 15:10:37 +0100)

are available in the git repository at:

git://git.openembedded.org/openembedded-core-contrib joshuagl/runqemu
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=joshuagl/runqemu

Joshua Lock (4):
runqemu: validate paths and attempt to infer unset paths
runqemu: try and guess qemu-system binary when MACHINE isn't set
runqemu: don't try and invoke bitbake when running in a toolchain env
runqemu: don't fail during check_arg_machine()

 scripts/runqemu | 50 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 47 insertions(+), 3 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/4 runqemu: validate paths and attempt to infer unset paths

We need to validate and ensure all paths are set regardless of whether runqemu was invoked with a .qemuboot.conf file or otherwise. Split this logic out into a separate method called during check_and_set()

---
 scripts/runqemu | 3 +++
 1 file changed, 3 insertions(+)
scripts/runqemu +3 -0
index 08dc306..5170d87 100755
@@ -536,6 +536,7 @@ class BaseConfig(object):
 
     def check_and_set(self):
         """Check configs sanity and set when needed"""
+        self.validate_paths()
         check_tun()
         # Check audio
         if self.audio_enabled:
@@ -598,6 +599,8 @@ class BaseConfig(object):
             k_upper = k.upper()
             self.set(k_upper, v)
 
+    def validate_paths(self):
+        """Ensure all relevant path variables are set"""
         # When we're started with a *.qemuboot.conf arg assume that image
         # artefacts are relative to that file, rather than in whatever
         # directory DEPLOY_DIR_IMAGE in the conf file points to.
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/4 runqemu: try and guess qemu-system binary when MACHINE isn't set

In reply to Joshua Lock

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.

---
 scripts/runqemu | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
scripts/runqemu +36 -0
index 5170d87..591746f 100755
@@ -846,9 +846,45 @@ 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!")
 
         qemu_bin = '%s/%s' % (self.get('STAGING_BINDIR_NATIVE'), qemu_system)
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/4 runqemu: don't try and invoke bitbake when running in a toolchain env

In reply to Joshua Lock

If a MACHINE value is passed we can't validate it by running bitbake as the toolchain environment doesn't include the build system, we must assume that the passed value for MACHINE is correct.

---
 scripts/runqemu | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
scripts/runqemu +7 -2
index 591746f..e8360c2 100755
@@ -306,11 +306,16 @@ class BaseConfig(object):
         # FIXME: testimage.bbclass exports these two variables into env,
         # are there other scenarios in which we need to support being
         # invoked by bitbake?
-        deploy = os.environ.get('DEPLOY_DIR_IMAGE', None)
-        bbchild = deploy and os.environ.get('OE_TMPDIR', None)
+        deploy = os.environ.get('DEPLOY_DIR_IMAGE')
+        bbchild = deploy and os.environ.get('OE_TMPDIR')
         if bbchild:
             self.set_machine_deploy_dir(arg, deploy)
             return
+        # also check whether we're running under a sourced toolchain
+        # environment file
+        if os.environ.get('OECORE_NATIVE_SYSROOT'):
+            self.set("MACHINE", arg)
+            return
 
         cmd = 'MACHINE=%s bitbake -e' % arg
         logger.info('Running %s...' % cmd)
Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/4 runqemu: don't fail during check_arg_machine()

In reply to Joshua Lock

If DEPLOY_DIR_IMAGE doesn't exist during check_arg_machine() we will attempt to guess a suitable value later when check_and_set() calls validate_paths(), therefore this shouldn't raise an exception

---
 scripts/runqemu | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/runqemu +1 -1
index e8360c2..658f7c8 100755
@@ -332,7 +332,7 @@ class BaseConfig(object):
             self.set_machine_deploy_dir(arg, deploy_dir_image)
         else:
             logger.error("%s not a directory valid DEPLOY_DIR_IMAGE" % deploy_dir_image)
-            raise Exception("Failed to set MACHINE to %s. Unknown arg: %s" % (arg, arg))
+            self.set("MACHINE", arg)
 
     def check_args(self):
         unknown_arg = ""
Signature · 1 line
2.7.4