From nobody Wed May 15 02:24:01 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=1667983532; cv=none; d=zohomail.com; s=zohoarc; b=PkJFLyKjKWQBawpvy3qBRxvKvqGLalcPQQogPv/hUXMmLcdOLPltBHc8+9VJ9J06mUabpJAvgUbrMzksT2qfrcWOW5BaM3B4AWHaRdB72pPXIXqyuZFxv2FJffL6QMY6aR+qRKCbwXqqGgKrjnc/hQRPGOnWjqxNEP8F0HqF9c0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667983532; 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=f2nFlUVhEaE4QoQjyCVUuU1debRJ0ojNm0IVEzjYKAY=; b=ZNcMXWJuiO4aytgV2buLbCpz+F+rMBblUx/+hVnuYDgiAVKzYWKf6b8ewcEORgwXrHLtiQd43xalQewbphY+s2Y15VTwdTe3ARaNuE26KDmh4oa4LuqmSbjfB90TSI6gp6H4ln+W7nl9/Fi1Oijt36r24qVRjYxKvD4LiONou4Y= 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 1667983532312854.8192195221598; Wed, 9 Nov 2022 00:45:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osghZ-00043f-Bu; Wed, 09 Nov 2022 03:44:53 -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 1osghP-000429-E1 for qemu-devel@nongnu.org; Wed, 09 Nov 2022 03:44:45 -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 1osghN-0001bi-FQ for qemu-devel@nongnu.org; Wed, 09 Nov 2022 03:44:43 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-606-aIgMKPXuN5WC8yqtWyEWaA-1; Wed, 09 Nov 2022 03:44:36 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B4EBD3850E8E; Wed, 9 Nov 2022 08:44:35 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.250]) by smtp.corp.redhat.com (Postfix) with ESMTP id C87CF18EB4; Wed, 9 Nov 2022 08:44:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667983480; 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=f2nFlUVhEaE4QoQjyCVUuU1debRJ0ojNm0IVEzjYKAY=; b=KfKlZX169huOvmm8n7rsWDng3ymnuj+2AzNXyHgJsQ0dN699cbgCN0Ih65UcFphVJ30gSR I7DhRHwCpuDqSpcb5HrKvAmilXJ1pxjQ5hkkAf3XwaSb3qRuNNhV4JZQrH9z1LawgbNqO8 gMjATgtx5wubodrqwn0E2T7dtGgfty4= X-MC-Unique: aIgMKPXuN5WC8yqtWyEWaA-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] util/qemu-config: Fix "query-command-line-options" to provide the right values Date: Wed, 9 Nov 2022 09:44:31 +0100 Message-Id: <20221109084431.47141-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1667983533836100001 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 class instead to assemble the list. Fixes: 0a7cf217d8 ("fix regression of qmp_query_command_line_options") Signed-off-by: Thomas Huth --- util/qemu-config.c | 141 ++++++++++++++++----------------------------- 1 file changed, 50 insertions(+), 91 deletions(-) diff --git a/util/qemu-config.c b/util/qemu-config.c index 433488aa56..097c6c3939 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 "qom/object.h" =20 static QemuOptsList *vm_config_groups[48]; static QemuOptsList *drive_config_groups[5]; @@ -149,97 +150,55 @@ 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 CommandLineParameterInfoList *query_machine_properties(void) +{ + CommandLineParameterInfoList *param_list =3D NULL; + CommandLineParameterInfo *info; + ObjectPropertyIterator iter; + ObjectProperty *prop; + ObjectClass *oc; + + oc =3D object_get_class(container_get(object_get_root(), "/machine")); + assert(oc); + + /* 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("emulated machine"); + QAPI_LIST_PREPEND(param_list, info); + + /* Now loop over the properties */ + object_class_property_iter_init(&iter, oc); + while ((prop =3D object_property_iter_next(&iter))) { + if (!prop->set) { + continue; + } + + info =3D g_malloc0(sizeof(*info)); + info->name =3D g_strdup(prop->name); + + if (g_str_equal(prop->type, "bool")) { + 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); + } + + QAPI_LIST_PREPEND(param_list, info); } -}; + + return param_list; +} =20 CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option, const char *opti= on, @@ -266,7 +225,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_machine_properties(); QAPI_LIST_PREPEND(conf_list, info); } =20 --=20 2.31.1