From nobody Mon Nov 17 19:53:34 2025 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=1605105096; cv=none; d=zohomail.com; s=zohoarc; b=Fsfe1k1wNZGeEKsneeVnUnObKdf5ei2sOOMVRbSr7LqMHyofAkLfSTrbzSO+f+/TaKYh4vqZ4ThTxD6Ifx9CZtHPGQhzYsMi8LIhXOkySGIMOQ40zQNbMIge/eTlkD/ZkcigKWjx1FUl+zRG8FyxropfC3KPcen/sfrG7neAr5U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605105096; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TAP/HF9F66LTUeTlSryBoA6ja8DnM0PX+A9pe06+0kE=; b=iA2dzQWNtZuIJWiLdc+eUJ9hS88A5SDrww8SQG8cxFKAeIGSH6s+f1X8I9l5DTdUS6ZxRG8g2+rKuHcnIwvnBIz7n9mXrfTwtUjQFObo3bFB4ZR0C2YybNq9fGQiezvFQYU2CgaV/sRDJw4wpdzj5FqfPouviAYNylKLY6FeDOg= 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 1605105096392987.4471474879289; Wed, 11 Nov 2020 06:31:36 -0800 (PST) Received: from localhost ([::1]:58728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcr9q-0006kb-Cz for importer@patchew.org; Wed, 11 Nov 2020 09:31:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcr4E-0008Gy-EP for qemu-devel@nongnu.org; Wed, 11 Nov 2020 09:25:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:36432) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kcr4C-0001mW-5H for qemu-devel@nongnu.org; Wed, 11 Nov 2020 09:25:46 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-184-6VzlWT-VP76aFoDRZZsnlQ-1; Wed, 11 Nov 2020 09:25:41 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E96B41899421 for ; Wed, 11 Nov 2020 14:25:39 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id A65D16115F; Wed, 11 Nov 2020 14:25:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605104742; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TAP/HF9F66LTUeTlSryBoA6ja8DnM0PX+A9pe06+0kE=; b=HS77VYRNeB5COoATNESXOKAzNFvLHGSltWU0N8GZnhq0hSnpKXRCJALIlV8lwcVihXhOwt sqVvxH0zXnfQ1RyM+k5X10s+mmKIeNgpA01tw8hKFxSBgZ+L9xfSk/LXB4FgPeQzKrYgqS OCTw81qSXpefcYpNqpZF6sg/uksUc9A= X-MC-Unique: 6VzlWT-VP76aFoDRZZsnlQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 05/12] hmp: special case help options for object_add Date: Wed, 11 Nov 2020 09:25:30 -0500 Message-Id: <20201111142537.1213209-6-pbonzini@redhat.com> In-Reply-To: <20201111142537.1213209-1-pbonzini@redhat.com> References: <20201111142537.1213209-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/11 01:42:46 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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_H5=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Fix "object_add help" and "object_add TYPE,help". Signed-off-by: Paolo Bonzini --- include/qom/object_interfaces.h | 9 ++++++++- monitor/hmp-cmds.c | 22 ++++++++-------------- qom/object_interfaces.c | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/include/qom/object_interfaces.h b/include/qom/object_interface= s.h index 07d5cc8832..abb23eaea3 100644 --- a/include/qom/object_interfaces.h +++ b/include/qom/object_interfaces.h @@ -149,6 +149,13 @@ typedef bool (*user_creatable_add_opts_predicate)(cons= t char *type); int user_creatable_add_opts_foreach(void *opaque, QemuOpts *opts, Error **errp); =20 +/** + * user_creatable_print_types: + * + * Prints a list of user-creatable objects to stdout or the monitor. + */ +void user_creatable_print_types(void); + /** * user_creatable_print_help: * @type: the QOM type to be added @@ -174,7 +181,7 @@ bool user_creatable_print_help(const char *type, QemuOp= ts *opts); * no help was requested. It should only be called if we know that help is * requested and it will always print some help. */ -void user_creatable_print_help_from_qdict(QDict *args); +void user_creatable_print_help_from_qdict(const QDict *args); =20 /** * user_creatable_del: diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 65d8ff4849..153ece8176 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1664,23 +1664,17 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdic= t) void hmp_object_add(Monitor *mon, const QDict *qdict) { Error *err =3D NULL; - QemuOpts *opts; - Object *obj =3D NULL; =20 - opts =3D qemu_opts_from_qdict(qemu_find_opts("object"), qdict, &err); - if (err) { - goto end; + if (is_help_option(qdict_get_str(qdict, "qom-type"))) { + user_creatable_print_types(); + return; } - - obj =3D user_creatable_add_opts(opts, &err); - qemu_opts_del(opts); - -end: - hmp_handle_error(mon, err); - - if (obj) { - object_unref(obj); + if (qdict_haskey(qdict, "help")) { + user_creatable_print_help_from_qdict(qdict); + return; } + user_creatable_add_dict((QDict *)qdict, true, &err); + hmp_handle_error(mon, err); } =20 void hmp_getfd(Monitor *mon, const QDict *qdict) diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index 34edc3d1d8..f7dcdf18e2 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -280,7 +280,7 @@ bool user_creatable_print_help(const char *type, QemuOp= ts *opts) return false; } =20 -void user_creatable_print_help_from_qdict(QDict *args) +void user_creatable_print_help_from_qdict(const QDict *args) { const char *type =3D qdict_get_try_str(args, "qom-type"); =20 --=20 2.26.2