python
python copied to clipboard
Raise RuntimeError if a libvmi feature has been disabled
At the moment, we assume that libvmi has been compiled with default options.
However, if someone disables the V2P cache for example, we have to detect it at runtime and raise an error when the user attempts to call the specified API.
$ python3 -c 'from libvmi import Libvmi'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/tarrma/fsecure/python-libvmi/libvmi/__init__.py", line 3, in <module>
from .libvmi import INIT_DOMAINNAME, INIT_DOMAINID, INIT_EVENTS, INIT_SHM, CR3
File "/home/tarrma/fsecure/python-libvmi/libvmi/libvmi.py", line 4, in <module>
from _libvmi import ffi, lib
ImportError: /home/tarrma/fsecure/python-libvmi/venv/lib/python3.5/site-packages/libvmi-3.0-py3.5-linux-x86_64.egg/_libvmi.abi3.so: undefined symbol: vmi_pidcache_flush
This is not as easy as i first though, since the error is raised when _libvmi.abi3.so is imported, not when the API is called.