[OE-core] [PATCH] scripts/runqemu: when qemu fails to start with kvm retry with kvm disabled

Joshua Lock joshua.g.lock at intel.com
Fri Nov 3 09:11:47 UTC 2017


On the Yocto Project Autobuilder we occasionally see qemu fail to start,
most frequently on Fedora 25, because kvm fails to allocate memory. See:

https://bugzilla.yoctoproject.org/show_bug.cgi?id=12058

This patch introduces a fallback path where if the inital qemu command fails
and kvm is enabled we retry running qemu with the kvm related options
removed from the qemu command line.

Signed-off-by: Joshua Lock <joshua.g.lock at intel.com>
---
 scripts/runqemu | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/scripts/runqemu b/scripts/runqemu
index df762709043..b7f8b3c4d55 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -1168,7 +1168,25 @@ class BaseConfig(object):
         logger.info('Running %s\n' % cmd)
         process = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE)
         if process.wait():
-            logger.error("Failed to run qemu: %s", process.stderr.read().decode())
+            # If starting qemu failed and kvm is enabled we try again, with the
+            # kvm related options removed. This is because we have observed
+            # failures where kvm is unable to allocate memory (particularly on
+            # Fedora 25) but where a run withou kvm may be successful.
+            if self.kvm_enabled:
+                logger.info("Failed to run qemu: %s\nRetrying without kvm...",
+                            process.stderr.read().decode())
+                nokvm_cmd = cmd
+                nokvm_cmd = nokvm_cmd.replace(' -enable-kvm', '')
+                nokvm_cmd = nokvm_cmd.replace(',vhost=on', '')
+                logger.info('Running %s\n' % nokvm_cmd)
+                process = subprocess.Popen(nokvm_cmd, shell=True,
+                                           stderr=subprocess.PIPE)
+                if process.wait():
+                    logger.error("Failed to run qemu (with kvm disabled): %s",
+                                 process.stderr.read().decode())
+            else:
+                logger.error("Failed to run qemu: %s",
+                             process.stderr.read().decode())
 
     def cleanup(self):
         if self.cleantap:
-- 
2.13.6




More information about the Openembedded-core mailing list