From nobody Mon Feb 9 19:06:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613735116; cv=none; d=zohomail.com; s=zohoarc; b=mutxlqhBxEdmA2s4bb1WesVGarqiHPcwdjB6Dg5fZGUiEs5Q+iy6jxRbPQjMsvjhTUN/z3TxoxmuoFPQYeK9hKddP5/8cTos/GXYKUJTTkXeKwM1eUlpNmU6epc7PpLR2qPlefyE3Ni5IOs1CvJtNeZr+HnZU1OkU6GuheCZY5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613735116; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=YJlwy/QOkf0QIlTzPZ6przivK3+kqukDr5TR8oal+wM=; b=W1rB57hE9aiXOwYt4nmFMWUJzThpKc4x2T/0yjeOoO7Hr1skqRvOaNwCoMlq8xyWFwu6m48DUxVEU1iCVl3aZXxwVV2Nve2+9ErLauI3MZcvujxMMLPsMnJpSjgHwmAFfKUj2AmGUTuv3fvJu5d7ODqI7QcLCvyqkRO12lW5EKY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1613735116034496.83935004479736; Fri, 19 Feb 2021 03:45:16 -0800 (PST) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-157-dIa3dkiLN2qiyUar3bfnOA-1; Fri, 19 Feb 2021 06:45:13 -0500 Received: by mail-wr1-f71.google.com with SMTP id o16so2370435wrn.1 for ; Fri, 19 Feb 2021 03:45:12 -0800 (PST) Return-Path: Return-Path: Received: from localhost.localdomain (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id z17sm15710920wrv.9.2021.02.19.03.45.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Feb 2021 03:45:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613735115; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YJlwy/QOkf0QIlTzPZ6przivK3+kqukDr5TR8oal+wM=; b=dJVP5+S1tMVic0IRKW2XmEswBeQV8YIS+t1d3w+xxw75aN4BbJft5z8j8elVX8zlG4mtrd Hxf3OlSMIAAt/ID4rqLcfJ5RVBSqodb3LTI7giRjJUA7Wx6XtpUk/s4cW6n636kO983pzl KnNPLkMRPtJaobU1I3E+gpVgVo19sz8= X-MC-Unique: dIa3dkiLN2qiyUar3bfnOA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YJlwy/QOkf0QIlTzPZ6przivK3+kqukDr5TR8oal+wM=; b=iw5xKPdbv7cPVSIMUJVDDGumDPSxFCQVb3DmFCXticoiI+ALpL82spjoB6uZd0OLHE Utq+EXiztvN5rV9uJUQ+qzmxkosJhHqkppy4ZKwbHdrHRpt/JKqwbdJMllhSI6PMdICD xoc8zDTI4pmGPV2QgiroYw9KWAYs4nG1AsMYBgZ8sqoqiC9Muk2Y+XKRu2snWaKU+zxu T/nVlxddXJ5uxey43bDi1X47mFY1gV6834YUCRgCg0VS/2wQT+4hwVL+iWHF2KCfbUDm Zyv6IpxGppkr67ZzzGf8dx1+hKMewh1aqbJcu3mlPzwhYtUcvmBkxLU7YUvO4QB/6Ua+ wEtw== X-Gm-Message-State: AOAM533FER5ZBH7lbpkYxyz9vI19xOo5o4/FvoMN6eBHEv02QMU2ysb4 HBiZFwSP9H1dv7yTQuPB2E6CcvlvNt8ejzXuyoQ6nitvJJ4qnxR7Ul0ZmaFzRXRKrUYp2J7XlRM YUvJXpM5SHbh/YQ== X-Received: by 2002:adf:bbca:: with SMTP id z10mr8877262wrg.168.1613735112114; Fri, 19 Feb 2021 03:45:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZHhoZ2Wy0Wkb5v1FsmoSovOJoQjV0ghbc4hAJ/cIFmfZspDESkeyO+OZmJZh6DupK3/KHUQ== X-Received: by 2002:adf:bbca:: with SMTP id z10mr8877239wrg.168.1613735111985; Fri, 19 Feb 2021 03:45:11 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Radoslaw Biernacki , Paolo Bonzini , qemu-s390x@nongnu.org, Greg Kurz , Marcel Apfelbaum , qemu-arm@nongnu.org, Cornelia Huck , Aleksandar Rikalo , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , BALATON Zoltan , Huacai Chen , Aurelien Jarno , Richard Henderson , "Edgar E. Iglesias" , Christian Borntraeger , Leif Lindholm , Alistair Francis , Thomas Huth , Peter Maydell , Eduardo Habkost , Jiaxun Yang , Halil Pasic , David Hildenbrand , qemu-ppc@nongnu.org, =?UTF-8?q?Herv=C3=A9=20Poussineau?= , David Gibson , Mark Cave-Ayland , kvm@vger.kernel.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 7/7] accel/kvm: Exit gracefully when KVM is not supported Date: Fri, 19 Feb 2021 12:44:28 +0100 Message-Id: <20210219114428.1936109-8-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210219114428.1936109-1-philmd@redhat.com> References: <20210219114428.1936109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Now that we added the 'kvm_supported' field to MachineClass and all our machines able to use KVM have this field set, we can check it in kvm_init() and exit gracefully with a friendly error message. Before: $ qemu-system-aarch64 -M raspi3b -enable-kvm qemu-system-aarch64: /build/qemu-ETIdrs/qemu-4.2/exec.c:865: cpu_address_= space_init: Assertion `asidx =3D=3D 0 || !kvm_enabled()' failed. Aborted $ qemu-system-aarch64 -M xlnx-zcu102 -enable-kvm -smp 6 qemu-system-aarch64: kvm_init_vcpu: kvm_arch_init_vcpu failed (0): Invali= d argument After: $ qemu-system-aarch64 -M raspi3b -enable-kvm Machine 'raspi3b' does not support KVM $ qemu-system-aarch64 -M xlnx-zcu102 -enable-kvm -smp 6 Machine 'xlnx-zcu102' does not support KVM Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- accel/kvm/kvm-all.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index b069938d881..8a8d3f64248 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2001,6 +2001,12 @@ static int kvm_init(MachineState *ms) =20 s =3D KVM_STATE(ms->accelerator); =20 + if (!mc->kvm_supported) { + ret =3D -EINVAL; + fprintf(stderr, "Machine '%s' does not support KVM\n", mc->name); + exit(1); + } + /* * On systems where the kernel can support different base page * sizes, host page size may be different from TARGET_PAGE_SIZE, --=20 2.26.2