SOLVED: VMware Tools create_proc_entry Error with vmballoon_procfs_init on Linux Kernel 3.11.0



Friday, August 23rd, 2013 at 3:11 pm | 4,815 views | trackback url

Another quick VMware Tools patch and fix if you’re using Linux Kernel 3.10 and 3.11.0 (and probably later, until this gets integrated into mainline). This time, if you’re seeing the following error:

Using 2.6.x kernel build system.
make: Entering directory `/tmp/modconfig-CZk9AS/vmmemctl-only'
/usr/bin/make -C /lib/modules/3.11.0-999-generic/build/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. \
	  MODULEBUILDDIR= modules
make[1]: Entering directory `/usr/src/linux-headers-3.11.0-999-generic'
  CC [M]  /tmp/modconfig-CZk9AS/vmmemctl-only/backdoorGcc64.o
  CC [M]  /tmp/modconfig-CZk9AS/vmmemctl-only/os.o
  CC [M]  /tmp/modconfig-CZk9AS/vmmemctl-only/vmballoon.o
/tmp/modconfig-CZk9AS/vmmemctl-only/os.c: In function ‘vmballoon_procfs_init’:
/tmp/modconfig-CZk9AS/vmmemctl-only/os.c:468:4: error: implicit declaration of function ‘create_proc_entry’ [-Werror=implicit-function-declaration]
/tmp/modconfig-CZk9AS/vmmemctl-only/os.c:468:8: warning: assignment makes pointer from integer without a cast [enabled by default]
/tmp/modconfig-CZk9AS/vmmemctl-only/os.c:470:10: error: dereferencing pointer to incomplete type
cc1: some warnings being treated as errors
make[2]: *** [/tmp/modconfig-CZk9AS/vmmemctl-only/os.o] Error 1
make[1]: *** [_module_/tmp/modconfig-CZk9AS/vmmemctl-only] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.11.0-999-generic'
make: *** [vmmemctl.ko] Error 2
make: Leaving directory `/tmp/modconfig-CZk9AS/vmmemctl-only'

create_proc_entry() has been deprecated in the latest kernel, replaced with proc_create(), with different accessors. I hacked up a quick-and-dirty patch to fix it:

--- os.c	2013-03-23 10:01:51.000000000 -0400
+++ os.c.patched	2013-08-23 15:00:01.416322190 -0400
@@ -460,15 +460,16 @@
    .release = single_release,
 };

-static void
+static int
 vmballoon_procfs_init(void)
 {
    struct proc_dir_entry *pde;

-   pde = create_proc_entry("vmmemctl", S_IFREG | S_IRUGO, NULL);
-   if (pde) {
-      pde->proc_fops = &vmballoon_proc_fops;
+   pde = proc_create("vmmemctl", 0, NULL, &vmballoon_proc_fops);
+   if (pde == NULL) {
+      return -ENOMEM;
    }
+   return 0;
 }

 static void

Apply this patch to os.c in vmmemctl-only, and you’ll have a clean build:

  1. Mount your VMware Tools ISO somewhere
    # mkdir /tmp/cdrom
    # mount /dev/sr0 /tmp/cdrom
  2. Extract the tarball to /tmp/
    # cd /tmp/cdrom
    # tar zxvf VMwareTools-9.0.5-1065307.tar.gz -C /tmp/
  3. Change into the VMware Tools directory that was just created
    # cd /tmp/vmware-tools-distrib/
  4. Patch the tree with the above patch
    # tar -xvf lib/modules/source/vmmemctl.tar
    # cd lib/modules/source/
    # patch -p0 < /tmp/vmware-tools-linux-kernel-3.11.0_vmmemctl_proc_create_vmballoon.patch
  5. Tar up the patched source so we can rebuild using the new tarball
    # tar -cf vmmemctl.tar vmmemctl-only/
  6. Now let's rebuild it!
    # cd /tmp/vmware-tools-distrib/
    # ./vmware-install.pl --clobber-kernel-modules=vmci    \
                      --clobber-kernel-modules=vsock   \
                      --clobber-kernel-modules=vmxnet3 \
                      --clobber-kernel-modules=pvscsi  \
                      --clobber-kernel-modules=vmmemctl
    

And it works, of course!

Using 2.6.x kernel build system.
make: Entering directory `/tmp/modconfig-AssZbT/vmmemctl-only'
/usr/bin/make -C /lib/modules/3.11.0-999-generic/build/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. \
	  MODULEBUILDDIR= modules
make[1]: Entering directory `/usr/src/linux-headers-3.11.0-999-generic'
  CC [M]  /tmp/modconfig-AssZbT/vmmemctl-only/backdoorGcc64.o
  CC [M]  /tmp/modconfig-AssZbT/vmmemctl-only/os.o
  CC [M]  /tmp/modconfig-AssZbT/vmmemctl-only/vmballoon.o
  CC [M]  /tmp/modconfig-AssZbT/vmmemctl-only/vmmemctl.mod.o
  LD [M]  /tmp/modconfig-AssZbT/vmmemctl-only/vmmemctl.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /tmp/modconfig-AssZbT/vmmemctl-only/vmmemctl.mod.o
  LD [M]  /tmp/modconfig-AssZbT/vmmemctl-only/vmmemctl.ko
make[1]: Leaving directory `/usr/src/linux-headers-3.11.0-999-generic'
/usr/bin/make -C $PWD SRCROOT=$PWD/. \
	  MODULEBUILDDIR= postbuild
make[1]: Entering directory `/tmp/modconfig-AssZbT/vmmemctl-only'
make[1]: `postbuild' is up to date.
make[1]: Leaving directory `/tmp/modconfig-AssZbT/vmmemctl-only'
cp -f vmmemctl.ko ./../vmmemctl.o
make: Leaving directory `/tmp/modconfig-AssZbT/vmmemctl-only'

Reboot your machine, and you should see something like the following:

$ uname -a 
Linux ubuntu-1304-esx-vm 3.11.0-999-generic #201308230405 SMP Fri Aug 23 08:06:47 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Good luck!

UPDATE: I tested this against the 3.10.9-200.fc19.x86_64 kernel in Fedora FC19 as well as the 3.11.0-999 kernel in Ubuntu Kernel Mainline, and they both work flawlessly. YMMV, but email me if you have trouble.

Last Modified: Friday, August 23rd, 2013 @ 16:49

Leave a Reply

You must be logged in to post a comment.

Bad Behavior has blocked 1450 access attempts in the last 7 days.