Message ID | 20210122204441.2145197-10-philmd@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | buildsys: Do not build various objects if not necessary | expand |
On 22/01/21 21:44, Philippe Mathieu-Daudé wrote: > Beside a CPU device, user-mode emulation doesn't access > anything else from qdev subsystem. > > Tools don't need anything from qdev. I prefer to avoid stubs. So if this patch can simply be dropped with no effects on 10-12, that's nicer for me. Paolo > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- > Cc: Laurent Vivier <laurent@vivier.eu> > Cc: Eduardo Habkost <ehabkost@redhat.com> > --- > stubs/qdev.c | 23 +++++++++++++++++++++++ > MAINTAINERS | 1 + > qapi/meson.build | 6 +++++- > stubs/meson.build | 2 ++ > 4 files changed, 31 insertions(+), 1 deletion(-) > create mode 100644 stubs/qdev.c > > diff --git a/stubs/qdev.c b/stubs/qdev.c > new file mode 100644 > index 00000000000..92e61431344 > --- /dev/null > +++ b/stubs/qdev.c > @@ -0,0 +1,23 @@ > +/* > + * QOM stubs > + * > + * Copyright (c) 2021 Red Hat, Inc. > + * > + * Author: > + * Philippe Mathieu-Daudé <philmd@redhat.com> > + * > + * SPDX-License-Identifier: GPL-2.0-or-later > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or later. > + * See the COPYING file in the top-level directory. > + */ > + > +#include "qemu/osdep.h" > +#include "qapi/qapi-events-qdev.h" > + > +void qapi_event_send_device_deleted(bool has_device, > + const char *device, > + const char *path) > +{ > + /* Nothing to do. */ > +} > diff --git a/MAINTAINERS b/MAINTAINERS > index 34359a99b8e..d2dd7c24228 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -2523,6 +2523,7 @@ F: qapi/qom.json > F: qapi/qdev.json > F: scripts/coccinelle/qom-parent-type.cocci > F: softmmu/qdev-monitor.c > +F: stubs/qdev.c > F: qom/ > F: tests/check-qom-interface.c > F: tests/check-qom-proplist.c > diff --git a/qapi/meson.build b/qapi/meson.build > index ab68e7900e4..2839871b478 100644 > --- a/qapi/meson.build > +++ b/qapi/meson.build > @@ -35,7 +35,6 @@ > 'misc-target', > 'net', > 'pragma', > - 'qdev', > 'pci', > 'qom', > 'rdma', > @@ -49,6 +48,11 @@ > 'ui', > 'yank', > ] > +if have_system > + qapi_all_modules += [ > + 'qdev', > + ] > +endif > > qapi_storage_daemon_modules = [ > 'block-core', > diff --git a/stubs/meson.build b/stubs/meson.build > index 1a656cd0704..a054d5877fb 100644 > --- a/stubs/meson.build > +++ b/stubs/meson.build > @@ -53,4 +53,6 @@ > if have_system > stub_ss.add(files('semihost.c')) > stub_ss.add(files('xen-hw-stub.c')) > +else > + stub_ss.add(files('qdev.c')) > endif >
On 1/23/21 7:10 PM, Paolo Bonzini wrote: > On 22/01/21 21:44, Philippe Mathieu-Daudé wrote: >> Beside a CPU device, user-mode emulation doesn't access >> anything else from qdev subsystem. >> >> Tools don't need anything from qdev. > > I prefer to avoid stubs. So if this patch can simply be dropped with no > effects on 10-12, that's nicer for me. The alternative is ugly: -- >8 -- diff --git a/hw/core/qdev.c b/hw/core/qdev.c index cefc5eaa0a9..d09f32e38d6 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -950,7 +950,9 @@ static void device_finalize(Object *obj) if (dev->pending_deleted_event) { g_assert(dev->canonical_path); +#ifdef CONFIG_USER_ONLY qapi_event_send_device_deleted(!!dev->id, dev->id, dev->canonical_path); +#endif g_free(dev->canonical_path); dev->canonical_path = NULL; } --- Maybe wrapping it in an inlined function?
On 24/01/21 01:32, Philippe Mathieu-Daudé wrote: > > The alternative is ugly: > > -- >8 -- > diff --git a/hw/core/qdev.c b/hw/core/qdev.c > index cefc5eaa0a9..d09f32e38d6 100644 > --- a/hw/core/qdev.c > +++ b/hw/core/qdev.c > @@ -950,7 +950,9 @@ static void device_finalize(Object *obj) > if (dev->pending_deleted_event) { > g_assert(dev->canonical_path); > > +#ifdef CONFIG_USER_ONLY > qapi_event_send_device_deleted(!!dev->id, dev->id, > dev->canonical_path); > +#endif > g_free(dev->canonical_path); > dev->canonical_path = NULL; > } > --- Well, the alternative is also to not do anything. There's already a stub for qapi_event_emit, does it really hurt to have the not-stubbed-out code for qapi_event_send_device_deleted? Paolo
diff --git a/stubs/qdev.c b/stubs/qdev.c new file mode 100644 index 00000000000..92e61431344 --- /dev/null +++ b/stubs/qdev.c @@ -0,0 +1,23 @@ +/* + * QOM stubs + * + * Copyright (c) 2021 Red Hat, Inc. + * + * Author: + * Philippe Mathieu-Daudé <philmd@redhat.com> + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qapi/qapi-events-qdev.h" + +void qapi_event_send_device_deleted(bool has_device, + const char *device, + const char *path) +{ + /* Nothing to do. */ +} diff --git a/MAINTAINERS b/MAINTAINERS index 34359a99b8e..d2dd7c24228 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2523,6 +2523,7 @@ F: qapi/qom.json F: qapi/qdev.json F: scripts/coccinelle/qom-parent-type.cocci F: softmmu/qdev-monitor.c +F: stubs/qdev.c F: qom/ F: tests/check-qom-interface.c F: tests/check-qom-proplist.c diff --git a/qapi/meson.build b/qapi/meson.build index ab68e7900e4..2839871b478 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -35,7 +35,6 @@ 'misc-target', 'net', 'pragma', - 'qdev', 'pci', 'qom', 'rdma', @@ -49,6 +48,11 @@ 'ui', 'yank', ] +if have_system + qapi_all_modules += [ + 'qdev', + ] +endif qapi_storage_daemon_modules = [ 'block-core', diff --git a/stubs/meson.build b/stubs/meson.build index 1a656cd0704..a054d5877fb 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -53,4 +53,6 @@ if have_system stub_ss.add(files('semihost.c')) stub_ss.add(files('xen-hw-stub.c')) +else + stub_ss.add(files('qdev.c')) endif
Beside a CPU device, user-mode emulation doesn't access anything else from qdev subsystem. Tools don't need anything from qdev. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> --- Cc: Laurent Vivier <laurent@vivier.eu> Cc: Eduardo Habkost <ehabkost@redhat.com> --- stubs/qdev.c | 23 +++++++++++++++++++++++ MAINTAINERS | 1 + qapi/meson.build | 6 +++++- stubs/meson.build | 2 ++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 stubs/qdev.c