diff mbox series

[PATCH-for-9.1,3/7] monitor: Rework stubs to simplify user emulation linking

Message ID 20240404194757.9343-4-philmd@linaro.org
State New
Headers show
Series buildsys: Start shrinking qemu-user build process | expand

Commit Message

Philippe Mathieu-Daudé April 4, 2024, 7:47 p.m. UTC
Currently monitor stubs are scattered in 3 files.

Merge these stubs in 2 files, a generic one (monitor-core)
included in all builds (in particular user emulation), and
a less generic one to be included by tools and system emulation.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 stubs/fdset.c        | 17 -----------------
 stubs/monitor-core.c | 20 +++++++++++++++-----
 stubs/monitor.c      |  8 ++++++--
 stubs/meson.build    |  5 +++--
 4 files changed, 24 insertions(+), 26 deletions(-)
 delete mode 100644 stubs/fdset.c

Comments

Paolo Bonzini April 8, 2024, 9:50 a.m. UTC | #1
On Thu, Apr 4, 2024 at 9:48 PM Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Currently monitor stubs are scattered in 3 files.
>
> Merge these stubs in 2 files, a generic one (monitor-core)
> included in all builds (in particular user emulation), and
> a less generic one to be included by tools and system emulation.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  stubs/fdset.c        | 17 -----------------

Oops, merging fdset.c breaks storage-daemon linking.

But it is not needed, all I need is

diff --git a/stubs/meson.build b/stubs/meson.build
index 0bf25e6ca53..67cf80aa846 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -10,7 +10,6 @@ stub_ss.add(files('qemu-timer-notify-cb.c'))
 stub_ss.add(files('icount.c'))
 stub_ss.add(files('dump.c'))
 stub_ss.add(files('error-printf.c'))
-stub_ss.add(files('fdset.c'))
 stub_ss.add(files('gdbstub.c'))
 stub_ss.add(files('get-vm-name.c'))
 stub_ss.add(files('graph-lock.c'))
@@ -28,7 +27,10 @@ if libaio.found()
 endif
 stub_ss.add(files('migr-blocker.c'))
 stub_ss.add(files('module-opts.c'))
-stub_ss.add(files('monitor.c'))
+if have_system or have_tools
+  stub_ss.add(files('monitor.c'))
+  stub_ss.add(files('fdset.c'))
+endif
 stub_ss.add(files('monitor-core.c'))
 stub_ss.add(files('physmem.c'))
 stub_ss.add(files('qemu-timer-notify-cb.c'))


Paolo

>  stubs/monitor-core.c | 20 +++++++++++++++-----
>  stubs/monitor.c      |  8 ++++++--
>  stubs/meson.build    |  5 +++--
>  4 files changed, 24 insertions(+), 26 deletions(-)
>  delete mode 100644 stubs/fdset.c
>
> diff --git a/stubs/fdset.c b/stubs/fdset.c
> deleted file mode 100644
> index 56b3663d58..0000000000
> --- a/stubs/fdset.c
> +++ /dev/null
> @@ -1,17 +0,0 @@
> -#include "qemu/osdep.h"
> -#include "monitor/monitor.h"
> -
> -int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags)
> -{
> -    errno = ENOSYS;
> -    return -1;
> -}
> -
> -int64_t monitor_fdset_dup_fd_find(int dup_fd)
> -{
> -    return -1;
> -}
> -
> -void monitor_fdset_dup_fd_remove(int dupfd)
> -{
> -}
> diff --git a/stubs/monitor-core.c b/stubs/monitor-core.c
> index afa477aae6..72e40bcc15 100644
> --- a/stubs/monitor-core.c
> +++ b/stubs/monitor-core.c
> @@ -1,6 +1,7 @@
> +/* Monitor stub required for user emulation */
>  #include "qemu/osdep.h"
>  #include "monitor/monitor.h"
> -#include "qapi/qapi-emit-events.h"
> +#include "../monitor/monitor-internal.h"
>
>  Monitor *monitor_cur(void)
>  {
> @@ -12,11 +13,22 @@ Monitor *monitor_set_cur(Coroutine *co, Monitor *mon)
>      return NULL;
>  }
>
> -void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp)
> +int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags)
> +{
> +    errno = ENOSYS;
> +    return -1;
> +}
> +
> +int64_t monitor_fdset_dup_fd_find(int dup_fd)
> +{
> +    return -1;
> +}
> +
> +void monitor_fdset_dup_fd_remove(int dupfd)
>  {
>  }
>
> -void qapi_event_emit(QAPIEvent event, QDict *qdict)
> +void monitor_fdsets_cleanup(void)
>  {
>  }
>
> @@ -24,5 +36,3 @@ int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
>  {
>      abort();
>  }
> -
> -
> diff --git a/stubs/monitor.c b/stubs/monitor.c
> index 20786ac4ff..2fc4dc1493 100644
> --- a/stubs/monitor.c
> +++ b/stubs/monitor.c
> @@ -1,7 +1,7 @@
>  #include "qemu/osdep.h"
>  #include "qapi/error.h"
> +#include "qapi/qapi-emit-events.h"
>  #include "monitor/monitor.h"
> -#include "../monitor/monitor-internal.h"
>
>  int monitor_get_fd(Monitor *mon, const char *name, Error **errp)
>  {
> @@ -13,6 +13,10 @@ void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp)
>  {
>  }
>
> -void monitor_fdsets_cleanup(void)
> +void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp)
> +{
> +}
> +
> +void qapi_event_emit(QAPIEvent event, QDict *qdict)
>  {
>  }
> diff --git a/stubs/meson.build b/stubs/meson.build
> index 0bf25e6ca5..ca1bc07d30 100644
> --- a/stubs/meson.build
> +++ b/stubs/meson.build
> @@ -10,7 +10,6 @@ stub_ss.add(files('qemu-timer-notify-cb.c'))
>  stub_ss.add(files('icount.c'))
>  stub_ss.add(files('dump.c'))
>  stub_ss.add(files('error-printf.c'))
> -stub_ss.add(files('fdset.c'))
>  stub_ss.add(files('gdbstub.c'))
>  stub_ss.add(files('get-vm-name.c'))
>  stub_ss.add(files('graph-lock.c'))
> @@ -28,7 +27,9 @@ if libaio.found()
>  endif
>  stub_ss.add(files('migr-blocker.c'))
>  stub_ss.add(files('module-opts.c'))
> -stub_ss.add(files('monitor.c'))
> +if have_system or have_tools
> +  stub_ss.add(files('monitor.c'))
> +endif
>  stub_ss.add(files('monitor-core.c'))
>  stub_ss.add(files('physmem.c'))
>  stub_ss.add(files('qemu-timer-notify-cb.c'))
> --
> 2.41.0
>
Philippe Mathieu-Daudé April 8, 2024, 10:59 a.m. UTC | #2
On 8/4/24 11:50, Paolo Bonzini wrote:
> On Thu, Apr 4, 2024 at 9:48 PM Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>
>> Currently monitor stubs are scattered in 3 files.
>>
>> Merge these stubs in 2 files, a generic one (monitor-core)
>> included in all builds (in particular user emulation), and
>> a less generic one to be included by tools and system emulation.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   stubs/fdset.c        | 17 -----------------
> 
> Oops, merging fdset.c breaks storage-daemon linking.

Odd. My 'tools_only' build directory is configured with:

'--enable-tools' '--disable-docs' '--disable-system' '--disable-user'

I was building qemu-img & co. I just checked it isn't anymore,
the directory only contains libqemuutil.a, libqom.fa,
libevent-loop-base.fa and tests/unit (I'm on macOS host).

This explained why I missed the link failure. I'll dig to
see when these tools disappeared on macOS.

Regards,

Phil.
diff mbox series

Patch

diff --git a/stubs/fdset.c b/stubs/fdset.c
deleted file mode 100644
index 56b3663d58..0000000000
--- a/stubs/fdset.c
+++ /dev/null
@@ -1,17 +0,0 @@ 
-#include "qemu/osdep.h"
-#include "monitor/monitor.h"
-
-int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags)
-{
-    errno = ENOSYS;
-    return -1;
-}
-
-int64_t monitor_fdset_dup_fd_find(int dup_fd)
-{
-    return -1;
-}
-
-void monitor_fdset_dup_fd_remove(int dupfd)
-{
-}
diff --git a/stubs/monitor-core.c b/stubs/monitor-core.c
index afa477aae6..72e40bcc15 100644
--- a/stubs/monitor-core.c
+++ b/stubs/monitor-core.c
@@ -1,6 +1,7 @@ 
+/* Monitor stub required for user emulation */
 #include "qemu/osdep.h"
 #include "monitor/monitor.h"
-#include "qapi/qapi-emit-events.h"
+#include "../monitor/monitor-internal.h"
 
 Monitor *monitor_cur(void)
 {
@@ -12,11 +13,22 @@  Monitor *monitor_set_cur(Coroutine *co, Monitor *mon)
     return NULL;
 }
 
-void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp)
+int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags)
+{
+    errno = ENOSYS;
+    return -1;
+}
+
+int64_t monitor_fdset_dup_fd_find(int dup_fd)
+{
+    return -1;
+}
+
+void monitor_fdset_dup_fd_remove(int dupfd)
 {
 }
 
-void qapi_event_emit(QAPIEvent event, QDict *qdict)
+void monitor_fdsets_cleanup(void)
 {
 }
 
@@ -24,5 +36,3 @@  int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
 {
     abort();
 }
-
-
diff --git a/stubs/monitor.c b/stubs/monitor.c
index 20786ac4ff..2fc4dc1493 100644
--- a/stubs/monitor.c
+++ b/stubs/monitor.c
@@ -1,7 +1,7 @@ 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "qapi/qapi-emit-events.h"
 #include "monitor/monitor.h"
-#include "../monitor/monitor-internal.h"
 
 int monitor_get_fd(Monitor *mon, const char *name, Error **errp)
 {
@@ -13,6 +13,10 @@  void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp)
 {
 }
 
-void monitor_fdsets_cleanup(void)
+void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp)
+{
+}
+
+void qapi_event_emit(QAPIEvent event, QDict *qdict)
 {
 }
diff --git a/stubs/meson.build b/stubs/meson.build
index 0bf25e6ca5..ca1bc07d30 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -10,7 +10,6 @@  stub_ss.add(files('qemu-timer-notify-cb.c'))
 stub_ss.add(files('icount.c'))
 stub_ss.add(files('dump.c'))
 stub_ss.add(files('error-printf.c'))
-stub_ss.add(files('fdset.c'))
 stub_ss.add(files('gdbstub.c'))
 stub_ss.add(files('get-vm-name.c'))
 stub_ss.add(files('graph-lock.c'))
@@ -28,7 +27,9 @@  if libaio.found()
 endif
 stub_ss.add(files('migr-blocker.c'))
 stub_ss.add(files('module-opts.c'))
-stub_ss.add(files('monitor.c'))
+if have_system or have_tools
+  stub_ss.add(files('monitor.c'))
+endif
 stub_ss.add(files('monitor-core.c'))
 stub_ss.add(files('physmem.c'))
 stub_ss.add(files('qemu-timer-notify-cb.c'))