libvmi / python

LibVMI Python bindings
http://libvmi.com/
GNU Lesser General Public License v3.0
30 stars 22 forks source link

error: ‘VMI_TM_INVALID’ undeclared #71

Closed qianfei11 closed 3 years ago

qianfei11 commented 3 years ago

I have met with this error and have no idea how to fix this:

(venv) ➜  python-libvmi git:(master) ./setup.py build
running build
running build_py
running build_ext
generating cffi module 'build/temp.linux-x86_64-3.6/_libvmi.c'
already up-to-date
building '_libvmi' extension
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/home/b3ale/venv/include -I/usr/include/python3.6m -c build/temp.linux-x86_64-3.6/_libvmi.c -o build/temp.linux-x86_64-3.6/build/temp.linux-x86_64-3.6/_libvmi.o
build/temp.linux-x86_64-3.6/_libvmi.c: In function ‘_cffi_const_VMI_TM_INVALID’:
build/temp.linux-x86_64-3.6/_libvmi.c:1382:12: error: ‘VMI_TM_INVALID’ undeclared (first use in this function)
   int n = (VMI_TM_INVALID) <= 0;
            ^
build/temp.linux-x86_64-3.6/_libvmi.c:1382:12: note: each undeclared identifier is reported only once for each function it appears in
build/temp.linux-x86_64-3.6/_libvmi.c: In function ‘_cffi_d_vmi_get_va_pages’:
build/temp.linux-x86_64-3.6/_libvmi.c:2810:3: warning: implicit declaration of function ‘vmi_get_va_pages’ [-Wimplicit-function-declaration]
   return vmi_get_va_pages(x0, x1);
   ^
build/temp.linux-x86_64-3.6/_libvmi.c:2810:3: warning: return makes pointer from integer without a cast [enabled by default]
build/temp.linux-x86_64-3.6/_libvmi.c: In function ‘_cffi_f_vmi_get_va_pages’:
build/temp.linux-x86_64-3.6/_libvmi.c:2843:12: warning: assignment makes pointer from integer without a cast [enabled by default]
   { result = vmi_get_va_pages(x0, x1); }
            ^
build/temp.linux-x86_64-3.6/_libvmi.c: In function ‘_cffi_checkfld__page_info_t’:
build/temp.linux-x86_64-3.6/_libvmi.c:9897:12: error: ‘page_info_t’ has no member named ‘dtb’
   (void)((p->dtb) | 0);  /* check that 'page_info_t.dtb' is an integer */
            ^
In file included from /usr/include/sched.h:29:0,
                 from /usr/include/pthread.h:23,
                 from /usr/include/glib-2.0/glib/deprecated/gthread.h:128,
                 from /usr/include/glib-2.0/glib.h:108,
                 from build/temp.linux-x86_64-3.6/_libvmi.c:572:
build/temp.linux-x86_64-3.6/_libvmi.c: At top level:
build/temp.linux-x86_64-3.6/_libvmi.c:10463:12: error: ‘page_info_t’ has no member named ‘dtb’
   { "dtb", offsetof(page_info_t, dtb),
            ^
build/temp.linux-x86_64-3.6/_libvmi.c:10464:37: error: ‘page_info_t’ has no member named ‘dtb’
            sizeof(((page_info_t *)0)->dtb),
                                     ^
error: command 'gcc' failed with exit status 1

here are some info about my installed libvmi:

(venv) ➜  python-libvmi git:(master) pkg-config --libs libvmi
-L/usr/local/lib64 -ldl -lglib-2.0 -lvmi  
(venv) ➜  python-libvmi git:(master) ls -l /usr/local/lib64          
total 8748
drwxr-xr-x 3 root root      20 Jan 12 22:36 cmake
-rw-r--r-- 1 root root  315326 Jan 12 22:36 libjson-c.a
lrwxrwxrwx 1 root root      14 Jan 12 22:36 libjson-c.so -> libjson-c.so.5
lrwxrwxrwx 1 root root      18 Jan 12 22:36 libjson-c.so.5 -> libjson-c.so.5.1.0
-rwxr-xr-x 1 root root  163304 Jan 12 22:36 libjson-c.so.5.1.0
-rw-r--r-- 1 root root 7286908 Jan 12 22:38 libvmi.a
-rw-r--r-- 1 root root     939 Jan 12 22:37 libvmi.la
lrwxrwxrwx 1 root root      11 Jan 13 02:04 libvmi.so -> libvmi.so.0
lrwxrwxrwx 1 root root      16 Jan 13 02:04 libvmi.so.0 -> libvmi.so.0.0.15
-rwxr-xr-x 1 root root 1182560 Jan 12 22:38 libvmi.so.0.0.15
drwxr-xr-x 2 root root      40 Jan 12 22:38 pkgconfig
Wenzel commented 3 years ago

Hi,

the reason is that Libvmi API changed: https://github.com/libvmi/libvmi/blob/master/libvmi/libvmi.h#L685

the translation_mechanism_t is now a typedef on uint32_t, and not an enum, so libvmi-python needs to be updated too.

Wenzel commented 3 years ago

The nested support changed the interface to page tables translation interface: https://github.com/libvmi/libvmi/pull/956

tklengyel commented 3 years ago

You can continue using the release version of LibVMI for now: https://github.com/libvmi/libvmi/releases/tag/v0.14.0

qianfei11 commented 3 years ago

You can continue using the release version of LibVMI for now: https://github.com/libvmi/libvmi/releases/tag/v0.14.0

@Wenzel @tklengyel Thanks for answering. v0.14.0 works for me.