cutils: Introduce bundle mechanism

Developers often run QEMU without installing. The bundle mechanism
allows to look up files which should be present in installation even in
such a situation.

It is a general mechanism and can find any files in the installation
tree. The build tree will have a new directory, qemu-bundle, to
represent what files the installation tree would have for reference by
the executables.

Note that it abandons compatibility with Windows older than 8. The
extended support for the prior version, 7 ended more than 2 years ago,
and it is unlikely that someone would like to run the latest QEMU on
such an old system.

Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20220624145039.49929-3-akihiko.odaki@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Akihiko Odaki 2022-06-24 23:50:37 +09:00 committed by Paolo Bonzini
parent 4367a20cc4
commit cf60ccc330
7 changed files with 101 additions and 25 deletions

View file

@ -224,9 +224,21 @@ const char *qemu_get_exec_dir(void);
* @dir: the directory (typically a `CONFIG_*DIR` variable) to be relocated.
*
* Returns a path for @dir that uses the directory of the running executable
* as the prefix. For example, if `bindir` is `/usr/bin` and @dir is
* `/usr/share/qemu`, the function will append `../share/qemu` to the
* directory that contains the running executable and return the result.
* as the prefix.
*
* When a directory named `qemu-bundle` exists in the directory of the running
* executable, the path to the directory will be prepended to @dir. For
* example, if the directory of the running executable is `/qemu/build` @dir
* is `/usr/share/qemu`, the result will be
* `/qemu/build/qemu-bundle/usr/share/qemu`. The directory is expected to exist
* in the build tree.
*
* Otherwise, the directory of the running executable will be used as the
* prefix and it appends the relative path from `bindir` to @dir. For example,
* if the directory of the running executable is `/opt/qemu/bin`, `bindir` is
* `/usr/bin` and @dir is `/usr/share/qemu`, the result will be
* `/opt/qemu/bin/../share/qemu`.
*
* The returned string should be freed by the caller.
*/
char *get_relocated_path(const char *dir);