From nobody Mon Feb 9 20:34:34 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 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 1613756397606407.4055424814121; Fri, 19 Feb 2021 09:39:57 -0800 (PST) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-147-E9znOExEM2Gd0Ve2tT3opQ-1; Fri, 19 Feb 2021 12:39:54 -0500 Received: by mail-wm1-f69.google.com with SMTP id j204so2794700wmj.4 for ; Fri, 19 Feb 2021 09:39:54 -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 r7sm15304999wre.25.2021.02.19.09.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Feb 2021 09:39:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613756396; 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=LKRfXZiJfNSqbVRL/SaOx1v+Z64xt5w41cSycQqYFFE=; b=GTGuLyHKA7H+YnH3Uu3iTtQ+U1LQZZw8r8pYOHnpZIL03nQP/p49zvNtTr6DDEs+FfO339 MlUeC5k7DORyMQkrLc5Ffofic0/gm+cTparvBsgSG96kk7xy4dAxk/7soqzmcnKrFr6BRW FxV1xpM60TxLOKkb6qZSbqJXVYTiFtQ= X-MC-Unique: E9znOExEM2Gd0Ve2tT3opQ-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=LKRfXZiJfNSqbVRL/SaOx1v+Z64xt5w41cSycQqYFFE=; b=jk7fKoXKD0BcUWgY6N1rbdxtpAphBylVnH0bgHxgBamj5v6bIOaArkkbu52xmPuTE9 d2VGig4lRZEvN5i0BsDcKnJOZx+IqhRNJ+zZnzTRdiaisNSaw3UpEN5ZmUiXit/0WlSc cMGWfMHzAVbii5gYNZ7MKwPtYDbzCIu2obPmsU/IKHvLGWYV+dLLsMqtdpiVYi0fwkxk YKw75dvSPOGDNXrNArdDBZKllptxPIDdt/t9EeKl5ZYMB7iVyHNTk4bTkugjd9fLO4wd M/HOZkpnSqDWfNjrNzKCpxsjDhkVg/m2eYJvIiy47MZmFdVVTmnKVMdxlu5k7zrrIlo4 NjYQ== X-Gm-Message-State: AOAM533RvejGsuZ+wwXBtD3XzG9Z3MCMmcoET1AkkTM2Y/vqXYD+MQfN JidtFOkPiRG1/y6afUNTZ+ZSuKjbl0w4Jue3EX69DiI5cpajuzpVg5C+dm3BxkGnRi8R2HlVJwG 65LUQiKgrH28s5A== X-Received: by 2002:a1c:4c03:: with SMTP id z3mr9342117wmf.82.1613756393450; Fri, 19 Feb 2021 09:39:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJx2yrJUDqwa1ymG/2RErXjJWx3WIzkQzNQF90+7ijmcN7yAwa2G2hjcHhwa/T8ilbMl1bPCyw== X-Received: by 2002:a1c:4c03:: with SMTP id z3mr9342087wmf.82.1613756393314; Fri, 19 Feb 2021 09:39:53 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Aurelien Jarno , Peter Maydell , Anthony Perard , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Halil Pasic , Huacai Chen , xen-devel@lists.xenproject.org, Marcel Apfelbaum , David Gibson , qemu-arm@nongnu.org, Stefano Stabellini , Paolo Bonzini , kvm@vger.kernel.org, BALATON Zoltan , Leif Lindholm , Richard Henderson , Radoslaw Biernacki , Alistair Francis , Paul Durrant , Eduardo Habkost , "Michael S. Tsirkin" , Thomas Huth , Jiaxun Yang , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Greg Kurz , Christian Borntraeger , Cornelia Huck , "Edgar E. Iglesias" , David Hildenbrand , Mark Cave-Ayland , Aleksandar Rikalo , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 11/11] softmmu/vl: Exit gracefully when accelerator is not supported Date: Fri, 19 Feb 2021 18:38:47 +0100 Message-Id: <20210219173847.2054123-12-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210219173847.2054123-1-philmd@redhat.com> References: <20210219173847.2054123-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) Before configuring an accelerator, check it is valid for the current machine. Doing so we can return a simple error message instead of criptic one. Before: $ qemu-system-arm -M raspi2b -enable-kvm qemu-system-arm: /build/qemu-ETIdrs/qemu-4.2/exec.c:865: cpu_address_spac= e_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-arm -M raspi2b -enable-kvm qemu-system-aarch64: invalid accelerator 'kvm' for machine raspi2b $ qemu-system-aarch64 -M xlnx-zcu102 -enable-kvm -smp 6 qemu-system-aarch64: -accel kvm: invalid accelerator 'kvm' for machine xl= nx-zcu102 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- softmmu/vl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/softmmu/vl.c b/softmmu/vl.c index b219ce1f357..f2c4074310b 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2133,6 +2133,7 @@ static int do_configure_accelerator(void *opaque, Qem= uOpts *opts, Error **errp) const char *acc =3D qemu_opt_get(opts, "accel"); AccelClass *ac =3D accel_find(acc); AccelState *accel; + MachineClass *mc; int ret; bool qtest_with_kvm; =20 @@ -2145,6 +2146,12 @@ static int do_configure_accelerator(void *opaque, Qe= muOpts *opts, Error **errp) } return 0; } + mc =3D MACHINE_GET_CLASS(current_machine); + if (!qtest_chrdev && !machine_class_valid_for_accelerator(mc, ac->name= )) { + *p_init_failed =3D true; + error_report("invalid accelerator '%s' for machine %s", acc, mc->n= ame); + return 0; + } accel =3D ACCEL(object_new_with_class(OBJECT_CLASS(ac))); object_apply_compat_props(OBJECT(accel)); qemu_opt_foreach(opts, accelerator_set_property, --=20 2.26.2