From nobody Sun Apr 28 02:31:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584120342; cv=none; d=zohomail.com; s=zohoarc; b=kVJnn6ronEZ7Rg4fSnQuK+WknBujwCR0rubWWugnjI96dL7oe0emTpdu4dM8Zjmu4RUq1iqnnjFcDRgvl5xbGW0UVmkeOIFwVZhwPYDkLRYrVmc+7g4uVRwxjG09vbe486ekM7/UqZ+hht1t7Urv9Kq1/FJuPLnrJqkpSvHRdqg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584120342; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=dLesLAm1eL1nhyeIN3Gcr4+dzCmfTRF/hQyK2zuFN6I=; b=SPBjCarSfn35lcK87FY+hAJBdsRBsWLHtnJPbjbyHJhj9pm7eVoAB5OtRmwMOCrN3PbRDxmMdGHa4c7sYkEdO1NlNoqafDfNaV8ejcGn/wWfG9NVsOENJ5t6ZSVsFJGSpTg6jHEQvtw+uncgDF5X9O+bnGVh3+ffjshnAezjlpE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584120342104750.6677971853806; Fri, 13 Mar 2020 10:25:42 -0700 (PDT) Received: from localhost ([::1]:34304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCo44-0003VY-Ds for importer@patchew.org; Fri, 13 Mar 2020 13:25:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55621) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCo3I-0002vj-Lp for qemu-devel@nongnu.org; Fri, 13 Mar 2020 13:24:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jCo3H-0006w3-41 for qemu-devel@nongnu.org; Fri, 13 Mar 2020 13:24:52 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:41847) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jCo3G-0006un-Tm for qemu-devel@nongnu.org; Fri, 13 Mar 2020 13:24:51 -0400 Received: by mail-wr1-x442.google.com with SMTP id s14so13122519wrt.8 for ; Fri, 13 Mar 2020 10:24:50 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id w204sm8002547wma.1.2020.03.13.10.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2020 10:24:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dLesLAm1eL1nhyeIN3Gcr4+dzCmfTRF/hQyK2zuFN6I=; b=uO9R+YS1tvNkPtMZ5eja5hMz4byHLg9cl1gHFw586JplciQNkgPiFaUgrs6T+AnmHH BTTSab+oD4p1sWCUdheFte8keNeRRJtHtE+S1SwvFJKTLyc8ranTaXqMBvAfi1WeS1Z4 mvLqDSXRzRu2sT59Rwoasgz5bSV6JDlUpr+EKR8j3BnBgvh9HJhJV5wBIWVE10vZ6ckT Um2C7aXww7zE75EyrO7v0ilMSUVae4mVRSroHkgjgvZ12RVSP0AvNdMUJ3DZrwyf7x5D 1cS+0eOoNv704MJOplUAJZsWRwd5/QCDmKwFBLl9KY4ikaseL1DVDGf21eO7hGt6sLb9 X7tw== 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:mime-version :content-transfer-encoding; bh=dLesLAm1eL1nhyeIN3Gcr4+dzCmfTRF/hQyK2zuFN6I=; b=inrGa5A80JJIu9w/J0Oce2LIEY5Dg20hgNPe/j+tKB3ULdstZoVIBWZ1mY0OSVcpZk 5L3eW7Dhc3ScjQ3MLfGX+l742J890Em9R5iZSGR4LXIY/bGvuyM6OXj3dx+4tGjB69no Gg40WsL0z1NIdQ64dQsxgM95sqDuedUOiriqOxjvMO7td20oaZ1ABSSsC+zjZKwY/1JL AEhh19UmAy2MOBTGcmN2wOyj9dbWODS5dAVjocgJoCzWYxaRorIpP6qn8l2ZC5HqiK1U BFUYvjrtdwvFNA+/+2PDhr4/nSXzpjuxBto/Goq4JYrCS8nEnVOmrSnX42fLxd6Z9+cL oFNg== X-Gm-Message-State: ANhLgQ254FzyH+H9eyDWddH6G+Diw4O7qfP8tOas9WDJXMGbXS0lltdI AyyWTSTTTL8O0BCTsZR5mTIaqSQeXR5lAA== X-Google-Smtp-Source: ADFU+vs6v8j5fvuUACzrCUL0+ilZx9PlAGpx2Nq/hnK51KZXJ4ynMf9DqjBowGh5ZyCU8UWt3sdu+w== X-Received: by 2002:adf:fc82:: with SMTP id g2mr19668554wrr.117.1584120289349; Fri, 13 Mar 2020 10:24:49 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH] softmmu/vl.c: Handle '-cpu help' and '-device help' before 'no default machine' Date: Fri, 13 Mar 2020 17:24:47 +0000 Message-Id: <20200313172447.15471-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Kashyap Chamarthy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Currently if you try to ask for the list of CPUs for a target architecture which does not specify a default machine type you just get an error: $ qemu-system-arm -cpu help qemu-system-arm: No machine specified, and there is no default Use -machine help to list supported machines Since the list of CPUs doesn't depend on the machine, this is unnecessarily unhelpful. "-device help" has a similar problem. Move the checks for "did the user ask for -cpu help or -device help" up so they precede the select_machine() call which checks that the user specified a valid machine type. Signed-off-by: Peter Maydell Reviewed-by: Markus Armbruster Tested-by: Kashyap Chamarthy --- This has been on-and-off irritating me for years, and it's embarrassing how simple the fix turns out to be... --- softmmu/vl.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index ff2685dff84..6a285925b37 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -3789,6 +3789,22 @@ void qemu_init(int argc, char **argv, char **envp) */ loc_set_none(); =20 + /* + * Check for -cpu help and -device help before we call select_machine(= ), + * which will return an error if the architecture has no default machi= ne + * type and the user did not specify one, so that the user doesn't need + * to say '-cpu help -machine something'. + */ + if (cpu_option && is_help_option(cpu_option)) { + list_cpus(cpu_option); + exit(0); + } + + if (qemu_opts_foreach(qemu_find_opts("device"), + device_help_func, NULL, NULL)) { + exit(0); + } + user_register_global_props(); =20 replay_configure(icount_opts); @@ -3877,11 +3893,6 @@ void qemu_init(int argc, char **argv, char **envp) qemu_set_hw_version(machine_class->hw_version); } =20 - if (cpu_option && is_help_option(cpu_option)) { - list_cpus(cpu_option); - exit(0); - } - if (!trace_init_backends()) { exit(1); } @@ -4112,11 +4123,6 @@ void qemu_init(int argc, char **argv, char **envp) fsdev_init_func, NULL, &error_fatal); #endif =20 - if (qemu_opts_foreach(qemu_find_opts("device"), - device_help_func, NULL, NULL)) { - exit(0); - } - /* * Note: we need to create block backends before * machine_set_property(), so machine properties can refer to --=20 2.20.1