summaryrefslogtreecommitdiffstats
path: root/util/module.c
Commit message (Collapse)AuthorAgeFilesLines
* modules: turn off lazy bindingGerd Hoffmann2020-10-291-1/+1
| | | | | | | | | | We want missing symbols fail module load right away instead of having qemu abort later on in case lazy binding fails. Can happen -- for example -- when trying to load a module for a pci device (virtio-gpu-pci) into a qemu without pci support (qemu-system-avr). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20201028054944.5772-1-kraxel@redhat.com
* virtio-gpu: add virtio-vga moduleGerd Hoffmann2020-10-291-0/+3
| | | | | | | | | Build virtio-gpu vga devices modular. Must be a separate module because not all qemu softmmu variants come with VGA support. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 20201023064618.21409-3-kraxel@redhat.com
* virtio-gpu: add virtio-gpu-pci moduleGerd Hoffmann2020-10-291-0/+3
| | | | | | | | Build virtio-gpu pci devices modular. Must be a separate module because not all qemu softmmu variants come with PCI support. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20201023064618.21409-2-kraxel@redhat.com
* opengl: build opengl helper code modularGerd Hoffmann2020-10-211-0/+7
| | | | | | | | | Removes opengl dependency from core qemu. The number of shared libraries for qemu-system-x86_64 goes down from 66 to 60 on my system. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 20201019075224.14803-15-kraxel@redhat.com
* modules: add spice dependenciesGerd Hoffmann2020-10-211-0/+5
| | | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 20201019075224.14803-12-kraxel@redhat.com
* modules: dependencies infrastructureGerd Hoffmann2020-10-211-5/+27
| | | | | | | | | | | | | | | | | | Allow modules depending on other modules. module_load_file() gets the option to export symbols (by not adding the G_MODULE_BIND_LOCAL flag). module_load_one() will check the module dependency list to figure (a) whenever are other modules must be loaded first, or (b) the module should export the symbols. The dependencies are specificed as static list in the source code for now as I expect the list will stay small. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 20201019075224.14803-11-kraxel@redhat.com
* chardev/spice: build spice chardevs as moduleGerd Hoffmann2020-10-151-0/+2
| | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20201014121120.13482-8-kraxel@redhat.com
* modules: update qom object module commentGerd Hoffmann2020-10-151-1/+3
| | | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20200923103728.12026-1-kraxel@redhat.com
* module: silence errors for module_load_qom_all().Gerd Hoffmann2020-10-151-10/+10
| | | | | | | | | | | | | | | | Add mayfail bool parameter to module loading functions. Set it to true for module_load_qom_all() because device modules might not load into all system emulation variants. qemu-system-s390x for example will not load qxl because it lacks vga support. Makes "make check" less chatty. Drop module_loaded_qom_all check in module_load_qom_one to make sure we see errors for explicit load requests, i.e. module_load_qom_one("qxl") failing will log an error no matter whenever module_load_qom_all() was called before or not. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 20200923091217.22662-1-kraxel@redhat.com
* module: relocate path to modulesPaolo Bonzini2020-09-301-1/+2
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* oslib: do not call g_strdup from qemu_get_exec_dirPaolo Bonzini2020-09-301-6/+1Star
| | | | | | | | Just return the directory without requiring the caller to free it. This also removes a bogus check for NULL in os_find_datadir and module_load_one; g_strdup of a static variable cannot return NULL. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-gpu: build modularGerd Hoffmann2020-09-151-0/+2
| | | | | | | | | Only build virtio-gpu-device modular (the code which actually depends on the external virglrenderer library). virtio-gpu-pci and virtio-vga are compiled into core qemu still. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20200914134224.29769-7-kraxel@redhat.com
* meson: replace create-config with meson configure_filePaolo Bonzini2020-08-211-2/+2
| | | | | | | | Move the create-config logic to meson.build; create a configuration_data object and let meson handle the quoting and output. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* meson: link emulators without Makefile.targetPaolo Bonzini2020-08-211-1/+0Star
| | | | | | | | The binaries move to the root directory, e.g. qemu-system-i386 or qemu-arm. This requires changes to qtests, CI, etc. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* module: ignore NULL typeGerd Hoffmann2020-07-211-0/+3
| | | | | | | | Just return in case module_load_qom_one(NULL) is called. vga_interface_available() can do that. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-Id: <20200720100352.2477-3-kraxel@redhat.com>
* Revert "vga: build virtio-gpu as module"Gerd Hoffmann2020-07-111-6/+0Star
| | | | | | | | | | | | | | | | This reverts commit 8d5a24c83dba90b08ef163bbf166d6dfbad9019b. Compiling all virtio-gpu objects into a single module isn't a good plan because the individual objects have different CONFIG_* dependencies. Leads to module load failures on s390x due to vga support being disabled, which in turn breaks '-device virtio-gpu-device' (flagged by travis ci). So back to the drawing board for modular virtio-gpu ... Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20200710203652.9708-3-kraxel@redhat.com>
* chardev: enable modules, use for brailleGerd Hoffmann2020-07-071-0/+1
| | | | | | | Removes brlapi library dependency from core qemu. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20200624131045.14512-11-kraxel@redhat.com
* vga: build virtio-gpu as moduleGerd Hoffmann2020-07-071-0/+6
| | | | | | | Drops libvirglrenderer.so dependency from core qemu. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20200624131045.14512-10-kraxel@redhat.com
* vga: build qxl as moduleGerd Hoffmann2020-07-071-0/+2
| | | | | | | First step in making spice support modular. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20200624131045.14512-8-kraxel@redhat.com
* usb: build usb-redir as moduleGerd Hoffmann2020-07-071-0/+1
| | | | | | | Drops libusbredirparser.so dependency from core qemu. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20200624131045.14512-7-kraxel@redhat.com
* ccid: build smartcard as moduleGerd Hoffmann2020-07-071-0/+2
| | | | | | | Drops libcacard.so dependency from core qemu. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20200624131045.14512-6-kraxel@redhat.com
* module: qom module supportGerd Hoffmann2020-07-071-0/+55
| | | | | | | | | | | | Add support for qom types provided by modules. For starters use a manually maintained list which maps qom type to module and prefix. Two load functions are added: One to load the module for a specific type, and one to load all modules (needed for object/device lists as printed by -- for example -- qemu -device help). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20200624131045.14512-2-kraxel@redhat.com
* module: increase dirs array size by oneBruce Rogers2020-04-131-1/+1
| | | | | | | | | | | With the module upgrades code change, the statically sized dirs array can now overflow. Increase it's size by one, according to the new maximum possible usage. Fixes: bd83c861c0 ("modules: load modules from versioned /var/run dir") Signed-off-by: Bruce Rogers <brogers@suse.com> Message-Id: <20200411010746.472295-1-brogers@suse.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* modules: load modules from versioned /var/run dirChristian Ehrhardt2020-03-161-0/+14
| | | | | | | | | | | | | | | | | | | | | | | On upgrades the old .so files usually are replaced. But on the other hand since a qemu process represents a guest instance it is usually kept around. That makes late addition of dynamic features e.g. 'hot-attach of a ceph disk' fail by trying to load a new version of e.f. block-rbd.so into an old still running qemu binary. This adds a fallback to also load modules from a versioned directory in the temporary /var/run path. That way qemu is providing a way for packaging to store modules of an upgraded qemu package as needed until the next reboot. An example how that can then be used in packaging can be seen in: https://git.launchpad.net/~paelzer/ubuntu/+source/qemu/log/?h=bug-1847361-miss-old-so-on-upgrade-UBUNTU Fixes: https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1847361 Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20200310145806.18335-2-christian.ehrhardt@canonical.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* module: check module wasn't already initializedAlexander Bulekov2020-02-221-0/+7
| | | | | | | | | | | | | | | The virtual-device fuzzer must initialize QOM, prior to running vl:qemu_init, so that it can use the qos_graph to identify the arguments required to initialize a guest for libqos-assisted fuzzing. This change prevents errors when vl:qemu_init tries to (re)initialize the previously initialized QOM module. Signed-off-by: Alexander Bulekov <alxndr@bu.edu> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Darren Kenny <darren.kenny@oracle.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20200220041118.23264-4-alxndr@bu.edu Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* util/module: fix a memory leakPan Nengyuan2020-01-081-0/+1
| | | | | | | | | | | spotted by ASAN Fixes: 81d8ccb1bea4fb9eaaf4c8e30bd4021180a9a39f Reported-by: Euler Robot <euler.robot@huawei.com> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1576805650-16380-1-git-send-email-pannengyuan@huawei.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* module: return success on module loadMarc-André Lureau2019-08-211-3/+11
| | | | | | | | | | Let the caller know of load success. Note that this also changes slightly the behaviour of the function to try loading on subsequent calls if the previous ones failed. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* module: use g_hash_table_add()Marc-André Lureau2019-08-211-2/+1Star
| | | | | | | | The hashtable is used like a set, use the convenience g_hash_table_add() function. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Include qemu-common.h exactly where neededMarkus Armbruster2019-06-121-1/+0Star
| | | | | | | | | | | | | | | | No header includes qemu-common.h after this commit, as prescribed by qemu-common.h's file comment. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20190523143508.25387-5-armbru@redhat.com> [Rebased with conflicts resolved automatically, except for include/hw/arm/xlnx-zynqmp.h hw/arm/nrf51_soc.c hw/arm/msf2-soc.c block/qcow2-refcount.c block/qcow2-cluster.c block/qcow2-cache.c target/arm/cpu.h target/lm32/cpu.h target/m68k/cpu.h target/mips/cpu.h target/moxie/cpu.h target/nios2/cpu.h target/openrisc/cpu.h target/riscv/cpu.h target/tilegx/cpu.h target/tricore/cpu.h target/unicore32/cpu.h target/xtensa/cpu.h; bsd-user/main.c and net/tap-bsd.c fixed up]
* module: Use QEMU_MODULE_DIR as a search pathryang2018-08-231-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current paths for modules are CONFIG_QEMU_MODDIR and paths relative to the executable. Qemu and its modules can be installed and executed in paths that are different from these search paths. This change allows a search path to be specified by environment variable. An example usage for this is postmarketOS[1]. This is a build environment for Alpine Linux. It sets up Alpine Linux in a chroot environment. Alpine's Qemu packages are installed in the chroot. The Alpine Linux Qemu package is used to test compiled Alpine Linux system images. This way there isn't a reliance on the which ever version of Qemu the host system / distro provides. postmarketOS executes Qemu on host system outside of the chroot The Qemu module search path needs to point to the location of the chroot relative to the host system. e.g. The root of the Alpine Linux chroot is: ~/.local/var/pmbootstrap/chroot_native/ Alpine's Qemu is installed at ~/.local/var/pmbootstrap/chroot_native/usr/bin/ The Qemu module search path needs to be: QEMU_MODULE_DIR=~/.local/var/pmbootstrap/chroot_native/usr/lib/qemu/ [1] https://postmarketos.org/ Signed-off-by: ryang <decatf@gmail.com> Message-Id: <20180704181010.GA918@computer> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* module: Don't load the same module if requested multiple timesFam Zheng2016-10-071-2/+16
| | | | | | | | | | Use a hash table to keep record of all loaded modules, and return early if the requested module is already loaded. Signed-off-by: Fam Zheng <famz@redhat.com> Message-id: 1473043845-13197-3-git-send-email-famz@redhat.com Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* blockdev: Add dynamic module loading for block driversMarc Mari2016-09-201-27/+11Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extend the current module interface to allow for block drivers to be loaded dynamically on request. The only block drivers that can be converted into modules are the drivers that don't perform any init operation except for registering themselves. In addition, only the protocol drivers are being modularized, as they are the only ones which see significant performance benefits. The format drivers do not generally link to external libraries, so modularizing them is of no benefit from a performance perspective. All the necessary module information is located in a new structure found in module_block.h This spoils the purpose of 5505e8b76f (block/dmg: make it modular). Before this patch, if module build is enabled, block-dmg.so is linked to libbz2, whereas the main binary is not. In downstream, theoretically, it means only the qemu-block-extra package depends on libbz2, while the main QEMU package needn't to. With this patch, we (temporarily) change the case so that the main QEMU depends on libbz2 again. Signed-off-by: Marc Marí <markmb@redhat.com> Signed-off-by: Colin Lord <clord@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 1471008424-16465-4-git-send-email-clord@redhat.com Reviewed-by: Max Reitz <mreitz@redhat.com> [mreitz: Do a signed comparison against the length of block_driver_modules[], so it will not cause a compile error when empty] Signed-off-by: Max Reitz <mreitz@redhat.com>
* coccinelle: Remove unnecessary variables for function return valueEduardo Habkost2016-06-201-5/+1Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Use Coccinelle script to replace 'ret = E; return ret' with 'return E'. The script will do the substitution only when the function return type and variable type are the same. Manual fixups: * audio/audio.c: coding style of "read (...)" and "write (...)" * block/qcow2-cluster.c: wrap line to make it shorter * block/qcow2-refcount.c: change indentation of wrapped line * target-tricore/op_helper.c: fix coding style of "remainder|quotient" * target-mips/dsp_helper.c: reverted changes because I don't want to argue about checkpatch.pl * ui/qemu-pixman.c: fix line indentation * block/rbd.c: restore blank line between declarations and statements Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <1465855078-19435-4-git-send-email-ehabkost@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Unused Coccinelle rule name dropped along with a redundant comment; whitespace touched up in block/qcow2-cluster.c; stale commit message paragraph deleted] Signed-off-by: Markus Armbruster <armbru@redhat.com>
* util: Clean up includesPeter Maydell2016-02-041-1/+1
| | | | | | | | | | Clean up includes so that osdep.h is included first and headers which it implies are not included manually. This commit was created with scripts/clean-includes. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 1454089805-5470-6-git-send-email-peter.maydell@linaro.org
* module: Don't complain when a module is absentAndreas Färber2014-07-181-3/+0Star
| | | | | | | | | | | | | | | | The current implementation depends on a configure-time generated list of block modules. When any of them is absent, module_load() emits a warning. This is suboptimal because extracting code to modules was mainly done to allow separate packaging of modules with intrusive dependencies. Absence of optional packages then leads to absence of modules and an error message, which users may recognize as new and report as error. Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* module: Simplify module_load()Andreas Färber2014-07-181-4/+2Star
| | | | | | | | | The file path is not used for error reporting, so we can free it directly after use. Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* util: Add 'static' attribute to function implementationStefan Weil2014-03-271-1/+1
| | | | | | | | | | | | | | | The static code analyzer smatch complains because of a missing 'static' attribute: util/module.c:166:6: warning: symbol 'module_load' was not declared. Should it be static? 'static' is used in the forward declaration, but not in the implementation. Add it there, too. Signed-off-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* modules: Fix building with --enable-modulesFam Zheng2014-02-281-1/+1
| | | | | | | | | | | Compiling util/modules.c with modules enabled fails now. Fix it by including qemu-common.h before #ifdef testing in module.c. Signed-off-by: Fam Zheng <famz@redhat.com> Message-id: 1393453893-12125-1-git-send-email-famz@redhat.com Reviewed-by: Hu Tao <hutao@cn.fujitsu.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* modules: do not include gmodule-2.0 in static buildsPaolo Bonzini2014-02-251-0/+2
| | | | | | | | | | | | | | | | gmodule-2.0's pkg-config files include -Wl,--export-dynamic, which breaks static builds. It is a glib bug, but we need to support --static builds for the linux-user targets, and in the end all that is needed to fix this is: * outlaw --enable-modules --static, which makes little sense anyway * only include gmodule-2.0's cflags and ldflags if --enable-modules is specified on the command line. Reported-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1393346215-5636-1-git-send-email-pbonzini@redhat.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* module: implement module loadingFam Zheng2014-02-201-2/+143
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds loading, stamp checking and initialization of modules. The init function of dynamic module is no longer directly called as __attribute__((constructor)) in static linked version, it is called only after passed the checking of presense of stamp symbol: qemu_stamp_$RELEASEHASH where $RELEASEHASH is generated by hashing version strings and content of configure script. With this, modules built from a different tree/version/configure will not be loaded. The module loading code requires gmodule-2.0. Modules are searched under - CONFIG_MODDIR - executable folder (to allow running qemu-{img,io} in the build directory) - ../ of executable folder (to allow running system emulator in the build directory) Modules are linked under their subdir respectively, then copied to top level of build directory for above convinience, e.g.: $(BUILD_DIR)/block/curl.so -> $(BUILD_DIR)/block-curl.so Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* build: move libqemuutil.a components to util/Paolo Bonzini2013-01-121-0/+81
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>