[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 1/5] iotests: add qmp recursive sorting funct
Re: [Qemu-devel] [PATCH v4 1/5] iotests: add qmp recursive sorting function
Wed, 19 Dec 2018 12:50:14 -0600
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1
On 12/19/18 11:55 AM, John Snow wrote:
+ # kwargs prior to 3.6 are not ordered, so:
+ od = OrderedDict()
+ for k in sorted(kwargs.keys()):
you can use for k, v in sorted(kwargs.items()):
and use then v instead of kwargs[k]
I don't need to sort the tuples, though, Only the keys -- which are not
duplicated. Is it really worth changing? ...
If I'm reading this correctly:
sorting tuples with unique keys is the same as sorting by the keys, but
gives you the value (as part of the tuple) for free. So the benefit is
+ if isinstance(kwargs[k], dict):
+ od[k] = ordered_kwargs(kwargs[k])
here, you'd write:
if isinstance(v, dict):
od[k] = ordered_kwargs(v)
instead of having to repeat the value lookup.
The motivation is that log() will log whatever you give it and apply
filters that work on that kind of object. Some callers need to filter
rich QMP objects and some callers need to filter text -- this is the way
log() behaves right now and I simply didn't change it.
What qmp_log currently does is convert both the outgoing and incoming
QMP objects to text, and then filters them as text. However, only
precisely one test (206) uses this functionality.
So... I need some way for test 206 to do what it does. One way is to
make a rich QMP filter, which is what I do later in this series under
the pretense that other tests will likely want to filter QMP output, too.
The other approach involves teaching qmp_log to accept two kinds of
filters (qmp and text) and then passing both along to log(), which will
then filter the object before pretty-printing and then apply the text
filters after pretty-printing, and then logging the result.
As it stands now, though, log() just applies all filters to the first
argument without the caller needing to disambiguate. If I teach log() to
use two types of filters, I need to go back through all of the iotests
and teach all callers to specify e.g. qfilters= or tfilters=.
I opted for an approach that let me just edit test 206 instead -- and
one that added a recursive QMP filter that might be useful in the future
for other purposes.
The reasoning here makes sense to me.
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[Qemu-devel] [PATCH v4 3/5] iotests: change qmp_log filters to expect QMP objects only, John Snow, 2018/12/18