From: "Daniel P. Berrangé" <berrange@redhat.com>
To: David Hildenbrand <david@redhat.com>
Cc: William Tsai <williamtsai1111@gmail.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Halil Pasic <pasic@linux.ibm.com>,
Eric Farman <farman@linux.ibm.com>,
qemu-devel@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
Hanna Reitz <hreitz@redhat.com>, Eric Blake <eblake@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>,
Peter Lieven <pl@kamp.de>, Fam Zheng <fam@euphon.net>,
"Richard W.M. Jones" <rjones@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Michael Roth <michael.roth@amd.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Eduardo Habkost <eduardo@habkost.net>,
Richard Henderson <richard.henderson@linaro.org>,
Ilya Leoshkevich <iii@linux.ibm.com>,
Thomas Huth <thuth@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
Laurent Vivier <lvivier@redhat.com>,
"open list:Block layer core" <qemu-block@nongnu.org>,
"open list:S390 TCG CPUs" <qemu-s390x@nongnu.org>,
"open list:ARM TCG CPUs" <qemu-arm@nongnu.org>
Subject: Re: [PATCH v2] qdict: Preserve order for iterating qdict elements
Date: Wed, 6 Sep 2023 13:21:03 +0100 [thread overview]
Message-ID: <ZPhurxruVwgfh46h@redhat.com> (raw)
In-Reply-To: <c9ab7061-22da-fed5-97bf-4924fe07cbf8@redhat.com>
On Wed, Sep 06, 2023 at 12:25:30PM +0200, David Hildenbrand wrote:
> On 04.09.23 18:38, Daniel P. Berrangé wrote:
> > On Sat, Sep 02, 2023 at 05:40:40PM +0800, William Tsai wrote:
> > > Changing the structure of qdict so that it can preserve order when
> > > iterating qdict. This will fix array_properties as it relies on `len-`
> > > prefixed argument to be set first.
> > >
> > > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1090
> > > Signed-off-by: William Tsai <williamtsai1111@gmail.com>
> >
> > This is a variation of what Markus illustrated a year ago
> >
> > https://lists.gnu.org/archive/html/qemu-devel/2022-07/msg00758.html
> >
> > I wasn't a particular fan of that approach at the time.
> >
> > I've made an alternative proposal here which avoids the broader
> > impact of this QDict change:
> >
> > https://lists.gnu.org/archive/html/qemu-devel/2023-09/msg00652.html
>
> Just a note regarding s390x CPU models (and how they are also affected, but
> it probably doesn't matter because it never 100% worked that way on all interfaces).
Oh, that's interesting to see a ordering scenario that isn't related
to the PROP_ARRAY stuff we already identified.
> I recall that I thought the order of parameters worked for s390x CPU models,
> where we support feature groups (due to the huge number of CPU features). But this
> might only have worked for the "-cpu" parameter, which parses them in-order and
> sets properties in-order.
>
> So when mixing a feature group with contained features, the end result might not
> be deterministic in other cases thatn "-pu" (CPU hotplug via "-device", but
> also qapi CPU model operations).
>
> For example, one might want to enable all but some features of a group, or
> disable all but some features of a group. Note that I doubt that there are really
> users of that, but it's possible on the QEMU cmdline.
>
> I guess it never really worked with qapi CPU model operations in general
> (baseline, comparison, expansion, ...) because these
> operations all rely on qdict as well (see cpu_model_from_info()). So they should
> never return something non-deterministic.
>
>
> To highlight one case that could now fail:
>
> $ ./qemu-system-s390x -smp 1,maxcpus=2 -cpu qemu,msa2=off,kimd-sha-512=on -nographic -nodefaults -monitor stdio -S -device qemu-s390x-cpu,core-id=1,msa2=off,kimd-sha-512=on
> QEMU 8.1.50 monitor - type 'help' for more information
> qemu-system-s390x: warning: 'msa5-base' requires 'klmd-sha-512'.
> qemu-system-s390x: -device qemu-s390x-cpu,core-id=1,msa2=off,kimd-sha-512=on: warning: 'msa5-base' requires 'kimd-sha-512'.
> qemu-system-s390x: -device qemu-s390x-cpu,core-id=1,msa2=off,kimd-sha-512=on: warning: 'msa5-base' requires 'klmd-sha-512'.
> qemu-system-s390x: -device qemu-s390x-cpu,core-id=1,msa2=off,kimd-sha-512=on: Mixed CPU models are not supported on s390x.
>
> Note that using "-device qemu-s390x-cpu,core-id=1" instead works as expected, as
> cpu_common_parse_features() registers all settings as global properties for
> that CPU type.
>
>
> Further, feature groups might not be used by actual users that way. CPU model expansion (s390_feat_bitmap_to_ascii()) only reports a feature group when all
> features are contained, so most of libvirt should be fine, unless someone decides to
> manually specify a non-deterministic CPU model as above.
>
> So maybe one can conclude that specifying "msa2=off,kimd-sha-512=on" is similar to
> "kimd-sha-512=off,kimd-sha-512=on", and which setting "wins" is not deterministic.
Right now you can have arbitrary ordering of CPU feature groups and
individual features, with both on/off. Historically you could even have
the same feature name repeated with different on/off values and the last
occurrance would "win". This is incredibly flexible, but I think we could
argue this level of flexibility is overkill in practice for 99% of QEMU
deployments.
If we were to define two semantic rules for CPU specification:
* All feature groups are processed before individiual features
* A given feature group name or individual feature name may
only appear once.
That would allow you to provide an implementation whose semantics
are not sensitive to the ordering of parameters, while still keeping
sufficient flexibility for all typical real world use cases.
The only thing I see lacking here is that it prevents users from doing
a "quick hack" of blindly appending "foo=off" to an existing -cpu
argument - they would have to first check if 'foo' already appeared
in the existing -cpu arg and modify it in place. IMHO that's an
acceptable loss
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
prev parent reply other threads:[~2023-09-06 12:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-02 9:40 [PATCH v2] qdict: Preserve order for iterating qdict elements William Tsai
2023-09-04 16:38 ` Daniel P. Berrangé
2023-09-06 10:25 ` David Hildenbrand
2023-09-06 12:21 ` Daniel P. Berrangé [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZPhurxruVwgfh46h@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=david@redhat.com \
--cc=eblake@redhat.com \
--cc=eduardo@habkost.net \
--cc=fam@euphon.net \
--cc=farman@linux.ibm.com \
--cc=hreitz@redhat.com \
--cc=iii@linux.ibm.com \
--cc=kwolf@redhat.com \
--cc=lvivier@redhat.com \
--cc=michael.roth@amd.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=pl@kamp.de \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=rjones@redhat.com \
--cc=thuth@redhat.com \
--cc=vsementsov@yandex-team.ru \
--cc=williamtsai1111@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).