def _IsKvmEnabled(self): kvm_supported = sys.platform.startswith('linux') and \ os.access('/dev/kvm', os.R_OK | os.W_OK) same_arch = \ (self._target_cpu == 'arm64' and platform.machine() == 'aarch64') or \ (self._target_cpu == 'x64' and platform.machine() == 'x86_64') if kvm_supported and same_arch: return True elif self._require_kvm: if same_arch: raise FuchsiaTargetException('KVM required but unavailable.') else: raise FuchsiaTargetException('KVM unavailable when CPU architecture of'\ ' host is different from that of target.') else: return False
def _IsKvmEnabled(self): kvm_supported = sys.platform.startswith('linux') and \ os.access('/dev/kvm', os.R_OK | os.W_OK) same_arch = \ (self._target_cpu == 'arm64' and platform.machine() == 'aarch64') or \ (self._target_cpu == 'x64' and platform.machine() == 'x86_64') if kvm_supported and same_arch: return True elif self._require_kvm: if same_arch: if not os.path.exists('/dev/kvm'): kvm_error = 'File /dev/kvm does not exist. Please install KVM first.' else: kvm_error = 'To use KVM acceleration, add user to the kvm group '\ 'with "sudo usermod -a -G kvm $USER". Log out and back '\ 'in for the change to take effect.' raise FuchsiaTargetException(kvm_error) else: raise FuchsiaTargetException('KVM unavailable when CPU architecture of'\ ' host is different from that of target.') else: return False