[PATCH 36/60] util: move datadir.c from system/

Marc-André Lureau posted 60 patches 3 weeks, 2 days ago
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>, John Snow <jsnow@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Mauro Carvalho Chehab <mchehab+huawei@kernel.org>, Pierrick Bouvier <pierrick.bouvier@linaro.org>, Jan Kiszka <jan.kiszka@web.de>, Phil Dennis-Jordan <phil@philjordan.eu>, Richard Henderson <richard.henderson@linaro.org>, Helge Deller <deller@gmx.de>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Gerd Hoffmann <kraxel@redhat.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Samuel Tardieu <sam@rfc1149.net>, Igor Mitsyanko <i.mitsyanko@gmail.com>, "Hervé Poussineau" <hpoussin@reactos.org>, Aleksandar Rikalo <arikalo@gmail.com>, Laurent Vivier <laurent@vivier.eu>, Thomas Huth <th.huth+qemu@posteo.eu>, BALATON Zoltan <balaton@eik.bme.hu>, "Michael S. Tsirkin" <mst@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>, Dmitry Osipenko <dmitry.osipenko@collabora.com>, Dmitry Fleytman <dmitry.fleytman@gmail.com>, Stefano Stabellini <sstabellini@kernel.org>, Anthony PERARD <anthony@xenproject.org>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Alistair Francis <alistair@alistair23.me>, Alex Williamson <alex@shazbot.org>, "Cédric Le Goater" <clg@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Fabiano Rosas <farosas@suse.de>
[PATCH 36/60] util: move datadir.c from system/
Posted by Marc-André Lureau 3 weeks, 2 days ago
The datadir module provides general-purpose data file lookup
utilities that are not specific to system emulation. Move it
to util/ so it can be reused more broadly.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 {system => util}/datadir.c | 0
 system/meson.build         | 1 -
 system/trace-events        | 1 -
 util/meson.build           | 1 +
 util/trace-events          | 3 +++
 5 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/system/datadir.c b/util/datadir.c
similarity index 100%
rename from system/datadir.c
rename to util/datadir.c
diff --git a/system/meson.build b/system/meson.build
index 579e8353d53..9cdfe1b3e75 100644
--- a/system/meson.build
+++ b/system/meson.build
@@ -8,7 +8,6 @@ system_ss.add(files(
   'bootdevice.c',
   'cpus.c',
   'cpu-timers.c',
-  'datadir.c',
   'dirtylimit.c',
   'dma-helpers.c',
   'exit-with-parent.c',
diff --git a/system/trace-events b/system/trace-events
index 6d29a823f04..e6e1b612798 100644
--- a/system/trace-events
+++ b/system/trace-events
@@ -46,7 +46,6 @@ vm_stop_flush_all(int ret) "ret %d"
 
 # vl.c
 vm_state_notify(int running, int reason, const char *reason_str) "running %d reason %d (%s)"
-load_file(const char *name, const char *path) "name %s location %s"
 runstate_set(int current_state, const char *current_state_str, int new_state, const char *new_state_str) "current_run_state %d (%s) new_state %d (%s)"
 system_wakeup_request(int reason) "reason=%d"
 qemu_system_shutdown_request(int reason) "reason=%d"
diff --git a/util/meson.build b/util/meson.build
index 33132c04ad6..cd56fe2ffe4 100644
--- a/util/meson.build
+++ b/util/meson.build
@@ -30,6 +30,7 @@ util_ss.add(when: linux_io_uring, if_true: files('fdmon-io_uring.c'))
 if glib_has_gslice
   util_ss.add(files('qtree.c'))
 endif
+util_ss.add(files('datadir.c'))
 util_ss.add(files('defer-call.c'))
 util_ss.add(files('envlist.c', 'path.c', 'module.c'))
 util_ss.add(files('event.c'))
diff --git a/util/trace-events b/util/trace-events
index 540d6625073..df549646d12 100644
--- a/util/trace-events
+++ b/util/trace-events
@@ -114,3 +114,6 @@ uffd_unregister_memory_failed(void *addr, uint64_t length, int err) "addr: %p le
 # module.c
 module_load_module(const char *name) "file %s"
 module_lookup_object_type(const char *name) "name %s"
+
+# datadir.c
+load_file(const char *name, const char *path) "name %s location %s"

-- 
2.53.0


Re: [PATCH 36/60] util: move datadir.c from system/
Posted by Philippe Mathieu-Daudé 1 week ago
On 17/3/26 09:50, Marc-André Lureau wrote:
> The datadir module provides general-purpose data file lookup
> utilities that are not specific to system emulation. Move it
> to util/ so it can be reused more broadly.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   {system => util}/datadir.c | 0
>   system/meson.build         | 1 -
>   system/trace-events        | 1 -
>   util/meson.build           | 1 +
>   util/trace-events          | 3 +++
>   5 files changed, 4 insertions(+), 2 deletions(-)


> diff --git a/util/meson.build b/util/meson.build
> index 33132c04ad6..cd56fe2ffe4 100644
> --- a/util/meson.build
> +++ b/util/meson.build
> @@ -30,6 +30,7 @@ util_ss.add(when: linux_io_uring, if_true: files('fdmon-io_uring.c'))
>   if glib_has_gslice
>     util_ss.add(files('qtree.c'))
>   endif
> +util_ss.add(files('datadir.c'))

Should we add under 'if have_system' or 'if not have_user'?

Otherwise:

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


Re: [PATCH 36/60] util: move datadir.c from system/
Posted by Marc-André Lureau 6 days, 19 hours ago
Hi

On Wed, Apr 1, 2026 at 1:30 PM Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> On 17/3/26 09:50, Marc-André Lureau wrote:
> > The datadir module provides general-purpose data file lookup
> > utilities that are not specific to system emulation. Move it
> > to util/ so it can be reused more broadly.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >   {system => util}/datadir.c | 0
> >   system/meson.build         | 1 -
> >   system/trace-events        | 1 -
> >   util/meson.build           | 1 +
> >   util/trace-events          | 3 +++
> >   5 files changed, 4 insertions(+), 2 deletions(-)
>
>
> > diff --git a/util/meson.build b/util/meson.build
> > index 33132c04ad6..cd56fe2ffe4 100644
> > --- a/util/meson.build
> > +++ b/util/meson.build
> > @@ -30,6 +30,7 @@ util_ss.add(when: linux_io_uring, if_true: files('fdmon-io_uring.c'))
> >   if glib_has_gslice
> >     util_ss.add(files('qtree.c'))
> >   endif
> > +util_ss.add(files('datadir.c'))
>
> Should we add under 'if have_system' or 'if not have_user'?

We could, it would need an extra condition for qemu-vnc.. but that
doesn't save us much.

There is probably room for improvement in util/ if we wanted to always
build strictly the minimum. But since those are small, generally
useful helpers, the linker will drop the unneeded parts..

> Otherwise:
>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>
Re: [PATCH 36/60] util: move datadir.c from system/
Posted by Daniel P. Berrangé 2 weeks, 1 day ago
On Tue, Mar 17, 2026 at 12:50:50PM +0400, Marc-André Lureau wrote:
> The datadir module provides general-purpose data file lookup
> utilities that are not specific to system emulation. Move it
> to util/ so it can be reused more broadly.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  {system => util}/datadir.c | 0
>  system/meson.build         | 1 -
>  system/trace-events        | 1 -
>  util/meson.build           | 1 +
>  util/trace-events          | 3 +++
>  5 files changed, 4 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|