linux(kali)下VM无法编译安装Virtual machine monitor和Virtual ethernet

💡 主要是为了解决linux下VM网络驱动vmmon-only、vmnet-only难装的问题。可以直接跳到最后

一、正常安装

sudo dpkg -i vm.bundle

然后打开桌面安装即可

二、kali下,无法安装

提示

Unable to install all modules. See log …

三、网上搜索得知可以编译

git clone https://github.com/mkubecek/vmware-host-modules.git
# 切换到项目目录
cd vmware-host-modules
# 查看你vmware版本 这个可以在你上面第二步执行./ 时,后面的路径中找到
# 切换分支
git checkout workstation-你的版本
# 编译
sudo make
# 上面的执行完成后,执行下面的命令
sudo make install
# 再次手动启动vmware
sudo /etc/init.d/vmware start

kali下提示错误,找不到ftddef

fatal error: stddef.h: 没有那个文件或目录
54 | # include <stddef.h>

安装了内核头

sudo apt install build-essential linux-headers-$(uname -r)
旧版本内核头下载地址
http://old.kali.org/kali/pool/main/l/linux/

更新gcc、gcc+

均不行

四、解决

找到大佬的一篇文章

bookmark

解决方法如下:

在Github上找到了一个修改后的模块repo-vmware-host-modules
使用方法
1- 
Then make Tar vmmon-only and vmnet-only folders
tar -cf vmmon.tar vmmon-only
tar -cf vmnet.tar vmnet-only


2- 
Later copy the files to this path /usr/lib/vmware/modules/source/ :
cp -v vmmon.tar vmnet.tar /usr/lib/vmware/modules/source/

3- 
Finally, run this command to compile headers manually:
sudo vmware-modconfig --console --install-all

五、原文备忘

关于 VM 虚拟机在 Linux 下安装的一个小问题 | 私は米沢ユカリニャー

系统

2022-05-18-08-18-44.png

问题 1

cpp

make: 进入目录“/tmp/modconfig-3bVkgp/vmmon-only”
Using kernel build system.
/usr/bin/make -C /lib/modules/5.17.5-76051705-generic/build/include/.. M=$PWD SRCROOT=$PWD/. \
  MODULEBUILDDIR= modules
make[1]: 进入目录“/usr/src/linux-headers-5.17.5-76051705-generic”
  CC [M]  /tmp/modconfig-3bVkgp/vmmon-only/linux/driver.o
  CC [M]  /tmp/modconfig-3bVkgp/vmmon-only/linux/driverLog.o
  CC [M]  /tmp/modconfig-3bVkgp/vmmon-only/linux/hostif.o
  CC [M]  /tmp/modconfig-3bVkgp/vmmon-only/common/apic.o
In file included from /tmp/modconfig-3bVkgp/vmmon-only/common/apic.c:19:
/tmp/modconfig-3bVkgp/vmmon-only/./include/vm_basic_defs.h:54:12: fatal error: stddef.h: 没有那个文件或目录
   54 | #  include <stddef.h>
      |            ^~~~~~~~~~
compilation terminated.
make[2]: *** [scripts/Makefile.build:288:/tmp/modconfig-3bVkgp/vmmon-only/common/apic.o] 错误 1
make[2]: *** 正在等待未完成的任务....
In file included from /tmp/modconfig-3bVkgp/vmmon-only/linux/driverLog.h:33,
                 from /tmp/modconfig-3bVkgp/vmmon-only/linux/driverLog.c:31:
/tmp/modconfig-3bVkgp/vmmon-only/./include/vm_assert.h:43:10: fatal error: stdarg.h: 没有那个文件或目录
   43 | #include <stdarg.h>
      |          ^~~~~~~~~~
compilation terminated.
make[2]: *** [scripts/Makefile.build:288:/tmp/modconfig-3bVkgp/vmmon-only/linux/driverLog.o] 错误 1
In file included from /tmp/modconfig-3bVkgp/vmmon-only/./include/cpu_types.h:29,
                 from /tmp/modconfig-3bVkgp/vmmon-only/./include/modulecall.h:33,
                 from /tmp/modconfig-3bVkgp/vmmon-only/linux/hostif.c:58:
/tmp/modconfig-3bVkgp/vmmon-only/./include/vm_basic_defs.h:54:12: fatal error: stddef.h: 没有那个文件或目录
   54 | #  include <stddef.h>
      |            ^~~~~~~~~~
compilation terminated.
make[2]: *** [scripts/Makefile.build:288:/tmp/modconfig-3bVkgp/vmmon-only/linux/hostif.o] 错误 1
In file included from /tmp/modconfig-3bVkgp/vmmon-only/linux/driverLog.h:33,
                 from /tmp/modconfig-3bVkgp/vmmon-only/linux/driver.c:46:
/tmp/modconfig-3bVkgp/vmmon-only/./include/vm_assert.h:43:10: fatal error: stdarg.h: 没有那个文件或目录
   43 | #include <stdarg.h>
      |          ^~~~~~~~~~
compilation terminated.
make[2]: *** [scripts/Makefile.build:288:/tmp/modconfig-3bVkgp/vmmon-only/linux/driver.o] 错误 1
make[1]: *** [Makefile:1837:/tmp/modconfig-3bVkgp/vmmon-only] 错误 2
make[1]: 离开目录“/usr/src/linux-headers-5.17.5-76051705-generic”
make: *** [Makefile:117:vmmon.ko] 错误 2
make: 离开目录“/tmp/modconfig-3bVkgp/vmmon-only”
make: 进入目录“/tmp/modconfig-3bVkgp/vmnet-only”

解决方案

shell

find /usr -type f | grep stdarg.h

➜  /tmp find /usr -type f | grep stdarg.h
/usr/lib/gcc/x86_64-linux-gnu/11/include/stdarg.h
/usr/lib/gcc/x86_64-linux-gnu/11/include/cross-stdarg.h
/usr/src/linux-headers-5.17.5-76051705/include/linux/stdarg.h
/usr/src/virtualbox-6.1.32/include/iprt/stdarg.h
/usr/src/linux-headers-5.16.19-76051619/include/linux/stdarg.h
/usr/include/c++/11/tr1/stdarg.h

找到头文件的位置之后 在运行 vmware-modconfig 时包含进去

shell

sudo CPATH=/usr/lib/gcc/x86_64-linux-gnu/11/include/ vmware-modconfig --console --install-all

问题 2

cpp

```text
make: 进入目录“/tmp/modconfig-Y3VkRY/vmmon-only”
Using kernel build system.
/usr/bin/make -C /lib/modules/5.16.19-76051619-generic/build/include/.. M=$PWD SRCROOT=$PWD/. \
  MODULEBUILDDIR= modules
make[1]: 进入目录“/usr/src/linux-headers-5.16.19-76051619-generic”
  CC [M]  /tmp/modconfig-Y3VkRY/vmmon-only/linux/driver.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmmon-only/linux/driverLog.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmmon-only/linux/hostif.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmmon-only/common/apic.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmmon-only/common/comport.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmmon-only/common/cpuid.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmmon-only/common/crosspage.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmmon-only/common/memtrack.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmmon-only/common/moduleloop.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmmon-only/common/phystrack.o
/tmp/modconfig-Y3VkRY/vmmon-only/common/phystrack.o: warning: objtool: PhysTrack_Free() falls through to next function PhysTrack_Add()
/tmp/modconfig-Y3VkRY/vmmon-only/common/phystrack.o: warning: objtool: PhysTrack_Add() falls through to next function PhysTrack_Remove()
/tmp/modconfig-Y3VkRY/vmmon-only/common/phystrack.o: warning: objtool: PhysTrack_Remove() falls through to next function PhysTrack_Test()
  CC [M]  /tmp/modconfig-Y3VkRY/vmmon-only/common/sharedAreaVmmon.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmmon-only/common/statVarsVmmon.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmmon-only/common/task.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmmon-only/common/vmx86.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmmon-only/bootstrap/bootstrap.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmmon-only/bootstrap/monLoader.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmmon-only/bootstrap/monLoaderVmmon.o
In file included from /tmp/modconfig-Y3VkRY/vmmon-only/./include/x86desc.h:33,
                 from /tmp/modconfig-Y3VkRY/vmmon-only/./include/modulecall.h:34,
                 from /tmp/modconfig-Y3VkRY/vmmon-only/common/task.c:60:
/tmp/modconfig-Y3VkRY/vmmon-only/common/task.c: In function ‘TaskRestoreHostGDTTRLDT’:
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:67:44: error: expression in static assertion is not constant
   67 |    ASSERT_ON_COMPILE(sizeof(Selector) == 2 &&                                \
      |                      ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |                      ((__builtin_constant_p(expr) && ((expr) >> 16) == 0) || \
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 |                       sizeof(expr) <= 2))
      |                       ~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_assert.h:372:22: note: in definition of macro ‘ASSERT_ON_COMPILE’
  372 |       _Static_assert(e, #e); \
      |                      ^
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:263:7: note: in expansion of macro ‘ASSERT_ON_COMPILE_SELECTOR_SIZE’
  263 |       ASSERT_ON_COMPILE_SELECTOR_SIZE(expr);                            \
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/common/task.c:726:7: note: in expansion of macro ‘SET_TR’
  726 |       SET_TR(tr);
      |       ^~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:67:44: error: expression in static assertion is not constant
   67 |    ASSERT_ON_COMPILE(sizeof(Selector) == 2 &&                                \
      |                      ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |                      ((__builtin_constant_p(expr) && ((expr) >> 16) == 0) || \
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 |                       sizeof(expr) <= 2))
      |                       ~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_assert.h:372:22: note: in definition of macro ‘ASSERT_ON_COMPILE’
  372 |       _Static_assert(e, #e); \
      |                      ^
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:129:7: note: in expansion of macro ‘ASSERT_ON_COMPILE_SELECTOR_SIZE’
  129 |       ASSERT_ON_COMPILE_SELECTOR_SIZE(expr);                            \
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/common/task.c:728:7: note: in expansion of macro ‘SET_LDT’
  728 |       SET_LDT(ldt);
      |       ^~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:67:44: error: expression in static assertion is not constant
   67 |    ASSERT_ON_COMPILE(sizeof(Selector) == 2 &&                                \
      |                      ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |                      ((__builtin_constant_p(expr) && ((expr) >> 16) == 0) || \
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 |                       sizeof(expr) <= 2))
      |                       ~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_assert.h:372:22: note: in definition of macro ‘ASSERT_ON_COMPILE’
  372 |       _Static_assert(e, #e); \
      |                      ^
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:263:7: note: in expansion of macro ‘ASSERT_ON_COMPILE_SELECTOR_SIZE’
  263 |       ASSERT_ON_COMPILE_SELECTOR_SIZE(expr);                            \
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/common/task.c:751:10: note: in expansion of macro ‘SET_TR’
  751 |          SET_TR(tr);
      |          ^~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:67:44: error: expression in static assertion is not constant
   67 |    ASSERT_ON_COMPILE(sizeof(Selector) == 2 &&                                \
      |                      ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |                      ((__builtin_constant_p(expr) && ((expr) >> 16) == 0) || \
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 |                       sizeof(expr) <= 2))
      |                       ~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_assert.h:372:22: note: in definition of macro ‘ASSERT_ON_COMPILE’
  372 |       _Static_assert(e, #e); \
      |                      ^
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:129:7: note: in expansion of macro ‘ASSERT_ON_COMPILE_SELECTOR_SIZE’
  129 |       ASSERT_ON_COMPILE_SELECTOR_SIZE(expr);                            \
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/common/task.c:761:7: note: in expansion of macro ‘SET_LDT’
  761 |       SET_LDT(ldt);
      |       ^~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/common/task.c: In function ‘Task_Switch’:
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:67:44: error: expression in static assertion is not constant
   67 |    ASSERT_ON_COMPILE(sizeof(Selector) == 2 &&                                \
      |                      ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |                      ((__builtin_constant_p(expr) && ((expr) >> 16) == 0) || \
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 |                       sizeof(expr) <= 2))
      |                       ~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_assert.h:372:22: note: in definition of macro ‘ASSERT_ON_COMPILE’
  372 |       _Static_assert(e, #e); \
      |                      ^
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:215:7: note: in expansion of macro ‘ASSERT_ON_COMPILE_SELECTOR_SIZE’
  215 |       ASSERT_ON_COMPILE_SELECTOR_SIZE(expr);                           \
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:228:22: note: in expansion of macro ‘SET_SEGREG’
  228 | #define SET_SS(expr) SET_SEGREG(ss, expr)
      |                      ^~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/common/task.c:2620:13: note: in expansion of macro ‘SET_SS’
 2620 |             SET_SS(kernelStackSegment);
      |             ^~~~~~
  CC [M]  /tmp/modconfig-Y3VkRY/vmmon-only/bootstrap/vmmblob.o
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:67:44: error: expression in static assertion is not constant
   67 |    ASSERT_ON_COMPILE(sizeof(Selector) == 2 &&                                \
      |                      ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |                      ((__builtin_constant_p(expr) && ((expr) >> 16) == 0) || \
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 |                       sizeof(expr) <= 2))
      |                       ~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_assert.h:372:22: note: in definition of macro ‘ASSERT_ON_COMPILE’
  372 |       _Static_assert(e, #e); \
      |                      ^
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:215:7: note: in expansion of macro ‘ASSERT_ON_COMPILE_SELECTOR_SIZE’
  215 |       ASSERT_ON_COMPILE_SELECTOR_SIZE(expr);                           \
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:224:22: note: in expansion of macro ‘SET_SEGREG’
  224 | #define SET_DS(expr) SET_SEGREG(ds, expr)
      |                      ^~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/common/task.c:2716:10: note: in expansion of macro ‘SET_DS’
 2716 |          SET_DS(ds);
      |          ^~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:67:44: error: expression in static assertion is not constant
   67 |    ASSERT_ON_COMPILE(sizeof(Selector) == 2 &&                                \
      |                      ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |                      ((__builtin_constant_p(expr) && ((expr) >> 16) == 0) || \
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 |                       sizeof(expr) <= 2))
      |                       ~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_assert.h:372:22: note: in definition of macro ‘ASSERT_ON_COMPILE’
  372 |       _Static_assert(e, #e); \
      |                      ^
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:215:7: note: in expansion of macro ‘ASSERT_ON_COMPILE_SELECTOR_SIZE’
  215 |       ASSERT_ON_COMPILE_SELECTOR_SIZE(expr);                           \
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:225:22: note: in expansion of macro ‘SET_SEGREG’
  225 | #define SET_ES(expr) SET_SEGREG(es, expr)
      |                      ^~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/common/task.c:2717:10: note: in expansion of macro ‘SET_ES’
 2717 |          SET_ES(es);
      |          ^~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:67:44: error: expression in static assertion is not constant
   67 |    ASSERT_ON_COMPILE(sizeof(Selector) == 2 &&                                \
      |                      ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |                      ((__builtin_constant_p(expr) && ((expr) >> 16) == 0) || \
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 |                       sizeof(expr) <= 2))
      |                       ~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_assert.h:372:22: note: in definition of macro ‘ASSERT_ON_COMPILE’
  372 |       _Static_assert(e, #e); \
      |                      ^
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:215:7: note: in expansion of macro ‘ASSERT_ON_COMPILE_SELECTOR_SIZE’
  215 |       ASSERT_ON_COMPILE_SELECTOR_SIZE(expr);                           \
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:226:22: note: in expansion of macro ‘SET_SEGREG’
  226 | #define SET_FS(expr) SET_SEGREG(fs, expr)
      |                      ^~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/common/task.c:2725:10: note: in expansion of macro ‘SET_FS’
 2725 |          SET_FS(fs);
      |          ^~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:67:44: error: expression in static assertion is not constant
   67 |    ASSERT_ON_COMPILE(sizeof(Selector) == 2 &&                                \
      |                      ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |                      ((__builtin_constant_p(expr) && ((expr) >> 16) == 0) || \
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 |                       sizeof(expr) <= 2))
      |                       ~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_assert.h:372:22: note: in definition of macro ‘ASSERT_ON_COMPILE’
  372 |       _Static_assert(e, #e); \
      |                      ^
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:215:7: note: in expansion of macro ‘ASSERT_ON_COMPILE_SELECTOR_SIZE’
  215 |       ASSERT_ON_COMPILE_SELECTOR_SIZE(expr);                           \
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/./include/vm_asm_x86.h:227:22: note: in expansion of macro ‘SET_SEGREG’
  227 | #define SET_GS(expr) SET_SEGREG(gs, expr)
      |                      ^~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmmon-only/common/task.c:2726:10: note: in expansion of macro ‘SET_GS’
 2726 |          SET_GS(gs);
      |          ^~~~~~
make[2]: *** [scripts/Makefile.build:287:/tmp/modconfig-Y3VkRY/vmmon-only/common/task.o] 错误 1
make[2]: *** 正在等待未完成的任务....
make[1]: *** [Makefile:1852:/tmp/modconfig-Y3VkRY/vmmon-only] 错误 2
make[1]: 离开目录“/usr/src/linux-headers-5.16.19-76051619-generic”
make: *** [Makefile:117:vmmon.ko] 错误 2
make: 离开目录“/tmp/modconfig-Y3VkRY/vmmon-only”
make: 进入目录“/tmp/modconfig-Y3VkRY/vmnet-only”
Using kernel build system.
/usr/bin/make -C /lib/modules/5.16.19-76051619-generic/build/include/.. M=$PWD SRCROOT=$PWD/. \
  MODULEBUILDDIR= modules
make[1]: 进入目录“/usr/src/linux-headers-5.16.19-76051619-generic”
  CC [M]  /tmp/modconfig-Y3VkRY/vmnet-only/driver.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmnet-only/hub.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmnet-only/userif.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmnet-only/netif.o
/tmp/modconfig-Y3VkRY/vmnet-only/driver.c: In function ‘VNetFileOpUnlockedIoctl’:
/tmp/modconfig-Y3VkRY/vmnet-only/driver.c:966:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
  966 |       {
      |       ^
/tmp/modconfig-Y3VkRY/vmnet-only/driver.c:976:4: note: here
  976 |    case SIOCGETAPIVERSION:
      |    ^~~~
/tmp/modconfig-Y3VkRY/vmnet-only/hub.c:237:24: warning: argument 1 of type ‘uint8[]’ {aka ‘unsigned char[]’} with mismatched bound [-Warray-parameter=]
  237 | VNetHub_AllocPvn(uint8 id[])
      |                  ~~~~~~^~~~
In file included from /tmp/modconfig-Y3VkRY/vmnet-only/hub.c:43:
/tmp/modconfig-Y3VkRY/vmnet-only/vnetInt.h:173:34: note: previously declared as ‘uint8[20]’ {aka ‘unsigned char[20]’}
  173 | VNetJack *VNetHub_AllocPvn(uint8 id[VNET_PVN_ID_LEN]);
      |                            ~~~~~~^~~~~~~~~~~~~~~~~~~
/tmp/modconfig-Y3VkRY/vmnet-only/hub.c:261:20: warning: argument 3 of type ‘uint8[]’ {aka ‘unsigned char[]’} with mismatched bound [-Warray-parameter=]
  261 |              uint8 id[])
      |              ~~~~~~^~~~
/tmp/modconfig-Y3VkRY/vmnet-only/hub.c:68:37: note: previously declared as ‘uint8[20]’ {aka ‘unsigned char[20]’}
   68 |                               uint8 id[VNET_PVN_ID_LEN]);
      |                               ~~~~~~^~~~~~~~~~~~~~~~~~~
  CC [M]  /tmp/modconfig-Y3VkRY/vmnet-only/bridge.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmnet-only/procfs.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmnet-only/smac_compat.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmnet-only/smac.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmnet-only/vnetEvent.o
  CC [M]  /tmp/modconfig-Y3VkRY/vmnet-only/vnetUserListener.o
  LD [M]  /tmp/modconfig-Y3VkRY/vmnet-only/vmnet.o
  MODPOST /tmp/modconfig-Y3VkRY/vmnet-only/Module.symvers
  CC [M]  /tmp/modconfig-Y3VkRY/vmnet-only/vmnet.mod.o
  LD [M]  /tmp/modconfig-Y3VkRY/vmnet-only/vmnet.ko
  BTF [M] /tmp/modconfig-Y3VkRY/vmnet-only/vmnet.ko
Skipping BTF generation for /tmp/modconfig-Y3VkRY/vmnet-only/vmnet.ko due to unavailability of vmlinux
make[1]: 离开目录“/usr/src/linux-headers-5.16.19-76051619-generic”
/usr/bin/make -C $PWD SRCROOT=$PWD/. \
  MODULEBUILDDIR= postbuild
make[1]: 进入目录“/tmp/modconfig-Y3VkRY/vmnet-only”
make[1]: “postbuild”已是最新。
make[1]: 离开目录“/tmp/modconfig-Y3VkRY/vmnet-only”
cp -f vmnet.ko ./../vmnet.o
make: 离开目录“/tmp/modconfig-Y3VkRY/vmnet-only”
Unable to install all modules.  See log for details.
```


### 解决方案


这个问题查了蛮久的


好像是 linux 新内核的问题


shell


```text
➜  /tmp find /usr -type f | grep vmmon
/usr/lib/vmware/modules/source/vmmon.tar
/usr/lib/vmware/symvers/vmmon-5.17.5-76051705-generic
/usr/lib/vmware/symvers/vmmon-5.16.19-76051619-generic
/usr/lib/modules/5.16.19-76051619-generic/misc/vmmon.ko
/usr/lib/modules/5.17.5-76051705-generic/misc/vmmon.ko
```


找到 vmware 的 vmmon 模块源码的位置


修改第 66 到 73 行的源码


cpp


```text
#ifndef USE_UBSAN

#define ASSERT_ON_COMPILE_SELECTOR_SIZE(expr)
```


之后打包回去,重新编译

万能的 Github

在 Github 上找到了一个修改后的模块 repo

vmware-host-modules

使用方法

shell

1- Then make Tar vmmon-only and vmnet-only folders

tar -cf vmmon.tar vmmon-only

tar -cf vmnet.tar vmnet-only



2- Later copy the files to this path /usr/lib/vmware/modules/source/ :

cp -v vmmon.tar vmnet.tar /usr/lib/vmware/modules/source/



3- Finally, run this command to compile headers manually:

sudo vmware-modconfig --console --install-all

版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 私は米沢ユカリニャー

六、建议复刻仓库

https://github.com/mkubecek/vmware-host-modules/branches


欢迎指出任何有错误或不够清晰的表达,可以在下面评论区评论。

×

喜欢就点赞,疼爱就打赏

//