softmmu: make qemu_find_file more flexible wrt build dir layout
Subsystems (2)
v3 cover softmmu: make qemu_find_file more flexible wrt build dir layout
The qemu_find_file method impl is rather crude with a variety of problems (detailed in commit message of first patch).
This series addresses those problems, making qemu_find_file much more flexible and able to be trivially extended to find any type of file, both in a (optionally relocated) install tree location and the local build tree.
This is proposed as an alternative to
https://lists.gnu.org/archive/html/qemu-devel/2022-06/msg02589.html
avoiding the need to add many more meson rules to simulate results of 'make install' in the build dir.
It has been tested as follows:
mkdir -p build/quick cd build/quick ./configure --target-list=x86_64-softmmu --prefix=/usr make -j 8 install DESTDIR=`pwd`/../vroot
Now running from build dir:
$ ./build/local/qemu-system-x86_64 -vnc :1 -k fr -trace 'datadir*' -display sdl
datadir_init default data dir /home/berrange/src/virt/qemu/build/local/../share/qemu icon dir /home/berrange/src/virt/qemu/build/local/../share/icons helper dir /home/berrange/src/virt/qemu/build/local/../libexec in build dir 1
datadir_load_file name bios-256k.bin location /home/berrange/src/virt/qemu/build/local/pc-bios/bios-256k.bin errno 0
datadir_load_file name bios-256k.bin location /home/berrange/src/virt/qemu/build/local/pc-bios/bios-256k.bin errno 0
datadir_load_file name kvmvapic.bin location /home/berrange/src/virt/qemu/build/local/pc-bios/kvmvapic.bin errno 0
datadir_load_file name vgabios-stdvga.bin location /home/berrange/src/virt/qemu/build/local/pc-bios/vgabios-stdvga.bin errno 0
datadir_load_file name efi-e1000.rom location /home/berrange/src/virt/qemu/build/local/pc-bios/efi-e1000.rom errno 0
datadir_load_file name 128x128/apps/qemu.png location /home/berrange/src/virt/qemu/build/local/ui/icons/128x128/apps/qemu.png errno 0
datadir_load_file name fr location /home/berrange/src/virt/qemu/build/local/ui/keymaps/fr errno 0 $ ./build/local/qemu-system-x86_64 -vnc :1 -k fr -trace 'datadir*' -display sdl -net bridge
datadir_init default data dir /home/berrange/src/virt/qemu/build/local/../share/qemu icon dir /home/berrange/src/virt/qemu/build/local/../share/icons helper dir /home/berrange/src/virt/qemu/build/local/../libexec in build dir 1
datadir_load_file name qemu-bridge-helper location /home/berrange/src/virt/qemu/build/local/qemu-bridge-helper errno 0
Helper /home/berrange/src/virt/qemu/build/local/qemu-bridge-helper
access denied by acl fileAnd running from the (relocated) install dir:
$ ./build/vroot/usr/bin/qemu-system-x86_64 -vnc :1 -k fr -trace 'datadir*' -display sdl
datadir_init default data dir /home/berrange/src/virt/qemu/build/vroot/usr/bin/../share/qemu icon dir /home/berrange/src/virt/qemu/build/vroot/usr/bin/../share/icons helper dir /home/berrange/src/virt/qemu/build/vroot/usr/bin/../libexec in build dir 0
datadir_load_file name bios-256k.bin location /home/berrange/src/virt/qemu/build/vroot/usr/bin/../qemu-firmware/bios-256k.bin errno 2
datadir_load_file name bios-256k.bin location /home/berrange/src/virt/qemu/build/vroot/usr/bin/../share/qemu/bios-256k.bin errno 0
datadir_load_file name bios-256k.bin location /home/berrange/src/virt/qemu/build/vroot/usr/bin/../qemu-firmware/bios-256k.bin errno 2
datadir_load_file name bios-256k.bin location /home/berrange/src/virt/qemu/build/vroot/usr/bin/../share/qemu/bios-256k.bin errno 0
datadir_load_file name kvmvapic.bin location /home/berrange/src/virt/qemu/build/vroot/usr/bin/../qemu-firmware/kvmvapic.bin errno 2
datadir_load_file name kvmvapic.bin location /home/berrange/src/virt/qemu/build/vroot/usr/bin/../share/qemu/kvmvapic.bin errno 0
datadir_load_file name vgabios-stdvga.bin location /home/berrange/src/virt/qemu/build/vroot/usr/bin/../qemu-firmware/vgabios-stdvga.bin errno 2
datadir_load_file name vgabios-stdvga.bin location /home/berrange/src/virt/qemu/build/vroot/usr/bin/../share/qemu/vgabios-stdvga.bin errno 0
datadir_load_file name efi-e1000.rom location /home/berrange/src/virt/qemu/build/vroot/usr/bin/../qemu-firmware/efi-e1000.rom errno 2
datadir_load_file name efi-e1000.rom location /home/berrange/src/virt/qemu/build/vroot/usr/bin/../share/qemu/efi-e1000.rom errno 0
datadir_load_file name 128x128/apps/qemu.png location /home/berrange/src/virt/qemu/build/vroot/usr/bin/../share/icons/hicolor/128x128/apps/qemu.png errno 0
datadir_load_file name fr location /home/berrange/src/virt/qemu/build/vroot/usr/bin/../share/qemu/keymaps/fr errno 0 $ ./build/vroot/usr/bin/qemu-system-x86_64 -vnc :1 -k fr -trace 'datadir*' -display sdl -net bridge
datadir_init default data dir /home/berrange/src/virt/qemu/build/vroot/usr/bin/../share/qemu icon dir /home/berrange/src/virt/qemu/build/vroot/usr/bin/../share/icons helper dir /home/berrange/src/virt/qemu/build/vroot/usr/bin/../libexec in build dir 0
datadir_load_file name qemu-bridge-helper location /home/berrange/src/virt/qemu/build/vroot/usr/bin/../libexec/qemu-bridge-helper errno 0
Helper /home/berrange/src/virt/qemu/build/vroot/usr/bin/../libexec/qemu-bridge-helper
access denied by acl fileThese trace messages show it searching the correct paths to find the files in both installed and build root cases.
NB, I've been unable to actually test the cocoa.m change since I lack macOS.
Daniel P. Berrangé (4):
softmmu: rewrite handling of qemu_find_file
ui: move 'pc-bios/keymaps' to 'ui/keymaps'
ui: find icons using qemu_find_file
net: convert to use qemu_find_file to locate bridge helper
configure | 1 +
docs/conf.py | 4 +-
include/net/net.h | 3 +-
include/qemu/datadir.h | 8 +-
net/tap.c | 5 +-
pc-bios/meson.build | 1 -
qemu-options.hx | 4 +-
softmmu/datadir.c | 164 +++++++++++-------
softmmu/trace-events | 5 +-
softmmu/vl.c | 2 +-
tests/qtest/fuzz/fuzz.c | 2 +-
ui/cocoa.m | 3 +-
ui/gtk.c | 3 +-
.../apps/qemu.png} | Bin
.../{qemu_16x16.png => 16x16/apps/qemu.png} | Bin
.../{qemu_24x24.png => 24x24/apps/qemu.png} | Bin
.../apps/qemu.png} | Bin
.../{qemu_32x32.bmp => 32x32/apps/qemu.bmp} | Bin
.../{qemu_32x32.png => 32x32/apps/qemu.png} | Bin
.../{qemu_48x48.png => 48x48/apps/qemu.png} | Bin
.../apps/qemu.png} | Bin
.../{qemu_64x64.png => 64x64/apps/qemu.png} | Bin
ui/icons/meson.build | 27 ++-
ui/icons/{ => scalable/apps}/qemu.svg | 0
{pc-bios => ui}/keymaps/ar | 0
{pc-bios => ui}/keymaps/bepo | 0
{pc-bios => ui}/keymaps/cz | 0
{pc-bios => ui}/keymaps/da | 0
{pc-bios => ui}/keymaps/de | 0
{pc-bios => ui}/keymaps/de-ch | 0
{pc-bios => ui}/keymaps/en-gb | 0
{pc-bios => ui}/keymaps/en-us | 0
{pc-bios => ui}/keymaps/es | 0
{pc-bios => ui}/keymaps/et | 0
{pc-bios => ui}/keymaps/fi | 0
{pc-bios => ui}/keymaps/fo | 0
{pc-bios => ui}/keymaps/fr | 0
{pc-bios => ui}/keymaps/fr-be | 0
{pc-bios => ui}/keymaps/fr-ca | 0
{pc-bios => ui}/keymaps/fr-ch | 0
{pc-bios => ui}/keymaps/hr | 0
{pc-bios => ui}/keymaps/hu | 0
{pc-bios => ui}/keymaps/is | 0
{pc-bios => ui}/keymaps/it | 0
{pc-bios => ui}/keymaps/ja | 0
{pc-bios => ui}/keymaps/lt | 0
{pc-bios => ui}/keymaps/lv | 0
{pc-bios => ui}/keymaps/meson.build | 0
{pc-bios => ui}/keymaps/mk | 0
{pc-bios => ui}/keymaps/nl | 0
{pc-bios => ui}/keymaps/no | 0
{pc-bios => ui}/keymaps/pl | 0
{pc-bios => ui}/keymaps/pt | 0
{pc-bios => ui}/keymaps/pt-br | 0
{pc-bios => ui}/keymaps/ru | 0
{pc-bios => ui}/keymaps/sl | 0
{pc-bios => ui}/keymaps/sv | 0
{pc-bios => ui}/keymaps/th | 0
{pc-bios => ui}/keymaps/tr | 0
ui/meson.build | 1 +
ui/sdl2.c | 5 +-
61 files changed, 152 insertions(+), 86 deletions(-)
rename ui/icons/{qemu_128x128.png => 128x128/apps/qemu.png} (100%)
rename ui/icons/{qemu_16x16.png => 16x16/apps/qemu.png} (100%)
rename ui/icons/{qemu_24x24.png => 24x24/apps/qemu.png} (100%)
rename ui/icons/{qemu_256x256.png => 256x256/apps/qemu.png} (100%)
rename ui/icons/{qemu_32x32.bmp => 32x32/apps/qemu.bmp} (100%)
rename ui/icons/{qemu_32x32.png => 32x32/apps/qemu.png} (100%)
rename ui/icons/{qemu_48x48.png => 48x48/apps/qemu.png} (100%)
rename ui/icons/{qemu_512x512.png => 512x512/apps/qemu.png} (100%)
rename ui/icons/{qemu_64x64.png => 64x64/apps/qemu.png} (100%)
rename ui/icons/{ => scalable/apps}/qemu.svg (100%)
rename {pc-bios => ui}/keymaps/ar (100%)
rename {pc-bios => ui}/keymaps/bepo (100%)
rename {pc-bios => ui}/keymaps/cz (100%)
rename {pc-bios => ui}/keymaps/da (100%)
rename {pc-bios => ui}/keymaps/de (100%)
rename {pc-bios => ui}/keymaps/de-ch (100%)
rename {pc-bios => ui}/keymaps/en-gb (100%)
rename {pc-bios => ui}/keymaps/en-us (100%)
rename {pc-bios => ui}/keymaps/es (100%)
rename {pc-bios => ui}/keymaps/et (100%)
rename {pc-bios => ui}/keymaps/fi (100%)
rename {pc-bios => ui}/keymaps/fo (100%)
rename {pc-bios => ui}/keymaps/fr (100%)
rename {pc-bios => ui}/keymaps/fr-be (100%)
rename {pc-bios => ui}/keymaps/fr-ca (100%)
rename {pc-bios => ui}/keymaps/fr-ch (100%)
rename {pc-bios => ui}/keymaps/hr (100%)
rename {pc-bios => ui}/keymaps/hu (100%)
rename {pc-bios => ui}/keymaps/is (100%)
rename {pc-bios => ui}/keymaps/it (100%)
rename {pc-bios => ui}/keymaps/ja (100%)
rename {pc-bios => ui}/keymaps/lt (100%)
rename {pc-bios => ui}/keymaps/lv (100%)
rename {pc-bios => ui}/keymaps/meson.build (100%)
rename {pc-bios => ui}/keymaps/mk (100%)
rename {pc-bios => ui}/keymaps/nl (100%)
rename {pc-bios => ui}/keymaps/no (100%)
rename {pc-bios => ui}/keymaps/pl (100%)
rename {pc-bios => ui}/keymaps/pt (100%)
rename {pc-bios => ui}/keymaps/pt-br (100%)
rename {pc-bios => ui}/keymaps/ru (100%)
rename {pc-bios => ui}/keymaps/sl (100%)
rename {pc-bios => ui}/keymaps/sv (100%)
rename {pc-bios => ui}/keymaps/th (100%)
rename {pc-bios => ui}/keymaps/tr (100%)Signature · 1 line
2.36.1
PATCH v3 1/4 softmmu: rewrite handling of qemu_find_file
The qemu_find_file method has a couple of flaws in its current implementation:
* The configure time 'qemu-firmware' search path is mistakenly also used to find keymaps
* The configure time 'qemu-firmware' search path is mistakenly relocated even when running from build dir resulting in non-sensical paths that won't resolve
* When searching for files it has the assumption that the in-build-tree layout will match the installed root layout
The latter problem has forced us to keep the keymap files under a sub-dir of the pc-bios/ instead of ui/.
This all stems from the way qemu_find_file tries to use a single list of data directory locations, appending a type specific subdir.
This can be addressed by refactoring the logic as follows
For each type of file to be found identify
* Optional: any user specified dir (non-relocated)
* Path relative to build dir
* Path relative to install dir
* Optional: extra configure time install dirs (bios only, relocated)
* The default install directory (relocated)
We can then search through:
* User specified dir
* If running from build dir
- Path relative to build dir
else
- Extra configure time dirs
- Path relative to default install dir
This is now flexible enough to extend to find any type of file, by plugging in different input values, regardless of what layout might be used in build dir vs install dir.
--- include/qemu/datadir.h | 5 +- softmmu/datadir.c | 145 +++++++++++++++++++++++----------------- softmmu/trace-events | 5 +- softmmu/vl.c | 2 +- tests/qtest/fuzz/fuzz.c | 2 +- 5 files changed, 92 insertions(+), 67 deletions(-)
include/qemu/datadir.h +4 -1
@@ -15,6 +15,9 @@* configured at build time (DATADIR) or registered with the -L command * line option. * +* @name may be NULL to indicate the caller just wants the +* first search directory that is found. +* * The caller must use g_free() to free the returned data when it is * no longer required. *
@@ -22,7 +25,7 @@*/ char *qemu_find_file (int type,const char *name);void qemu_add_default_firmwarepath (void ); -void qemu_add_data_dir (char *path); +void qemu_set_user_data_dir (const char *path);void qemu_list_data_dirs (void );#endif
softmmu/datadir.c +82 -63
184 lines not on this page · raw message
softmmu/trace-events +4 -1
@@ -4,6 +4,10 @@ # Since requests are raised via monitor, not many tracepoints are needed. balloon_event(void *opaque, unsigned long addr) "opaque %p addr %lu" +# datadir.c +datadir_load_file(const char *name, const char *path, int err) "name %s location %s errno %d" +datadir_init(const char *defdatadir, bool inbuilddir) "default data dir %s in build dir %d" + # ioport.c cpu_in(unsigned int addr, char size, unsigned int val) "addr 0x%x(%c) value %u" cpu_out(unsigned int addr, char size, unsigned int val) "addr 0x%x(%c) value %u"
@@ -26,7 +30,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"
softmmu/vl.c +1 -1
@@ -2898,7 +2898,7 @@ void qemu_init(int argc, char **argv, char **envp)if (is_help_option (optarg)) { list_data_dirs = true; }else { -qemu_add_data_dir (g_strdup (optarg)); +qemu_set_user_data_dir (optarg); }break ;case QEMU_OPTION_bios:
tests/qtest/fuzz/fuzz.c +1 -1
@@ -186,7 +186,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp) bindir =qemu_get_exec_dir (); datadir =g_build_filename (bindir,"pc-bios" ,NULL );if (g_file_test (datadir,G_FILE_TEST_IS_DIR )) { -qemu_add_data_dir (datadir); +qemu_set_data_dir (datadir); }else {g_free (datadir); }
Signature · 1 line
2.36.1
PATCH v3 2/4 ui: move 'pc-bios/keymaps' to 'ui/keymaps'
In reply to Daniel P. BerrangéThe 'keymaps' directory contents is nothing to do with the firmware blobs. The 'pc-bios/keymaps' directory appears to have been used previously as a convenience for getting the files installed into a subdir of the firmware install dir, as well as to make it easier to launch QEMU directly from the build tree. These requirements do not need to be reflected in the source tree arrangement. The keymaps logically belong with the UI code, and meson can install them into the right place. For in-tree execution, we merely need a suitable symlink from the source tree to the build tree.
---
pc-bios/meson.build | 1 -
softmmu/datadir.c | 2 +-
{pc-bios => ui}/keymaps/ar | 0
{pc-bios => ui}/keymaps/bepo | 0
{pc-bios => ui}/keymaps/cz | 0
{pc-bios => ui}/keymaps/da | 0
{pc-bios => ui}/keymaps/de | 0
{pc-bios => ui}/keymaps/de-ch | 0
{pc-bios => ui}/keymaps/en-gb | 0
{pc-bios => ui}/keymaps/en-us | 0
{pc-bios => ui}/keymaps/es | 0
{pc-bios => ui}/keymaps/et | 0
{pc-bios => ui}/keymaps/fi | 0
{pc-bios => ui}/keymaps/fo | 0
{pc-bios => ui}/keymaps/fr | 0
{pc-bios => ui}/keymaps/fr-be | 0
{pc-bios => ui}/keymaps/fr-ca | 0
{pc-bios => ui}/keymaps/fr-ch | 0
{pc-bios => ui}/keymaps/hr | 0
{pc-bios => ui}/keymaps/hu | 0
{pc-bios => ui}/keymaps/is | 0
{pc-bios => ui}/keymaps/it | 0
{pc-bios => ui}/keymaps/ja | 0
{pc-bios => ui}/keymaps/lt | 0
{pc-bios => ui}/keymaps/lv | 0
{pc-bios => ui}/keymaps/meson.build | 0
{pc-bios => ui}/keymaps/mk | 0
{pc-bios => ui}/keymaps/nl | 0
{pc-bios => ui}/keymaps/no | 0
{pc-bios => ui}/keymaps/pl | 0
{pc-bios => ui}/keymaps/pt | 0
{pc-bios => ui}/keymaps/pt-br | 0
{pc-bios => ui}/keymaps/ru | 0
{pc-bios => ui}/keymaps/sl | 0
{pc-bios => ui}/keymaps/sv | 0
{pc-bios => ui}/keymaps/th | 0
{pc-bios => ui}/keymaps/tr | 0
ui/meson.build | 1 +
38 files changed, 2 insertions(+), 2 deletions(-)
rename {pc-bios => ui}/keymaps/ar (100%)
rename {pc-bios => ui}/keymaps/bepo (100%)
rename {pc-bios => ui}/keymaps/cz (100%)
rename {pc-bios => ui}/keymaps/da (100%)
rename {pc-bios => ui}/keymaps/de (100%)
rename {pc-bios => ui}/keymaps/de-ch (100%)
rename {pc-bios => ui}/keymaps/en-gb (100%)
rename {pc-bios => ui}/keymaps/en-us (100%)
rename {pc-bios => ui}/keymaps/es (100%)
rename {pc-bios => ui}/keymaps/et (100%)
rename {pc-bios => ui}/keymaps/fi (100%)
rename {pc-bios => ui}/keymaps/fo (100%)
rename {pc-bios => ui}/keymaps/fr (100%)
rename {pc-bios => ui}/keymaps/fr-be (100%)
rename {pc-bios => ui}/keymaps/fr-ca (100%)
rename {pc-bios => ui}/keymaps/fr-ch (100%)
rename {pc-bios => ui}/keymaps/hr (100%)
rename {pc-bios => ui}/keymaps/hu (100%)
rename {pc-bios => ui}/keymaps/is (100%)
rename {pc-bios => ui}/keymaps/it (100%)
rename {pc-bios => ui}/keymaps/ja (100%)
rename {pc-bios => ui}/keymaps/lt (100%)
rename {pc-bios => ui}/keymaps/lv (100%)
rename {pc-bios => ui}/keymaps/meson.build (100%)
rename {pc-bios => ui}/keymaps/mk (100%)
rename {pc-bios => ui}/keymaps/nl (100%)
rename {pc-bios => ui}/keymaps/no (100%)
rename {pc-bios => ui}/keymaps/pl (100%)
rename {pc-bios => ui}/keymaps/pt (100%)
rename {pc-bios => ui}/keymaps/pt-br (100%)
rename {pc-bios => ui}/keymaps/ru (100%)
rename {pc-bios => ui}/keymaps/sl (100%)
rename {pc-bios => ui}/keymaps/sv (100%)
rename {pc-bios => ui}/keymaps/th (100%)
rename {pc-bios => ui}/keymaps/tr (100%)pc-bios/meson.build +0 -1
@@ -97,4 +97,3 @@ foreach f : blobs endforeach subdir('descriptors') -subdir('keymaps')
softmmu/datadir.c +1 -1
@@ -62,7 +62,7 @@ char *qemu_find_file(int type, const char *name)case QEMU_FILE_TYPE_KEYMAP : user_install_dir = user_data_dir; rel_install_dir ="keymaps" ; - rel_build_dir ="pc-bios/keymaps" ; + rel_build_dir ="ui/keymaps" ; default_install_dir = default_data_dir;break ;
ui/keymaps/ar renamed from pc-bios/keymaps/ar +0 -0
ui/keymaps/bepo renamed from pc-bios/keymaps/bepo +0 -0
ui/keymaps/cz renamed from pc-bios/keymaps/cz +0 -0
ui/keymaps/da renamed from pc-bios/keymaps/da +0 -0
ui/keymaps/de renamed from pc-bios/keymaps/de +0 -0
ui/keymaps/de-ch renamed from pc-bios/keymaps/de-ch +0 -0
ui/keymaps/en-gb renamed from pc-bios/keymaps/en-gb +0 -0
ui/keymaps/en-us renamed from pc-bios/keymaps/en-us +0 -0
ui/keymaps/es renamed from pc-bios/keymaps/es +0 -0
ui/keymaps/et renamed from pc-bios/keymaps/et +0 -0
ui/keymaps/fi renamed from pc-bios/keymaps/fi +0 -0
ui/keymaps/fo renamed from pc-bios/keymaps/fo +0 -0
ui/keymaps/fr renamed from pc-bios/keymaps/fr +0 -0
ui/keymaps/fr-be renamed from pc-bios/keymaps/fr-be +0 -0
ui/keymaps/fr-ca renamed from pc-bios/keymaps/fr-ca +0 -0
ui/keymaps/fr-ch renamed from pc-bios/keymaps/fr-ch +0 -0
ui/keymaps/hr renamed from pc-bios/keymaps/hr +0 -0
ui/keymaps/hu renamed from pc-bios/keymaps/hu +0 -0
ui/keymaps/is renamed from pc-bios/keymaps/is +0 -0
ui/keymaps/it renamed from pc-bios/keymaps/it +0 -0
ui/keymaps/ja renamed from pc-bios/keymaps/ja +0 -0
ui/keymaps/lt renamed from pc-bios/keymaps/lt +0 -0
ui/keymaps/lv renamed from pc-bios/keymaps/lv +0 -0
ui/keymaps/meson.build renamed from pc-bios/keymaps/meson.build +0 -0
ui/keymaps/mk renamed from pc-bios/keymaps/mk +0 -0
ui/keymaps/nl renamed from pc-bios/keymaps/nl +0 -0
ui/keymaps/no renamed from pc-bios/keymaps/no +0 -0
ui/keymaps/pl renamed from pc-bios/keymaps/pl +0 -0
ui/keymaps/pt renamed from pc-bios/keymaps/pt +0 -0
ui/keymaps/pt-br renamed from pc-bios/keymaps/pt-br +0 -0
ui/keymaps/ru renamed from pc-bios/keymaps/ru +0 -0
ui/keymaps/sl renamed from pc-bios/keymaps/sl +0 -0
ui/keymaps/sv renamed from pc-bios/keymaps/sv +0 -0
ui/keymaps/th renamed from pc-bios/keymaps/th +0 -0
ui/keymaps/tr renamed from pc-bios/keymaps/tr +0 -0
ui/meson.build +1 -0
@@ -170,6 +170,7 @@ if have_system or xkbcommon.found() endif subdir('shader') +subdir('keymaps') if have_system subdir('icons')
Signature · 1 line
2.36.1
PATCH v3 3/4 ui: find icons using qemu_find_file
In reply to Daniel P. BerrangéThe SDL/GTK/Cocoa UIs currently fail to load icons when run from the build directory as get_resource returns a bogus path.
To address this we first re-arrange the ui/icons sub-directory so that its layout reflects the contents that will be installed.
Then we introduce QEMU_FILE_TYPE_ICON to qemu_find_file such that it can locate icons from the build dir.
---
configure | 1 +
docs/conf.py | 4 +--
include/qemu/datadir.h | 2 ++
softmmu/datadir.c | 12 +++++++-
softmmu/trace-events | 2 +-
ui/cocoa.m | 3 +-
ui/gtk.c | 3 +-
.../apps/qemu.png} | Bin
.../{qemu_16x16.png => 16x16/apps/qemu.png} | Bin
.../{qemu_24x24.png => 24x24/apps/qemu.png} | Bin
.../apps/qemu.png} | Bin
.../{qemu_32x32.bmp => 32x32/apps/qemu.bmp} | Bin
.../{qemu_32x32.png => 32x32/apps/qemu.png} | Bin
.../{qemu_48x48.png => 48x48/apps/qemu.png} | Bin
.../apps/qemu.png} | Bin
.../{qemu_64x64.png => 64x64/apps/qemu.png} | Bin
ui/icons/meson.build | 27 ++++++++++++------
ui/icons/{ => scalable/apps}/qemu.svg | 0
ui/sdl2.c | 5 ++--
19 files changed, 43 insertions(+), 16 deletions(-)
rename ui/icons/{qemu_128x128.png => 128x128/apps/qemu.png} (100%)
rename ui/icons/{qemu_16x16.png => 16x16/apps/qemu.png} (100%)
rename ui/icons/{qemu_24x24.png => 24x24/apps/qemu.png} (100%)
rename ui/icons/{qemu_256x256.png => 256x256/apps/qemu.png} (100%)
rename ui/icons/{qemu_32x32.bmp => 32x32/apps/qemu.bmp} (100%)
rename ui/icons/{qemu_32x32.png => 32x32/apps/qemu.png} (100%)
rename ui/icons/{qemu_48x48.png => 48x48/apps/qemu.png} (100%)
rename ui/icons/{qemu_512x512.png => 512x512/apps/qemu.png} (100%)
rename ui/icons/{qemu_64x64.png => 64x64/apps/qemu.png} (100%)
rename ui/icons/{ => scalable/apps}/qemu.svg (100%)configure +1 -0
@@ -2218,6 +2218,7 @@ LINKS="$LINKS tests/avocado tests/data" LINKS="$LINKS tests/qemu-iotests/check" LINKS="$LINKS python" LINKS="$LINKS contrib/plugins/Makefile " +LINKS="$LINKS ui/icons " for f in $LINKS ; do if [ -e "$source_path/$f" ]; then mkdir -p `dirname ./$f`
docs/conf.py +2 -2
@@ -180,9 +180,9 @@ "navigation_with_keys": True, } -html_logo = os.path.join(qemu_docdir, "../ui/icons/qemu_128x128.png") +html_logo = os.path.join(qemu_docdir, "../ui/icons/128x128/apps/qemu.png") -html_favicon = os.path.join(qemu_docdir, "../ui/icons/qemu_32x32.png") +html_favicon = os.path.join(qemu_docdir, "../ui/icons/32x32/apps/qemu.png") # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files,
include/qemu/datadir.h +2 -0
@@ -3,6 +3,8 @@#define QEMU_FILE_TYPE_BIOS 0#define QEMU_FILE_TYPE_KEYMAP 1 +#define QEMU_FILE_TYPE_ICON 2 +/** * qemu_find_file: * @type: QEMU_FILE_TYPE_BIOS (for BIOS, VGA BIOS)
softmmu/datadir.c +11 -1
@@ -35,6 +35,7 @@ static char **extra_firmware_dirs;/* Default built-in directories */ static char *default_data_dir; +static char *default_icon_dir;/* Whether we're known to be executing from a build tree */ static bool in_build_dir;
@@ -66,6 +67,12 @@ char *qemu_find_file(int type, const char *name) default_install_dir = default_data_dir;break ; +case QEMU_FILE_TYPE_ICON : + rel_install_dir ="hicolor" ; + rel_build_dir ="ui/icons" ; + default_install_dir = default_icon_dir; +break ; +default :abort (); }
@@ -132,8 +139,11 @@ void qemu_add_default_firmwarepath(void)/* Add default dirs relative to the executable path */ default_data_dir =get_relocated_path (CONFIG_QEMU_DATADIR ); + default_icon_dir =get_relocated_path (CONFIG_QEMU_ICONDIR ); -trace_datadir_init (default_data_dir, in_build_dir); +trace_datadir_init (default_data_dir, + default_icon_dir, + in_build_dir); }void qemu_list_data_dirs (void )
softmmu/trace-events +1 -1
@@ -6,7 +6,7 @@ balloon_event(void *opaque, unsigned long addr) "opaque %p addr %lu" # datadir.c datadir_load_file(const char *name, const char *path, int err) "name %s location %s errno %d" -datadir_init(const char *defdatadir, bool inbuilddir) "default data dir %s in build dir %d" +datadir_init(const char *defdatadir, const char *deficondir, bool inbuilddir) "default data dir %s icon dir %s in build dir %d" # ioport.c cpu_in(unsigned int addr, char size, unsigned int val) "addr 0x%x(%c) value %u"
ui/cocoa.m +2 -1
@@ -45,6 +45,7 @@ #include "qemu/cutils.h" #include "qemu/main-loop.h" #include "qemu/module.h" +#include "qemu/datadir.h" #include <Carbon/Carbon.h> #include "hw/core/cpu.h"
@@ -1558,7 +1559,7 @@ - (BOOL)verifyQuit - (IBAction) do_about_menu_item: (id) sender { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - char *icon_path_c = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/512x512/apps/qemu.png"); + char *icon_path_c = qemu_find_file(QEMU_FILE_TYPE_ICON, "512x512/apps/qemu.png"); NSString *icon_path = [NSString stringWithUTF8String:icon_path_c]; g_free(icon_path_c); NSImage *icon = [[NSImage alloc] initWithContentsOfFile:icon_path];
ui/gtk.c +2 -1
@@ -31,6 +31,7 @@#define LOCALEDIR "po"#include "qemu/osdep.h" +#include "qemu/datadir.h" #include "qapi/error.h" #include "qapi/qapi-commands-control.h" #include "qapi/qapi-commands-machine.h"
@@ -2314,7 +2315,7 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts) s->opts = opts; theme =gtk_icon_theme_get_default (); - dir =get_relocated_path (CONFIG_QEMU_ICONDIR ); + dir =qemu_find_file (QEMU_FILE_TYPE_ICON ,NULL );gtk_icon_theme_prepend_search_path (theme, dir);g_free (dir);g_set_prgname ("qemu" );
ui/icons/128x128/apps/qemu.png renamed from ui/icons/qemu_128x128.png +0 -0
ui/icons/16x16/apps/qemu.png renamed from ui/icons/qemu_16x16.png +0 -0
ui/icons/24x24/apps/qemu.png renamed from ui/icons/qemu_24x24.png +0 -0
ui/icons/256x256/apps/qemu.png renamed from ui/icons/qemu_256x256.png +0 -0
ui/icons/32x32/apps/qemu.bmp renamed from ui/icons/qemu_32x32.bmp +0 -0
ui/icons/32x32/apps/qemu.png renamed from ui/icons/qemu_32x32.png +0 -0
ui/icons/48x48/apps/qemu.png renamed from ui/icons/qemu_48x48.png +0 -0
ui/icons/512x512/apps/qemu.png renamed from ui/icons/qemu_512x512.png +0 -0
ui/icons/64x64/apps/qemu.png renamed from ui/icons/qemu_64x64.png +0 -0
ui/icons/meson.build +19 -8
@@ -1,13 +1,24 @@ -foreach s: [16, 24, 32, 48, 64, 128, 256, 512] - s = '@0@x@0@'.format(s.to_string()) - install_data('qemu_@[email protected]'.format(s), - rename: 'qemu.png', - install_dir: qemu_icondir / 'hicolor' / s / 'apps') + +png_icon_sizes = [ + '16x16', + '24x24', + '32x32', + '48x48', + '64x64', + '128x128', + '256x256', + '512x512', +] + +foreach icon_size: png_icon_sizes + install_data( + join_paths(icon_size, 'apps', 'qemu.png'), + install_dir: join_paths(qemu_icondir, 'hicolor', icon_size, 'apps') + ) endforeach -install_data('qemu_32x32.bmp', - rename: 'qemu.bmp', +install_data('32x32/apps/qemu.bmp', install_dir: qemu_icondir / 'hicolor' / '32x32' / 'apps') -install_data('qemu.svg', +install_data('scalable/apps/qemu.svg', install_dir: qemu_icondir / 'hicolor' / 'scalable' / 'apps')
ui/icons/scalable/apps/qemu.svg renamed from ui/icons/qemu.svg +0 -0
ui/sdl2.c +3 -2
@@ -26,6 +26,7 @@#include "qemu/osdep.h" #include "qemu/module.h" #include "qemu/cutils.h" +#include "qemu/datadir.h" #include "ui/console.h" #include "ui/input.h" #include "ui/sdl2.h"
@@ -910,11 +911,11 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o) }#ifdef CONFIG_SDL_IMAGE - dir =get_relocated_path (CONFIG_QEMU_ICONDIR "/hicolor/128x128/apps/qemu.png" ); + dir =qemu_find_file (QEMU_FILE_TYPE_ICON ,"128x128/apps/qemu.png" ); icon =IMG_Load (dir);#else /* Load a 32x32x4 image. White pixels are transparent. */ - dir =get_relocated_path (CONFIG_QEMU_ICONDIR "/hicolor/32x32/apps/qemu.bmp" ); + dir =qemu_find_file (QEMU_FILE_TYPE_ICON ,"32x32/apps/qemu.bmp" ); icon =SDL_LoadBMP (dir);if (icon) {uint32_t colorkey =SDL_MapRGB (icon->format,255 ,255 ,255 );
Signature · 1 line
2.36.1
PATCH v3 4/4 net: convert to use qemu_find_file to locate bridge helper
In reply to Daniel P. BerrangéThe TAP device code currently uses get_relocate_path to find the bridge helper, however, this fails when run from the build dir. Adding support to qemu_find_file for helper binaries, allows it to work from both the (relocated) install tree and build dir.
--- include/net/net.h | 3 ++- include/qemu/datadir.h | 1 + net/tap.c | 5 ++++- qemu-options.hx | 4 ++-- softmmu/datadir.c | 9 +++++++++ softmmu/trace-events | 2 +- 6 files changed, 19 insertions(+), 5 deletions(-)
include/net/net.h +2 -1
@@ -228,7 +228,8 @@ NetClientState *net_hub_port_find(int hub_id);#define DEFAULT_NETWORK_SCRIPT CONFIG_SYSCONFDIR "/qemu-ifup"#define DEFAULT_NETWORK_DOWN_SCRIPT CONFIG_SYSCONFDIR "/qemu-ifdown" -#define DEFAULT_BRIDGE_HELPER CONFIG_QEMU_HELPERDIR "/qemu-bridge-helper" +#define DEFAULT_BRIDGE_HELPER "qemu-bridge-helper" +#define DEFAULT_BRIDGE_HELPER_PATH CONFIG_QEMU_HELPERDIR "/qemu-bridge-helper"#define DEFAULT_BRIDGE_INTERFACE "br0"void qdev_set_nic_properties (DeviceState *dev,NICInfo *nd);
include/qemu/datadir.h +1 -0
@@ -4,6 +4,7 @@#define QEMU_FILE_TYPE_BIOS 0#define QEMU_FILE_TYPE_KEYMAP 1#define QEMU_FILE_TYPE_ICON 2 +#define QEMU_FILE_TYPE_HELPER 3/** * qemu_find_file:
net/tap.c +4 -1
@@ -42,6 +42,7 @@#include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/sockets.h" +#include "qemu/datadir.h" #include "net/tap.h"
@@ -507,9 +508,11 @@ static int net_bridge_run_helper(const char *helper, const char *bridge,sigprocmask (SIG_BLOCK , &mask, &oldmask);if (!helper) { - helper = default_helper =get_relocated_path (DEFAULT_BRIDGE_HELPER ); + helper = default_helper =qemu_find_file (QEMU_FILE_TYPE_HELPER , +DEFAULT_BRIDGE_HELPER ); } +g_printerr ("Helper %s\n" , helper);if (socketpair (PF_UNIX ,SOCK_STREAM ,0 , sv) ==-1 ) {error_setg_errno (errp, errno,"socketpair() failed" );return -1 ;
qemu-options.hx +2 -2
@@ -2665,7 +2665,7 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, " to configure it and 'dfile' (default=" DEFAULT_NETWORK_DOWN_SCRIPT ")\n" " to deconfigure it\n" " use '[down]script=no' to disable script execution\n" - " use network helper 'helper' (default=" DEFAULT_BRIDGE_HELPER ") to\n" + " use network helper 'helper' (default=" DEFAULT_BRIDGE_HELPER_PATH ") to\n" " configure it\n" " use 'fd=h' to connect to an already opened TAP interface\n" " use 'fds=x:y:...:z' to connect to already opened multiqueue capable TAP interfaces\n"
@@ -2684,7 +2684,7 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, "-netdev bridge,id=str[,br=bridge][,helper=helper]\n" " configure a host TAP network backend with ID 'str' that is\n" " connected to a bridge (default=" DEFAULT_BRIDGE_INTERFACE ")\n" - " using the program 'helper (default=" DEFAULT_BRIDGE_HELPER ")\n" + " using the program 'helper (default=" DEFAULT_BRIDGE_HELPER_PATH ")\n" #endif #ifdef __linux__ "-netdev l2tpv3,id=str,src=srcaddr,dst=dstaddr[,srcport=srcport][,dstport=dstport]\n"
softmmu/datadir.c +9 -0
@@ -36,6 +36,7 @@ static char **extra_firmware_dirs;/* Default built-in directories */ static char *default_data_dir;static char *default_icon_dir; +static char *default_helper_dir;/* Whether we're known to be executing from a build tree */ static bool in_build_dir;
@@ -73,6 +74,12 @@ char *qemu_find_file(int type, const char *name) default_install_dir = default_icon_dir;break ; +case QEMU_FILE_TYPE_HELPER : + rel_install_dir ="" ; + rel_build_dir ="" ; + default_install_dir = default_helper_dir; +break ; +default :abort (); }
@@ -140,9 +147,11 @@ void qemu_add_default_firmwarepath(void)/* Add default dirs relative to the executable path */ default_data_dir =get_relocated_path (CONFIG_QEMU_DATADIR ); default_icon_dir =get_relocated_path (CONFIG_QEMU_ICONDIR ); + default_helper_dir =get_relocated_path (CONFIG_QEMU_HELPERDIR );trace_datadir_init (default_data_dir, default_icon_dir, + default_helper_dir, in_build_dir); }
softmmu/trace-events +1 -1
@@ -6,7 +6,7 @@ balloon_event(void *opaque, unsigned long addr) "opaque %p addr %lu" # datadir.c datadir_load_file(const char *name, const char *path, int err) "name %s location %s errno %d" -datadir_init(const char *defdatadir, const char *deficondir, bool inbuilddir) "default data dir %s icon dir %s in build dir %d" +datadir_init(const char *defdatadir, const char *deficondir, const char *defhelperdir, bool inbuilddir) "default data dir %s icon dir %s helper dir %s in build dir %d" # ioport.c cpu_in(unsigned int addr, char size, unsigned int val) "addr 0x%x(%c) value %u"
Signature · 1 line
2.36.1
Re: [PATCH v3 4/4] net: convert to use qemu_find_file to locate bridge helper
softmmu/datadir.c char *qemu_find_file(int type, const char *name) · line 82
Quoted 7 lines · Daniel P. Berrangé
softmmu/datadir.c +6
-0+case QEMU_FILE_TYPE_HELPER : + rel_install_dir ="" ; + rel_build_dir ="" ; + default_install_dir = default_helper_dir; +break ; +
You're replacing ad hoc rules in Akihiko's meson.build with an ad hoc enum + the corresponding "case"s here in qemu_find_file(). There is duplication anyway, in this case between Meson and QEMU (plus QEMU needs to know about two filesystem layouts).
Paolo
Re: [PATCH v3 4/4] net: convert to use qemu_find_file to locate bridge helper
Quoted 8 lines · Paolo Bonzini
softmmu/datadir.c char *qemu_find_file(int type, const char *name) · line 82
Quoted 6 lines · Daniel P. Berrangé
softmmu/datadir.c +6
-0+case QEMU_FILE_TYPE_HELPER : + rel_install_dir ="" ; + rel_build_dir ="" ; + default_install_dir = default_helper_dir; +break ; +
Quoted 4 lines
You're replacing ad hoc rules in Akihiko's meson.build with an ad hoc enum + the corresponding "case"s here in
qemu_find_file(). There is duplication anyway, in this case between Meson and QEMU (plus QEMU needs to know about two filesystem layouts).
IMHO this is simpler to deal with than the meson additions, and also avoids the confusion of having files appearing in two places in the build dir.
If we really want to have the build dir look just like the install dir though, why write custom meson commands per file type at all, instead add a rule that always invokes
DESTDIR=$(BUILDDIR)/vroot ninja install
to populate a dir that's guaranteed identical to the install layout
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH v3 4/4] net: convert to use qemu_find_file to locate bridge helper
Quoted 9 lines · Daniel P. Berrangé
Quoted 8 lines · Paolo Bonzini
Quoted 6 lines · Daniel P. Berrangé
softmmu/datadir.c +6
-0+case QEMU_FILE_TYPE_HELPER : + rel_install_dir ="" ; + rel_build_dir ="" ; + default_install_dir = default_helper_dir; +break ; +
Quoted 8 lines
Quoted 4 lines
You're replacing ad hoc rules in Akihiko's meson.build with an ad hoc enum + the corresponding "case"s here in
qemu_find_file(). There is duplication anyway, in this case between Meson and QEMU (plus QEMU needs to know about two filesystem layouts).IMHO this is simpler to deal with than the meson additions, and also avoids the confusion of having files appearing in two places in the build dir.
Thanks to Paolo's suggestion to unify the common code to build the bundle tree, the required code for each bundled file is just a statement now (something like: bundles += { destination: source }) in the v6. Doing everything in Meson also allows to reuse the knowledge of the build tree Meson already has. I do no longer think my patch series are complicated more than yours. It even has less lines now.
There is still a room for improvements though. Particularly, the installing code and bundle-tree code are still duplicate. For example, pc-bios/meson.build now has the following code:install_data(blobs, install_dir: qemu_datadir)
foreach f : blobs
bundles += { qemu_datadir / f: meson.current_source_dir() / f }
endforeach
It would be nice if it can be written like:
foreach f : blobs
bundle_data(qemu_datadir / f, f)
endforeach
Unfortunately Meson does not allow this.
Another problem is that the top-level meson.build is somewhat clutter. In my opinion, it is a persistent problem of the build system but I don't have a solution.
Anyway, I think my patch series is as close to the ideal as Meson currently allows.
The confusion caused by the files appearing in two places in the
build tree should be minimal. qemu-bundle is implemented entirely with symbolic links. If you know what is a symbolic link, you also know it is an alias and the files appear in different places, and I expect everyone hacking QEMU knows symbolic link.
Quoted 8 lines
If we really want to have the build dir look just like the install dir though, why write custom meson commands per file type at all, instead add a rule that always invokes
DESTDIR=$(BUILDDIR)/vroot ninja installto populate a dir that's guaranteed identical to the install layout
Unfortunately Meson cannot define a rule which will be always invoked as far as I know.
Regards,
Akihiko Odaki
Quoted 3 lines
Regards,
Daniel