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

akuster808 akuster808 at gmail.com
Fri Nov 3 15:18:09 UTC 2017


Joshua,


On 11/03/2017 02:11 AM, Joshua Lock wrote:
> 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.

I will backport once this lands in master.
thanks,
 - armin
> 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:




More information about the Openembedded-core mailing list