From nobody Thu May 16 20:46:28 2024 Delivered-To: importer@patchew.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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1668176087; cv=none; d=zohomail.com; s=zohoarc; b=fdRDogPcEviXnvmoHjGGB0t3c9h8E11fMHHgOYI+D45bBXA+nzVzZLDCh7OTg8WNGUyhmQzyp+cfgcy8CR2X/EBYEM0+GpdyfqF7kNG4oGJXnY8xNzM8Ggrgap0IfjesVlp0GyRylf4jLRX8n5fKIbBnIgbm1UDHXITMr/ziato= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668176087; 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=6CJN9ZDmLYomDUxnJ18ItSlzOOfLd3RY7FrtiC+MpRE=; b=fiEa2JgxHEIJkZvx8e+xS/B102BshNuLVm6M2e4SvgI5eZk8QH6ZD1lW2Z9glv44HHEEWyL2pYbGAsoJrgzwS1e5OaJlgvNl4CPc6TM5k53k8OTiVwhShD8vwYFo3loBiENw+93v/V4rbUfI07kqoUyx78I23EnvUZSGi0AW+DY= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668176087485949.9509079944949; Fri, 11 Nov 2022 06:14:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otUn8-0002sj-IR; Fri, 11 Nov 2022 09:13:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otUn6-0002bK-5g for qemu-devel@nongnu.org; Fri, 11 Nov 2022 09:13:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otUn4-0003aI-5H for qemu-devel@nongnu.org; Fri, 11 Nov 2022 09:13:55 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-530-zRz0OMLSOaewTwqN8OV0zQ-1; Fri, 11 Nov 2022 09:13:51 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AC75C8001B8; Fri, 11 Nov 2022 14:13:50 +0000 (UTC) Received: from thuth.com (unknown [10.39.194.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id D06B1140EBF5; Fri, 11 Nov 2022 14:13:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668176032; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=6CJN9ZDmLYomDUxnJ18ItSlzOOfLd3RY7FrtiC+MpRE=; b=DiwSx1MX535Zq3lbMPHJFUPlOJ7+reVezslpS/u6z4Y5vOHa3sXOhHIdnnOusJrLzE7m6h lkYhGxsJTAmfo66Hew7Y6Mq1qZoE1fY++sSsvIOCr0XHA2Sw6lHyjQo71fujSy5tZBn7I3 4ryLdZu3stdNE7gFE+dt07HsJ4OnoDo= X-MC-Unique: zRz0OMLSOaewTwqN8OV0zQ-1 From: Thomas Huth To: Paolo Bonzini , qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, Matthew Rosato , Tony Krowiak , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Marcel Apfelbaum , Markus Armbruster Subject: [PATCH v2] util/qemu-config: Fix "query-command-line-options" to provide the right values Date: Fri, 11 Nov 2022 15:13:23 +0100 Message-Id: <20221111141323.246267-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1668176088571100001 Content-Type: text/plain; charset="utf-8" The "query-command-line-options" command uses a hand-crafted list of options that should be returned for the "machine" parameter. This is pretty much out of sync with reality, for example settings like "kvm_shadow_mem" or "accel" are not parameters for the machine anymore. Also, there is no distinction between the targets here, so e.g. the s390x-specific values like "loadparm" in this list also show up with the other targets like x86_64. Let's fix this now by geting rid of the hand-crafted list and by querying the properties of the machine classes instead to assemble the list. Fixes: 0a7cf217d8 ("fix regression of qmp_query_command_line_options") Signed-off-by: Thomas Huth --- v2: Query properties from all machine classes, not only from the current o= ne util/qemu-config.c | 168 +++++++++++++++++++++------------------------ 1 file changed, 77 insertions(+), 91 deletions(-) diff --git a/util/qemu-config.c b/util/qemu-config.c index 433488aa56..cf47e8a3d0 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -8,6 +8,7 @@ #include "qemu/error-report.h" #include "qemu/option.h" #include "qemu/config-file.h" +#include "hw/boards.h" =20 static QemuOptsList *vm_config_groups[48]; static QemuOptsList *drive_config_groups[5]; @@ -149,97 +150,82 @@ static CommandLineParameterInfoList *get_drive_infoli= st(void) return head; } =20 -/* restore machine options that are now machine's properties */ -static QemuOptsList machine_opts =3D { - .merge_lists =3D true, - .head =3D QTAILQ_HEAD_INITIALIZER(machine_opts.head), - .desc =3D { - { - .name =3D "type", - .type =3D QEMU_OPT_STRING, - .help =3D "emulated machine" - },{ - .name =3D "accel", - .type =3D QEMU_OPT_STRING, - .help =3D "accelerator list", - },{ - .name =3D "kernel_irqchip", - .type =3D QEMU_OPT_BOOL, - .help =3D "use KVM in-kernel irqchip", - },{ - .name =3D "kvm_shadow_mem", - .type =3D QEMU_OPT_SIZE, - .help =3D "KVM shadow MMU size", - },{ - .name =3D "kernel", - .type =3D QEMU_OPT_STRING, - .help =3D "Linux kernel image file", - },{ - .name =3D "initrd", - .type =3D QEMU_OPT_STRING, - .help =3D "Linux initial ramdisk file", - },{ - .name =3D "append", - .type =3D QEMU_OPT_STRING, - .help =3D "Linux kernel command line", - },{ - .name =3D "dtb", - .type =3D QEMU_OPT_STRING, - .help =3D "Linux kernel device tree file", - },{ - .name =3D "dumpdtb", - .type =3D QEMU_OPT_STRING, - .help =3D "Dump current dtb to a file and quit", - },{ - .name =3D "phandle_start", - .type =3D QEMU_OPT_NUMBER, - .help =3D "The first phandle ID we may generate dynamically", - },{ - .name =3D "dt_compatible", - .type =3D QEMU_OPT_STRING, - .help =3D "Overrides the \"compatible\" property of the dt roo= t node", - },{ - .name =3D "dump-guest-core", - .type =3D QEMU_OPT_BOOL, - .help =3D "Include guest memory in a core dump", - },{ - .name =3D "mem-merge", - .type =3D QEMU_OPT_BOOL, - .help =3D "enable/disable memory merge support", - },{ - .name =3D "usb", - .type =3D QEMU_OPT_BOOL, - .help =3D "Set on/off to enable/disable usb", - },{ - .name =3D "firmware", - .type =3D QEMU_OPT_STRING, - .help =3D "firmware image", - },{ - .name =3D "iommu", - .type =3D QEMU_OPT_BOOL, - .help =3D "Set on/off to enable/disable Intel IOMMU (VT-d)", - },{ - .name =3D "suppress-vmdesc", - .type =3D QEMU_OPT_BOOL, - .help =3D "Set on to disable self-describing migration", - },{ - .name =3D "aes-key-wrap", - .type =3D QEMU_OPT_BOOL, - .help =3D "enable/disable AES key wrapping using the CPACF wra= pping key", - },{ - .name =3D "dea-key-wrap", - .type =3D QEMU_OPT_BOOL, - .help =3D "enable/disable DEA key wrapping using the CPACF wra= pping key", - },{ - .name =3D "loadparm", - .type =3D QEMU_OPT_STRING, - .help =3D "Up to 8 chars in set of [A-Za-z0-9. ](lower case ch= ars" - " converted to upper case) to pass to machine" - " loader, boot manager, and guest kernel", - }, - { /* End of list */ } +static CommandLineParameterInfo *objprop_to_cmdline_prop(ObjectProperty *p= rop) +{ + CommandLineParameterInfo *info; + + info =3D g_malloc0(sizeof(*info)); + info->name =3D g_strdup(prop->name); + + if (g_str_equal(prop->type, "bool") || g_str_equal(prop->type, "OnOffA= uto")) { + info->type =3D COMMAND_LINE_PARAMETER_TYPE_BOOLEAN; + } else if (g_str_equal(prop->type, "int")) { + info->type =3D COMMAND_LINE_PARAMETER_TYPE_NUMBER; + } else if (g_str_equal(prop->type, "size")) { + info->type =3D COMMAND_LINE_PARAMETER_TYPE_SIZE; + } else { + info->type =3D COMMAND_LINE_PARAMETER_TYPE_STRING; } -}; + + if (prop->description) { + info->has_help =3D true; + info->help =3D g_strdup(prop->description); + } + + return info; +} + +static CommandLineParameterInfoList *query_all_machine_properties(void) +{ + CommandLineParameterInfoList *params =3D NULL, *clpiter; + CommandLineParameterInfo *info; + GSList *machines, *curr_mach; + ObjectPropertyIterator op_iter; + ObjectProperty *prop; + bool is_new; + + machines =3D object_class_get_list(TYPE_MACHINE, false); + assert(machines); + + /* Loop over all machine classes */ + for (curr_mach =3D machines; curr_mach; curr_mach =3D curr_mach->next)= { + object_class_property_iter_init(&op_iter, curr_mach->data); + /* ... and over the properties of each machine: */ + while ((prop =3D object_property_iter_next(&op_iter))) { + if (!prop->set) { + continue; + } + /* + * Check whether the property has already been put into the li= st + * (via another machine class) + */ + is_new =3D true; + for (clpiter =3D params; clpiter !=3D NULL; clpiter =3D clpite= r->next) { + if (g_str_equal(clpiter->value->name, prop->name)) { + is_new =3D false; + break; + } + } + /* If it hasn't been added before, add it now to the list */ + if (is_new) { + info =3D objprop_to_cmdline_prop(prop); + QAPI_LIST_PREPEND(params, info); + } + } + } + + g_slist_free(machines); + + /* Add entry for the "type" parameter */ + info =3D g_malloc0(sizeof(*info)); + info->name =3D g_strdup("type"); + info->type =3D COMMAND_LINE_PARAMETER_TYPE_STRING; + info->has_help =3D true; + info->help =3D g_strdup("machine type"); + QAPI_LIST_PREPEND(params, info); + + return params; +} =20 CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option, const char *opti= on, @@ -266,7 +252,7 @@ CommandLineOptionInfoList *qmp_query_command_line_optio= ns(bool has_option, if (!has_option || !strcmp(option, "machine")) { info =3D g_malloc0(sizeof(*info)); info->option =3D g_strdup("machine"); - info->parameters =3D query_option_descs(machine_opts.desc); + info->parameters =3D query_all_machine_properties(); QAPI_LIST_PREPEND(conf_list, info); } =20 --=20 2.31.1