diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-05-30 23:08:16 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-05-31 15:36:20 +0100 |
commit | a07a6a74159d9fa2d0ca52c990f69ceac7c237d8 (patch) | |
tree | 3033f364517098a4518dab8a5a024e58404fce06 /scripts/runqemu | |
parent | 6a28a193906f07bdc52c12c9af7cb101d867856f (diff) | |
download | poky-a07a6a74159d9fa2d0ca52c990f69ceac7c237d8.tar.gz |
runqemu: Add support for kvm on aarch64
The main issue is to make the x86 checks apply to x86 targets only. We may
end up with better checks on other architectures but this adapts the code to
allow for that and its still controlled by whether QB_CPU_KVM is set.
The code needed minor refactoring so the qemu-system-XXX name is set
earlier so the kvm code can use it.
(From OE-Core rev: 06c473a0127f19b76d0f647b87873944add1e331)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/runqemu')
-rwxr-xr-x | scripts/runqemu | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/scripts/runqemu b/scripts/runqemu index 39bed038d5..5752ecda73 100755 --- a/scripts/runqemu +++ b/scripts/runqemu | |||
@@ -491,12 +491,13 @@ class BaseConfig(object): | |||
491 | yocto_paravirt_kvm_wiki = "https://wiki.yoctoproject.org/wiki/Running_an_x86_Yocto_Linux_image_under_QEMU_KVM" | 491 | yocto_paravirt_kvm_wiki = "https://wiki.yoctoproject.org/wiki/Running_an_x86_Yocto_Linux_image_under_QEMU_KVM" |
492 | dev_kvm = '/dev/kvm' | 492 | dev_kvm = '/dev/kvm' |
493 | dev_vhost = '/dev/vhost-net' | 493 | dev_vhost = '/dev/vhost-net' |
494 | with open('/proc/cpuinfo', 'r') as f: | 494 | if self.qemu_system.endswith(('i386', 'x86_64')): |
495 | kvm_cap = re.search('vmx|svm', "".join(f.readlines())) | 495 | with open('/proc/cpuinfo', 'r') as f: |
496 | if not kvm_cap: | 496 | kvm_cap = re.search('vmx|svm', "".join(f.readlines())) |
497 | logger.error("You are trying to enable KVM on a cpu without VT support.") | 497 | if not kvm_cap: |
498 | logger.error("Remove kvm from the command-line, or refer:") | 498 | logger.error("You are trying to enable KVM on a cpu without VT support.") |
499 | raise RunQemuError(yocto_kvm_wiki) | 499 | logger.error("Remove kvm from the command-line, or refer:") |
500 | raise RunQemuError(yocto_kvm_wiki) | ||
500 | 501 | ||
501 | if not os.path.exists(dev_kvm): | 502 | if not os.path.exists(dev_kvm): |
502 | logger.error("Missing KVM device. Have you inserted kvm modules?") | 503 | logger.error("Missing KVM device. Have you inserted kvm modules?") |
@@ -703,6 +704,7 @@ class BaseConfig(object): | |||
703 | else: | 704 | else: |
704 | os.putenv('QEMU_AUDIO_DRV', 'none') | 705 | os.putenv('QEMU_AUDIO_DRV', 'none') |
705 | 706 | ||
707 | self.check_qemu_system() | ||
706 | self.check_kvm() | 708 | self.check_kvm() |
707 | self.check_fstype() | 709 | self.check_fstype() |
708 | self.check_rootfs() | 710 | self.check_rootfs() |
@@ -1128,21 +1130,23 @@ class BaseConfig(object): | |||
1128 | 1130 | ||
1129 | return 'qemu-system-%s' % qbsys | 1131 | return 'qemu-system-%s' % qbsys |
1130 | 1132 | ||
1131 | def setup_final(self): | 1133 | def check_qemu_system(self): |
1132 | qemu_system = self.get('QB_SYSTEM_NAME') | 1134 | qemu_system = self.get('QB_SYSTEM_NAME') |
1133 | if not qemu_system: | 1135 | if not qemu_system: |
1134 | qemu_system = self.guess_qb_system() | 1136 | qemu_system = self.guess_qb_system() |
1135 | if not qemu_system: | 1137 | if not qemu_system: |
1136 | raise RunQemuError("Failed to boot, QB_SYSTEM_NAME is NULL!") | 1138 | raise RunQemuError("Failed to boot, QB_SYSTEM_NAME is NULL!") |
1139 | self.qemu_system = qemu_system | ||
1137 | 1140 | ||
1138 | qemu_bin = os.path.join(self.bindir_native, qemu_system) | 1141 | def setup_final(self): |
1142 | qemu_bin = os.path.join(self.bindir_native, self.qemu_system) | ||
1139 | 1143 | ||
1140 | # It is possible to have qemu-native in ASSUME_PROVIDED, and it won't | 1144 | # It is possible to have qemu-native in ASSUME_PROVIDED, and it won't |
1141 | # find QEMU in sysroot, it needs to use host's qemu. | 1145 | # find QEMU in sysroot, it needs to use host's qemu. |
1142 | if not os.path.exists(qemu_bin): | 1146 | if not os.path.exists(qemu_bin): |
1143 | logger.info("QEMU binary not found in %s, trying host's QEMU" % qemu_bin) | 1147 | logger.info("QEMU binary not found in %s, trying host's QEMU" % qemu_bin) |
1144 | for path in (os.environ['PATH'] or '').split(':'): | 1148 | for path in (os.environ['PATH'] or '').split(':'): |
1145 | qemu_bin_tmp = os.path.join(path, qemu_system) | 1149 | qemu_bin_tmp = os.path.join(path, self.qemu_system) |
1146 | logger.info("Trying: %s" % qemu_bin_tmp) | 1150 | logger.info("Trying: %s" % qemu_bin_tmp) |
1147 | if os.path.exists(qemu_bin_tmp): | 1151 | if os.path.exists(qemu_bin_tmp): |
1148 | qemu_bin = qemu_bin_tmp | 1152 | qemu_bin = qemu_bin_tmp |