[Top][All Lists]

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

Re: [RFC PATCH] qapi: Incorrect attempt to fix building with MC146818RTC

From: Paolo Bonzini
Subject: Re: [RFC PATCH] qapi: Incorrect attempt to fix building with MC146818RTC=n
Date: Tue, 21 Jan 2020 21:44:01 +0100

Il mar 21 gen 2020, 15:22 Markus Armbruster <address@hidden> ha scritto:
> To see it a different way, these are the "C bindings" to QMP, just that
> the implementation is an in-process call rather than RPC.  If the QAPI
> code generator was also able to generate Python bindings and the like,
> they would have to be the same for all QEMU binaries, wouldn't they?

Ommitting the kind of #if we've been discussing is relatively harmless but what about this one, in qapi-types-block-core.h:

    typedef enum BlockdevDriver {
    #if defined(CONFIG_REPLICATION)
    #endif /* defined(CONFIG_REPLICATION) */
    } BlockdevDriver;

Well, I don't think this should be conditional at all. Introspection is a tool to detect unsupported features, not working features. KVM will be present in introspection data even if /dev/kvm doesn't exist on your machine or you don't have permission to access it. I would restrict very much #if usage in QAPI to the very minimum necessary.


If I omit it in the header, I then have to omit it in

    const QEnumLookup BlockdevDriver_lookup = {
        .array = (const char *const[]) {
            [BLOCKDEV_DRIVER_BLKDEBUG] = "blkdebug",
    #if defined(CONFIG_REPLICATION)
            [BLOCKDEV_DRIVER_REPLICATION] = "replication",
    #endif /* defined(CONFIG_REPLICATION) */
        .size = BLOCKDEV_DRIVER__MAX

and God knows what else.  But I must not omit it in qapi-introspect.c's

        QLIT_QDICT(((QLitDictEntry[]) {
            { "meta-type", QLIT_QSTR("enum"), },
            { "name", QLIT_QSTR("245"), },
            { "values", QLIT_QLIST(((QLitObject[]) {
    #if defined(CONFIG_REPLICATION)
    #endif /* defined(CONFIG_REPLICATION) */
            })), },

because that would defeat introspection.

I smell a swamp.

I'd rather not complicate the generator to support not including a
header I feel we *should* include.  #ifdef CONFIG_FOO can occur not just
in QAPI-generated code, and neglecting to include the relevant header
can cause *nasty* problems not just in QAPI-generated code.  Like
inconsistent struct definitions in separate compilation units.  Been
there, debugged that, wasn't fun, do not want to go there again.

reply via email to

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