From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50797C433DB for ; Sat, 13 Mar 2021 10:06:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E2A664D74 for ; Sat, 13 Mar 2021 10:06:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E2A664D74 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lL1AM-0002gA-M8 for qemu-devel@archiver.kernel.org; Sat, 13 Mar 2021 05:06:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lL19U-00028N-31 for qemu-devel@nongnu.org; Sat, 13 Mar 2021 05:05:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:52797) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lL19S-0000NB-6v for qemu-devel@nongnu.org; Sat, 13 Mar 2021 05:05:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615629941; 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: in-reply-to:in-reply-to:references:references; bh=gDRuux+fKj38+t/AkJDOyYNJj6wA/8dRWw5CzEjTOAQ=; b=UhDJCNceSylHBpyHJCEsjJXHi3I1f/Q/KQjye5mtXddp7KfiuqFsEbS9PNZOPJ/GllLYrK 7Kuprep/MU5+21Xe5GzhAkCmNiQA+6JepQvirHsx2GApIAPIJq2b9+2xzuqs8L0F3Ch/FS ftpZ3fDpvyHk5KIaHHyt9e9mPFpkdHI= Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-476-qFYPSI0IMEyS9pRR555_kQ-1; Sat, 13 Mar 2021 05:05:38 -0500 X-MC-Unique: qFYPSI0IMEyS9pRR555_kQ-1 Received: by mail-pf1-f199.google.com with SMTP id g6so10840352pfo.2 for ; Sat, 13 Mar 2021 02:05:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gDRuux+fKj38+t/AkJDOyYNJj6wA/8dRWw5CzEjTOAQ=; b=t3/ZwzCemBYvgV+1rffQ26jJBWuAfSzx9MgPCvAAVUL7IG78WnIU9GyASw7a0GfHre U+Y1X2aPSou3JIFoNNMvqryuhWFshPe7oAiWLNl6bWj/ChtilmpLgm7hMmqPEgl7x3GS Dp0kXWZ6iYV7maaWYAkfSR6uDS4nLbRGKPlmpEWnk3mf9d0gH3A6J8JJRo6nuiA+Ky4T CijPuEWhWacCHzaNnTWWDyiCsYfHZMZ2nT3bezgbZdjM8jXx6NjHst46MHrJpTr7uMze zCpqt46MdgK0xBcOneF39ZmNb/t+zUtfReKkbHvkC3XjYVTQjMhJj29NMo7CKxkQYRnK pSbQ== X-Gm-Message-State: AOAM533JwVHytUVq06+fvPt1P0hIzhn52Y3d9S1+M4VwqLu8g6LT0TKN +QXjHE4AGgNWMRph51NrvIs1YRNlFIDXpBvzyb/xc/4Pru5no4a5sVnebttbA1/1yyDHcPtOe/+ AECEeTJVm0mP447KU+kita8LqirIOl4k= X-Received: by 2002:a17:90a:5d14:: with SMTP id s20mr2916459pji.6.1615629937411; Sat, 13 Mar 2021 02:05:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJHZOxPsg1uj+o4r8G6+f8sW2dlOm4a+wZJom1cxa6bZu1iLuDCnceCVOipaaaKTMsHxAistg8llm50jZAqa4= X-Received: by 2002:a17:90a:5d14:: with SMTP id s20mr2916441pji.6.1615629937131; Sat, 13 Mar 2021 02:05:37 -0800 (PST) MIME-Version: 1.0 References: <20210311172459.990281-1-pbonzini@redhat.com> <20210311172459.990281-3-pbonzini@redhat.com> <87im5vv0j4.fsf@dusky.pond.sub.org> In-Reply-To: <87im5vv0j4.fsf@dusky.pond.sub.org> From: Paolo Bonzini Date: Sat, 13 Mar 2021 11:05:25 +0100 Message-ID: Subject: Re: [PATCH 2/3] qom: move user_creatable_add_opts logic to vl.c and QAPIfy it To: Markus Armbruster 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-Type: multipart/alternative; boundary="0000000000007dd5b205bd682844" Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=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: "Wolf, Kevin" , qemu-devel Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --0000000000007dd5b205bd682844 Content-Type: text/plain; charset="UTF-8" I will use ObjectOptionsQueue like the typedef just above. Paolo Il sab 13 mar 2021, 10:57 Markus Armbruster ha scritto: > One more little thing... > > Paolo Bonzini writes: > > > Emulators are currently using OptsVisitor (via user_creatable_add_opts) > > to parse the -object command line option. This has one extra feature, > > compared to keyval, which is automatic conversion of integers to lists > > as well as support for lists as repeated options: > > > > -object > memory-backend-ram,id=pc.ram,size=1048576000,host-nodes=0,policy=bind > > > > So we cannot replace OptsVisitor with keyval right now. Still, this > > patch moves the user_creatable_add_opts logic to vl.c since it is > > not needed anywhere else, and makes it go through > user_creatable_add_qapi. > > > > In order to minimize code changes, the predicate still takes a string. > > This can be changed later to use the ObjectType QAPI enum directly. > > > > Signed-off-by: Paolo Bonzini > [...] > > diff --git a/softmmu/vl.c b/softmmu/vl.c > > index ff488ea3e7..b245e912e5 100644 > > --- a/softmmu/vl.c > > +++ b/softmmu/vl.c > > @@ -117,6 +117,7 @@ > > #include "qapi/qapi-commands-block-core.h" > > #include "qapi/qapi-commands-migration.h" > > #include "qapi/qapi-commands-misc.h" > > +#include "qapi/qapi-visit-qom.h" > > #include "qapi/qapi-commands-ui.h" > > #include "qapi/qmp/qerror.h" > > #include "sysemu/iothread.h" > > @@ -132,10 +133,16 @@ typedef struct BlockdevOptionsQueueEntry { > > > > typedef QSIMPLEQ_HEAD(, BlockdevOptionsQueueEntry) BlockdevOptionsQueue; > > > > +typedef struct ObjectOption { > > + ObjectOptions *opts; > > + QTAILQ_ENTRY(ObjectOption) next; > > +} ObjectOption; > > + > > The names feel awkward. > > ObjectOption represents a -object option. Fair enough. > > ObjectOptions represents the "options" in its option argument. > > Confusing. Calling the whole thing and one of its parts the same is a > bad idea. > > I never liked calling the key=value things in option arguments > "options". They aren't CLI options, they are optional CLI option > parameters. > > I also don't like calling so many different things "object" (QObject, > Object, ObjectOption, ObjectOptions), but that feels out of scope here. > > Can we please rename ObjectOptions? > > A naming convention for CLI option argument types and boxed QMP command > argument types would be nice. > > [...] > > --0000000000007dd5b205bd682844 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I will use ObjectOptionsQueue like the typedef just = above.

Paolo


I= l sab 13 mar 2021, 10:57 Markus Armbruster <armbru@redhat.com> ha scritto:
One more little thing...

Paolo Bonzini <pbonzini@redhat.com> writes:

> Emulators are currently using OptsVisitor (via user_creatable_add_opts= )
> to parse the -object command line option.=C2=A0 This has one extra fea= ture,
> compared to keyval, which is automatic conversion of integers to lists=
> as well as support for lists as repeated options:
>
>=C2=A0 =C2=A0-object memory-backend-ram,id=3Dpc.ram,size=3D1048576000,h= ost-nodes=3D0,policy=3Dbind
>
> So we cannot replace OptsVisitor with keyval right now.=C2=A0 Still, t= his
> patch moves the user_creatable_add_opts logic to vl.c since it is
> not needed anywhere else, and makes it go through user_creatable_add_q= api.
>
> In order to minimize code changes, the predicate still takes a string.=
> This can be changed later to use the ObjectType QAPI enum directly. >
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[...]
> diff --git a/softmmu/vl.c b/softmmu/vl.c
> index ff488ea3e7..b245e912e5 100644
> --- a/softmmu/vl.c
> +++ b/softmmu/vl.c
> @@ -117,6 +117,7 @@
>=C2=A0 #include "qapi/qapi-commands-block-core.h"
>=C2=A0 #include "qapi/qapi-commands-migration.h"
>=C2=A0 #include "qapi/qapi-commands-misc.h"
> +#include "qapi/qapi-visit-qom.h"
>=C2=A0 #include "qapi/qapi-commands-ui.h"
>=C2=A0 #include "qapi/qmp/qerror.h"
>=C2=A0 #include "sysemu/iothread.h"
> @@ -132,10 +133,16 @@ typedef struct BlockdevOptionsQueueEntry {
>=C2=A0
>=C2=A0 typedef QSIMPLEQ_HEAD(, BlockdevOptionsQueueEntry) BlockdevOptio= nsQueue;
>=C2=A0
> +typedef struct ObjectOption {
> +=C2=A0 =C2=A0 ObjectOptions *opts;
> +=C2=A0 =C2=A0 QTAILQ_ENTRY(ObjectOption) next;
> +} ObjectOption;
> +

The names feel awkward.

ObjectOption represents a -object option.=C2=A0 Fair enough.

ObjectOptions represents the "options" in its option argument.
Confusing.=C2=A0 Calling the whole thing and one of its parts the same is a=
bad idea.

I never liked calling the key=3Dvalue things in option arguments
"options".=C2=A0 They aren't CLI options, they are optional C= LI option
parameters.

I also don't like calling so many different things "object" (= QObject,
Object, ObjectOption, ObjectOptions), but that feels out of scope here.

Can we please rename ObjectOptions?

A naming convention for CLI option argument types and boxed QMP command
argument types would be nice.

[...]

--0000000000007dd5b205bd682844--