From nobody Sun May 5 10:13:24 2024 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 Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509387817093851.1157556544596; Mon, 30 Oct 2017 11:23:37 -0700 (PDT) Received: from localhost ([::1]:42042 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9EiS-0005oF-4C for importer@patchew.org; Mon, 30 Oct 2017 14:23:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9Eh0-0004sz-0n for qemu-devel@nongnu.org; Mon, 30 Oct 2017 14:21:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e9Egw-00044i-Lj for qemu-devel@nongnu.org; Mon, 30 Oct 2017 14:21:46 -0400 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:48864) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e9Egw-00044Y-Gf; Mon, 30 Oct 2017 14:21:42 -0400 Received: by mail-qk0-x243.google.com with SMTP id d67so17330431qkg.5; Mon, 30 Oct 2017 11:21:42 -0700 (PDT) Received: from x1.local ([181.93.89.178]) by smtp.gmail.com with ESMTPSA id c10sm9978240qtj.29.2017.10.30.11.21.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Oct 2017 11:21:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3s2TNKK9nVaBozO6isVF13EjBSzDIr9nty/k8WuDd04=; b=UcTSqPRxL576+DykgiFjRzjYtbdcKM7pMe6lI4ZBnmJMxPP3XuoqxFRUUbl6wH1/Ll agxkLz8bZ87KWceKmhqKOijm61uHEiybY9Jc+Pbm/NfwU0eeL7skm2tQ7cMYKhx3Vxn7 ECGWg42xGpa6oXKkRPq9jIfZ9jFxuh6P9tgeLe+ThEHY40DIsKx8h6T9QIbYyX0O/kk+ fzktUPfsB4ASDWJ6aovDbb1HuUhA7uVe9wL+EOuok2HTgIG1hXP1QnjoroLs0cNyuRrA ml71SCfigEJ05C8z+hCwIWwCHOb3g66dvqognyJUaRadA1o1P15LgprDhqPm1zx2h6AH CdIg== 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 :mime-version:content-transfer-encoding; bh=3s2TNKK9nVaBozO6isVF13EjBSzDIr9nty/k8WuDd04=; b=AKkb6nczJKbvRFHPyZowRHizYhk22h5mgYUcOJp5nu13wWDi1pGrQS8wsgpx4HgG+4 TA9euS4FdcaNwEtDfMK9l52+leES6vyVmVs4I1+EbFglP9NG8fqudyHokywEyzBsZxD5 divfKvEPeYlJHwRRKcTAGTXNuDcZ981WZKuR/hAbahraE5M9dNEpyihAvQb01uc6kXWY u80lqBYNz+2XL13AKsrscWWFpvA7JrAww7NFlwbATV+iO32W83RhDtlPqxEV4hte5l+x C8BS/EWgScDK/r4wNcqLSQFbB1tK2SYXz67nvjw033HaB6iGFiTZrmF26n6zfl8Arofv ckVg== X-Gm-Message-State: AMCzsaV+4/c9W3euQybwao8AqO1Uyc7/fakMoPRW153nZS0vupRLxTBK WaWgiB6E4bYeekr+xAS/828= X-Google-Smtp-Source: ABhQp+Rc1r5A9OckfovV8+XM1LUtaBHn3aE0PSW+THnNk0LsgwD5mPWfTiqXngMO/B1K7aCqOxyiDw== X-Received: by 10.55.214.142 with SMTP id p14mr14594420qkl.199.1509387701715; Mon, 30 Oct 2017 11:21:41 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Paolo Bonzini , Thomas Huth , Eduardo Habkost , Peter Xu , Markus Armbruster , Stefano Stabellini , Anthony Perard Date: Mon, 30 Oct 2017 15:20:21 -0300 Message-Id: <20171030182021.2175-1-f4bug@amsat.org> X-Mailer: git-send-email 2.15.0.rc2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::243 Subject: [Qemu-devel] [PATCH RESEND] vl: only display available accelerators 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: qemu-trivial@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, "Emilio G . Cota" , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 examples configuring with '--enable-kvm --disable-tcg' - before $ qemu-system-x86_64 -accel help Possible accelerators: kvm, xen, hax, tcg $ qemu-system-x86_64 -accel tcg qemu-system-x86_64: -machine accel=3Dtcg: No accelerator found # qemu-system-x86_64 -accel hax qemu-system-x86_64: -machine accel=3Dhax: No accelerator found - after $ qemu-system-x86_64 -accel help Possible accelerators: xen kvm Suggested-by: Eduardo Habkost Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- resend without RFC in subject... since RFC: - use much cleaner object_class_get_list(TYPE_ACCEL, false) vl.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/vl.c b/vl.c index ec299099ff..0f13641715 100644 --- a/vl.c +++ b/vl.c @@ -2764,6 +2764,39 @@ static gint machine_class_cmp(gconstpointer a, gcons= tpointer b) exit(!name || !is_help_option(name)); } =20 +static void accel_list_entry(gpointer data, gpointer user_data) +{ + ObjectClass *oc =3D data; + const char *typename =3D object_class_get_name(oc); + int len; + + if (!qtest_driver() && !g_strcmp0(typename, ACCEL_CLASS_NAME("qtest"))= ) { + return; /* used by test cases */ + } + + len =3D strlen(typename) - strlen("-" TYPE_ACCEL); + if (len > 0) { + error_printf(" %.*s\n", len, typename); + } +} + +static void accel_parse(const char *name, QemuOpts *accel_opts) +{ + const char *optarg =3D qemu_opt_get(accel_opts, "accel"); + GSList *list; + + if (!is_help_option(optarg)) { + return; + } + + list =3D object_class_get_list(TYPE_ACCEL, false); + error_printf("Possible accelerators:\n"); + g_slist_foreach(list, accel_list_entry, NULL); + g_slist_free(list); + + exit(0); +} + void qemu_add_exit_notifier(Notifier *notify) { notifier_list_add(&exit_notifiers, notify); @@ -3881,11 +3914,7 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_accel: accel_opts =3D qemu_opts_parse_noisily(qemu_find_opts("acc= el"), optarg, true); - optarg =3D qemu_opt_get(accel_opts, "accel"); - if (!optarg || is_help_option(optarg)) { - error_printf("Possible accelerators: kvm, xen, hax, tc= g\n"); - exit(0); - } + accel_parse(optarg, accel_opts); opts =3D qemu_opts_create(qemu_find_opts("machine"), NULL, false, &error_abort); qemu_opt_set(opts, "accel", optarg, &error_abort); --=20 2.15.0.rc2