From nobody Fri Nov 7 00:45:55 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544628469727938.6982969340702; Wed, 12 Dec 2018 07:27:49 -0800 (PST) Received: from localhost ([::1]:45583 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX6QK-0003eA-T7 for importer@patchew.org; Wed, 12 Dec 2018 10:27:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX6MC-0000YJ-Kt for qemu-devel@nongnu.org; Wed, 12 Dec 2018 10:23:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gX6M7-0008K6-00 for qemu-devel@nongnu.org; Wed, 12 Dec 2018 10:23:28 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:43611) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gX6M5-0008HA-OT for qemu-devel@nongnu.org; Wed, 12 Dec 2018 10:23:22 -0500 Received: by mail-wr1-x42a.google.com with SMTP id r10so18075317wrs.10 for ; Wed, 12 Dec 2018 07:23:19 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id u10sm15878859wrr.33.2018.12.12.07.23.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 07:23:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=G2kYVQ6NWFGMBbth0ospSQxYl+nK+fvsyNW7f5/Wduo=; b=SSkEg71JwmUjKvHyqhMIKxzjnUVDeGXwwQz3l7M2c3UvIlIHmIHY/04TyFB/w0b7+s ZjYV59mQVpLnl7p5uWXFxtEqZR6t88Jdi7uq2reB2uQCiOFTjXaE1uD0aClrOHiX0bvi dDqriyek5wrMGbbW7k7LYzXek4oiRuO787s8LV7BP4tl8390qYBuaxqem4bLUc1IyGAK Wh+MXKAAPhK/YPRWs/szkOPS+5M+88OMk0oirwelrNNFsvpCJRoQwVBVa63o244sf1Ym pbUqSPvIuNLvii814uVsWXhCpNd4V1G+7O6FYbpAM776TKHg5sWeG1NvDPcTzpT6/i4V 2SFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=G2kYVQ6NWFGMBbth0ospSQxYl+nK+fvsyNW7f5/Wduo=; b=CMznKOCWKGyNasDHhRBEcs9Pok/NaqvhX9VNqizGsRQymgK3ebCi+aliajc9Q/ZnQX cl8mb5o4up7tUpn2FYFnZK2TXBBF+cxFLbG/AsCqUSAqxC07i9sGafbBQAeXF5DcXVII sZZxRsDbGZQiTwnvVPLZP2IqQwsZ/AkX5PZaRTMjH2UL3SEemnjEtCcRVNYMp/jSeNl3 lznq3L8allA1xh9FwU0uaeWm6Lz46vCQrh8XQ0IA7qaLKte/5iRuhp/kiG4KOkD0+8JL HtUfBDrxPYVzhelOAztEl16cWmvokQvMMlpNyUXxwiUuqdO9iBQ1b+JsFX8jSGuIF1bM CNKg== X-Gm-Message-State: AA+aEWY1rbEAknwoKGNF1ejRx561YifSZ8t12DyuRvb3VGK8PdRP5Vmy uckL52ZrhH6y9FDPlkcnhY4Fm+jM X-Google-Smtp-Source: AFSGD/VLIHVjVVtC4tNKPbovNmwW/kH0TJ6a0WY8ZhTPMeTnKsIQTBIZr7e6Z7K/eTd3AhUCsJYs/g== X-Received: by 2002:a5d:660e:: with SMTP id n14mr17366403wru.19.1544628198449; Wed, 12 Dec 2018 07:23:18 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 12 Dec 2018 16:22:22 +0100 Message-Id: <1544628195-37728-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1544628195-37728-1-git-send-email-pbonzini@redhat.com> References: <1544628195-37728-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42a Subject: [Qemu-devel] [PULL 01/54] accel: Improve selection of the default accelerator X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth When compiling with "--disable-tcg", we currently still use "tcg" as default accelerator. "kvm" should be used in this case instead. Also, some downstream distros provide QEMU binaries which have "kvm" in their names (e.g. "qemu-kvm" on RHEL or "kvm" on Ubuntu) that use KVM by default - and some users might want to do something similar with upstream binaries, too. Accomodate them by using "kvm:tcg" as default when we detect such a binary name. Signed-off-by: Thomas Huth Message-Id: <1538748792-19444-1-git-send-email-thuth@redhat.com> Signed-off-by: Paolo Bonzini --- accel/accel.c | 18 +++++++++++++++--- include/sysemu/accel.h | 2 +- vl.c | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/accel/accel.c b/accel/accel.c index 3da26eb..1b1214e 100644 --- a/accel/accel.c +++ b/accel/accel.c @@ -69,7 +69,7 @@ static int accel_init_machine(AccelClass *acc, MachineSta= te *ms) return ret; } =20 -void configure_accelerator(MachineState *ms) +void configure_accelerator(MachineState *ms, const char *progname) { const char *accel; char **accel_list, **tmp; @@ -80,8 +80,20 @@ void configure_accelerator(MachineState *ms) =20 accel =3D qemu_opt_get(qemu_get_machine_opts(), "accel"); if (accel =3D=3D NULL) { - /* Use the default "accelerator", tcg */ - accel =3D "tcg"; + /* Select the default accelerator */ + int pnlen =3D strlen(progname); + if (pnlen >=3D 3 && g_str_equal(&progname[pnlen - 3], "kvm")) { + /* If the program name ends with "kvm", we prefer KVM */ + accel =3D "kvm:tcg"; + } else { +#if defined(CONFIG_TCG) + accel =3D "tcg"; +#elif defined(CONFIG_KVM) + accel =3D "kvm"; +#else +#error "No default accelerator available" +#endif + } } =20 accel_list =3D g_strsplit(accel, ":", 0); diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h index 637358f..285899e 100644 --- a/include/sysemu/accel.h +++ b/include/sysemu/accel.h @@ -66,7 +66,7 @@ typedef struct AccelClass { =20 extern unsigned long tcg_tb_size; =20 -void configure_accelerator(MachineState *ms); +void configure_accelerator(MachineState *ms, const char *progname); /* Register accelerator specific global properties */ void accel_register_compat_props(AccelState *accel); /* Called just before os_setup_post (ie just before drop OS privs) */ diff --git a/vl.c b/vl.c index a5ae5f2..f6a6193 100644 --- a/vl.c +++ b/vl.c @@ -4308,7 +4308,7 @@ int main(int argc, char **argv, char **envp) qemu_opt_foreach(machine_opts, machine_set_property, current_machine, &error_fatal); =20 - configure_accelerator(current_machine); + configure_accelerator(current_machine, argv[0]); =20 if (!qtest_enabled() && machine_class->deprecation_reason) { error_report("Machine type '%s' is deprecated: %s", --=20 1.8.3.1