qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v6 05/12] qapi: Track location that created an i


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v6 05/12] qapi: Track location that created an implicit type
Date: Fri, 02 Oct 2015 18:07:39 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Eric Blake <address@hidden> writes:

> On 10/02/2015 02:54 AM, Markus Armbruster wrote:
>> Eric Blake <address@hidden> writes:
>> 
>>> A future patch will enable deferred error detection in the
>>> various QAPISchema*.check() methods (rather than the current
>>> ad hoc parse checks).
>> 
>> What's "deferred" about them?
>
> With ad hoc parse checks, we validate the .json before calling
> QAPISchemaEntity constructors.  With QAPISchemaEntity.check(), the
> constructor is called on various strings, but the strings may not
> resolve; we don't know about the problem until check() is called.

I guess I'd say something like

    A future patch will move some error checking from the parser to the
    various QAPISchema*.check() methods.  These run only after parsing
    completes.

>> 
>> Perhaps simply: A future patch will move error checking into the various
>> QAPISchema*.check() methods.
>> 
>>>                        But that means the user can request
>>> a QAPI entity that will only fail validation after it has
>>> been initialized.
>> 
>> I'm not sure I get this sentence.
>
> Trying to point out that while pre-patch, the check() method was only
> run on well-formed entities, now post-patch it can raise errors that we
> chose not to detect prior to __init__ time.
>
>>> RFC: I used a class-level static flag to track whether we expected
>>> 'info is None' when creating a QAPISchemaEntity.  This is gross,
>>> because the flag will only be set on the first QAPISchema() instance
>>> (it works because none of our client scripts ever instantiate more
>>> than one schema).  But the only other thing I could think of would
>>> be passing the QAPISchema instance into the constructor for each
>>> QAPISchemaEntity, which is a lot of churn.  Any better ideas on how
>>> best to do the assertion, or should I just drop it?
>>>
>>> Signed-off-by: Eric Blake <address@hidden>
>> 
>> I'd check in QAPISchema._def_entity().
>
> Ah, instead of an assert in QAPISchemaEntity.__init__() (which requires
> a leaky abstraction), instead write the assert into QAPISchema (so the
> flag can now be instance-local).  Makes sense; I'll play with the idea.

:)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]