qapi/misc-target.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
When configured with --without-default-devices and setting
MC146818RTC=n, the build fails:
LINK x86_64-softmmu/qemu-system-x86_64
/usr/bin/ld: qapi/qapi-commands-misc-target.o: in function `qmp_marshal_rtc_reset_reinjection':
qapi/qapi-commands-misc-target.c:46: undefined reference to `qmp_rtc_reset_reinjection'
/usr/bin/ld: qapi/qapi-commands-misc-target.c:46: undefined reference to `qmp_rtc_reset_reinjection'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:206: qemu-system-x86_64] Error 1
make: *** [Makefile:483: x86_64-softmmu/all] Error 2
This patch tries to fix this, but this is incorrect because QAPI
scripts only provide TARGET definitions, so with MC146818RTC=y we
get:
hw/rtc/mc146818rtc.c:113:6: error: no previous prototype for ‘qmp_rtc_reset_reinjection’ [-Werror=missing-prototypes]
113 | void qmp_rtc_reset_reinjection(Error **errp)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [rules.mak:69: hw/rtc/mc146818rtc.o] Error 1
Any idea? :)
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
qapi/misc-target.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/qapi/misc-target.json b/qapi/misc-target.json
index a00fd821eb..8e49c113d1 100644
--- a/qapi/misc-target.json
+++ b/qapi/misc-target.json
@@ -41,7 +41,7 @@
#
##
{ 'command': 'rtc-reset-reinjection',
- 'if': 'defined(TARGET_I386)' }
+ 'if': 'defined(TARGET_I386) && defined(CONFIG_MC146818RTC)' }
##
--
2.21.0
On 31/12/19 19:49, Philippe Mathieu-Daudé wrote: > When configured with --without-default-devices and setting > MC146818RTC=n, the build fails: > > LINK x86_64-softmmu/qemu-system-x86_64 > /usr/bin/ld: qapi/qapi-commands-misc-target.o: in function `qmp_marshal_rtc_reset_reinjection': > qapi/qapi-commands-misc-target.c:46: undefined reference to `qmp_rtc_reset_reinjection' > /usr/bin/ld: qapi/qapi-commands-misc-target.c:46: undefined reference to `qmp_rtc_reset_reinjection' > collect2: error: ld returned 1 exit status > make[1]: *** [Makefile:206: qemu-system-x86_64] Error 1 > make: *** [Makefile:483: x86_64-softmmu/all] Error 2 > > This patch tries to fix this, but this is incorrect because QAPI > scripts only provide TARGET definitions, so with MC146818RTC=y we > get: > > hw/rtc/mc146818rtc.c:113:6: error: no previous prototype for ‘qmp_rtc_reset_reinjection’ [-Werror=missing-prototypes] > 113 | void qmp_rtc_reset_reinjection(Error **errp) > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > cc1: all warnings being treated as errors > make[1]: *** [rules.mak:69: hw/rtc/mc146818rtc.o] Error 1 > > Any idea? :) Adding a stub seems like a good alternative. Is the purpose of this to change MicroVM's select directive to imply? Paolo
Philippe Mathieu-Daudé <philmd@redhat.com> writes: > When configured with --without-default-devices and setting > MC146818RTC=n, the build fails: > > LINK x86_64-softmmu/qemu-system-x86_64 > /usr/bin/ld: qapi/qapi-commands-misc-target.o: in function `qmp_marshal_rtc_reset_reinjection': > qapi/qapi-commands-misc-target.c:46: undefined reference to `qmp_rtc_reset_reinjection' > /usr/bin/ld: qapi/qapi-commands-misc-target.c:46: undefined reference to `qmp_rtc_reset_reinjection' > collect2: error: ld returned 1 exit status > make[1]: *** [Makefile:206: qemu-system-x86_64] Error 1 > make: *** [Makefile:483: x86_64-softmmu/all] Error 2 > > This patch tries to fix this, but this is incorrect because QAPI > scripts only provide TARGET definitions, so with MC146818RTC=y we > get: > > hw/rtc/mc146818rtc.c:113:6: error: no previous prototype for ‘qmp_rtc_reset_reinjection’ [-Werror=missing-prototypes] > 113 | void qmp_rtc_reset_reinjection(Error **errp) > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > cc1: all warnings being treated as errors > make[1]: *** [rules.mak:69: hw/rtc/mc146818rtc.o] Error 1 > > Any idea? :) > > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- > qapi/misc-target.json | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/qapi/misc-target.json b/qapi/misc-target.json > index a00fd821eb..8e49c113d1 100644 > --- a/qapi/misc-target.json > +++ b/qapi/misc-target.json > @@ -41,7 +41,7 @@ > # > ## > { 'command': 'rtc-reset-reinjection', > - 'if': 'defined(TARGET_I386)' } > + 'if': 'defined(TARGET_I386) && defined(CONFIG_MC146818RTC)' } > > > ## The generated qapi-commands-misc-target.h duly has #if defined(TARGET_I386) && defined(CONFIG_MC146818RTC) void qmp_rtc_reset_reinjection(Error **errp); void qmp_marshal_rtc_reset_reinjection(QDict *args, QObject **ret, Error **errp); #endif /* defined(TARGET_I386) && defined(CONFIG_MC146818RTC) */ mc146818rtc.c includes it. But since it doesn't include config-devices.h, CONFIG_MC146818RTC remains undefined, and the prototype gets suppressed. Crude fix: make mc146818rtc.c #include "config-devices.h".
On 13/01/20 15:01, Markus Armbruster wrote: > Philippe Mathieu-Daudé <philmd@redhat.com> writes: > >> When configured with --without-default-devices and setting >> MC146818RTC=n, the build fails: >> >> LINK x86_64-softmmu/qemu-system-x86_64 >> /usr/bin/ld: qapi/qapi-commands-misc-target.o: in function `qmp_marshal_rtc_reset_reinjection': >> qapi/qapi-commands-misc-target.c:46: undefined reference to `qmp_rtc_reset_reinjection' >> /usr/bin/ld: qapi/qapi-commands-misc-target.c:46: undefined reference to `qmp_rtc_reset_reinjection' >> collect2: error: ld returned 1 exit status >> make[1]: *** [Makefile:206: qemu-system-x86_64] Error 1 >> make: *** [Makefile:483: x86_64-softmmu/all] Error 2 >> >> This patch tries to fix this, but this is incorrect because QAPI >> scripts only provide TARGET definitions, so with MC146818RTC=y we >> get: >> >> hw/rtc/mc146818rtc.c:113:6: error: no previous prototype for ‘qmp_rtc_reset_reinjection’ [-Werror=missing-prototypes] >> 113 | void qmp_rtc_reset_reinjection(Error **errp) >> | ^~~~~~~~~~~~~~~~~~~~~~~~~ >> cc1: all warnings being treated as errors >> make[1]: *** [rules.mak:69: hw/rtc/mc146818rtc.o] Error 1 >> >> Any idea? :) >> >> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> >> --- >> qapi/misc-target.json | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/qapi/misc-target.json b/qapi/misc-target.json >> index a00fd821eb..8e49c113d1 100644 >> --- a/qapi/misc-target.json >> +++ b/qapi/misc-target.json >> @@ -41,7 +41,7 @@ >> # >> ## >> { 'command': 'rtc-reset-reinjection', >> - 'if': 'defined(TARGET_I386)' } >> + 'if': 'defined(TARGET_I386) && defined(CONFIG_MC146818RTC)' } >> >> >> ## > > The generated qapi-commands-misc-target.h duly has > > #if defined(TARGET_I386) && defined(CONFIG_MC146818RTC) > void qmp_rtc_reset_reinjection(Error **errp); > void qmp_marshal_rtc_reset_reinjection(QDict *args, QObject **ret, Error **errp); > #endif /* defined(TARGET_I386) && defined(CONFIG_MC146818RTC) */ > > mc146818rtc.c includes it. But since it doesn't include > config-devices.h, CONFIG_MC146818RTC remains undefined, and the > prototype gets suppressed. > > Crude fix: make mc146818rtc.c #include "config-devices.h". Can we modify the code generator to leave out the #if from the header, and only include it in the .c file? An extra prototype is harmless. Paolo
Paolo Bonzini <pbonzini@redhat.com> writes: > On 13/01/20 15:01, Markus Armbruster wrote: >> Philippe Mathieu-Daudé <philmd@redhat.com> writes: >> >>> When configured with --without-default-devices and setting >>> MC146818RTC=n, the build fails: >>> >>> LINK x86_64-softmmu/qemu-system-x86_64 >>> /usr/bin/ld: qapi/qapi-commands-misc-target.o: in function `qmp_marshal_rtc_reset_reinjection': >>> qapi/qapi-commands-misc-target.c:46: undefined reference to `qmp_rtc_reset_reinjection' >>> /usr/bin/ld: qapi/qapi-commands-misc-target.c:46: undefined reference to `qmp_rtc_reset_reinjection' >>> collect2: error: ld returned 1 exit status >>> make[1]: *** [Makefile:206: qemu-system-x86_64] Error 1 >>> make: *** [Makefile:483: x86_64-softmmu/all] Error 2 >>> >>> This patch tries to fix this, but this is incorrect because QAPI >>> scripts only provide TARGET definitions, so with MC146818RTC=y we >>> get: >>> >>> hw/rtc/mc146818rtc.c:113:6: error: no previous prototype for ‘qmp_rtc_reset_reinjection’ [-Werror=missing-prototypes] >>> 113 | void qmp_rtc_reset_reinjection(Error **errp) >>> | ^~~~~~~~~~~~~~~~~~~~~~~~~ >>> cc1: all warnings being treated as errors >>> make[1]: *** [rules.mak:69: hw/rtc/mc146818rtc.o] Error 1 >>> >>> Any idea? :) >>> >>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> >>> --- >>> qapi/misc-target.json | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/qapi/misc-target.json b/qapi/misc-target.json >>> index a00fd821eb..8e49c113d1 100644 >>> --- a/qapi/misc-target.json >>> +++ b/qapi/misc-target.json >>> @@ -41,7 +41,7 @@ >>> # >>> ## >>> { 'command': 'rtc-reset-reinjection', >>> - 'if': 'defined(TARGET_I386)' } >>> + 'if': 'defined(TARGET_I386) && defined(CONFIG_MC146818RTC)' } >>> >>> >>> ## >> >> The generated qapi-commands-misc-target.h duly has >> >> #if defined(TARGET_I386) && defined(CONFIG_MC146818RTC) >> void qmp_rtc_reset_reinjection(Error **errp); >> void qmp_marshal_rtc_reset_reinjection(QDict *args, QObject **ret, Error **errp); >> #endif /* defined(TARGET_I386) && defined(CONFIG_MC146818RTC) */ >> >> mc146818rtc.c includes it. But since it doesn't include >> config-devices.h, CONFIG_MC146818RTC remains undefined, and the >> prototype gets suppressed. >> >> Crude fix: make mc146818rtc.c #include "config-devices.h". > > Can we modify the code generator to leave out the #if from the header, > and only include it in the .c file? An extra prototype is harmless. Is *everything* we generate into headers just as harmless? Another idea: provide a hook to make the generator insert the #include necessary to get the macros used in 'if'. Yet another idea: include it always in target-specific code, just like config-target.h.
On 21/01/20 06:49, Markus Armbruster wrote: > Paolo Bonzini <pbonzini@redhat.com> writes: > >> On 13/01/20 15:01, Markus Armbruster wrote: >>> Philippe Mathieu-Daudé <philmd@redhat.com> writes: >>> >>>> When configured with --without-default-devices and setting >>>> MC146818RTC=n, the build fails: >>>> >>>> LINK x86_64-softmmu/qemu-system-x86_64 >>>> /usr/bin/ld: qapi/qapi-commands-misc-target.o: in function `qmp_marshal_rtc_reset_reinjection': >>>> qapi/qapi-commands-misc-target.c:46: undefined reference to `qmp_rtc_reset_reinjection' >>>> /usr/bin/ld: qapi/qapi-commands-misc-target.c:46: undefined reference to `qmp_rtc_reset_reinjection' >>>> collect2: error: ld returned 1 exit status >>>> make[1]: *** [Makefile:206: qemu-system-x86_64] Error 1 >>>> make: *** [Makefile:483: x86_64-softmmu/all] Error 2 >>>> >>>> This patch tries to fix this, but this is incorrect because QAPI >>>> scripts only provide TARGET definitions, so with MC146818RTC=y we >>>> get: >>>> >>>> hw/rtc/mc146818rtc.c:113:6: error: no previous prototype for ‘qmp_rtc_reset_reinjection’ [-Werror=missing-prototypes] >>>> 113 | void qmp_rtc_reset_reinjection(Error **errp) >>>> | ^~~~~~~~~~~~~~~~~~~~~~~~~ >>>> cc1: all warnings being treated as errors >>>> make[1]: *** [rules.mak:69: hw/rtc/mc146818rtc.o] Error 1 >>>> >>>> Any idea? :) >>>> >>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> >>>> --- >>>> qapi/misc-target.json | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/qapi/misc-target.json b/qapi/misc-target.json >>>> index a00fd821eb..8e49c113d1 100644 >>>> --- a/qapi/misc-target.json >>>> +++ b/qapi/misc-target.json >>>> @@ -41,7 +41,7 @@ >>>> # >>>> ## >>>> { 'command': 'rtc-reset-reinjection', >>>> - 'if': 'defined(TARGET_I386)' } >>>> + 'if': 'defined(TARGET_I386) && defined(CONFIG_MC146818RTC)' } >>>> >>>> >>>> ## >>> >>> The generated qapi-commands-misc-target.h duly has >>> >>> #if defined(TARGET_I386) && defined(CONFIG_MC146818RTC) >>> void qmp_rtc_reset_reinjection(Error **errp); >>> void qmp_marshal_rtc_reset_reinjection(QDict *args, QObject **ret, Error **errp); >>> #endif /* defined(TARGET_I386) && defined(CONFIG_MC146818RTC) */ >>> >>> mc146818rtc.c includes it. But since it doesn't include >>> config-devices.h, CONFIG_MC146818RTC remains undefined, and the >>> prototype gets suppressed. >>> >>> Crude fix: make mc146818rtc.c #include "config-devices.h". >> >> Can we modify the code generator to leave out the #if from the header, >> and only include it in the .c file? An extra prototype is harmless. > > Is *everything* we generate into headers just as harmless? It should be, since it's just the C version of some JSON. The only problematic thing could be different definitions of the same command for multiple targets, and I think we want to avoid that anyway. 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? Paolo
Paolo Bonzini <pbonzini@redhat.com> writes: > On 21/01/20 06:49, Markus Armbruster wrote: >> Paolo Bonzini <pbonzini@redhat.com> writes: >> >>> On 13/01/20 15:01, Markus Armbruster wrote: >>>> Philippe Mathieu-Daudé <philmd@redhat.com> writes: >>>> >>>>> When configured with --without-default-devices and setting >>>>> MC146818RTC=n, the build fails: >>>>> >>>>> LINK x86_64-softmmu/qemu-system-x86_64 >>>>> /usr/bin/ld: qapi/qapi-commands-misc-target.o: in function `qmp_marshal_rtc_reset_reinjection': >>>>> qapi/qapi-commands-misc-target.c:46: undefined reference to `qmp_rtc_reset_reinjection' >>>>> /usr/bin/ld: qapi/qapi-commands-misc-target.c:46: undefined reference to `qmp_rtc_reset_reinjection' >>>>> collect2: error: ld returned 1 exit status >>>>> make[1]: *** [Makefile:206: qemu-system-x86_64] Error 1 >>>>> make: *** [Makefile:483: x86_64-softmmu/all] Error 2 >>>>> >>>>> This patch tries to fix this, but this is incorrect because QAPI >>>>> scripts only provide TARGET definitions, so with MC146818RTC=y we >>>>> get: >>>>> >>>>> hw/rtc/mc146818rtc.c:113:6: error: no previous prototype for ‘qmp_rtc_reset_reinjection’ [-Werror=missing-prototypes] >>>>> 113 | void qmp_rtc_reset_reinjection(Error **errp) >>>>> | ^~~~~~~~~~~~~~~~~~~~~~~~~ >>>>> cc1: all warnings being treated as errors >>>>> make[1]: *** [rules.mak:69: hw/rtc/mc146818rtc.o] Error 1 >>>>> >>>>> Any idea? :) >>>>> >>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> >>>>> --- >>>>> qapi/misc-target.json | 2 +- >>>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>>> >>>>> diff --git a/qapi/misc-target.json b/qapi/misc-target.json >>>>> index a00fd821eb..8e49c113d1 100644 >>>>> --- a/qapi/misc-target.json >>>>> +++ b/qapi/misc-target.json >>>>> @@ -41,7 +41,7 @@ >>>>> # >>>>> ## >>>>> { 'command': 'rtc-reset-reinjection', >>>>> - 'if': 'defined(TARGET_I386)' } >>>>> + 'if': 'defined(TARGET_I386) && defined(CONFIG_MC146818RTC)' } >>>>> >>>>> >>>>> ## >>>> >>>> The generated qapi-commands-misc-target.h duly has >>>> >>>> #if defined(TARGET_I386) && defined(CONFIG_MC146818RTC) >>>> void qmp_rtc_reset_reinjection(Error **errp); >>>> void qmp_marshal_rtc_reset_reinjection(QDict *args, QObject **ret, Error **errp); >>>> #endif /* defined(TARGET_I386) && defined(CONFIG_MC146818RTC) */ >>>> >>>> mc146818rtc.c includes it. But since it doesn't include >>>> config-devices.h, CONFIG_MC146818RTC remains undefined, and the >>>> prototype gets suppressed. >>>> >>>> Crude fix: make mc146818rtc.c #include "config-devices.h". >>> >>> Can we modify the code generator to leave out the #if from the header, >>> and only include it in the .c file? An extra prototype is harmless. >> >> Is *everything* we generate into headers just as harmless? > > It should be, since it's just the C version of some JSON. The only > problematic thing could be different definitions of the same command for > multiple targets, and I think we want to avoid that anyway. > > 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: #if defined(TARGET_I386) void qmp_rtc_reset_reinjection(Error **errp); void qmp_marshal_rtc_reset_reinjection(QDict *args, QObject **ret, Error **errp); #endif /* defined(TARGET_I386) */ But what about this one, in qapi-types-block-core.h: typedef enum BlockdevDriver { BLOCKDEV_DRIVER_BLKDEBUG, [...] #if defined(CONFIG_REPLICATION) BLOCKDEV_DRIVER_REPLICATION, #endif /* defined(CONFIG_REPLICATION) */ [...] BLOCKDEV_DRIVER__MAX, } BlockdevDriver; If I omit it in the header, I then have to omit it in qapi-types-block-core.c's 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[]) { QLIT_QSTR("blkdebug"), [...] #if defined(CONFIG_REPLICATION) QLIT_QSTR("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.
On 1/21/20 3:22 PM, Markus Armbruster wrote: > Paolo Bonzini <pbonzini@redhat.com> writes: > >> On 21/01/20 06:49, Markus Armbruster wrote: >>> Paolo Bonzini <pbonzini@redhat.com> writes: >>> >>>> On 13/01/20 15:01, Markus Armbruster wrote: >>>>> Philippe Mathieu-Daudé <philmd@redhat.com> writes: >>>>> >>>>>> When configured with --without-default-devices and setting >>>>>> MC146818RTC=n, the build fails: >>>>>> >>>>>> LINK x86_64-softmmu/qemu-system-x86_64 >>>>>> /usr/bin/ld: qapi/qapi-commands-misc-target.o: in function `qmp_marshal_rtc_reset_reinjection': >>>>>> qapi/qapi-commands-misc-target.c:46: undefined reference to `qmp_rtc_reset_reinjection' >>>>>> /usr/bin/ld: qapi/qapi-commands-misc-target.c:46: undefined reference to `qmp_rtc_reset_reinjection' >>>>>> collect2: error: ld returned 1 exit status >>>>>> make[1]: *** [Makefile:206: qemu-system-x86_64] Error 1 >>>>>> make: *** [Makefile:483: x86_64-softmmu/all] Error 2 >>>>>> >>>>>> This patch tries to fix this, but this is incorrect because QAPI >>>>>> scripts only provide TARGET definitions, so with MC146818RTC=y we >>>>>> get: >>>>>> >>>>>> hw/rtc/mc146818rtc.c:113:6: error: no previous prototype for ‘qmp_rtc_reset_reinjection’ [-Werror=missing-prototypes] >>>>>> 113 | void qmp_rtc_reset_reinjection(Error **errp) >>>>>> | ^~~~~~~~~~~~~~~~~~~~~~~~~ >>>>>> cc1: all warnings being treated as errors >>>>>> make[1]: *** [rules.mak:69: hw/rtc/mc146818rtc.o] Error 1 >>>>>> >>>>>> Any idea? :) >>>>>> >>>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> >>>>>> --- >>>>>> qapi/misc-target.json | 2 +- >>>>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>>>> >>>>>> diff --git a/qapi/misc-target.json b/qapi/misc-target.json >>>>>> index a00fd821eb..8e49c113d1 100644 >>>>>> --- a/qapi/misc-target.json >>>>>> +++ b/qapi/misc-target.json >>>>>> @@ -41,7 +41,7 @@ >>>>>> # >>>>>> ## >>>>>> { 'command': 'rtc-reset-reinjection', >>>>>> - 'if': 'defined(TARGET_I386)' } >>>>>> + 'if': 'defined(TARGET_I386) && defined(CONFIG_MC146818RTC)' } >>>>>> >>>>>> >>>>>> ## >>>>> >>>>> The generated qapi-commands-misc-target.h duly has >>>>> >>>>> #if defined(TARGET_I386) && defined(CONFIG_MC146818RTC) >>>>> void qmp_rtc_reset_reinjection(Error **errp); >>>>> void qmp_marshal_rtc_reset_reinjection(QDict *args, QObject **ret, Error **errp); >>>>> #endif /* defined(TARGET_I386) && defined(CONFIG_MC146818RTC) */ >>>>> >>>>> mc146818rtc.c includes it. But since it doesn't include >>>>> config-devices.h, CONFIG_MC146818RTC remains undefined, and the >>>>> prototype gets suppressed. >>>>> >>>>> Crude fix: make mc146818rtc.c #include "config-devices.h". I am happy enough if this 'crude fix' works, I'll test it, thanks! >>>> >>>> Can we modify the code generator to leave out the #if from the header, >>>> and only include it in the .c file? An extra prototype is harmless. >>> >>> Is *everything* we generate into headers just as harmless? >> >> It should be, since it's just the C version of some JSON. The only >> problematic thing could be different definitions of the same command for >> multiple targets, and I think we want to avoid that anyway. >> >> 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: > > #if defined(TARGET_I386) > void qmp_rtc_reset_reinjection(Error **errp); > void qmp_marshal_rtc_reset_reinjection(QDict *args, QObject **ret, Error **errp); > #endif /* defined(TARGET_I386) */ > > But what about this one, in qapi-types-block-core.h: > > typedef enum BlockdevDriver { > BLOCKDEV_DRIVER_BLKDEBUG, > [...] > #if defined(CONFIG_REPLICATION) > BLOCKDEV_DRIVER_REPLICATION, > #endif /* defined(CONFIG_REPLICATION) */ > [...] > BLOCKDEV_DRIVER__MAX, > } BlockdevDriver; > > If I omit it in the header, I then have to omit it in > qapi-types-block-core.c's > > 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[]) { > QLIT_QSTR("blkdebug"), > [...] > #if defined(CONFIG_REPLICATION) > QLIT_QSTR("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. >
Il mar 21 gen 2020, 15:22 Markus Armbruster <armbru@redhat.com> 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 { > BLOCKDEV_DRIVER_BLKDEBUG, > [...] > #if defined(CONFIG_REPLICATION) > BLOCKDEV_DRIVER_REPLICATION, > #endif /* defined(CONFIG_REPLICATION) */ > [...] > BLOCKDEV_DRIVER__MAX, > } 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. Paolo > If I omit it in the header, I then have to omit it in > qapi-types-block-core.c's > > 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[]) { > QLIT_QSTR("blkdebug"), > [...] > #if defined(CONFIG_REPLICATION) > QLIT_QSTR("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. > >
Paolo Bonzini <pbonzini@redhat.com> writes: > Il mar 21 gen 2020, 15:22 Markus Armbruster <armbru@redhat.com> 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 { >> BLOCKDEV_DRIVER_BLKDEBUG, >> [...] >> #if defined(CONFIG_REPLICATION) >> BLOCKDEV_DRIVER_REPLICATION, >> #endif /* defined(CONFIG_REPLICATION) */ >> [...] >> BLOCKDEV_DRIVER__MAX, >> } BlockdevDriver; >> > > Well, I don't think this should be conditional at all. Introspection is a > tool to detect unsupported features, not working features. Isn't this what it does? To detect "replication" is unsupported, check whether it's absent, and "supported" does not imply "works". > 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. Yes. Likewise, "nfs" is present in introspection data even if no NFS server exists on your network, or you don't have permission to use it. QAPI/QMP introspection is compile-time static by design. It can't tell you more than "this QEMU build supports X". That's it's mission. > I would restrict very > much #if usage in QAPI to the very minimum necessary. I'm not sure I understand how you propose to change introspection.
On 22/01/20 06:41, Markus Armbruster wrote: > Paolo Bonzini <pbonzini@redhat.com> writes: > >> Il mar 21 gen 2020, 15:22 Markus Armbruster <armbru@redhat.com> 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 { >>> BLOCKDEV_DRIVER_BLKDEBUG, >>> [...] >>> #if defined(CONFIG_REPLICATION) >>> BLOCKDEV_DRIVER_REPLICATION, >>> #endif /* defined(CONFIG_REPLICATION) */ >>> [...] >>> BLOCKDEV_DRIVER__MAX, >>> } BlockdevDriver; >>> >> >> Well, I don't think this should be conditional at all. Introspection is a >> tool to detect unsupported features, not working features. > > Isn't this what it does? To detect "replication" is unsupported, check > whether it's absent, and "supported" does not imply "works". Indeed... >> 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. > > Yes. > > QAPI/QMP introspection is compile-time static by design. It can't tell > you more than "this QEMU build supports X". ... and I think it would be fine even if it told you less: "this QEMU will not give a parse error if X appears in QMP syntax". For example, QEMU could accept "replication" even if CONFIG_REPLICATION is not defined and therefore using it would always fail. This would allow limiting even more use of conditional compilation. Paolo
Paolo Bonzini <pbonzini@redhat.com> writes: > On 22/01/20 06:41, Markus Armbruster wrote: >> Paolo Bonzini <pbonzini@redhat.com> writes: >> >>> Il mar 21 gen 2020, 15:22 Markus Armbruster <armbru@redhat.com> 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 { >>>> BLOCKDEV_DRIVER_BLKDEBUG, >>>> [...] >>>> #if defined(CONFIG_REPLICATION) >>>> BLOCKDEV_DRIVER_REPLICATION, >>>> #endif /* defined(CONFIG_REPLICATION) */ >>>> [...] >>>> BLOCKDEV_DRIVER__MAX, >>>> } BlockdevDriver; >>>> >>> >>> Well, I don't think this should be conditional at all. Introspection is a >>> tool to detect unsupported features, not working features. >> >> Isn't this what it does? To detect "replication" is unsupported, check >> whether it's absent, and "supported" does not imply "works". > > Indeed... > >>> 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. >> >> Yes. >> >> QAPI/QMP introspection is compile-time static by design. It can't tell >> you more than "this QEMU build supports X". > > ... and I think it would be fine even if it told you less: "this QEMU > will not give a parse error if X appears in QMP syntax". For example, > QEMU could accept "replication" even if CONFIG_REPLICATION is not > defined and therefore using it would always fail. This would allow > limiting even more use of conditional compilation. This is effectively how things worked before we added 'if' to the QAPI schema language. A feature F may (1) not exist in this version of QEMU (2) exist, but configured off for this build of QEMU (3) be present in this build of QEMU When the management application sees (1) or (2), it knows that using F cannot possibly work no matter what you do to the host short of using another build of QEMU. The management application can then reject attempts to use F with a useful error message, or make such attempts impossible (think graying out menu entries). When the management application sees (3), it still needs to be prepared for actual use to fail. Possible failures depend on the feature. Identifying the various kinds of failures can be awkward and/or brittle. Useful error reporting is often hard. A management application doesn't care for the difference between (1) and (2). We added 'if' to the QAPI schema language in part to make the difference disappear. Without it, introspection munges together (2) and (3) instead. The management application's information degrades from "the QEMU I have does not provide F" to "something went wrong". Perhaps the management application can figure out what went wrong, perhaps it can't. Perhaps it doesn't need to know. My point is: we trade away information at the external interface for the benefit of "limiting even more use of conditional compilation". I doubt that's a good trade, not least because I can't quite see how exactly the benefit is, well, beneficial[*]. Anyway, we've had introspection reflect compile time configuration since v3.0.0. I don't think we can break that now. [*] It saves us including headers we really should be including. Anything else?
© 2016 - 2024 Red Hat, Inc.