Libvirt provides a portable, long term stable C API for managing the virtualization technologies provided by many operating systems. It includes support for QEMU, KVM, Xen, LXC, bhyve, Virtuozzo, VMware vCenter and ESX, VMware Desktop, Hyper-V, VirtualBox and the POWER Hypervisor.
Go to file
Laine Stump 568efef729 util: properly deal with VFIO module name vs. driver name
Historically libvirt hasn't differentiated between the name of a
loadable kernel module, and the name of the device driver that module
implements, but these two names can be (and usually are) at least
subtly different.

For example, the loadable module called "vfio_pci" implements a PCI
driver called "vfio-pci". We have always used the name "vfio-pci" both
to load the module (with modprobe) and to check (in
/sys/bus/pci/drivers) if the driver is available. (This has happened
to work because modprobe "normalizes" all the names it is given by
replacing "-" with "_", so "vfio-pci" works for both loading the
module and checking for the driver.)

When we recently gained the ability to manually specify the driver for
"virsh nodedev-detach", the fragility of this system became apparent -
if a user gave the "driver name" as "vfio_pci", then we would modprobe
the module correctly, but then erroneously believe it hadn't been
loaded because /sys/bus/pci/drivers/vfio_pci didn't exist. For manual
specification of the driver name, we could deal with this by telling
the user "always use the correct name for the driver, don't assume
that it has the same name as the module", but it would still end up
confusing people, especially since some drivers do use underscore in
their name (e.g. the mlx5_vfio_pci driver/module).

This will only get worse when an upcoming patch starts automatically
determining the driver to use for VFIO-assigned devices - it will look
in the kernel's modules.alias file to find "best" VFIO variant
*module* for a device, and 3 out of 4 current examples of
vfio-pci/variant drivers have a mismatch between module name and
driver name, so the current code would end up properly loading the
module, but then erroneously think that the driver wasn't available.

This patch makes the code more forgiving by

1) checking for both $drivername and underscore($drivername) in
   /sys/bus/pci/drivers

2) when we determine a module needs to be loaded, look at the link in
   /sys/module/$modulename/driver/pci:$drivername to determine the
   name of the driver we need to bind to the device(rather than just
   assuming the driver has the same name as the module

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2024-01-07 23:57:08 -05:00
.ctags.d maint: Add support for .ctags.d 2019-05-31 17:54:28 +02:00
.github/workflows Switch to new GitHub repo-lockdown configuration 2021-10-20 14:27:20 +01:00
.gitlab/issue_templates gitlab: issue_template: Remove labelling commands 2022-06-01 12:27:10 +02:00
build-aux syntax-check: Forbid use of qsort() 2023-11-24 09:53:14 +01:00
ci ci: Update Alpine and Fedora and regenerate 2024-01-03 17:24:11 +01:00
docs docs: fix typo in qemu-passthrough-security 2024-01-03 16:05:03 +00:00
examples examples: Fix printf format string in event-test.c 2023-10-20 10:22:34 +02:00
include virDomainBlockResize: Introduce VIR_DOMAIN_BLOCK_RESIZE_CAPACITY 2023-12-14 16:09:05 +01:00
po Translated using Weblate (Georgian) 2024-01-01 12:37:07 +01:00
scripts rpcgen: Skip generator tests on macOS 2023-12-01 13:50:19 +01:00
src util: properly deal with VFIO module name vs. driver name 2024-01-07 23:57:08 -05:00
subprojects Move src/keycodemapdb -> subprojects/keycodemapdb 2023-04-17 15:02:38 +02:00
tests tests: Ensure test files are newline-terminated 2024-01-05 14:38:49 +01:00
tools virDomainBlockResize: Introduce VIR_DOMAIN_BLOCK_RESIZE_CAPACITY 2023-12-14 16:09:05 +01:00
.ctags ctags: Generate tags for headers, i.e. function prototypes 2018-09-18 14:21:33 +02:00
.dir-locals.el
.editorconfig Add .editorconfig 2019-09-06 12:47:46 +02:00
.gitattributes Add .gitattributes file 2022-03-17 14:33:12 +01:00
.gitignore Revert ".gitignore: Ignore cscope and other *tags files" 2023-02-08 17:24:31 +01:00
.gitlab-ci.yml ci: Build RPMs on MinGW 2023-11-23 18:32:03 +01:00
.gitmodules Move src/keycodemapdb -> subprojects/keycodemapdb 2023-04-17 15:02:38 +02:00
.gitpublish gitpublish: Tweak prefix 2023-12-05 11:48:28 +01:00
.mailmap mailmap: consolidate my email addresses 2020-10-06 12:05:09 +02:00
AUTHORS.rst.in AUTHORS: change my (Nikolay Shirokovskiy) email 2022-04-06 11:00:53 +03:00
config.h configure: bump min required CLang to 6.0 / XCode 10.0 2022-01-17 10:44:29 +00:00
configmake.h.in meson: generate configmake.h 2020-08-03 09:26:48 +02:00
CONTRIBUTING.rst meson: adjust our documentation to mention meson instead of autoconf 2020-08-03 09:27:09 +02:00
COPYING
COPYING.LESSER
gitdm.config gitdm: add 'ibm' file 2019-10-18 17:32:52 +02:00
libvirt-admin.pc.in
libvirt-lxc.pc.in
libvirt-qemu.pc.in
libvirt.pc.in
libvirt.spec.in libvirt.spec: Fix nbdkit selection logic on mingw and old rhel 2024-01-05 11:08:41 +01:00
meson_options.txt qemu: add runtime config option for nbdkit 2024-01-04 14:34:40 -06:00
meson.build qemu: add runtime config option for nbdkit 2024-01-04 14:34:40 -06:00
NEWS.rst NEWS: Fix indentation 2023-12-01 16:58:35 +01:00
README.rst docs: update docs pointing to old mailing list addrs 2023-10-31 10:04:27 +00:00
run.in run: add ability to set selinux context 2023-08-23 14:22:36 -05:00

GitLab CI Build Status

CII Best Practices

Translation status

Libvirt API for virtualization

Libvirt provides a portable, long term stable C API for managing the virtualization technologies provided by many operating systems. It includes support for QEMU, KVM, Xen, LXC, bhyve, Virtuozzo, VMware vCenter and ESX, VMware Desktop, Hyper-V, VirtualBox and the POWER Hypervisor.

For some of these hypervisors, it provides a stateful management daemon which runs on the virtualization host allowing access to the API both by non-privileged local users and remote users.

Layered packages provide bindings of the libvirt C API into other languages including Python, Perl, PHP, Go, Java, OCaml, as well as mappings into object systems such as GObject, CIM and SNMP.

Further information about the libvirt project can be found on the website:

https://libvirt.org

License

The libvirt C API is distributed under the terms of GNU Lesser General Public License, version 2.1 (or later). Some parts of the code that are not part of the C library may have the more restrictive GNU General Public License, version 2.0 (or later). See the files COPYING.LESSER and COPYING for full license terms & conditions.

Installation

Instructions on building and installing libvirt can be found on the website:

https://libvirt.org/compiling.html

Contributing

The libvirt project welcomes contributions in many ways. For most components the best way to contribute is to send patches to the primary development mailing list. Further guidance on this can be found on the website:

https://libvirt.org/contribute.html

Contact

The libvirt project has two primary mailing lists:

Further details on contacting the project are available on the website:

https://libvirt.org/contact.html