宿主机 Ubuntu 20.04 + VirtualBox 6.1.11,虚拟机 Win7
Ubuntu一直不定时的升级,虚机的Win7有阵子没用到了,今天忽然启动不了,提示执行/sbin/vboxconfig。
这种情况以前也是有过,一般执行一下就可以了。
今天执行vboxconfig也报错,日志提示
/tmp/vbox.0/r0drv/linux/the-linux-kernel.h:141:11: fatal error: linux/smp_lock.h: 没有那个文件或目录
141 | # include <linux/smp_lock.h>
| ^~~~~~~~~~~~~~~~~~
compilation terminated.
想起VirtualBox启动时提示升级,想来是Ubuntu升级导致VirtualBox需要的头文件不存在了,就升级VirtualBox到 6.1.18。
虚机Win7依然启动不了,提示执行/sbin/vboxconfig,再次运行vboxconfig依然失败,日志提示
/tmp/vbox.0/linux/VBoxNetFlt-linux.c:1761:47: error: dereferencing pointer to incomplete type ‘const struct ethtool_ops’
1761 | if (pDev->ethtool_ops && pDev->ethtool_ops->get_drvinfo)
| ^~
/tmp/vbox.0/linux/VBoxNetFlt-linux.c:1763:32: error: storage size of ‘Info’ isn’t known
1763 | struct ethtool_drvinfo Info;
| ^~~~
/tmp/vbox.0/linux/VBoxNetFlt-linux.c:1766:20: error: ‘ETHTOOL_GDRVINFO’ undeclared (first use in this function)
1766 | Info.cmd = ETHTOOL_GDRVINFO;
| ^~~~~~~~~~~~~~~~
/tmp/vbox.0/linux/VBoxNetFlt-linux.c:1766:20: note: each undeclared identifier is reported only once for each function it appears in
/tmp/vbox.0/linux/VBoxNetFlt-linux.c:1763:32: warning: unused variable ‘Info’ [-Wunused-variable]
1763 | struct ethtool_drvinfo Info;
| ^~~~
看来新版本VirtualBox确实解决了对smp_lock.h的依赖,这个新错误在网上找到了答案,原文在 https://www.virtualbox.org/ticket/20198:
Adding the following line in /usr/share/virtualbox/src/vboxhost/vboxnetflt/linux/VBoxNetFlt-linux.c fixed the problem.
#include <linux/ethtool.h>
按此法修改源文件后,再次执行vboxconfig未报错,虚机Win7正常启动。
版权声明:本文为qwas原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。